1a25f0a04SGreg Roach<?php 2a25f0a04SGreg Roach/** 3a25f0a04SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 5a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify 6a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by 7a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a25f0a04SGreg Roach * (at your option) any later version. 9a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful, 10a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a25f0a04SGreg Roach * GNU General Public License for more details. 13a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License 14a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a25f0a04SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1876692c8bSGreg Roachnamespace Fisharebest\Webtrees; 19a25f0a04SGreg Roach 202e5b4452SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 212e5b4452SGreg Roach 22a25f0a04SGreg Roach/** 2376692c8bSGreg Roach * A GEDCOM family (FAM) object. 24a25f0a04SGreg Roach */ 25c1010edaSGreg Roachclass Family extends GedcomRecord 26c1010edaSGreg Roach{ 27*16d6367aSGreg Roach public const RECORD_TYPE = 'FAM'; 28*16d6367aSGreg Roach 29*16d6367aSGreg Roach protected const ROUTE_NAME = 'family'; 30a25f0a04SGreg Roach 31a25f0a04SGreg Roach /** @var Individual|null The husband (or first spouse for same-sex couples) */ 32a25f0a04SGreg Roach private $husb; 33a25f0a04SGreg Roach 34a25f0a04SGreg Roach /** @var Individual|null The wife (or second spouse for same-sex couples) */ 35a25f0a04SGreg Roach private $wife; 36a25f0a04SGreg Roach 3776692c8bSGreg Roach /** 3876692c8bSGreg Roach * Create a GedcomRecord object from raw GEDCOM data. 3976692c8bSGreg Roach * 4076692c8bSGreg Roach * @param string $xref 4176692c8bSGreg Roach * @param string $gedcom an empty string for new/pending records 4276692c8bSGreg Roach * @param string|null $pending null for a record with no pending edits, 4376692c8bSGreg Roach * empty string for records with pending deletions 4476692c8bSGreg Roach * @param Tree $tree 4576692c8bSGreg Roach */ 4676f666f4SGreg Roach public function __construct(string $xref, string $gedcom, $pending, Tree $tree) 47c1010edaSGreg Roach { 4824ec66ceSGreg Roach parent::__construct($xref, $gedcom, $pending, $tree); 49a25f0a04SGreg Roach 50395f0fe0SGreg Roach // Fetch family members 51395f0fe0SGreg Roach if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) { 52395f0fe0SGreg Roach Individual::load($tree, $match[1]); 53395f0fe0SGreg Roach } 54395f0fe0SGreg Roach 55a25f0a04SGreg Roach if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) { 5624ec66ceSGreg Roach $this->husb = Individual::getInstance($match[1], $tree); 57a25f0a04SGreg Roach } 58a25f0a04SGreg Roach if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) { 5924ec66ceSGreg Roach $this->wife = Individual::getInstance($match[1], $tree); 60a25f0a04SGreg Roach } 61a25f0a04SGreg Roach } 62a25f0a04SGreg Roach 6376692c8bSGreg Roach /** 64e71ef9d2SGreg Roach * Get an instance of a family object. For single records, 65e71ef9d2SGreg Roach * we just receive the XREF. For bulk records (such as lists 66e71ef9d2SGreg Roach * and search results) we can receive the GEDCOM data as well. 67e71ef9d2SGreg Roach * 68e71ef9d2SGreg Roach * @param string $xref 69e71ef9d2SGreg Roach * @param Tree $tree 70e71ef9d2SGreg Roach * @param string|null $gedcom 71e71ef9d2SGreg Roach * 72e71ef9d2SGreg Roach * @throws \Exception 73e71ef9d2SGreg Roach * 74e71ef9d2SGreg Roach * @return Family|null 75e71ef9d2SGreg Roach */ 7676f666f4SGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null) 77c1010edaSGreg Roach { 78e71ef9d2SGreg Roach $record = parent::getInstance($xref, $tree, $gedcom); 79e71ef9d2SGreg Roach 80e71ef9d2SGreg Roach if ($record instanceof Family) { 81e71ef9d2SGreg Roach return $record; 82e71ef9d2SGreg Roach } 83b2ce94c6SRico Sonntag 84b2ce94c6SRico Sonntag return null; 85e71ef9d2SGreg Roach } 86e71ef9d2SGreg Roach 87e71ef9d2SGreg Roach /** 8876692c8bSGreg Roach * Generate a private version of this record 8976692c8bSGreg Roach * 9076692c8bSGreg Roach * @param int $access_level 9176692c8bSGreg Roach * 9276692c8bSGreg Roach * @return string 9376692c8bSGreg Roach */ 943c90ed31SGreg Roach protected function createPrivateGedcomRecord(int $access_level): string 95c1010edaSGreg Roach { 96d86cc606SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 97a25f0a04SGreg Roach 98a25f0a04SGreg Roach $rec = '0 @' . $this->xref . '@ FAM'; 99a25f0a04SGreg Roach // Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data 1008d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER); 101a25f0a04SGreg Roach foreach ($matches as $match) { 10224ec66ceSGreg Roach $rela = Individual::getInstance($match[1], $this->tree); 103a25f0a04SGreg Roach if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) { 104a25f0a04SGreg Roach $rec .= $match[0]; 105a25f0a04SGreg Roach } 106a25f0a04SGreg Roach } 107a25f0a04SGreg Roach 108a25f0a04SGreg Roach return $rec; 109a25f0a04SGreg Roach } 110a25f0a04SGreg Roach 11176692c8bSGreg Roach /** 11276692c8bSGreg Roach * Fetch data from the database 11376692c8bSGreg Roach * 11476692c8bSGreg Roach * @param string $xref 11576692c8bSGreg Roach * @param int $tree_id 11676692c8bSGreg Roach * 11776692c8bSGreg Roach * @return null|string 11876692c8bSGreg Roach */ 11976f666f4SGreg Roach protected static function fetchGedcomRecord(string $xref, int $tree_id) 120c1010edaSGreg Roach { 1212e5b4452SGreg Roach return DB::table('families') 1222e5b4452SGreg Roach ->where('f_id', '=', $xref) 1232e5b4452SGreg Roach ->where('f_file', '=', $tree_id) 1242e5b4452SGreg Roach ->value('f_gedcom'); 125a25f0a04SGreg Roach } 126a25f0a04SGreg Roach 127a25f0a04SGreg Roach /** 128a25f0a04SGreg Roach * Get the male (or first female) partner of the family 129a25f0a04SGreg Roach * 130e93111adSRico Sonntag * @param int|null $access_level 131b3f49e6cSGreg Roach * 132a25f0a04SGreg Roach * @return Individual|null 133a25f0a04SGreg Roach */ 134c1010edaSGreg Roach public function getHusband($access_level = null) 135c1010edaSGreg Roach { 136b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 137b3f49e6cSGreg Roach 138b3f49e6cSGreg Roach if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) { 139a25f0a04SGreg Roach return $this->husb; 140a25f0a04SGreg Roach } 141b2ce94c6SRico Sonntag 142b2ce94c6SRico Sonntag return null; 143a25f0a04SGreg Roach } 144a25f0a04SGreg Roach 145a25f0a04SGreg Roach /** 146a25f0a04SGreg Roach * Get the female (or second male) partner of the family 147a25f0a04SGreg Roach * 148e93111adSRico Sonntag * @param int|null $access_level 149b3f49e6cSGreg Roach * 150a25f0a04SGreg Roach * @return Individual|null 151a25f0a04SGreg Roach */ 152c1010edaSGreg Roach public function getWife($access_level = null) 153c1010edaSGreg Roach { 154b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 155b3f49e6cSGreg Roach 156b3f49e6cSGreg Roach if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) { 157a25f0a04SGreg Roach return $this->wife; 158a25f0a04SGreg Roach } 159b2ce94c6SRico Sonntag 160b2ce94c6SRico Sonntag return null; 161a25f0a04SGreg Roach } 162a25f0a04SGreg Roach 16376692c8bSGreg Roach /** 16476692c8bSGreg Roach * Each object type may have its own special rules, and re-implement this function. 16576692c8bSGreg Roach * 16676692c8bSGreg Roach * @param int $access_level 16776692c8bSGreg Roach * 16876692c8bSGreg Roach * @return bool 16976692c8bSGreg Roach */ 17035584196SGreg Roach protected function canShowByType(int $access_level): bool 171c1010edaSGreg Roach { 172a25f0a04SGreg Roach // Hide a family if any member is private 1738d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches); 174a25f0a04SGreg Roach foreach ($matches[1] as $match) { 17524ec66ceSGreg Roach $person = Individual::getInstance($match, $this->tree); 176a25f0a04SGreg Roach if ($person && !$person->canShow($access_level)) { 177a25f0a04SGreg Roach return false; 178a25f0a04SGreg Roach } 179a25f0a04SGreg Roach } 180a25f0a04SGreg Roach 181a25f0a04SGreg Roach return true; 182a25f0a04SGreg Roach } 183a25f0a04SGreg Roach 18476692c8bSGreg Roach /** 18576692c8bSGreg Roach * Can the name of this record be shown? 18676692c8bSGreg Roach * 18776692c8bSGreg Roach * @param int|null $access_level 18876692c8bSGreg Roach * 18976692c8bSGreg Roach * @return bool 19076692c8bSGreg Roach */ 19135584196SGreg Roach public function canShowName(int $access_level = null): bool 192c1010edaSGreg Roach { 193a25f0a04SGreg Roach // We can always see the name (Husband-name + Wife-name), however, 194a25f0a04SGreg Roach // the name will often be "private + private" 195a25f0a04SGreg Roach return true; 196a25f0a04SGreg Roach } 197a25f0a04SGreg Roach 198a25f0a04SGreg Roach /** 199a25f0a04SGreg Roach * Find the spouse of a person. 200a25f0a04SGreg Roach * 201a25f0a04SGreg Roach * @param Individual $person 20213e3123bSGreg Roach * @param int|null $access_level 203a25f0a04SGreg Roach * 204a25f0a04SGreg Roach * @return Individual|null 205a25f0a04SGreg Roach */ 206c1010edaSGreg Roach public function getSpouse(Individual $person, $access_level = null) 207c1010edaSGreg Roach { 208a25f0a04SGreg Roach if ($person === $this->wife) { 20913e3123bSGreg Roach return $this->getHusband($access_level); 210a25f0a04SGreg Roach } 211b2ce94c6SRico Sonntag 212b2ce94c6SRico Sonntag return $this->getWife($access_level); 213a25f0a04SGreg Roach } 214a25f0a04SGreg Roach 215a25f0a04SGreg Roach /** 216a25f0a04SGreg Roach * Get the (zero, one or two) spouses from this family. 217a25f0a04SGreg Roach * 218cbc1590aSGreg Roach * @param int|null $access_level 219a25f0a04SGreg Roach * 220a25f0a04SGreg Roach * @return Individual[] 221a25f0a04SGreg Roach */ 2228f53f488SRico Sonntag public function getSpouses($access_level = null): array 223c1010edaSGreg Roach { 22413abd6f3SGreg Roach return array_filter([ 225b3f49e6cSGreg Roach $this->getHusband($access_level), 226b3f49e6cSGreg Roach $this->getWife($access_level), 22713abd6f3SGreg Roach ]); 228a25f0a04SGreg Roach } 229a25f0a04SGreg Roach 230a25f0a04SGreg Roach /** 231a25f0a04SGreg Roach * Get a list of this family’s children. 232a25f0a04SGreg Roach * 233cbc1590aSGreg Roach * @param int|null $access_level 234a25f0a04SGreg Roach * 235a25f0a04SGreg Roach * @return Individual[] 236a25f0a04SGreg Roach */ 2378f53f488SRico Sonntag public function getChildren($access_level = null): array 238c1010edaSGreg Roach { 2394b9ff166SGreg Roach if ($access_level === null) { 2404b9ff166SGreg Roach $access_level = Auth::accessLevel($this->tree); 2414b9ff166SGreg Roach } 2424b9ff166SGreg Roach 243845c3ce6SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 244a25f0a04SGreg Roach 24513abd6f3SGreg Roach $children = []; 2468d0ebef0SGreg Roach foreach ($this->facts(['CHIL'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { 247dc124885SGreg Roach $child = $fact->target(); 248e24444eeSGreg Roach if ($child instanceof Individual && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { 249a25f0a04SGreg Roach $children[] = $child; 250a25f0a04SGreg Roach } 251a25f0a04SGreg Roach } 252a25f0a04SGreg Roach 253a25f0a04SGreg Roach return $children; 254a25f0a04SGreg Roach } 255a25f0a04SGreg Roach 256a25f0a04SGreg Roach /** 257a25f0a04SGreg Roach * Static helper function to sort an array of families by marriage date 258a25f0a04SGreg Roach * 259a25f0a04SGreg Roach * @param Family $x 260a25f0a04SGreg Roach * @param Family $y 261a25f0a04SGreg Roach * 262cbc1590aSGreg Roach * @return int 263a25f0a04SGreg Roach */ 2648f53f488SRico Sonntag public static function compareMarrDate(Family $x, Family $y): int 265c1010edaSGreg Roach { 266f5b60decSGreg Roach return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); 267a25f0a04SGreg Roach } 268a25f0a04SGreg Roach 269a25f0a04SGreg Roach /** 270a25f0a04SGreg Roach * Number of children - for the individual list 271a25f0a04SGreg Roach * 272cbc1590aSGreg Roach * @return int 273a25f0a04SGreg Roach */ 2748f53f488SRico Sonntag public function getNumberOfChildren(): int 275c1010edaSGreg Roach { 276a25f0a04SGreg Roach $nchi = count($this->getChildren()); 2778d0ebef0SGreg Roach foreach ($this->facts(['NCHI']) as $fact) { 27884586c02SGreg Roach $nchi = max($nchi, (int) $fact->value()); 279a25f0a04SGreg Roach } 280a25f0a04SGreg Roach 281a25f0a04SGreg Roach return $nchi; 282a25f0a04SGreg Roach } 283a25f0a04SGreg Roach 284a25f0a04SGreg Roach /** 285a25f0a04SGreg Roach * get the marriage event 286a25f0a04SGreg Roach * 28766107289SGreg Roach * @return Fact|null 288a25f0a04SGreg Roach */ 28966107289SGreg Roach public function getMarriage() 290c1010edaSGreg Roach { 291a25f0a04SGreg Roach return $this->getFirstFact('MARR'); 292a25f0a04SGreg Roach } 293a25f0a04SGreg Roach 294a25f0a04SGreg Roach /** 295a25f0a04SGreg Roach * Get marriage date 296a25f0a04SGreg Roach * 297a25f0a04SGreg Roach * @return Date 298a25f0a04SGreg Roach */ 299c1010edaSGreg Roach public function getMarriageDate() 300c1010edaSGreg Roach { 301a25f0a04SGreg Roach $marriage = $this->getMarriage(); 302a25f0a04SGreg Roach if ($marriage) { 3032decada7SGreg Roach return $marriage->date(); 304a25f0a04SGreg Roach } 305b2ce94c6SRico Sonntag 306b2ce94c6SRico Sonntag return new Date(''); 307a25f0a04SGreg Roach } 308a25f0a04SGreg Roach 309a25f0a04SGreg Roach /** 310a25f0a04SGreg Roach * Get the marriage year - displayed on lists of families 311a25f0a04SGreg Roach * 312cbc1590aSGreg Roach * @return int 313a25f0a04SGreg Roach */ 3148f53f488SRico Sonntag public function getMarriageYear(): int 315c1010edaSGreg Roach { 3164a83f5d7SGreg Roach return $this->getMarriageDate()->minimumDate()->year; 317a25f0a04SGreg Roach } 318a25f0a04SGreg Roach 319a25f0a04SGreg Roach /** 320a25f0a04SGreg Roach * Get the marriage place 321a25f0a04SGreg Roach * 322a25f0a04SGreg Roach * @return Place 323a25f0a04SGreg Roach */ 3248f53f488SRico Sonntag public function getMarriagePlace(): Place 325c1010edaSGreg Roach { 326a25f0a04SGreg Roach $marriage = $this->getMarriage(); 327a25f0a04SGreg Roach 3284fb14fcbSGreg Roach return $marriage->place(); 329a25f0a04SGreg Roach } 330a25f0a04SGreg Roach 331a25f0a04SGreg Roach /** 332a25f0a04SGreg Roach * Get a list of all marriage dates - for the family lists. 333a25f0a04SGreg Roach * 334a25f0a04SGreg Roach * @return Date[] 335a25f0a04SGreg Roach */ 3368f53f488SRico Sonntag public function getAllMarriageDates(): array 337c1010edaSGreg Roach { 3388d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3398d0ebef0SGreg Roach if ($array = $this->getAllEventDates([$event])) { 340a25f0a04SGreg Roach return $array; 341a25f0a04SGreg Roach } 342a25f0a04SGreg Roach } 343a25f0a04SGreg Roach 34413abd6f3SGreg Roach return []; 345a25f0a04SGreg Roach } 346a25f0a04SGreg Roach 347a25f0a04SGreg Roach /** 348a25f0a04SGreg Roach * Get a list of all marriage places - for the family lists. 349a25f0a04SGreg Roach * 3504080d558SGreg Roach * @return Place[] 351a25f0a04SGreg Roach */ 3528f53f488SRico Sonntag public function getAllMarriagePlaces(): array 353c1010edaSGreg Roach { 3548d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3556e83554dSGreg Roach $places = $this->getAllEventPlaces([$event]); 3564080d558SGreg Roach if (!empty($places)) { 3574080d558SGreg Roach return $places; 358a25f0a04SGreg Roach } 359a25f0a04SGreg Roach } 360a25f0a04SGreg Roach 36113abd6f3SGreg Roach return []; 362a25f0a04SGreg Roach } 363a25f0a04SGreg Roach 36476692c8bSGreg Roach /** 36576692c8bSGreg Roach * Derived classes should redefine this function, otherwise the object will have no name 36676692c8bSGreg Roach * 36776692c8bSGreg Roach * @return string[][] 36876692c8bSGreg Roach */ 3698f53f488SRico Sonntag public function getAllNames(): array 370c1010edaSGreg Roach { 3718f038c36SRico Sonntag if ($this->getAllNames === null) { 372a25f0a04SGreg Roach // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc. 373e88674d4SGreg Roach $husb_names = []; 374a25f0a04SGreg Roach if ($this->husb) { 375492c7072SGreg Roach $husb_names = array_filter($this->husb->getAllNames(), function (array $x): bool { 3768d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3778d68cabeSGreg Roach }); 378e88674d4SGreg Roach } 379e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 380e88674d4SGreg Roach if (empty($husb_names)) { 381e88674d4SGreg Roach $husb_names[] = [ 382a25f0a04SGreg Roach 'type' => 'BIRT', 383a25f0a04SGreg Roach 'sort' => '@N.N.', 384ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 38513abd6f3SGreg Roach ]; 386a25f0a04SGreg Roach } 387a25f0a04SGreg Roach foreach ($husb_names as $n => $husb_name) { 388a25f0a04SGreg Roach $husb_names[$n]['script'] = I18N::textScript($husb_name['full']); 389a25f0a04SGreg Roach } 390e88674d4SGreg Roach 391e88674d4SGreg Roach $wife_names = []; 392a25f0a04SGreg Roach if ($this->wife) { 393492c7072SGreg Roach $wife_names = array_filter($this->wife->getAllNames(), function (array $x): bool { 3948d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3958d68cabeSGreg Roach }); 396e88674d4SGreg Roach } 397e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 398e88674d4SGreg Roach if (empty($wife_names)) { 399e88674d4SGreg Roach $wife_names[] = [ 400a25f0a04SGreg Roach 'type' => 'BIRT', 401a25f0a04SGreg Roach 'sort' => '@N.N.', 402ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 40313abd6f3SGreg Roach ]; 404a25f0a04SGreg Roach } 405a25f0a04SGreg Roach foreach ($wife_names as $n => $wife_name) { 406a25f0a04SGreg Roach $wife_names[$n]['script'] = I18N::textScript($wife_name['full']); 407a25f0a04SGreg Roach } 408e88674d4SGreg Roach 409a25f0a04SGreg Roach // Add the matched names first 410a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 411a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 412e88674d4SGreg Roach if ($husb_name['script'] == $wife_name['script']) { 413bdb3725aSGreg Roach $this->getAllNames[] = [ 414a25f0a04SGreg Roach 'type' => $husb_name['type'], 415a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 416a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 417a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 41813abd6f3SGreg Roach ]; 419a25f0a04SGreg Roach } 420a25f0a04SGreg Roach } 421a25f0a04SGreg Roach } 422e88674d4SGreg Roach 423a25f0a04SGreg Roach // Add the unmatched names second (there may be no matched names) 424a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 425a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 426e88674d4SGreg Roach if ($husb_name['script'] != $wife_name['script']) { 427bdb3725aSGreg Roach $this->getAllNames[] = [ 428a25f0a04SGreg Roach 'type' => $husb_name['type'], 429a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 430a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 431a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 43213abd6f3SGreg Roach ]; 433a25f0a04SGreg Roach } 434a25f0a04SGreg Roach } 435a25f0a04SGreg Roach } 436a25f0a04SGreg Roach } 437a25f0a04SGreg Roach 438bdb3725aSGreg Roach return $this->getAllNames; 439a25f0a04SGreg Roach } 440a25f0a04SGreg Roach 44176692c8bSGreg Roach /** 44276692c8bSGreg Roach * This function should be redefined in derived classes to show any major 44376692c8bSGreg Roach * identifying characteristics of this record. 44476692c8bSGreg Roach * 44576692c8bSGreg Roach * @return string 44676692c8bSGreg Roach */ 4478f53f488SRico Sonntag public function formatListDetails(): string 448c1010edaSGreg Roach { 449a25f0a04SGreg Roach return 4508d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 1) . 4518d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 1); 452a25f0a04SGreg Roach } 453a25f0a04SGreg Roach} 454