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 20a25f0a04SGreg Roach/** 2176692c8bSGreg Roach * A GEDCOM family (FAM) object. 22a25f0a04SGreg Roach */ 23c1010edaSGreg Roachclass Family extends GedcomRecord 24c1010edaSGreg Roach{ 25a25f0a04SGreg Roach const RECORD_TYPE = 'FAM'; 26225e381fSGreg Roach const ROUTE_NAME = 'family'; 27a25f0a04SGreg Roach 28a25f0a04SGreg Roach /** @var Individual|null The husband (or first spouse for same-sex couples) */ 29a25f0a04SGreg Roach private $husb; 30a25f0a04SGreg Roach 31a25f0a04SGreg Roach /** @var Individual|null The wife (or second spouse for same-sex couples) */ 32a25f0a04SGreg Roach private $wife; 33a25f0a04SGreg Roach 3476692c8bSGreg Roach /** 3576692c8bSGreg Roach * Create a GedcomRecord object from raw GEDCOM data. 3676692c8bSGreg Roach * 3776692c8bSGreg Roach * @param string $xref 3876692c8bSGreg Roach * @param string $gedcom an empty string for new/pending records 3976692c8bSGreg Roach * @param string|null $pending null for a record with no pending edits, 4076692c8bSGreg Roach * empty string for records with pending deletions 4176692c8bSGreg Roach * @param Tree $tree 4276692c8bSGreg Roach */ 4376f666f4SGreg Roach public function __construct(string $xref, string $gedcom, $pending, Tree $tree) 44c1010edaSGreg Roach { 4524ec66ceSGreg Roach parent::__construct($xref, $gedcom, $pending, $tree); 46a25f0a04SGreg Roach 47395f0fe0SGreg Roach // Fetch family members 48395f0fe0SGreg Roach if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) { 49395f0fe0SGreg Roach Individual::load($tree, $match[1]); 50395f0fe0SGreg Roach } 51395f0fe0SGreg Roach 52a25f0a04SGreg Roach if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) { 5324ec66ceSGreg Roach $this->husb = Individual::getInstance($match[1], $tree); 54a25f0a04SGreg Roach } 55a25f0a04SGreg Roach if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) { 5624ec66ceSGreg Roach $this->wife = Individual::getInstance($match[1], $tree); 57a25f0a04SGreg Roach } 58a25f0a04SGreg Roach 59a25f0a04SGreg Roach // Make sure husb/wife are the right way round. 60a5adda01SGreg Roach if ($this->husb && $this->husb->getSex() === 'F' || $this->wife && $this->wife->getSex() === 'M') { 61c1010edaSGreg Roach list($this->husb, $this->wife) = [ 62c1010edaSGreg Roach $this->wife, 63c1010edaSGreg Roach $this->husb, 64c1010edaSGreg Roach ]; 65a25f0a04SGreg Roach } 66a25f0a04SGreg Roach } 67a25f0a04SGreg Roach 6876692c8bSGreg Roach /** 69e71ef9d2SGreg Roach * Get an instance of a family object. For single records, 70e71ef9d2SGreg Roach * we just receive the XREF. For bulk records (such as lists 71e71ef9d2SGreg Roach * and search results) we can receive the GEDCOM data as well. 72e71ef9d2SGreg Roach * 73e71ef9d2SGreg Roach * @param string $xref 74e71ef9d2SGreg Roach * @param Tree $tree 75e71ef9d2SGreg Roach * @param string|null $gedcom 76e71ef9d2SGreg Roach * 77e71ef9d2SGreg Roach * @throws \Exception 78e71ef9d2SGreg Roach * 79e71ef9d2SGreg Roach * @return Family|null 80e71ef9d2SGreg Roach */ 8176f666f4SGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null) 82c1010edaSGreg Roach { 83e71ef9d2SGreg Roach $record = parent::getInstance($xref, $tree, $gedcom); 84e71ef9d2SGreg Roach 85e71ef9d2SGreg Roach if ($record instanceof Family) { 86e71ef9d2SGreg Roach return $record; 87e71ef9d2SGreg Roach } 88b2ce94c6SRico Sonntag 89b2ce94c6SRico Sonntag return null; 90e71ef9d2SGreg Roach } 91e71ef9d2SGreg Roach 92e71ef9d2SGreg Roach /** 9376692c8bSGreg Roach * Generate a private version of this record 9476692c8bSGreg Roach * 9576692c8bSGreg Roach * @param int $access_level 9676692c8bSGreg Roach * 9776692c8bSGreg Roach * @return string 9876692c8bSGreg Roach */ 993c90ed31SGreg Roach protected function createPrivateGedcomRecord(int $access_level): string 100c1010edaSGreg Roach { 101d86cc606SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 102a25f0a04SGreg Roach 103a25f0a04SGreg Roach $rec = '0 @' . $this->xref . '@ FAM'; 104a25f0a04SGreg Roach // Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data 105a25f0a04SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER); 106a25f0a04SGreg Roach foreach ($matches as $match) { 10724ec66ceSGreg Roach $rela = Individual::getInstance($match[1], $this->tree); 108a25f0a04SGreg Roach if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) { 109a25f0a04SGreg Roach $rec .= $match[0]; 110a25f0a04SGreg Roach } 111a25f0a04SGreg Roach } 112a25f0a04SGreg Roach 113a25f0a04SGreg Roach return $rec; 114a25f0a04SGreg Roach } 115a25f0a04SGreg Roach 11676692c8bSGreg Roach /** 11776692c8bSGreg Roach * Fetch data from the database 11876692c8bSGreg Roach * 11976692c8bSGreg Roach * @param string $xref 12076692c8bSGreg Roach * @param int $tree_id 12176692c8bSGreg Roach * 12276692c8bSGreg Roach * @return null|string 12376692c8bSGreg Roach */ 12476f666f4SGreg Roach protected static function fetchGedcomRecord(string $xref, int $tree_id) 125c1010edaSGreg Roach { 12664d9078aSGreg Roach return Database::prepare( 12764d9078aSGreg Roach "SELECT f_gedcom FROM `##families` WHERE f_id = :xref AND f_file = :tree_id" 12813abd6f3SGreg Roach )->execute([ 12964d9078aSGreg Roach 'xref' => $xref, 13064d9078aSGreg Roach 'tree_id' => $tree_id, 13113abd6f3SGreg Roach ])->fetchOne(); 132a25f0a04SGreg Roach } 133a25f0a04SGreg Roach 134a25f0a04SGreg Roach /** 135a25f0a04SGreg Roach * Get the male (or first female) partner of the family 136a25f0a04SGreg Roach * 137e93111adSRico Sonntag * @param int|null $access_level 138b3f49e6cSGreg Roach * 139a25f0a04SGreg Roach * @return Individual|null 140a25f0a04SGreg Roach */ 141c1010edaSGreg Roach public function getHusband($access_level = null) 142c1010edaSGreg Roach { 143b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 144b3f49e6cSGreg Roach 145b3f49e6cSGreg Roach if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) { 146a25f0a04SGreg Roach return $this->husb; 147a25f0a04SGreg Roach } 148b2ce94c6SRico Sonntag 149b2ce94c6SRico Sonntag return null; 150a25f0a04SGreg Roach } 151a25f0a04SGreg Roach 152a25f0a04SGreg Roach /** 153a25f0a04SGreg Roach * Get the female (or second male) partner of the family 154a25f0a04SGreg Roach * 155e93111adSRico Sonntag * @param int|null $access_level 156b3f49e6cSGreg Roach * 157a25f0a04SGreg Roach * @return Individual|null 158a25f0a04SGreg Roach */ 159c1010edaSGreg Roach public function getWife($access_level = null) 160c1010edaSGreg Roach { 161b3f49e6cSGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 162b3f49e6cSGreg Roach 163b3f49e6cSGreg Roach if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) { 164a25f0a04SGreg Roach return $this->wife; 165a25f0a04SGreg Roach } 166b2ce94c6SRico Sonntag 167b2ce94c6SRico Sonntag return null; 168a25f0a04SGreg Roach } 169a25f0a04SGreg Roach 17076692c8bSGreg Roach /** 17176692c8bSGreg Roach * Each object type may have its own special rules, and re-implement this function. 17276692c8bSGreg Roach * 17376692c8bSGreg Roach * @param int $access_level 17476692c8bSGreg Roach * 17576692c8bSGreg Roach * @return bool 17676692c8bSGreg Roach */ 17735584196SGreg Roach protected function canShowByType(int $access_level): bool 178c1010edaSGreg Roach { 179a25f0a04SGreg Roach // Hide a family if any member is private 180a25f0a04SGreg Roach preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches); 181a25f0a04SGreg Roach foreach ($matches[1] as $match) { 18224ec66ceSGreg Roach $person = Individual::getInstance($match, $this->tree); 183a25f0a04SGreg Roach if ($person && !$person->canShow($access_level)) { 184a25f0a04SGreg Roach return false; 185a25f0a04SGreg Roach } 186a25f0a04SGreg Roach } 187a25f0a04SGreg Roach 188a25f0a04SGreg Roach return true; 189a25f0a04SGreg Roach } 190a25f0a04SGreg Roach 19176692c8bSGreg Roach /** 19276692c8bSGreg Roach * Can the name of this record be shown? 19376692c8bSGreg Roach * 19476692c8bSGreg Roach * @param int|null $access_level 19576692c8bSGreg Roach * 19676692c8bSGreg Roach * @return bool 19776692c8bSGreg Roach */ 19835584196SGreg Roach public function canShowName(int $access_level = null): bool 199c1010edaSGreg Roach { 200a25f0a04SGreg Roach // We can always see the name (Husband-name + Wife-name), however, 201a25f0a04SGreg Roach // the name will often be "private + private" 202a25f0a04SGreg Roach return true; 203a25f0a04SGreg Roach } 204a25f0a04SGreg Roach 205a25f0a04SGreg Roach /** 206a25f0a04SGreg Roach * Find the spouse of a person. 207a25f0a04SGreg Roach * 208a25f0a04SGreg Roach * @param Individual $person 20913e3123bSGreg Roach * @param int|null $access_level 210a25f0a04SGreg Roach * 211a25f0a04SGreg Roach * @return Individual|null 212a25f0a04SGreg Roach */ 213c1010edaSGreg Roach public function getSpouse(Individual $person, $access_level = null) 214c1010edaSGreg Roach { 215a25f0a04SGreg Roach if ($person === $this->wife) { 21613e3123bSGreg Roach return $this->getHusband($access_level); 217a25f0a04SGreg Roach } 218b2ce94c6SRico Sonntag 219b2ce94c6SRico Sonntag return $this->getWife($access_level); 220a25f0a04SGreg Roach } 221a25f0a04SGreg Roach 222a25f0a04SGreg Roach /** 223a25f0a04SGreg Roach * Get the (zero, one or two) spouses from this family. 224a25f0a04SGreg Roach * 225cbc1590aSGreg Roach * @param int|null $access_level 226a25f0a04SGreg Roach * 227a25f0a04SGreg Roach * @return Individual[] 228a25f0a04SGreg Roach */ 2298f53f488SRico Sonntag public function getSpouses($access_level = null): array 230c1010edaSGreg Roach { 23113abd6f3SGreg Roach return array_filter([ 232b3f49e6cSGreg Roach $this->getHusband($access_level), 233b3f49e6cSGreg Roach $this->getWife($access_level), 23413abd6f3SGreg Roach ]); 235a25f0a04SGreg Roach } 236a25f0a04SGreg Roach 237a25f0a04SGreg Roach /** 238a25f0a04SGreg Roach * Get a list of this family’s children. 239a25f0a04SGreg Roach * 240cbc1590aSGreg Roach * @param int|null $access_level 241a25f0a04SGreg Roach * 242a25f0a04SGreg Roach * @return Individual[] 243a25f0a04SGreg Roach */ 2448f53f488SRico Sonntag public function getChildren($access_level = null): array 245c1010edaSGreg Roach { 2464b9ff166SGreg Roach if ($access_level === null) { 2474b9ff166SGreg Roach $access_level = Auth::accessLevel($this->tree); 2484b9ff166SGreg Roach } 2494b9ff166SGreg Roach 250845c3ce6SGreg Roach $SHOW_PRIVATE_RELATIONSHIPS = (bool) $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS'); 251a25f0a04SGreg Roach 25213abd6f3SGreg Roach $children = []; 253a25f0a04SGreg Roach foreach ($this->getFacts('CHIL', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) { 254a25f0a04SGreg Roach $child = $fact->getTarget(); 255a25f0a04SGreg Roach if ($child && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) { 256a25f0a04SGreg Roach $children[] = $child; 257a25f0a04SGreg Roach } 258a25f0a04SGreg Roach } 259a25f0a04SGreg Roach 260a25f0a04SGreg Roach return $children; 261a25f0a04SGreg Roach } 262a25f0a04SGreg Roach 263a25f0a04SGreg Roach /** 264a25f0a04SGreg Roach * Static helper function to sort an array of families by marriage date 265a25f0a04SGreg Roach * 266a25f0a04SGreg Roach * @param Family $x 267a25f0a04SGreg Roach * @param Family $y 268a25f0a04SGreg Roach * 269cbc1590aSGreg Roach * @return int 270a25f0a04SGreg Roach */ 2718f53f488SRico Sonntag public static function compareMarrDate(Family $x, Family $y): int 272c1010edaSGreg Roach { 273f5b60decSGreg Roach return Date::compare($x->getMarriageDate(), $y->getMarriageDate()); 274a25f0a04SGreg Roach } 275a25f0a04SGreg Roach 276a25f0a04SGreg Roach /** 277a25f0a04SGreg Roach * Number of children - for the individual list 278a25f0a04SGreg Roach * 279cbc1590aSGreg Roach * @return int 280a25f0a04SGreg Roach */ 2818f53f488SRico Sonntag public function getNumberOfChildren(): int 282c1010edaSGreg Roach { 283a25f0a04SGreg Roach $nchi = count($this->getChildren()); 284a25f0a04SGreg Roach foreach ($this->getFacts('NCHI') as $fact) { 285a25f0a04SGreg Roach $nchi = max($nchi, (int) $fact->getValue()); 286a25f0a04SGreg Roach } 287a25f0a04SGreg Roach 288a25f0a04SGreg Roach return $nchi; 289a25f0a04SGreg Roach } 290a25f0a04SGreg Roach 291a25f0a04SGreg Roach /** 292a25f0a04SGreg Roach * get the marriage event 293a25f0a04SGreg Roach * 29466107289SGreg Roach * @return Fact|null 295a25f0a04SGreg Roach */ 29666107289SGreg Roach public function getMarriage() 297c1010edaSGreg Roach { 298a25f0a04SGreg Roach return $this->getFirstFact('MARR'); 299a25f0a04SGreg Roach } 300a25f0a04SGreg Roach 301a25f0a04SGreg Roach /** 302a25f0a04SGreg Roach * Get marriage date 303a25f0a04SGreg Roach * 304a25f0a04SGreg Roach * @return Date 305a25f0a04SGreg Roach */ 306c1010edaSGreg Roach public function getMarriageDate() 307c1010edaSGreg Roach { 308a25f0a04SGreg Roach $marriage = $this->getMarriage(); 309a25f0a04SGreg Roach if ($marriage) { 310a25f0a04SGreg Roach return $marriage->getDate(); 311a25f0a04SGreg Roach } 312b2ce94c6SRico Sonntag 313b2ce94c6SRico Sonntag return new Date(''); 314a25f0a04SGreg Roach } 315a25f0a04SGreg Roach 316a25f0a04SGreg Roach /** 317a25f0a04SGreg Roach * Get the marriage year - displayed on lists of families 318a25f0a04SGreg Roach * 319cbc1590aSGreg Roach * @return int 320a25f0a04SGreg Roach */ 3218f53f488SRico Sonntag public function getMarriageYear(): int 322c1010edaSGreg Roach { 323*4a83f5d7SGreg Roach return $this->getMarriageDate()->minimumDate()->year; 324a25f0a04SGreg Roach } 325a25f0a04SGreg Roach 326a25f0a04SGreg Roach /** 327a25f0a04SGreg Roach * Get the marriage place 328a25f0a04SGreg Roach * 329a25f0a04SGreg Roach * @return Place 330a25f0a04SGreg Roach */ 3318f53f488SRico Sonntag public function getMarriagePlace(): Place 332c1010edaSGreg Roach { 333a25f0a04SGreg Roach $marriage = $this->getMarriage(); 334a25f0a04SGreg Roach 335a25f0a04SGreg Roach return $marriage->getPlace(); 336a25f0a04SGreg Roach } 337a25f0a04SGreg Roach 338a25f0a04SGreg Roach /** 339a25f0a04SGreg Roach * Get a list of all marriage dates - for the family lists. 340a25f0a04SGreg Roach * 341a25f0a04SGreg Roach * @return Date[] 342a25f0a04SGreg Roach */ 3438f53f488SRico Sonntag public function getAllMarriageDates(): array 344c1010edaSGreg Roach { 345a25f0a04SGreg Roach foreach (explode('|', WT_EVENTS_MARR) as $event) { 346a25f0a04SGreg Roach if ($array = $this->getAllEventDates($event)) { 347a25f0a04SGreg Roach return $array; 348a25f0a04SGreg Roach } 349a25f0a04SGreg Roach } 350a25f0a04SGreg Roach 35113abd6f3SGreg Roach return []; 352a25f0a04SGreg Roach } 353a25f0a04SGreg Roach 354a25f0a04SGreg Roach /** 355a25f0a04SGreg Roach * Get a list of all marriage places - for the family lists. 356a25f0a04SGreg Roach * 3574080d558SGreg Roach * @return Place[] 358a25f0a04SGreg Roach */ 3598f53f488SRico Sonntag public function getAllMarriagePlaces(): array 360c1010edaSGreg Roach { 361a25f0a04SGreg Roach foreach (explode('|', WT_EVENTS_MARR) as $event) { 3624080d558SGreg Roach $places = $this->getAllEventPlaces($event); 3634080d558SGreg Roach if (!empty($places)) { 3644080d558SGreg Roach return $places; 365a25f0a04SGreg Roach } 366a25f0a04SGreg Roach } 367a25f0a04SGreg Roach 36813abd6f3SGreg Roach return []; 369a25f0a04SGreg Roach } 370a25f0a04SGreg Roach 37176692c8bSGreg Roach /** 37276692c8bSGreg Roach * Derived classes should redefine this function, otherwise the object will have no name 37376692c8bSGreg Roach * 37476692c8bSGreg Roach * @return string[][] 37576692c8bSGreg Roach */ 3768f53f488SRico Sonntag public function getAllNames(): array 377c1010edaSGreg Roach { 3788f038c36SRico Sonntag if ($this->getAllNames === null) { 379a25f0a04SGreg Roach // Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc. 380e88674d4SGreg Roach $husb_names = []; 381a25f0a04SGreg Roach if ($this->husb) { 382492c7072SGreg Roach $husb_names = array_filter($this->husb->getAllNames(), function (array $x): bool { 3838d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 3848d68cabeSGreg Roach }); 385e88674d4SGreg Roach } 386e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 387e88674d4SGreg Roach if (empty($husb_names)) { 388e88674d4SGreg Roach $husb_names[] = [ 389a25f0a04SGreg Roach 'type' => 'BIRT', 390a25f0a04SGreg Roach 'sort' => '@N.N.', 391ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 39213abd6f3SGreg Roach ]; 393a25f0a04SGreg Roach } 394a25f0a04SGreg Roach foreach ($husb_names as $n => $husb_name) { 395a25f0a04SGreg Roach $husb_names[$n]['script'] = I18N::textScript($husb_name['full']); 396a25f0a04SGreg Roach } 397e88674d4SGreg Roach 398e88674d4SGreg Roach $wife_names = []; 399a25f0a04SGreg Roach if ($this->wife) { 400492c7072SGreg Roach $wife_names = array_filter($this->wife->getAllNames(), function (array $x): bool { 4018d68cabeSGreg Roach return $x['type'] !== '_MARNM'; 4028d68cabeSGreg Roach }); 403e88674d4SGreg Roach } 404e88674d4SGreg Roach // If the individual only has married names, create a dummy birth name. 405e88674d4SGreg Roach if (empty($wife_names)) { 406e88674d4SGreg Roach $wife_names[] = [ 407a25f0a04SGreg Roach 'type' => 'BIRT', 408a25f0a04SGreg Roach 'sort' => '@N.N.', 409ad1a1cd2SGreg Roach 'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'), 41013abd6f3SGreg Roach ]; 411a25f0a04SGreg Roach } 412a25f0a04SGreg Roach foreach ($wife_names as $n => $wife_name) { 413a25f0a04SGreg Roach $wife_names[$n]['script'] = I18N::textScript($wife_name['full']); 414a25f0a04SGreg Roach } 415e88674d4SGreg Roach 416a25f0a04SGreg Roach // Add the matched names first 417a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 418a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 419e88674d4SGreg Roach if ($husb_name['script'] == $wife_name['script']) { 420bdb3725aSGreg Roach $this->getAllNames[] = [ 421a25f0a04SGreg Roach 'type' => $husb_name['type'], 422a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 423a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 424a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 42513abd6f3SGreg Roach ]; 426a25f0a04SGreg Roach } 427a25f0a04SGreg Roach } 428a25f0a04SGreg Roach } 429e88674d4SGreg Roach 430a25f0a04SGreg Roach // Add the unmatched names second (there may be no matched names) 431a25f0a04SGreg Roach foreach ($husb_names as $husb_name) { 432a25f0a04SGreg Roach foreach ($wife_names as $wife_name) { 433e88674d4SGreg Roach if ($husb_name['script'] != $wife_name['script']) { 434bdb3725aSGreg Roach $this->getAllNames[] = [ 435a25f0a04SGreg Roach 'type' => $husb_name['type'], 436a25f0a04SGreg Roach 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 437a25f0a04SGreg Roach 'full' => $husb_name['full'] . ' + ' . $wife_name['full'], 438a25f0a04SGreg Roach // No need for a fullNN entry - we do not currently store FAM names in the database 43913abd6f3SGreg Roach ]; 440a25f0a04SGreg Roach } 441a25f0a04SGreg Roach } 442a25f0a04SGreg Roach } 443a25f0a04SGreg Roach } 444a25f0a04SGreg Roach 445bdb3725aSGreg Roach return $this->getAllNames; 446a25f0a04SGreg Roach } 447a25f0a04SGreg Roach 44876692c8bSGreg Roach /** 44976692c8bSGreg Roach * This function should be redefined in derived classes to show any major 45076692c8bSGreg Roach * identifying characteristics of this record. 45176692c8bSGreg Roach * 45276692c8bSGreg Roach * @return string 45376692c8bSGreg Roach */ 4548f53f488SRico Sonntag public function formatListDetails(): string 455c1010edaSGreg Roach { 456a25f0a04SGreg Roach return 457841014f1SGreg Roach $this->formatFirstMajorFact(WT_EVENTS_MARR, 1) . 458841014f1SGreg Roach $this->formatFirstMajorFact(WT_EVENTS_DIV, 1); 459a25f0a04SGreg Roach } 460a25f0a04SGreg Roach} 461