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 */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees; 17a25f0a04SGreg Roach 18a25f0a04SGreg Roach/** 1976692c8bSGreg Roach * A GEDCOM family (FAM) object. 20a25f0a04SGreg Roach */ 21c1010edaSGreg Roachclass Family extends GedcomRecord 22c1010edaSGreg Roach{ 23a25f0a04SGreg Roach const RECORD_TYPE = 'FAM'; 24225e381fSGreg Roach const ROUTE_NAME = 'family'; 25a25f0a04SGreg Roach 26a25f0a04SGreg Roach /** @var Individual|null The husband (or first spouse for same-sex couples) */ 27a25f0a04SGreg Roach private $husb; 28a25f0a04SGreg Roach 29a25f0a04SGreg Roach /** @var Individual|null The wife (or second spouse for same-sex couples) */ 30a25f0a04SGreg Roach private $wife; 31a25f0a04SGreg Roach 3276692c8bSGreg Roach /** 3376692c8bSGreg Roach * Create a GedcomRecord object from raw GEDCOM data. 3476692c8bSGreg Roach * 3576692c8bSGreg Roach * @param string $xref 3676692c8bSGreg Roach * @param string $gedcom an empty string for new/pending records 3776692c8bSGreg Roach * @param string|null $pending null for a record with no pending edits, 3876692c8bSGreg Roach * empty string for records with pending deletions 3976692c8bSGreg Roach * @param Tree $tree 4076692c8bSGreg Roach */ 4176f666f4SGreg Roach public function __construct(string $xref, string $gedcom, $pending, Tree $tree) 42c1010edaSGreg Roach { 4324ec66ceSGreg Roach parent::__construct($xref, $gedcom, $pending, $tree); 44a25f0a04SGreg Roach 45395f0fe0SGreg Roach // Fetch family members 46395f0fe0SGreg Roach if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) { 47395f0fe0SGreg Roach Individual::load($tree, $match[1]); 48395f0fe0SGreg Roach } 49395f0fe0SGreg Roach 50a25f0a04SGreg Roach if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) { 5124ec66ceSGreg Roach $this->husb = Individual::getInstance($match[1], $tree); 52a25f0a04SGreg Roach } 53a25f0a04SGreg Roach if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) { 5424ec66ceSGreg Roach $this->wife = Individual::getInstance($match[1], $tree); 55a25f0a04SGreg Roach } 56a25f0a04SGreg Roach 57a25f0a04SGreg Roach // Make sure husb/wife are the right way round. 58a5adda01SGreg Roach if ($this->husb && $this->husb->getSex() === 'F' || $this->wife && $this->wife->getSex() === 'M') { 59c1010edaSGreg Roach list($this->husb, $this->wife) = [ 60c1010edaSGreg Roach $this->wife, 61c1010edaSGreg Roach $this->husb, 62c1010edaSGreg Roach ]; 63a25f0a04SGreg Roach } 64a25f0a04SGreg Roach } 65a25f0a04SGreg Roach 6676692c8bSGreg Roach /** 67e71ef9d2SGreg Roach * Get an instance of a family object. For single records, 68e71ef9d2SGreg Roach * we just receive the XREF. For bulk records (such as lists 69e71ef9d2SGreg Roach * and search results) we can receive the GEDCOM data as well. 70e71ef9d2SGreg Roach * 71e71ef9d2SGreg Roach * @param string $xref 72e71ef9d2SGreg Roach * @param Tree $tree 73e71ef9d2SGreg Roach * @param string|null $gedcom 74e71ef9d2SGreg Roach * 75e71ef9d2SGreg Roach * @throws \Exception 76e71ef9d2SGreg Roach * 77e71ef9d2SGreg Roach * @return Family|null 78e71ef9d2SGreg Roach */ 7976f666f4SGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null) 80c1010edaSGreg Roach { 81e71ef9d2SGreg Roach $record = parent::getInstance($xref, $tree, $gedcom); 82e71ef9d2SGreg Roach 83e71ef9d2SGreg Roach if ($record instanceof Family) { 84e71ef9d2SGreg Roach return $record; 85e71ef9d2SGreg Roach } 86*b2ce94c6SRico Sonntag 87*b2ce94c6SRico Sonntag return null; 88e71ef9d2SGreg Roach } 89e71ef9d2SGreg Roach 90e71ef9d2SGreg Roach /** 9176692c8bSGreg Roach * Generate a private version of this record 9276692c8bSGreg Roach * 9376692c8bSGreg Roach * @param int $access_level 9476692c8bSGreg Roach * 9576692c8bSGreg Roach * @return string 9676692c8bSGreg Roach */ 978f53f488SRico Sonntag protected function createPrivateGedcomRecord($access_level): string 98c1010edaSGreg Roach { 99d86cc606SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 100a25f0a04SGreg Roach 101a25f0a04SGreg Roach $rec = '0 @' . $this->xref . '@ FAM'; 102a25f0a04SGreg Roach // Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data 103a25f0a04SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER); 104a25f0a04SGreg Roach foreach ($matches as $match) { 10524ec66ceSGreg Roach $rela = Individual::getInstance($match[1], $this->tree); 106a25f0a04SGreg Roach if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) { 107a25f0a04SGreg Roach $rec .= $match[0]; 108a25f0a04SGreg Roach } 109a25f0a04SGreg Roach } 110a25f0a04SGreg Roach 111a25f0a04SGreg Roach return $rec; 112a25f0a04SGreg Roach } 113a25f0a04SGreg Roach 11476692c8bSGreg Roach /** 11576692c8bSGreg Roach * Fetch data from the database 11676692c8bSGreg Roach * 11776692c8bSGreg Roach * @param string $xref 11876692c8bSGreg Roach * @param int $tree_id 11976692c8bSGreg Roach * 12076692c8bSGreg Roach * @return null|string 12176692c8bSGreg Roach */ 12276f666f4SGreg Roach protected static function fetchGedcomRecord(string $xref, int $tree_id) 123c1010edaSGreg Roach { 12464d9078aSGreg Roach return Database::prepare( 12564d9078aSGreg Roach "SELECT f_gedcom FROM `##families` WHERE f_id = :xref AND f_file = :tree_id" 12613abd6f3SGreg Roach )->execute([ 12764d9078aSGreg Roach 'xref' => $xref, 12864d9078aSGreg Roach 'tree_id' => $tree_id, 12913abd6f3SGreg Roach ])->fetchOne(); 130a25f0a04SGreg Roach } 131a25f0a04SGreg Roach 132a25f0a04SGreg Roach /** 133a25f0a04SGreg Roach * Get the male (or first female) partner of the family 134a25f0a04SGreg Roach * 135e93111adSRico Sonntag * @param int|null $access_level 136b3f49e6cSGreg Roach * 137a25f0a04SGreg Roach * @return Individual|null 138a25f0a04SGreg Roach */ 139c1010edaSGreg Roach public function getHusband($access_level = null) 140c1010edaSGreg Roach { 141b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 142b3f49e6cSGreg Roach 143b3f49e6cSGreg Roach if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) { 144a25f0a04SGreg Roach return $this->husb; 145a25f0a04SGreg Roach } 146*b2ce94c6SRico Sonntag 147*b2ce94c6SRico Sonntag return null; 148a25f0a04SGreg Roach } 149a25f0a04SGreg Roach 150a25f0a04SGreg Roach /** 151a25f0a04SGreg Roach * Get the female (or second male) partner of the family 152a25f0a04SGreg Roach * 153e93111adSRico Sonntag * @param int|null $access_level 154b3f49e6cSGreg Roach * 155a25f0a04SGreg Roach * @return Individual|null 156a25f0a04SGreg Roach */ 157c1010edaSGreg Roach public function getWife($access_level = null) 158c1010edaSGreg Roach { 159b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 160b3f49e6cSGreg Roach 161b3f49e6cSGreg Roach if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) { 162a25f0a04SGreg Roach return $this->wife; 163a25f0a04SGreg Roach } 164*b2ce94c6SRico Sonntag 165*b2ce94c6SRico Sonntag return null; 166a25f0a04SGreg Roach } 167a25f0a04SGreg Roach 16876692c8bSGreg Roach /** 16976692c8bSGreg Roach * Each object type may have its own special rules, and re-implement this function. 17076692c8bSGreg Roach * 17176692c8bSGreg Roach * @param int $access_level 17276692c8bSGreg Roach * 17376692c8bSGreg Roach * @return bool 17476692c8bSGreg Roach */ 1758f53f488SRico Sonntag protected function canShowByType($access_level): bool 176c1010edaSGreg Roach { 177a25f0a04SGreg Roach // Hide a family if any member is private 178a25f0a04SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches); 179a25f0a04SGreg Roach foreach ($matches[1] as $match) { 18024ec66ceSGreg Roach $person = Individual::getInstance($match, $this->tree); 181a25f0a04SGreg Roach if ($person && !$person->canShow($access_level)) { 182a25f0a04SGreg Roach return false; 183a25f0a04SGreg Roach } 184a25f0a04SGreg Roach } 185a25f0a04SGreg Roach 186a25f0a04SGreg Roach return true; 187a25f0a04SGreg Roach } 188a25f0a04SGreg Roach 18976692c8bSGreg Roach /** 19076692c8bSGreg Roach * Can the name of this record be shown? 19176692c8bSGreg Roach * 19276692c8bSGreg Roach * @param int|null $access_level 19376692c8bSGreg Roach * 19476692c8bSGreg Roach * @return bool 19576692c8bSGreg Roach */ 1968f53f488SRico Sonntag public function canShowName($access_level = null): bool 197c1010edaSGreg Roach { 198a25f0a04SGreg Roach // We can always see the name (Husband-name + Wife-name), however, 199a25f0a04SGreg Roach // the name will often be "private + private" 200a25f0a04SGreg Roach return true; 201a25f0a04SGreg Roach } 202a25f0a04SGreg Roach 203a25f0a04SGreg Roach /** 204a25f0a04SGreg Roach * Find the spouse of a person. 205a25f0a04SGreg Roach * 206a25f0a04SGreg Roach * @param Individual $person 20713e3123bSGreg Roach * @param int|null $access_level 208a25f0a04SGreg Roach * 209a25f0a04SGreg Roach * @return Individual|null 210a25f0a04SGreg Roach */ 211c1010edaSGreg Roach public function getSpouse(Individual $person, $access_level = null) 212c1010edaSGreg Roach { 213a25f0a04SGreg Roach if ($person === $this->wife) { 21413e3123bSGreg Roach return $this->getHusband($access_level); 215a25f0a04SGreg Roach } 216*b2ce94c6SRico Sonntag 217*b2ce94c6SRico Sonntag return $this->getWife($access_level); 218a25f0a04SGreg Roach } 219a25f0a04SGreg Roach 220a25f0a04SGreg Roach /** 221a25f0a04SGreg Roach * Get the (zero, one or two) spouses from this family. 222a25f0a04SGreg Roach * 223cbc1590aSGreg Roach * @param int|null $access_level 224a25f0a04SGreg Roach * 225a25f0a04SGreg Roach * @return Individual[] 226a25f0a04SGreg Roach */ 2278f53f488SRico Sonntag public function getSpouses($access_level = null): array 228c1010edaSGreg Roach { 22913abd6f3SGreg Roach return array_filter([ 230b3f49e6cSGreg Roach $this->getHusband($access_level), 231b3f49e6cSGreg Roach $this->getWife($access_level), 23213abd6f3SGreg Roach ]); 233a25f0a04SGreg Roach } 234a25f0a04SGreg Roach 235a25f0a04SGreg Roach /** 236a25f0a04SGreg Roach * Get a list of this family’s children. 237a25f0a04SGreg Roach * 238cbc1590aSGreg Roach * @param int|null $access_level 239a25f0a04SGreg Roach * 240a25f0a04SGreg Roach * @return Individual[] 241a25f0a04SGreg Roach */ 2428f53f488SRico Sonntag public function getChildren($access_level = null): array 243c1010edaSGreg Roach { 2444b9ff166SGreg Roach if ($access_level === null) { 2454b9ff166SGreg Roach $access_level = Auth::accessLevel($this->tree); 2464b9ff166SGreg Roach } 2474b9ff166SGreg Roach 248845c3ce6SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 249a25f0a04SGreg Roach 25013abd6f3SGreg Roach $children = []; 251a25f0a04SGreg Roach foreach ($this->getFacts('CHIL', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { 252a25f0a04SGreg Roach $child = $fact->getTarget(); 253a25f0a04SGreg Roach if ($child && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { 254a25f0a04SGreg Roach $children[] = $child; 255a25f0a04SGreg Roach } 256a25f0a04SGreg Roach } 257a25f0a04SGreg Roach 258a25f0a04SGreg Roach return $children; 259a25f0a04SGreg Roach } 260a25f0a04SGreg Roach 261a25f0a04SGreg Roach /** 262a25f0a04SGreg Roach * Static helper function to sort an array of families by marriage date 263a25f0a04SGreg Roach * 264a25f0a04SGreg Roach * @param Family $x 265a25f0a04SGreg Roach * @param Family $y 266a25f0a04SGreg Roach * 267cbc1590aSGreg Roach * @return int 268a25f0a04SGreg Roach */ 2698f53f488SRico Sonntag public static function compareMarrDate(Family $x, Family $y): int 270c1010edaSGreg Roach { 271f5b60decSGreg Roach return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); 272a25f0a04SGreg Roach } 273a25f0a04SGreg Roach 274a25f0a04SGreg Roach /** 275a25f0a04SGreg Roach * Number of children - for the individual list 276a25f0a04SGreg Roach * 277cbc1590aSGreg Roach * @return int 278a25f0a04SGreg Roach */ 2798f53f488SRico Sonntag public function getNumberOfChildren(): int 280c1010edaSGreg Roach { 281a25f0a04SGreg Roach $nchi = count($this->getChildren()); 282a25f0a04SGreg Roach foreach ($this->getFacts('NCHI') as $fact) { 283a25f0a04SGreg Roach $nchi = max($nchi, (int)$fact->getValue()); 284a25f0a04SGreg Roach } 285a25f0a04SGreg Roach 286a25f0a04SGreg Roach return $nchi; 287a25f0a04SGreg Roach } 288a25f0a04SGreg Roach 289a25f0a04SGreg Roach /** 290a25f0a04SGreg Roach * get the marriage event 291a25f0a04SGreg Roach * 29266107289SGreg Roach * @return Fact|null 293a25f0a04SGreg Roach */ 29466107289SGreg Roach public function getMarriage() 295c1010edaSGreg Roach { 296a25f0a04SGreg Roach return $this->getFirstFact('MARR'); 297a25f0a04SGreg Roach } 298a25f0a04SGreg Roach 299a25f0a04SGreg Roach /** 300a25f0a04SGreg Roach * Get marriage date 301a25f0a04SGreg Roach * 302a25f0a04SGreg Roach * @return Date 303a25f0a04SGreg Roach */ 304c1010edaSGreg Roach public function getMarriageDate() 305c1010edaSGreg Roach { 306a25f0a04SGreg Roach $marriage = $this->getMarriage(); 307a25f0a04SGreg Roach if ($marriage) { 308a25f0a04SGreg Roach return $marriage->getDate(); 309a25f0a04SGreg Roach } 310*b2ce94c6SRico Sonntag 311*b2ce94c6SRico Sonntag return new Date(''); 312a25f0a04SGreg Roach } 313a25f0a04SGreg Roach 314a25f0a04SGreg Roach /** 315a25f0a04SGreg Roach * Get the marriage year - displayed on lists of families 316a25f0a04SGreg Roach * 317cbc1590aSGreg Roach * @return int 318a25f0a04SGreg Roach */ 3198f53f488SRico Sonntag public function getMarriageYear(): int 320c1010edaSGreg Roach { 321f5b60decSGreg Roach return $this->getMarriageDate()->minimumDate()->y; 322a25f0a04SGreg Roach } 323a25f0a04SGreg Roach 324a25f0a04SGreg Roach /** 325a25f0a04SGreg Roach * Get the marriage place 326a25f0a04SGreg Roach * 327a25f0a04SGreg Roach * @return Place 328a25f0a04SGreg Roach */ 3298f53f488SRico Sonntag public function getMarriagePlace(): Place 330c1010edaSGreg Roach { 331a25f0a04SGreg Roach $marriage = $this->getMarriage(); 332a25f0a04SGreg Roach 333a25f0a04SGreg Roach return $marriage->getPlace(); 334a25f0a04SGreg Roach } 335a25f0a04SGreg Roach 336a25f0a04SGreg Roach /** 337a25f0a04SGreg Roach * Get a list of all marriage dates - for the family lists. 338a25f0a04SGreg Roach * 339a25f0a04SGreg Roach * @return Date[] 340a25f0a04SGreg Roach */ 3418f53f488SRico Sonntag public function getAllMarriageDates(): array 342c1010edaSGreg Roach { 343a25f0a04SGreg Roach foreach (explode('|', WT_EVENTS_MARR) as $event) { 344a25f0a04SGreg Roach if ($array = $this->getAllEventDates($event)) { 345a25f0a04SGreg Roach return $array; 346a25f0a04SGreg Roach } 347a25f0a04SGreg Roach } 348a25f0a04SGreg Roach 34913abd6f3SGreg Roach return []; 350a25f0a04SGreg Roach } 351a25f0a04SGreg Roach 352a25f0a04SGreg Roach /** 353a25f0a04SGreg Roach * Get a list of all marriage places - for the family lists. 354a25f0a04SGreg Roach * 3554080d558SGreg Roach * @return Place[] 356a25f0a04SGreg Roach */ 3578f53f488SRico Sonntag public function getAllMarriagePlaces(): array 358c1010edaSGreg Roach { 359a25f0a04SGreg Roach foreach (explode('|', WT_EVENTS_MARR) as $event) { 3604080d558SGreg Roach $places = $this->getAllEventPlaces($event); 3614080d558SGreg Roach if (!empty($places)) { 3624080d558SGreg Roach return $places; 363a25f0a04SGreg Roach } 364a25f0a04SGreg Roach } 365a25f0a04SGreg Roach 36613abd6f3SGreg Roach return []; 367a25f0a04SGreg Roach } 368a25f0a04SGreg Roach 36976692c8bSGreg Roach /** 37076692c8bSGreg Roach * Derived classes should redefine this function, otherwise the object will have no name 37176692c8bSGreg Roach * 37276692c8bSGreg Roach * @return string[][] 37376692c8bSGreg Roach */ 3748f53f488SRico Sonntag public function getAllNames(): array 375c1010edaSGreg Roach { 3768f038c36SRico Sonntag if ($this->getAllNames === null) { 377a25f0a04SGreg Roach // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc. 378e88674d4SGreg Roach $husb_names = []; 379a25f0a04SGreg Roach if ($this->husb) { 380492c7072SGreg Roach $husb_names = array_filter($this->husb->getAllNames(), function (array $x): bool { 3818d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3828d68cabeSGreg Roach }); 383e88674d4SGreg Roach } 384e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 385e88674d4SGreg Roach if (empty($husb_names)) { 386e88674d4SGreg Roach $husb_names[] = [ 387a25f0a04SGreg Roach 'type' => 'BIRT', 388a25f0a04SGreg Roach 'sort' => '@N.N.', 389ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 39013abd6f3SGreg Roach ]; 391a25f0a04SGreg Roach } 392a25f0a04SGreg Roach foreach ($husb_names as $n => $husb_name) { 393a25f0a04SGreg Roach $husb_names[$n]['script'] = I18N::textScript($husb_name['full']); 394a25f0a04SGreg Roach } 395e88674d4SGreg Roach 396e88674d4SGreg Roach $wife_names = []; 397a25f0a04SGreg Roach if ($this->wife) { 398492c7072SGreg Roach $wife_names = array_filter($this->wife->getAllNames(), function (array $x): bool { 3998d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 4008d68cabeSGreg Roach }); 401e88674d4SGreg Roach } 402e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 403e88674d4SGreg Roach if (empty($wife_names)) { 404e88674d4SGreg Roach $wife_names[] = [ 405a25f0a04SGreg Roach 'type' => 'BIRT', 406a25f0a04SGreg Roach 'sort' => '@N.N.', 407ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 40813abd6f3SGreg Roach ]; 409a25f0a04SGreg Roach } 410a25f0a04SGreg Roach foreach ($wife_names as $n => $wife_name) { 411a25f0a04SGreg Roach $wife_names[$n]['script'] = I18N::textScript($wife_name['full']); 412a25f0a04SGreg Roach } 413e88674d4SGreg Roach 414a25f0a04SGreg Roach // Add the matched names first 415a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 416a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 417e88674d4SGreg Roach if ($husb_name['script'] == $wife_name['script']) { 418bdb3725aSGreg Roach $this->getAllNames[] = [ 419a25f0a04SGreg Roach 'type' => $husb_name['type'], 420a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 421a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 422a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 42313abd6f3SGreg Roach ]; 424a25f0a04SGreg Roach } 425a25f0a04SGreg Roach } 426a25f0a04SGreg Roach } 427e88674d4SGreg Roach 428a25f0a04SGreg Roach // Add the unmatched names second (there may be no matched names) 429a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 430a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 431e88674d4SGreg Roach if ($husb_name['script'] != $wife_name['script']) { 432bdb3725aSGreg Roach $this->getAllNames[] = [ 433a25f0a04SGreg Roach 'type' => $husb_name['type'], 434a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 435a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 436a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 43713abd6f3SGreg Roach ]; 438a25f0a04SGreg Roach } 439a25f0a04SGreg Roach } 440a25f0a04SGreg Roach } 441a25f0a04SGreg Roach } 442a25f0a04SGreg Roach 443bdb3725aSGreg Roach return $this->getAllNames; 444a25f0a04SGreg Roach } 445a25f0a04SGreg Roach 44676692c8bSGreg Roach /** 44776692c8bSGreg Roach * This function should be redefined in derived classes to show any major 44876692c8bSGreg Roach * identifying characteristics of this record. 44976692c8bSGreg Roach * 45076692c8bSGreg Roach * @return string 45176692c8bSGreg Roach */ 4528f53f488SRico Sonntag public function formatListDetails(): string 453c1010edaSGreg Roach { 454a25f0a04SGreg Roach return 455841014f1SGreg Roach $this->formatFirstMajorFact(WT_EVENTS_MARR, 1) . 456841014f1SGreg Roach $this->formatFirstMajorFact(WT_EVENTS_DIV, 1); 457a25f0a04SGreg Roach } 458a25f0a04SGreg Roach} 459