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 20886b77daSGreg Roachuse Closure; 212e5b4452SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 22886b77daSGreg Roachuse stdClass; 232e5b4452SGreg Roach 24a25f0a04SGreg Roach/** 2576692c8bSGreg Roach * A GEDCOM family (FAM) object. 26a25f0a04SGreg Roach */ 27c1010edaSGreg Roachclass Family extends GedcomRecord 28c1010edaSGreg Roach{ 2916d6367aSGreg Roach public const RECORD_TYPE = 'FAM'; 3016d6367aSGreg Roach 3116d6367aSGreg Roach protected const ROUTE_NAME = 'family'; 32a25f0a04SGreg Roach 33a25f0a04SGreg Roach /** @var Individual|null The husband (or first spouse for same-sex couples) */ 34a25f0a04SGreg Roach private $husb; 35a25f0a04SGreg Roach 36a25f0a04SGreg Roach /** @var Individual|null The wife (or second spouse for same-sex couples) */ 37a25f0a04SGreg Roach private $wife; 38a25f0a04SGreg Roach 3976692c8bSGreg Roach /** 4076692c8bSGreg Roach * Create a GedcomRecord object from raw GEDCOM data. 4176692c8bSGreg Roach * 4276692c8bSGreg Roach * @param string $xref 4376692c8bSGreg Roach * @param string $gedcom an empty string for new/pending records 4476692c8bSGreg Roach * @param string|null $pending null for a record with no pending edits, 4576692c8bSGreg Roach * empty string for records with pending deletions 4676692c8bSGreg Roach * @param Tree $tree 4776692c8bSGreg Roach */ 4876f666f4SGreg Roach public function __construct(string $xref, string $gedcom, $pending, Tree $tree) 49c1010edaSGreg Roach { 5024ec66ceSGreg Roach parent::__construct($xref, $gedcom, $pending, $tree); 51a25f0a04SGreg Roach 52395f0fe0SGreg Roach // Fetch family members 53395f0fe0SGreg Roach if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) { 54395f0fe0SGreg Roach Individual::load($tree, $match[1]); 55395f0fe0SGreg Roach } 56395f0fe0SGreg Roach 57a25f0a04SGreg Roach if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) { 5824ec66ceSGreg Roach $this->husb = Individual::getInstance($match[1], $tree); 59a25f0a04SGreg Roach } 60a25f0a04SGreg Roach if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) { 6124ec66ceSGreg Roach $this->wife = Individual::getInstance($match[1], $tree); 62a25f0a04SGreg Roach } 63a25f0a04SGreg Roach } 64a25f0a04SGreg Roach 6576692c8bSGreg Roach /** 66886b77daSGreg Roach * A closure which will create a record from a database row. 67886b77daSGreg Roach * 68886b77daSGreg Roach * @return Closure 69886b77daSGreg Roach */ 70c0804649SGreg Roach public static function rowMapper(): Closure 71886b77daSGreg Roach { 72c0804649SGreg Roach return function (stdClass $row): Family { 73a7a24840SGreg Roach return Family::getInstance($row->f_id, Tree::findById((int) $row->f_file), $row->f_gedcom); 74886b77daSGreg Roach }; 75886b77daSGreg Roach } 76886b77daSGreg Roach 77886b77daSGreg Roach /** 78c156e8f5SGreg Roach * A closure which will compare families by marriage date. 79c156e8f5SGreg Roach * 80c156e8f5SGreg Roach * @return Closure 81c156e8f5SGreg Roach */ 82c156e8f5SGreg Roach public static function marriageDateComparator(): Closure 83c156e8f5SGreg Roach { 84a9199cb2SGreg Roach return function (Family $x, Family $y): int { 85c156e8f5SGreg Roach return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); 86c156e8f5SGreg Roach }; 87c156e8f5SGreg Roach } 88c156e8f5SGreg Roach 89c156e8f5SGreg Roach /** 90e71ef9d2SGreg Roach * Get an instance of a family object. For single records, 91e71ef9d2SGreg Roach * we just receive the XREF. For bulk records (such as lists 92e71ef9d2SGreg Roach * and search results) we can receive the GEDCOM data as well. 93e71ef9d2SGreg Roach * 94e71ef9d2SGreg Roach * @param string $xref 95e71ef9d2SGreg Roach * @param Tree $tree 96e71ef9d2SGreg Roach * @param string|null $gedcom 97e71ef9d2SGreg Roach * 98e71ef9d2SGreg Roach * @throws \Exception 99e71ef9d2SGreg Roach * 100e71ef9d2SGreg Roach * @return Family|null 101e71ef9d2SGreg Roach */ 10276f666f4SGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null) 103c1010edaSGreg Roach { 104e71ef9d2SGreg Roach $record = parent::getInstance($xref, $tree, $gedcom); 105e71ef9d2SGreg Roach 106e71ef9d2SGreg Roach if ($record instanceof Family) { 107e71ef9d2SGreg Roach return $record; 108e71ef9d2SGreg Roach } 109b2ce94c6SRico Sonntag 110b2ce94c6SRico Sonntag return null; 111e71ef9d2SGreg Roach } 112e71ef9d2SGreg Roach 113e71ef9d2SGreg Roach /** 11476692c8bSGreg Roach * Generate a private version of this record 11576692c8bSGreg Roach * 11676692c8bSGreg Roach * @param int $access_level 11776692c8bSGreg Roach * 11876692c8bSGreg Roach * @return string 11976692c8bSGreg Roach */ 1203c90ed31SGreg Roach protected function createPrivateGedcomRecord(int $access_level): string 121c1010edaSGreg Roach { 122d86cc606SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 123a25f0a04SGreg Roach 124a25f0a04SGreg Roach $rec = '0 @' . $this->xref . '@ FAM'; 125a25f0a04SGreg Roach // Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data 1268d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER); 127a25f0a04SGreg Roach foreach ($matches as $match) { 12824ec66ceSGreg Roach $rela = Individual::getInstance($match[1], $this->tree); 129a25f0a04SGreg Roach if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) { 130a25f0a04SGreg Roach $rec .= $match[0]; 131a25f0a04SGreg Roach } 132a25f0a04SGreg Roach } 133a25f0a04SGreg Roach 134a25f0a04SGreg Roach return $rec; 135a25f0a04SGreg Roach } 136a25f0a04SGreg Roach 13776692c8bSGreg Roach /** 13876692c8bSGreg Roach * Fetch data from the database 13976692c8bSGreg Roach * 14076692c8bSGreg Roach * @param string $xref 14176692c8bSGreg Roach * @param int $tree_id 14276692c8bSGreg Roach * 14376692c8bSGreg Roach * @return null|string 14476692c8bSGreg Roach */ 14576f666f4SGreg Roach protected static function fetchGedcomRecord(string $xref, int $tree_id) 146c1010edaSGreg Roach { 1472e5b4452SGreg Roach return DB::table('families') 1482e5b4452SGreg Roach ->where('f_id', '=', $xref) 1492e5b4452SGreg Roach ->where('f_file', '=', $tree_id) 1502e5b4452SGreg Roach ->value('f_gedcom'); 151a25f0a04SGreg Roach } 152a25f0a04SGreg Roach 153a25f0a04SGreg Roach /** 154a25f0a04SGreg Roach * Get the male (or first female) partner of the family 155a25f0a04SGreg Roach * 156e93111adSRico Sonntag * @param int|null $access_level 157b3f49e6cSGreg Roach * 158a25f0a04SGreg Roach * @return Individual|null 159a25f0a04SGreg Roach */ 160*39ca88baSGreg Roach public function husband($access_level = null): ?Individual 161c1010edaSGreg Roach { 162b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 163b3f49e6cSGreg Roach 164b3f49e6cSGreg Roach if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) { 165a25f0a04SGreg Roach return $this->husb; 166a25f0a04SGreg Roach } 167b2ce94c6SRico Sonntag 168b2ce94c6SRico Sonntag return null; 169a25f0a04SGreg Roach } 170a25f0a04SGreg Roach 171a25f0a04SGreg Roach /** 172a25f0a04SGreg Roach * Get the female (or second male) partner of the family 173a25f0a04SGreg Roach * 174e93111adSRico Sonntag * @param int|null $access_level 175b3f49e6cSGreg Roach * 176a25f0a04SGreg Roach * @return Individual|null 177a25f0a04SGreg Roach */ 178*39ca88baSGreg Roach public function wife($access_level = null): ?Individual 179c1010edaSGreg Roach { 180b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 181b3f49e6cSGreg Roach 182b3f49e6cSGreg Roach if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) { 183a25f0a04SGreg Roach return $this->wife; 184a25f0a04SGreg Roach } 185b2ce94c6SRico Sonntag 186b2ce94c6SRico Sonntag return null; 187a25f0a04SGreg Roach } 188a25f0a04SGreg Roach 18976692c8bSGreg Roach /** 19076692c8bSGreg Roach * Each object type may have its own special rules, and re-implement this function. 19176692c8bSGreg Roach * 19276692c8bSGreg Roach * @param int $access_level 19376692c8bSGreg Roach * 19476692c8bSGreg Roach * @return bool 19576692c8bSGreg Roach */ 19635584196SGreg Roach protected function canShowByType(int $access_level): bool 197c1010edaSGreg Roach { 198a25f0a04SGreg Roach // Hide a family if any member is private 1998d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches); 200a25f0a04SGreg Roach foreach ($matches[1] as $match) { 20124ec66ceSGreg Roach $person = Individual::getInstance($match, $this->tree); 202a25f0a04SGreg Roach if ($person && !$person->canShow($access_level)) { 203a25f0a04SGreg Roach return false; 204a25f0a04SGreg Roach } 205a25f0a04SGreg Roach } 206a25f0a04SGreg Roach 207a25f0a04SGreg Roach return true; 208a25f0a04SGreg Roach } 209a25f0a04SGreg Roach 21076692c8bSGreg Roach /** 21176692c8bSGreg Roach * Can the name of this record be shown? 21276692c8bSGreg Roach * 21376692c8bSGreg Roach * @param int|null $access_level 21476692c8bSGreg Roach * 21576692c8bSGreg Roach * @return bool 21676692c8bSGreg Roach */ 21735584196SGreg Roach public function canShowName(int $access_level = null): bool 218c1010edaSGreg Roach { 219a25f0a04SGreg Roach // We can always see the name (Husband-name + Wife-name), however, 220a25f0a04SGreg Roach // the name will often be "private + private" 221a25f0a04SGreg Roach return true; 222a25f0a04SGreg Roach } 223a25f0a04SGreg Roach 224a25f0a04SGreg Roach /** 225a25f0a04SGreg Roach * Find the spouse of a person. 226a25f0a04SGreg Roach * 227a25f0a04SGreg Roach * @param Individual $person 22813e3123bSGreg Roach * @param int|null $access_level 229a25f0a04SGreg Roach * 230a25f0a04SGreg Roach * @return Individual|null 231a25f0a04SGreg Roach */ 232*39ca88baSGreg Roach public function spouse(Individual $person, $access_level = null) 233c1010edaSGreg Roach { 234a25f0a04SGreg Roach if ($person === $this->wife) { 235*39ca88baSGreg Roach return $this->husband($access_level); 236a25f0a04SGreg Roach } 237b2ce94c6SRico Sonntag 238*39ca88baSGreg Roach return $this->wife($access_level); 239a25f0a04SGreg Roach } 240a25f0a04SGreg Roach 241a25f0a04SGreg Roach /** 242a25f0a04SGreg Roach * Get the (zero, one or two) spouses from this family. 243a25f0a04SGreg Roach * 244cbc1590aSGreg Roach * @param int|null $access_level 245a25f0a04SGreg Roach * 246a25f0a04SGreg Roach * @return Individual[] 247a25f0a04SGreg Roach */ 248*39ca88baSGreg Roach public function spouses($access_level = null): array 249c1010edaSGreg Roach { 25013abd6f3SGreg Roach return array_filter([ 251*39ca88baSGreg Roach $this->husband($access_level), 252*39ca88baSGreg Roach $this->wife($access_level), 25313abd6f3SGreg Roach ]); 254a25f0a04SGreg Roach } 255a25f0a04SGreg Roach 256a25f0a04SGreg Roach /** 257a25f0a04SGreg Roach * Get a list of this family’s children. 258a25f0a04SGreg Roach * 259cbc1590aSGreg Roach * @param int|null $access_level 260a25f0a04SGreg Roach * 261a25f0a04SGreg Roach * @return Individual[] 262a25f0a04SGreg Roach */ 263*39ca88baSGreg Roach public function children($access_level = null): array 264c1010edaSGreg Roach { 2654b9ff166SGreg Roach if ($access_level === null) { 2664b9ff166SGreg Roach $access_level = Auth::accessLevel($this->tree); 2674b9ff166SGreg Roach } 2684b9ff166SGreg Roach 269845c3ce6SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 270a25f0a04SGreg Roach 27113abd6f3SGreg Roach $children = []; 2728d0ebef0SGreg Roach foreach ($this->facts(['CHIL'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { 273dc124885SGreg Roach $child = $fact->target(); 274e24444eeSGreg Roach if ($child instanceof Individual && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { 275a25f0a04SGreg Roach $children[] = $child; 276a25f0a04SGreg Roach } 277a25f0a04SGreg Roach } 278a25f0a04SGreg Roach 279a25f0a04SGreg Roach return $children; 280a25f0a04SGreg Roach } 281a25f0a04SGreg Roach 282a25f0a04SGreg Roach /** 283a25f0a04SGreg Roach * Number of children - for the individual list 284a25f0a04SGreg Roach * 285cbc1590aSGreg Roach * @return int 286a25f0a04SGreg Roach */ 287*39ca88baSGreg Roach public function numberOfChildren(): int 288c1010edaSGreg Roach { 289*39ca88baSGreg Roach $nchi = count($this->children()); 2908d0ebef0SGreg Roach foreach ($this->facts(['NCHI']) as $fact) { 29184586c02SGreg Roach $nchi = max($nchi, (int) $fact->value()); 292a25f0a04SGreg Roach } 293a25f0a04SGreg Roach 294a25f0a04SGreg Roach return $nchi; 295a25f0a04SGreg Roach } 296a25f0a04SGreg Roach 297a25f0a04SGreg Roach /** 298a25f0a04SGreg Roach * get the marriage event 299a25f0a04SGreg Roach * 30066107289SGreg Roach * @return Fact|null 301a25f0a04SGreg Roach */ 30266107289SGreg Roach public function getMarriage() 303c1010edaSGreg Roach { 304*39ca88baSGreg Roach return $this->firstFact('MARR'); 305a25f0a04SGreg Roach } 306a25f0a04SGreg Roach 307a25f0a04SGreg Roach /** 308a25f0a04SGreg Roach * Get marriage date 309a25f0a04SGreg Roach * 310a25f0a04SGreg Roach * @return Date 311a25f0a04SGreg Roach */ 312c1010edaSGreg Roach public function getMarriageDate() 313c1010edaSGreg Roach { 314a25f0a04SGreg Roach $marriage = $this->getMarriage(); 315a25f0a04SGreg Roach if ($marriage) { 3162decada7SGreg Roach return $marriage->date(); 317a25f0a04SGreg Roach } 318b2ce94c6SRico Sonntag 319b2ce94c6SRico Sonntag return new Date(''); 320a25f0a04SGreg Roach } 321a25f0a04SGreg Roach 322a25f0a04SGreg Roach /** 323a25f0a04SGreg Roach * Get the marriage year - displayed on lists of families 324a25f0a04SGreg Roach * 325cbc1590aSGreg Roach * @return int 326a25f0a04SGreg Roach */ 3278f53f488SRico Sonntag public function getMarriageYear(): int 328c1010edaSGreg Roach { 3294a83f5d7SGreg Roach return $this->getMarriageDate()->minimumDate()->year; 330a25f0a04SGreg Roach } 331a25f0a04SGreg Roach 332a25f0a04SGreg Roach /** 333a25f0a04SGreg Roach * Get the marriage place 334a25f0a04SGreg Roach * 335a25f0a04SGreg Roach * @return Place 336a25f0a04SGreg Roach */ 3378f53f488SRico Sonntag public function getMarriagePlace(): Place 338c1010edaSGreg Roach { 339a25f0a04SGreg Roach $marriage = $this->getMarriage(); 340a25f0a04SGreg Roach 3414fb14fcbSGreg Roach return $marriage->place(); 342a25f0a04SGreg Roach } 343a25f0a04SGreg Roach 344a25f0a04SGreg Roach /** 345a25f0a04SGreg Roach * Get a list of all marriage dates - for the family lists. 346a25f0a04SGreg Roach * 347a25f0a04SGreg Roach * @return Date[] 348a25f0a04SGreg Roach */ 3498f53f488SRico Sonntag public function getAllMarriageDates(): array 350c1010edaSGreg Roach { 3518d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3528d0ebef0SGreg Roach if ($array = $this->getAllEventDates([$event])) { 353a25f0a04SGreg Roach return $array; 354a25f0a04SGreg Roach } 355a25f0a04SGreg Roach } 356a25f0a04SGreg Roach 35713abd6f3SGreg Roach return []; 358a25f0a04SGreg Roach } 359a25f0a04SGreg Roach 360a25f0a04SGreg Roach /** 361a25f0a04SGreg Roach * Get a list of all marriage places - for the family lists. 362a25f0a04SGreg Roach * 3634080d558SGreg Roach * @return Place[] 364a25f0a04SGreg Roach */ 3658f53f488SRico Sonntag public function getAllMarriagePlaces(): array 366c1010edaSGreg Roach { 3678d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3686e83554dSGreg Roach $places = $this->getAllEventPlaces([$event]); 3694080d558SGreg Roach if (!empty($places)) { 3704080d558SGreg Roach return $places; 371a25f0a04SGreg Roach } 372a25f0a04SGreg Roach } 373a25f0a04SGreg Roach 37413abd6f3SGreg Roach return []; 375a25f0a04SGreg Roach } 376a25f0a04SGreg Roach 37776692c8bSGreg Roach /** 37876692c8bSGreg Roach * Derived classes should redefine this function, otherwise the object will have no name 37976692c8bSGreg Roach * 38076692c8bSGreg Roach * @return string[][] 38176692c8bSGreg Roach */ 3828f53f488SRico Sonntag public function getAllNames(): array 383c1010edaSGreg Roach { 3848f038c36SRico Sonntag if ($this->getAllNames === null) { 385a25f0a04SGreg Roach // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc. 386e88674d4SGreg Roach $husb_names = []; 387a25f0a04SGreg Roach if ($this->husb) { 388492c7072SGreg Roach $husb_names = array_filter($this->husb->getAllNames(), function (array $x): bool { 3898d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3908d68cabeSGreg Roach }); 391e88674d4SGreg Roach } 392e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 393e88674d4SGreg Roach if (empty($husb_names)) { 394e88674d4SGreg Roach $husb_names[] = [ 395a25f0a04SGreg Roach 'type' => 'BIRT', 396a25f0a04SGreg Roach 'sort' => '@N.N.', 397ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 39813abd6f3SGreg Roach ]; 399a25f0a04SGreg Roach } 400a25f0a04SGreg Roach foreach ($husb_names as $n => $husb_name) { 401a25f0a04SGreg Roach $husb_names[$n]['script'] = I18N::textScript($husb_name['full']); 402a25f0a04SGreg Roach } 403e88674d4SGreg Roach 404e88674d4SGreg Roach $wife_names = []; 405a25f0a04SGreg Roach if ($this->wife) { 406492c7072SGreg Roach $wife_names = array_filter($this->wife->getAllNames(), function (array $x): bool { 4078d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 4088d68cabeSGreg Roach }); 409e88674d4SGreg Roach } 410e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 411e88674d4SGreg Roach if (empty($wife_names)) { 412e88674d4SGreg Roach $wife_names[] = [ 413a25f0a04SGreg Roach 'type' => 'BIRT', 414a25f0a04SGreg Roach 'sort' => '@N.N.', 415ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 41613abd6f3SGreg Roach ]; 417a25f0a04SGreg Roach } 418a25f0a04SGreg Roach foreach ($wife_names as $n => $wife_name) { 419a25f0a04SGreg Roach $wife_names[$n]['script'] = I18N::textScript($wife_name['full']); 420a25f0a04SGreg Roach } 421e88674d4SGreg Roach 422a25f0a04SGreg Roach // Add the matched names first 423a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 424a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 425e88674d4SGreg Roach if ($husb_name['script'] == $wife_name['script']) { 426bdb3725aSGreg Roach $this->getAllNames[] = [ 427a25f0a04SGreg Roach 'type' => $husb_name['type'], 428a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 429a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 430a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 43113abd6f3SGreg Roach ]; 432a25f0a04SGreg Roach } 433a25f0a04SGreg Roach } 434a25f0a04SGreg Roach } 435e88674d4SGreg Roach 436a25f0a04SGreg Roach // Add the unmatched names second (there may be no matched names) 437a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 438a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 439e88674d4SGreg Roach if ($husb_name['script'] != $wife_name['script']) { 440bdb3725aSGreg Roach $this->getAllNames[] = [ 441a25f0a04SGreg Roach 'type' => $husb_name['type'], 442a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 443a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 444a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 44513abd6f3SGreg Roach ]; 446a25f0a04SGreg Roach } 447a25f0a04SGreg Roach } 448a25f0a04SGreg Roach } 449a25f0a04SGreg Roach } 450a25f0a04SGreg Roach 451bdb3725aSGreg Roach return $this->getAllNames; 452a25f0a04SGreg Roach } 453a25f0a04SGreg Roach 45476692c8bSGreg Roach /** 45576692c8bSGreg Roach * This function should be redefined in derived classes to show any major 45676692c8bSGreg Roach * identifying characteristics of this record. 45776692c8bSGreg Roach * 45876692c8bSGreg Roach * @return string 45976692c8bSGreg Roach */ 4608f53f488SRico Sonntag public function formatListDetails(): string 461c1010edaSGreg Roach { 462a25f0a04SGreg Roach return 4638d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 1) . 4648d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 1); 465a25f0a04SGreg Roach } 466a25f0a04SGreg Roach} 467