1a25f0a04SGreg Roach<?php 2a25f0a04SGreg Roach/** 3a25f0a04SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 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 20*2e5b4452SGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 21*2e5b4452SGreg Roach 22a25f0a04SGreg Roach/** 2376692c8bSGreg Roach * A GEDCOM family (FAM) object. 24a25f0a04SGreg Roach */ 25c1010edaSGreg Roachclass Family extends GedcomRecord 26c1010edaSGreg Roach{ 27a25f0a04SGreg Roach const RECORD_TYPE = 'FAM'; 28225e381fSGreg Roach const ROUTE_NAME = 'family'; 29a25f0a04SGreg Roach 30a25f0a04SGreg Roach /** @var Individual|null The husband (or first spouse for same-sex couples) */ 31a25f0a04SGreg Roach private $husb; 32a25f0a04SGreg Roach 33a25f0a04SGreg Roach /** @var Individual|null The wife (or second spouse for same-sex couples) */ 34a25f0a04SGreg Roach private $wife; 35a25f0a04SGreg Roach 3676692c8bSGreg Roach /** 3776692c8bSGreg Roach * Create a GedcomRecord object from raw GEDCOM data. 3876692c8bSGreg Roach * 3976692c8bSGreg Roach * @param string $xref 4076692c8bSGreg Roach * @param string $gedcom an empty string for new/pending records 4176692c8bSGreg Roach * @param string|null $pending null for a record with no pending edits, 4276692c8bSGreg Roach * empty string for records with pending deletions 4376692c8bSGreg Roach * @param Tree $tree 4476692c8bSGreg Roach */ 4576f666f4SGreg Roach public function __construct(string $xref, string $gedcom, $pending, Tree $tree) 46c1010edaSGreg Roach { 4724ec66ceSGreg Roach parent::__construct($xref, $gedcom, $pending, $tree); 48a25f0a04SGreg Roach 49395f0fe0SGreg Roach // Fetch family members 50395f0fe0SGreg Roach if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) { 51395f0fe0SGreg Roach Individual::load($tree, $match[1]); 52395f0fe0SGreg Roach } 53395f0fe0SGreg Roach 54a25f0a04SGreg Roach if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) { 5524ec66ceSGreg Roach $this->husb = Individual::getInstance($match[1], $tree); 56a25f0a04SGreg Roach } 57a25f0a04SGreg Roach if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) { 5824ec66ceSGreg Roach $this->wife = Individual::getInstance($match[1], $tree); 59a25f0a04SGreg Roach } 60a25f0a04SGreg Roach } 61a25f0a04SGreg Roach 6276692c8bSGreg Roach /** 63e71ef9d2SGreg Roach * Get an instance of a family object. For single records, 64e71ef9d2SGreg Roach * we just receive the XREF. For bulk records (such as lists 65e71ef9d2SGreg Roach * and search results) we can receive the GEDCOM data as well. 66e71ef9d2SGreg Roach * 67e71ef9d2SGreg Roach * @param string $xref 68e71ef9d2SGreg Roach * @param Tree $tree 69e71ef9d2SGreg Roach * @param string|null $gedcom 70e71ef9d2SGreg Roach * 71e71ef9d2SGreg Roach * @throws \Exception 72e71ef9d2SGreg Roach * 73e71ef9d2SGreg Roach * @return Family|null 74e71ef9d2SGreg Roach */ 7576f666f4SGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null) 76c1010edaSGreg Roach { 77e71ef9d2SGreg Roach $record = parent::getInstance($xref, $tree, $gedcom); 78e71ef9d2SGreg Roach 79e71ef9d2SGreg Roach if ($record instanceof Family) { 80e71ef9d2SGreg Roach return $record; 81e71ef9d2SGreg Roach } 82b2ce94c6SRico Sonntag 83b2ce94c6SRico Sonntag return null; 84e71ef9d2SGreg Roach } 85e71ef9d2SGreg Roach 86e71ef9d2SGreg Roach /** 8776692c8bSGreg Roach * Generate a private version of this record 8876692c8bSGreg Roach * 8976692c8bSGreg Roach * @param int $access_level 9076692c8bSGreg Roach * 9176692c8bSGreg Roach * @return string 9276692c8bSGreg Roach */ 933c90ed31SGreg Roach protected function createPrivateGedcomRecord(int $access_level): string 94c1010edaSGreg Roach { 95d86cc606SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 96a25f0a04SGreg Roach 97a25f0a04SGreg Roach $rec = '0 @' . $this->xref . '@ FAM'; 98a25f0a04SGreg Roach // Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data 998d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER); 100a25f0a04SGreg Roach foreach ($matches as $match) { 10124ec66ceSGreg Roach $rela = Individual::getInstance($match[1], $this->tree); 102a25f0a04SGreg Roach if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) { 103a25f0a04SGreg Roach $rec .= $match[0]; 104a25f0a04SGreg Roach } 105a25f0a04SGreg Roach } 106a25f0a04SGreg Roach 107a25f0a04SGreg Roach return $rec; 108a25f0a04SGreg Roach } 109a25f0a04SGreg Roach 11076692c8bSGreg Roach /** 11176692c8bSGreg Roach * Fetch data from the database 11276692c8bSGreg Roach * 11376692c8bSGreg Roach * @param string $xref 11476692c8bSGreg Roach * @param int $tree_id 11576692c8bSGreg Roach * 11676692c8bSGreg Roach * @return null|string 11776692c8bSGreg Roach */ 11876f666f4SGreg Roach protected static function fetchGedcomRecord(string $xref, int $tree_id) 119c1010edaSGreg Roach { 120*2e5b4452SGreg Roach return DB::table('families') 121*2e5b4452SGreg Roach ->where('f_id', '=', $xref) 122*2e5b4452SGreg Roach ->where('f_file', '=', $tree_id) 123*2e5b4452SGreg Roach ->value('f_gedcom'); 124a25f0a04SGreg Roach } 125a25f0a04SGreg Roach 126a25f0a04SGreg Roach /** 127a25f0a04SGreg Roach * Get the male (or first female) partner of the family 128a25f0a04SGreg Roach * 129e93111adSRico Sonntag * @param int|null $access_level 130b3f49e6cSGreg Roach * 131a25f0a04SGreg Roach * @return Individual|null 132a25f0a04SGreg Roach */ 133c1010edaSGreg Roach public function getHusband($access_level = null) 134c1010edaSGreg Roach { 135b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 136b3f49e6cSGreg Roach 137b3f49e6cSGreg Roach if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) { 138a25f0a04SGreg Roach return $this->husb; 139a25f0a04SGreg Roach } 140b2ce94c6SRico Sonntag 141b2ce94c6SRico Sonntag return null; 142a25f0a04SGreg Roach } 143a25f0a04SGreg Roach 144a25f0a04SGreg Roach /** 145a25f0a04SGreg Roach * Get the female (or second male) partner of the family 146a25f0a04SGreg Roach * 147e93111adSRico Sonntag * @param int|null $access_level 148b3f49e6cSGreg Roach * 149a25f0a04SGreg Roach * @return Individual|null 150a25f0a04SGreg Roach */ 151c1010edaSGreg Roach public function getWife($access_level = null) 152c1010edaSGreg Roach { 153b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 154b3f49e6cSGreg Roach 155b3f49e6cSGreg Roach if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) { 156a25f0a04SGreg Roach return $this->wife; 157a25f0a04SGreg Roach } 158b2ce94c6SRico Sonntag 159b2ce94c6SRico Sonntag return null; 160a25f0a04SGreg Roach } 161a25f0a04SGreg Roach 16276692c8bSGreg Roach /** 16376692c8bSGreg Roach * Each object type may have its own special rules, and re-implement this function. 16476692c8bSGreg Roach * 16576692c8bSGreg Roach * @param int $access_level 16676692c8bSGreg Roach * 16776692c8bSGreg Roach * @return bool 16876692c8bSGreg Roach */ 16935584196SGreg Roach protected function canShowByType(int $access_level): bool 170c1010edaSGreg Roach { 171a25f0a04SGreg Roach // Hide a family if any member is private 1728d0ebef0SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . Gedcom::REGEX_XREF . ')@/', $this->gedcom, $matches); 173a25f0a04SGreg Roach foreach ($matches[1] as $match) { 17424ec66ceSGreg Roach $person = Individual::getInstance($match, $this->tree); 175a25f0a04SGreg Roach if ($person && !$person->canShow($access_level)) { 176a25f0a04SGreg Roach return false; 177a25f0a04SGreg Roach } 178a25f0a04SGreg Roach } 179a25f0a04SGreg Roach 180a25f0a04SGreg Roach return true; 181a25f0a04SGreg Roach } 182a25f0a04SGreg Roach 18376692c8bSGreg Roach /** 18476692c8bSGreg Roach * Can the name of this record be shown? 18576692c8bSGreg Roach * 18676692c8bSGreg Roach * @param int|null $access_level 18776692c8bSGreg Roach * 18876692c8bSGreg Roach * @return bool 18976692c8bSGreg Roach */ 19035584196SGreg Roach public function canShowName(int $access_level = null): bool 191c1010edaSGreg Roach { 192a25f0a04SGreg Roach // We can always see the name (Husband-name + Wife-name), however, 193a25f0a04SGreg Roach // the name will often be "private + private" 194a25f0a04SGreg Roach return true; 195a25f0a04SGreg Roach } 196a25f0a04SGreg Roach 197a25f0a04SGreg Roach /** 198a25f0a04SGreg Roach * Find the spouse of a person. 199a25f0a04SGreg Roach * 200a25f0a04SGreg Roach * @param Individual $person 20113e3123bSGreg Roach * @param int|null $access_level 202a25f0a04SGreg Roach * 203a25f0a04SGreg Roach * @return Individual|null 204a25f0a04SGreg Roach */ 205c1010edaSGreg Roach public function getSpouse(Individual $person, $access_level = null) 206c1010edaSGreg Roach { 207a25f0a04SGreg Roach if ($person === $this->wife) { 20813e3123bSGreg Roach return $this->getHusband($access_level); 209a25f0a04SGreg Roach } 210b2ce94c6SRico Sonntag 211b2ce94c6SRico Sonntag return $this->getWife($access_level); 212a25f0a04SGreg Roach } 213a25f0a04SGreg Roach 214a25f0a04SGreg Roach /** 215a25f0a04SGreg Roach * Get the (zero, one or two) spouses from this family. 216a25f0a04SGreg Roach * 217cbc1590aSGreg Roach * @param int|null $access_level 218a25f0a04SGreg Roach * 219a25f0a04SGreg Roach * @return Individual[] 220a25f0a04SGreg Roach */ 2218f53f488SRico Sonntag public function getSpouses($access_level = null): array 222c1010edaSGreg Roach { 22313abd6f3SGreg Roach return array_filter([ 224b3f49e6cSGreg Roach $this->getHusband($access_level), 225b3f49e6cSGreg Roach $this->getWife($access_level), 22613abd6f3SGreg Roach ]); 227a25f0a04SGreg Roach } 228a25f0a04SGreg Roach 229a25f0a04SGreg Roach /** 230a25f0a04SGreg Roach * Get a list of this family’s children. 231a25f0a04SGreg Roach * 232cbc1590aSGreg Roach * @param int|null $access_level 233a25f0a04SGreg Roach * 234a25f0a04SGreg Roach * @return Individual[] 235a25f0a04SGreg Roach */ 2368f53f488SRico Sonntag public function getChildren($access_level = null): array 237c1010edaSGreg Roach { 2384b9ff166SGreg Roach if ($access_level === null) { 2394b9ff166SGreg Roach $access_level = Auth::accessLevel($this->tree); 2404b9ff166SGreg Roach } 2414b9ff166SGreg Roach 242845c3ce6SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 243a25f0a04SGreg Roach 24413abd6f3SGreg Roach $children = []; 2458d0ebef0SGreg Roach foreach ($this->facts(['CHIL'], false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { 246dc124885SGreg Roach $child = $fact->target(); 247e24444eeSGreg Roach if ($child instanceof Individual && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { 248a25f0a04SGreg Roach $children[] = $child; 249a25f0a04SGreg Roach } 250a25f0a04SGreg Roach } 251a25f0a04SGreg Roach 252a25f0a04SGreg Roach return $children; 253a25f0a04SGreg Roach } 254a25f0a04SGreg Roach 255a25f0a04SGreg Roach /** 256a25f0a04SGreg Roach * Static helper function to sort an array of families by marriage date 257a25f0a04SGreg Roach * 258a25f0a04SGreg Roach * @param Family $x 259a25f0a04SGreg Roach * @param Family $y 260a25f0a04SGreg Roach * 261cbc1590aSGreg Roach * @return int 262a25f0a04SGreg Roach */ 2638f53f488SRico Sonntag public static function compareMarrDate(Family $x, Family $y): int 264c1010edaSGreg Roach { 265f5b60decSGreg Roach return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); 266a25f0a04SGreg Roach } 267a25f0a04SGreg Roach 268a25f0a04SGreg Roach /** 269a25f0a04SGreg Roach * Number of children - for the individual list 270a25f0a04SGreg Roach * 271cbc1590aSGreg Roach * @return int 272a25f0a04SGreg Roach */ 2738f53f488SRico Sonntag public function getNumberOfChildren(): int 274c1010edaSGreg Roach { 275a25f0a04SGreg Roach $nchi = count($this->getChildren()); 2768d0ebef0SGreg Roach foreach ($this->facts(['NCHI']) as $fact) { 27784586c02SGreg Roach $nchi = max($nchi, (int) $fact->value()); 278a25f0a04SGreg Roach } 279a25f0a04SGreg Roach 280a25f0a04SGreg Roach return $nchi; 281a25f0a04SGreg Roach } 282a25f0a04SGreg Roach 283a25f0a04SGreg Roach /** 284a25f0a04SGreg Roach * get the marriage event 285a25f0a04SGreg Roach * 28666107289SGreg Roach * @return Fact|null 287a25f0a04SGreg Roach */ 28866107289SGreg Roach public function getMarriage() 289c1010edaSGreg Roach { 290a25f0a04SGreg Roach return $this->getFirstFact('MARR'); 291a25f0a04SGreg Roach } 292a25f0a04SGreg Roach 293a25f0a04SGreg Roach /** 294a25f0a04SGreg Roach * Get marriage date 295a25f0a04SGreg Roach * 296a25f0a04SGreg Roach * @return Date 297a25f0a04SGreg Roach */ 298c1010edaSGreg Roach public function getMarriageDate() 299c1010edaSGreg Roach { 300a25f0a04SGreg Roach $marriage = $this->getMarriage(); 301a25f0a04SGreg Roach if ($marriage) { 3022decada7SGreg Roach return $marriage->date(); 303a25f0a04SGreg Roach } 304b2ce94c6SRico Sonntag 305b2ce94c6SRico Sonntag return new Date(''); 306a25f0a04SGreg Roach } 307a25f0a04SGreg Roach 308a25f0a04SGreg Roach /** 309a25f0a04SGreg Roach * Get the marriage year - displayed on lists of families 310a25f0a04SGreg Roach * 311cbc1590aSGreg Roach * @return int 312a25f0a04SGreg Roach */ 3138f53f488SRico Sonntag public function getMarriageYear(): int 314c1010edaSGreg Roach { 3154a83f5d7SGreg Roach return $this->getMarriageDate()->minimumDate()->year; 316a25f0a04SGreg Roach } 317a25f0a04SGreg Roach 318a25f0a04SGreg Roach /** 319a25f0a04SGreg Roach * Get the marriage place 320a25f0a04SGreg Roach * 321a25f0a04SGreg Roach * @return Place 322a25f0a04SGreg Roach */ 3238f53f488SRico Sonntag public function getMarriagePlace(): Place 324c1010edaSGreg Roach { 325a25f0a04SGreg Roach $marriage = $this->getMarriage(); 326a25f0a04SGreg Roach 3274fb14fcbSGreg Roach return $marriage->place(); 328a25f0a04SGreg Roach } 329a25f0a04SGreg Roach 330a25f0a04SGreg Roach /** 331a25f0a04SGreg Roach * Get a list of all marriage dates - for the family lists. 332a25f0a04SGreg Roach * 333a25f0a04SGreg Roach * @return Date[] 334a25f0a04SGreg Roach */ 3358f53f488SRico Sonntag public function getAllMarriageDates(): array 336c1010edaSGreg Roach { 3378d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3388d0ebef0SGreg Roach if ($array = $this->getAllEventDates([$event])) { 339a25f0a04SGreg Roach return $array; 340a25f0a04SGreg Roach } 341a25f0a04SGreg Roach } 342a25f0a04SGreg Roach 34313abd6f3SGreg Roach return []; 344a25f0a04SGreg Roach } 345a25f0a04SGreg Roach 346a25f0a04SGreg Roach /** 347a25f0a04SGreg Roach * Get a list of all marriage places - for the family lists. 348a25f0a04SGreg Roach * 3494080d558SGreg Roach * @return Place[] 350a25f0a04SGreg Roach */ 3518f53f488SRico Sonntag public function getAllMarriagePlaces(): array 352c1010edaSGreg Roach { 3538d0ebef0SGreg Roach foreach (Gedcom::MARRIAGE_EVENTS as $event) { 3546e83554dSGreg Roach $places = $this->getAllEventPlaces([$event]); 3554080d558SGreg Roach if (!empty($places)) { 3564080d558SGreg Roach return $places; 357a25f0a04SGreg Roach } 358a25f0a04SGreg Roach } 359a25f0a04SGreg Roach 36013abd6f3SGreg Roach return []; 361a25f0a04SGreg Roach } 362a25f0a04SGreg Roach 36376692c8bSGreg Roach /** 36476692c8bSGreg Roach * Derived classes should redefine this function, otherwise the object will have no name 36576692c8bSGreg Roach * 36676692c8bSGreg Roach * @return string[][] 36776692c8bSGreg Roach */ 3688f53f488SRico Sonntag public function getAllNames(): array 369c1010edaSGreg Roach { 3708f038c36SRico Sonntag if ($this->getAllNames === null) { 371a25f0a04SGreg Roach // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc. 372e88674d4SGreg Roach $husb_names = []; 373a25f0a04SGreg Roach if ($this->husb) { 374492c7072SGreg Roach $husb_names = array_filter($this->husb->getAllNames(), function (array $x): bool { 3758d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3768d68cabeSGreg Roach }); 377e88674d4SGreg Roach } 378e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 379e88674d4SGreg Roach if (empty($husb_names)) { 380e88674d4SGreg Roach $husb_names[] = [ 381a25f0a04SGreg Roach 'type' => 'BIRT', 382a25f0a04SGreg Roach 'sort' => '@N.N.', 383ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 38413abd6f3SGreg Roach ]; 385a25f0a04SGreg Roach } 386a25f0a04SGreg Roach foreach ($husb_names as $n => $husb_name) { 387a25f0a04SGreg Roach $husb_names[$n]['script'] = I18N::textScript($husb_name['full']); 388a25f0a04SGreg Roach } 389e88674d4SGreg Roach 390e88674d4SGreg Roach $wife_names = []; 391a25f0a04SGreg Roach if ($this->wife) { 392492c7072SGreg Roach $wife_names = array_filter($this->wife->getAllNames(), function (array $x): bool { 3938d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3948d68cabeSGreg Roach }); 395e88674d4SGreg Roach } 396e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 397e88674d4SGreg Roach if (empty($wife_names)) { 398e88674d4SGreg Roach $wife_names[] = [ 399a25f0a04SGreg Roach 'type' => 'BIRT', 400a25f0a04SGreg Roach 'sort' => '@N.N.', 401ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 40213abd6f3SGreg Roach ]; 403a25f0a04SGreg Roach } 404a25f0a04SGreg Roach foreach ($wife_names as $n => $wife_name) { 405a25f0a04SGreg Roach $wife_names[$n]['script'] = I18N::textScript($wife_name['full']); 406a25f0a04SGreg Roach } 407e88674d4SGreg Roach 408a25f0a04SGreg Roach // Add the matched names first 409a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 410a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 411e88674d4SGreg Roach if ($husb_name['script'] == $wife_name['script']) { 412bdb3725aSGreg Roach $this->getAllNames[] = [ 413a25f0a04SGreg Roach 'type' => $husb_name['type'], 414a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 415a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 416a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 41713abd6f3SGreg Roach ]; 418a25f0a04SGreg Roach } 419a25f0a04SGreg Roach } 420a25f0a04SGreg Roach } 421e88674d4SGreg Roach 422a25f0a04SGreg Roach // Add the unmatched names second (there may be no matched names) 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 } 435a25f0a04SGreg Roach } 436a25f0a04SGreg Roach 437bdb3725aSGreg Roach return $this->getAllNames; 438a25f0a04SGreg Roach } 439a25f0a04SGreg Roach 44076692c8bSGreg Roach /** 44176692c8bSGreg Roach * This function should be redefined in derived classes to show any major 44276692c8bSGreg Roach * identifying characteristics of this record. 44376692c8bSGreg Roach * 44476692c8bSGreg Roach * @return string 44576692c8bSGreg Roach */ 4468f53f488SRico Sonntag public function formatListDetails(): string 447c1010edaSGreg Roach { 448a25f0a04SGreg Roach return 4498d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::MARRIAGE_EVENTS, 1) . 4508d0ebef0SGreg Roach $this->formatFirstMajorFact(Gedcom::DIVORCE_EVENTS, 1); 451a25f0a04SGreg Roach } 452a25f0a04SGreg Roach} 453