xref: /webtrees/app/Family.php (revision e71ef9d2ff0aa5d82e80016f655eee252a32e958)
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 */
21a25f0a04SGreg Roachclass Family extends GedcomRecord {
22a25f0a04SGreg Roach	const RECORD_TYPE = 'FAM';
23225e381fSGreg Roach	const ROUTE_NAME  = 'family';
24a25f0a04SGreg Roach
25a25f0a04SGreg Roach	/** @var Individual|null The husband (or first spouse for same-sex couples) */
26a25f0a04SGreg Roach	private $husb;
27a25f0a04SGreg Roach
28a25f0a04SGreg Roach	/** @var Individual|null The wife (or second spouse for same-sex couples) */
29a25f0a04SGreg Roach	private $wife;
30a25f0a04SGreg Roach
3176692c8bSGreg Roach	/**
3276692c8bSGreg Roach	 * Create a GedcomRecord object from raw GEDCOM data.
3376692c8bSGreg Roach	 *
3476692c8bSGreg Roach	 * @param string      $xref
3576692c8bSGreg Roach	 * @param string      $gedcom  an empty string for new/pending records
3676692c8bSGreg Roach	 * @param string|null $pending null for a record with no pending edits,
3776692c8bSGreg Roach	 *                             empty string for records with pending deletions
3876692c8bSGreg Roach	 * @param Tree        $tree
3976692c8bSGreg Roach	 */
4024ec66ceSGreg Roach	public function __construct($xref, $gedcom, $pending, $tree) {
4124ec66ceSGreg Roach		parent::__construct($xref, $gedcom, $pending, $tree);
42a25f0a04SGreg Roach
43395f0fe0SGreg Roach		// Fetch family members
44395f0fe0SGreg Roach		if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) {
45395f0fe0SGreg Roach			Individual::load($tree, $match[1]);
46395f0fe0SGreg Roach		}
47395f0fe0SGreg Roach
48a25f0a04SGreg Roach		if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) {
4924ec66ceSGreg Roach			$this->husb = Individual::getInstance($match[1], $tree);
50a25f0a04SGreg Roach		}
51a25f0a04SGreg Roach		if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) {
5224ec66ceSGreg Roach			$this->wife = Individual::getInstance($match[1], $tree);
53a25f0a04SGreg Roach		}
54a25f0a04SGreg Roach
55a25f0a04SGreg Roach		// Make sure husb/wife are the right way round.
56a5adda01SGreg Roach		if ($this->husb && $this->husb->getSex() === 'F' || $this->wife && $this->wife->getSex() === 'M') {
5713abd6f3SGreg Roach			list($this->husb, $this->wife) = [$this->wife, $this->husb];
58a25f0a04SGreg Roach		}
59a25f0a04SGreg Roach	}
60a25f0a04SGreg Roach
6176692c8bSGreg Roach	/**
62*e71ef9d2SGreg Roach	 * Get an instance of a family object. For single records,
63*e71ef9d2SGreg Roach	 * we just receive the XREF. For bulk records (such as lists
64*e71ef9d2SGreg Roach	 * and search results) we can receive the GEDCOM data as well.
65*e71ef9d2SGreg Roach	 *
66*e71ef9d2SGreg Roach	 * @param string      $xref
67*e71ef9d2SGreg Roach	 * @param Tree        $tree
68*e71ef9d2SGreg Roach	 * @param string|null $gedcom
69*e71ef9d2SGreg Roach	 *
70*e71ef9d2SGreg Roach	 * @throws \Exception
71*e71ef9d2SGreg Roach	 *
72*e71ef9d2SGreg Roach	 * @return Family|null
73*e71ef9d2SGreg Roach	 */
74*e71ef9d2SGreg Roach	public static function getInstance($xref, Tree $tree, $gedcom = null) {
75*e71ef9d2SGreg Roach		$record = parent::getInstance($xref, $tree, $gedcom);
76*e71ef9d2SGreg Roach
77*e71ef9d2SGreg Roach		if ($record instanceof Family) {
78*e71ef9d2SGreg Roach			return $record;
79*e71ef9d2SGreg Roach		} else {
80*e71ef9d2SGreg Roach			return null;
81*e71ef9d2SGreg Roach		}
82*e71ef9d2SGreg Roach	}
83*e71ef9d2SGreg Roach
84*e71ef9d2SGreg Roach		/**
8576692c8bSGreg Roach	 * Generate a private version of this record
8676692c8bSGreg Roach	 *
8776692c8bSGreg Roach	 * @param int $access_level
8876692c8bSGreg Roach	 *
8976692c8bSGreg Roach	 * @return string
9076692c8bSGreg Roach	 */
91a25f0a04SGreg Roach	protected function createPrivateGedcomRecord($access_level) {
92d86cc606SGreg Roach		$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
93a25f0a04SGreg Roach
94a25f0a04SGreg Roach		$rec = '0 @' . $this->xref . '@ FAM';
95a25f0a04SGreg Roach		// Just show the 1 CHIL/HUSB/WIFE tag, not any subtags, which may contain private data
96a25f0a04SGreg Roach		preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches, PREG_SET_ORDER);
97a25f0a04SGreg Roach		foreach ($matches as $match) {
9824ec66ceSGreg Roach			$rela = Individual::getInstance($match[1], $this->tree);
99a25f0a04SGreg Roach			if ($rela && ($SHOW_PRIVATE_RELATIONSHIPS || $rela->canShow($access_level))) {
100a25f0a04SGreg Roach				$rec .= $match[0];
101a25f0a04SGreg Roach			}
102a25f0a04SGreg Roach		}
103a25f0a04SGreg Roach
104a25f0a04SGreg Roach		return $rec;
105a25f0a04SGreg Roach	}
106a25f0a04SGreg Roach
10776692c8bSGreg Roach	/**
10876692c8bSGreg Roach	 * Fetch data from the database
10976692c8bSGreg Roach	 *
11076692c8bSGreg Roach	 * @param string $xref
11176692c8bSGreg Roach	 * @param int    $tree_id
11276692c8bSGreg Roach	 *
11376692c8bSGreg Roach	 * @return null|string
11476692c8bSGreg Roach	 */
11564d9078aSGreg Roach	protected static function fetchGedcomRecord($xref, $tree_id) {
11664d9078aSGreg Roach		return Database::prepare(
11764d9078aSGreg Roach			"SELECT f_gedcom FROM `##families` WHERE f_id = :xref AND f_file = :tree_id"
11813abd6f3SGreg Roach		)->execute([
11964d9078aSGreg Roach			'xref'    => $xref,
12064d9078aSGreg Roach			'tree_id' => $tree_id,
12113abd6f3SGreg Roach		])->fetchOne();
122a25f0a04SGreg Roach	}
123a25f0a04SGreg Roach
124a25f0a04SGreg Roach	/**
125a25f0a04SGreg Roach	 * Get the male (or first female) partner of the family
126a25f0a04SGreg Roach	 *
127b3f49e6cSGreg Roach	 * @param $access_level int|null
128b3f49e6cSGreg Roach	 *
129a25f0a04SGreg Roach	 * @return Individual|null
130a25f0a04SGreg Roach	 */
131b3f49e6cSGreg Roach	public function getHusband($access_level = null) {
132b3f49e6cSGreg Roach		$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
133b3f49e6cSGreg Roach
134b3f49e6cSGreg Roach		if ($this->husb && ($SHOW_PRIVATE_RELATIONSHIPS || $this->husb->canShowName($access_level))) {
135a25f0a04SGreg Roach			return $this->husb;
136a25f0a04SGreg Roach		} else {
137a25f0a04SGreg Roach			return null;
138a25f0a04SGreg Roach		}
139a25f0a04SGreg Roach	}
140a25f0a04SGreg Roach
141a25f0a04SGreg Roach	/**
142a25f0a04SGreg Roach	 * Get the female (or second male) partner of the family
143a25f0a04SGreg Roach	 *
144b3f49e6cSGreg Roach	 * @param $access_level int|null
145b3f49e6cSGreg Roach	 *
146a25f0a04SGreg Roach	 * @return Individual|null
147a25f0a04SGreg Roach	 */
148b3f49e6cSGreg Roach	public function getWife($access_level = null) {
149b3f49e6cSGreg Roach		$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
150b3f49e6cSGreg Roach
151b3f49e6cSGreg Roach		if ($this->wife && ($SHOW_PRIVATE_RELATIONSHIPS || $this->wife->canShowName($access_level))) {
152a25f0a04SGreg Roach			return $this->wife;
153a25f0a04SGreg Roach		} else {
154a25f0a04SGreg Roach			return null;
155a25f0a04SGreg Roach		}
156a25f0a04SGreg Roach	}
157a25f0a04SGreg Roach
15876692c8bSGreg Roach	/**
15976692c8bSGreg Roach	 * Each object type may have its own special rules, and re-implement this function.
16076692c8bSGreg Roach	 *
16176692c8bSGreg Roach	 * @param int $access_level
16276692c8bSGreg Roach	 *
16376692c8bSGreg Roach	 * @return bool
16476692c8bSGreg Roach	 */
165a25f0a04SGreg Roach	protected function canShowByType($access_level) {
166a25f0a04SGreg Roach		// Hide a family if any member is private
167a25f0a04SGreg Roach		preg_match_all('/\n1 (?:CHIL|HUSB|WIFE) @(' . WT_REGEX_XREF . ')@/', $this->gedcom, $matches);
168a25f0a04SGreg Roach		foreach ($matches[1] as $match) {
16924ec66ceSGreg Roach			$person = Individual::getInstance($match, $this->tree);
170a25f0a04SGreg Roach			if ($person && !$person->canShow($access_level)) {
171a25f0a04SGreg Roach				return false;
172a25f0a04SGreg Roach			}
173a25f0a04SGreg Roach		}
174a25f0a04SGreg Roach
175a25f0a04SGreg Roach		return true;
176a25f0a04SGreg Roach	}
177a25f0a04SGreg Roach
17876692c8bSGreg Roach	/**
17976692c8bSGreg Roach	 * Can the name of this record be shown?
18076692c8bSGreg Roach	 *
18176692c8bSGreg Roach	 * @param int|null $access_level
18276692c8bSGreg Roach	 *
18376692c8bSGreg Roach	 * @return bool
18476692c8bSGreg Roach	 */
1854b9ff166SGreg Roach	public function canShowName($access_level = null) {
186a25f0a04SGreg Roach		// We can always see the name (Husband-name + Wife-name), however,
187a25f0a04SGreg Roach		// the name will often be "private + private"
188a25f0a04SGreg Roach		return true;
189a25f0a04SGreg Roach	}
190a25f0a04SGreg Roach
191a25f0a04SGreg Roach	/**
192a25f0a04SGreg Roach	 * Find the spouse of a person.
193a25f0a04SGreg Roach	 *
194a25f0a04SGreg Roach	 * @param Individual $person
19513e3123bSGreg Roach	 * @param int|null   $access_level
196a25f0a04SGreg Roach	 *
197a25f0a04SGreg Roach	 * @return Individual|null
198a25f0a04SGreg Roach	 */
19913e3123bSGreg Roach	public function getSpouse(Individual $person, $access_level = null) {
200a25f0a04SGreg Roach		if ($person === $this->wife) {
20113e3123bSGreg Roach			return $this->getHusband($access_level);
202a25f0a04SGreg Roach		} else {
20313e3123bSGreg Roach			return $this->getWife($access_level);
204a25f0a04SGreg Roach		}
205a25f0a04SGreg Roach	}
206a25f0a04SGreg Roach
207a25f0a04SGreg Roach	/**
208a25f0a04SGreg Roach	 * Get the (zero, one or two) spouses from this family.
209a25f0a04SGreg Roach	 *
210cbc1590aSGreg Roach	 * @param int|null $access_level
211a25f0a04SGreg Roach	 *
212a25f0a04SGreg Roach	 * @return Individual[]
213a25f0a04SGreg Roach	 */
214ffd703eaSGreg Roach	public function getSpouses($access_level = null) {
21513abd6f3SGreg Roach		return array_filter([
216b3f49e6cSGreg Roach			$this->getHusband($access_level),
217b3f49e6cSGreg Roach			$this->getWife($access_level),
21813abd6f3SGreg Roach		]);
219a25f0a04SGreg Roach	}
220a25f0a04SGreg Roach
221a25f0a04SGreg Roach	/**
222a25f0a04SGreg Roach	 * Get a list of this family’s children.
223a25f0a04SGreg Roach	 *
224cbc1590aSGreg Roach	 * @param int|null $access_level
225a25f0a04SGreg Roach	 *
226a25f0a04SGreg Roach	 * @return Individual[]
227a25f0a04SGreg Roach	 */
228ffd703eaSGreg Roach	public function getChildren($access_level = null) {
2294b9ff166SGreg Roach		if ($access_level === null) {
2304b9ff166SGreg Roach			$access_level = Auth::accessLevel($this->tree);
2314b9ff166SGreg Roach		}
2324b9ff166SGreg Roach
233d86cc606SGreg Roach		$SHOW_PRIVATE_RELATIONSHIPS = $this->tree->getPreference('SHOW_PRIVATE_RELATIONSHIPS');
234a25f0a04SGreg Roach
23513abd6f3SGreg Roach		$children = [];
236a25f0a04SGreg Roach		foreach ($this->getFacts('CHIL', false, $access_level, $SHOW_PRIVATE_RELATIONSHIPS) as $fact) {
237a25f0a04SGreg Roach			$child = $fact->getTarget();
238a25f0a04SGreg Roach			if ($child && ($SHOW_PRIVATE_RELATIONSHIPS || $child->canShowName($access_level))) {
239a25f0a04SGreg Roach				$children[] = $child;
240a25f0a04SGreg Roach			}
241a25f0a04SGreg Roach		}
242a25f0a04SGreg Roach
243a25f0a04SGreg Roach		return $children;
244a25f0a04SGreg Roach	}
245a25f0a04SGreg Roach
246a25f0a04SGreg Roach	/**
247a25f0a04SGreg Roach	 * Static helper function to sort an array of families by marriage date
248a25f0a04SGreg Roach	 *
249a25f0a04SGreg Roach	 * @param Family $x
250a25f0a04SGreg Roach	 * @param Family $y
251a25f0a04SGreg Roach	 *
252cbc1590aSGreg Roach	 * @return int
253a25f0a04SGreg Roach	 */
254a25f0a04SGreg Roach	public static function compareMarrDate(Family $x, Family $y) {
255f5b60decSGreg Roach		return Date::compare($x->getMarriageDate(), $y->getMarriageDate());
256a25f0a04SGreg Roach	}
257a25f0a04SGreg Roach
258a25f0a04SGreg Roach	/**
259a25f0a04SGreg Roach	 * Number of children - for the individual list
260a25f0a04SGreg Roach	 *
261cbc1590aSGreg Roach	 * @return int
262a25f0a04SGreg Roach	 */
263a25f0a04SGreg Roach	public function getNumberOfChildren() {
264a25f0a04SGreg Roach		$nchi = count($this->getChildren());
265a25f0a04SGreg Roach		foreach ($this->getFacts('NCHI') as $fact) {
266a25f0a04SGreg Roach			$nchi = max($nchi, (int) $fact->getValue());
267a25f0a04SGreg Roach		}
268a25f0a04SGreg Roach
269a25f0a04SGreg Roach		return $nchi;
270a25f0a04SGreg Roach	}
271a25f0a04SGreg Roach
272a25f0a04SGreg Roach	/**
273a25f0a04SGreg Roach	 * get the marriage event
274a25f0a04SGreg Roach	 *
275a25f0a04SGreg Roach	 * @return Fact
276a25f0a04SGreg Roach	 */
277a25f0a04SGreg Roach	public function getMarriage() {
278a25f0a04SGreg Roach		return $this->getFirstFact('MARR');
279a25f0a04SGreg Roach	}
280a25f0a04SGreg Roach
281a25f0a04SGreg Roach	/**
282a25f0a04SGreg Roach	 * Get marriage date
283a25f0a04SGreg Roach	 *
284a25f0a04SGreg Roach	 * @return Date
285a25f0a04SGreg Roach	 */
286a25f0a04SGreg Roach	public function getMarriageDate() {
287a25f0a04SGreg Roach		$marriage = $this->getMarriage();
288a25f0a04SGreg Roach		if ($marriage) {
289a25f0a04SGreg Roach			return $marriage->getDate();
290a25f0a04SGreg Roach		} else {
291a25f0a04SGreg Roach			return new Date('');
292a25f0a04SGreg Roach		}
293a25f0a04SGreg Roach	}
294a25f0a04SGreg Roach
295a25f0a04SGreg Roach	/**
296a25f0a04SGreg Roach	 * Get the marriage year - displayed on lists of families
297a25f0a04SGreg Roach	 *
298cbc1590aSGreg Roach	 * @return int
299a25f0a04SGreg Roach	 */
300a25f0a04SGreg Roach	public function getMarriageYear() {
301f5b60decSGreg Roach		return $this->getMarriageDate()->minimumDate()->y;
302a25f0a04SGreg Roach	}
303a25f0a04SGreg Roach
304a25f0a04SGreg Roach	/**
305a25f0a04SGreg Roach	 * Get the marriage place
306a25f0a04SGreg Roach	 *
307a25f0a04SGreg Roach	 * @return Place
308a25f0a04SGreg Roach	 */
309a25f0a04SGreg Roach	public function getMarriagePlace() {
310a25f0a04SGreg Roach		$marriage = $this->getMarriage();
311a25f0a04SGreg Roach
312a25f0a04SGreg Roach		return $marriage->getPlace();
313a25f0a04SGreg Roach	}
314a25f0a04SGreg Roach
315a25f0a04SGreg Roach	/**
316a25f0a04SGreg Roach	 * Get a list of all marriage dates - for the family lists.
317a25f0a04SGreg Roach	 *
318a25f0a04SGreg Roach	 * @return Date[]
319a25f0a04SGreg Roach	 */
320a25f0a04SGreg Roach	public function getAllMarriageDates() {
321a25f0a04SGreg Roach		foreach (explode('|', WT_EVENTS_MARR) as $event) {
322a25f0a04SGreg Roach			if ($array = $this->getAllEventDates($event)) {
323a25f0a04SGreg Roach				return $array;
324a25f0a04SGreg Roach			}
325a25f0a04SGreg Roach		}
326a25f0a04SGreg Roach
32713abd6f3SGreg Roach		return [];
328a25f0a04SGreg Roach	}
329a25f0a04SGreg Roach
330a25f0a04SGreg Roach	/**
331a25f0a04SGreg Roach	 * Get a list of all marriage places - for the family lists.
332a25f0a04SGreg Roach	 *
3334080d558SGreg Roach	 * @return Place[]
334a25f0a04SGreg Roach	 */
335a25f0a04SGreg Roach	public function getAllMarriagePlaces() {
336a25f0a04SGreg Roach		foreach (explode('|', WT_EVENTS_MARR) as $event) {
3374080d558SGreg Roach			$places = $this->getAllEventPlaces($event);
3384080d558SGreg Roach			if (!empty($places)) {
3394080d558SGreg Roach				return $places;
340a25f0a04SGreg Roach			}
341a25f0a04SGreg Roach		}
342a25f0a04SGreg Roach
34313abd6f3SGreg Roach		return [];
344a25f0a04SGreg Roach	}
345a25f0a04SGreg Roach
34676692c8bSGreg Roach	/**
34776692c8bSGreg Roach	 * Derived classes should redefine this function, otherwise the object will have no name
34876692c8bSGreg Roach	 *
34976692c8bSGreg Roach	 * @return string[][]
35076692c8bSGreg Roach	 */
351a25f0a04SGreg Roach	public function getAllNames() {
352a25f0a04SGreg Roach		if (is_null($this->_getAllNames)) {
353a25f0a04SGreg Roach			// Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc.
354e88674d4SGreg Roach			$husb_names = [];
355a25f0a04SGreg Roach			if ($this->husb) {
3568d68cabeSGreg Roach				$husb_names = array_filter($this->husb->getAllNames(), function (array $x) {
3578d68cabeSGreg Roach					return $x['type'] !== '_MARNM';
3588d68cabeSGreg Roach				} );
359e88674d4SGreg Roach			}
360e88674d4SGreg Roach			// If the individual only has married names, create a dummy birth name.
361e88674d4SGreg Roach			if (empty($husb_names)) {
362e88674d4SGreg Roach				$husb_names[] = [
363a25f0a04SGreg Roach					'type' => 'BIRT',
364a25f0a04SGreg Roach					'sort' => '@N.N.',
365ad1a1cd2SGreg Roach					'full' => I18N::translateContext('Unknown given name', '…') . ' ' . I18N::translateContext('Unknown surname', '…'),
36613abd6f3SGreg Roach				];
367a25f0a04SGreg Roach			}
368a25f0a04SGreg Roach			foreach ($husb_names as $n => $husb_name) {
369a25f0a04SGreg Roach				$husb_names[$n]['script'] = I18N::textScript($husb_name['full']);
370a25f0a04SGreg Roach			}
371e88674d4SGreg Roach
372e88674d4SGreg Roach			$wife_names = [];
373a25f0a04SGreg Roach			if ($this->wife) {
3748d68cabeSGreg Roach				$wife_names = array_filter($this->wife->getAllNames(), function (array $x) {
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($wife_names)) {
380e88674d4SGreg Roach				$wife_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 ($wife_names as $n => $wife_name) {
387a25f0a04SGreg Roach				$wife_names[$n]['script'] = I18N::textScript($wife_name['full']);
388a25f0a04SGreg Roach			}
389e88674d4SGreg Roach
390a25f0a04SGreg Roach			// Add the matched names first
391a25f0a04SGreg Roach			foreach ($husb_names as $husb_name) {
392a25f0a04SGreg Roach				foreach ($wife_names as $wife_name) {
393e88674d4SGreg Roach					if ($husb_name['script'] == $wife_name['script']) {
39413abd6f3SGreg Roach						$this->_getAllNames[] = [
395a25f0a04SGreg Roach							'type' => $husb_name['type'],
396a25f0a04SGreg Roach							'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'],
397a25f0a04SGreg Roach							'full' => $husb_name['full'] . ' + ' . $wife_name['full'],
398a25f0a04SGreg Roach							// No need for a fullNN entry - we do not currently store FAM names in the database
39913abd6f3SGreg Roach						];
400a25f0a04SGreg Roach					}
401a25f0a04SGreg Roach				}
402a25f0a04SGreg Roach			}
403e88674d4SGreg Roach
404a25f0a04SGreg Roach			// Add the unmatched names second (there may be no matched names)
405a25f0a04SGreg Roach			foreach ($husb_names as $husb_name) {
406a25f0a04SGreg Roach				foreach ($wife_names as $wife_name) {
407e88674d4SGreg Roach					if ($husb_name['script'] != $wife_name['script']) {
40813abd6f3SGreg Roach						$this->_getAllNames[] = [
409a25f0a04SGreg Roach							'type' => $husb_name['type'],
410a25f0a04SGreg Roach							'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'],
411a25f0a04SGreg Roach							'full' => $husb_name['full'] . ' + ' . $wife_name['full'],
412a25f0a04SGreg Roach							// No need for a fullNN entry - we do not currently store FAM names in the database
41313abd6f3SGreg Roach						];
414a25f0a04SGreg Roach					}
415a25f0a04SGreg Roach				}
416a25f0a04SGreg Roach			}
417a25f0a04SGreg Roach		}
418a25f0a04SGreg Roach
419a25f0a04SGreg Roach		return $this->_getAllNames;
420a25f0a04SGreg Roach	}
421a25f0a04SGreg Roach
42276692c8bSGreg Roach	/**
42376692c8bSGreg Roach	 * This function should be redefined in derived classes to show any major
42476692c8bSGreg Roach	 * identifying characteristics of this record.
42576692c8bSGreg Roach	 *
42676692c8bSGreg Roach	 * @return string
42776692c8bSGreg Roach	 */
428ffd703eaSGreg Roach	public function formatListDetails() {
429a25f0a04SGreg Roach		return
430841014f1SGreg Roach			$this->formatFirstMajorFact(WT_EVENTS_MARR, 1) .
431841014f1SGreg Roach			$this->formatFirstMajorFact(WT_EVENTS_DIV, 1);
432a25f0a04SGreg Roach	}
433a25f0a04SGreg Roach}
434