1852ede8cSGreg Roach<?php 2852ede8cSGreg Roach 3852ede8cSGreg Roach/** 4852ede8cSGreg Roach * webtrees: online genealogy 5852ede8cSGreg Roach * Copyright (C) 2019 webtrees development team 6852ede8cSGreg Roach * This program is free software: you can redistribute it and/or modify 7852ede8cSGreg Roach * it under the terms of the GNU General Public License as published by 8852ede8cSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9852ede8cSGreg Roach * (at your option) any later version. 10852ede8cSGreg Roach * This program is distributed in the hope that it will be useful, 11852ede8cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12852ede8cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13852ede8cSGreg Roach * GNU General Public License for more details. 14852ede8cSGreg Roach * You should have received a copy of the GNU General Public License 15852ede8cSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16852ede8cSGreg Roach */ 17852ede8cSGreg Roach 18852ede8cSGreg Roachdeclare(strict_types=1); 19852ede8cSGreg Roach 20852ede8cSGreg Roachnamespace Fisharebest\Webtrees\Http\RequestHandlers; 21852ede8cSGreg Roach 22852ede8cSGreg Roachuse Fisharebest\Webtrees\Auth; 23852ede8cSGreg Roachuse Fisharebest\Webtrees\Date; 24852ede8cSGreg Roachuse Fisharebest\Webtrees\Fact; 25852ede8cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsDate; 26852ede8cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsPrint; 27852ede8cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsPrintFacts; 28852ede8cSGreg Roachuse Fisharebest\Webtrees\GedcomCode\GedcomCodeName; 29852ede8cSGreg Roachuse Fisharebest\Webtrees\GedcomTag; 30852ede8cSGreg Roachuse Fisharebest\Webtrees\Http\ViewResponseTrait; 31852ede8cSGreg Roachuse Fisharebest\Webtrees\I18N; 32852ede8cSGreg Roachuse Fisharebest\Webtrees\Individual; 33852ede8cSGreg Roachuse Fisharebest\Webtrees\Media; 34852ede8cSGreg Roachuse Fisharebest\Webtrees\MediaFile; 35852ede8cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleSidebarInterface; 36852ede8cSGreg Roachuse Fisharebest\Webtrees\Module\ModuleTabInterface; 37852ede8cSGreg Roachuse Fisharebest\Webtrees\Services\ClipboardService; 38852ede8cSGreg Roachuse Fisharebest\Webtrees\Services\ModuleService; 39852ede8cSGreg Roachuse Fisharebest\Webtrees\Services\UserService; 40852ede8cSGreg Roachuse Fisharebest\Webtrees\Tree; 41852ede8cSGreg Roachuse Illuminate\Support\Collection; 42852ede8cSGreg Roachuse Psr\Http\Message\ResponseInterface; 43852ede8cSGreg Roachuse Psr\Http\Message\ServerRequestInterface; 44852ede8cSGreg Roachuse Psr\Http\Server\RequestHandlerInterface; 45852ede8cSGreg Roachuse stdClass; 46852ede8cSGreg Roach 47852ede8cSGreg Roachuse function assert; 48852ede8cSGreg Roachuse function e; 49852ede8cSGreg Roachuse function explode; 50852ede8cSGreg Roachuse function is_string; 51852ede8cSGreg Roachuse function ob_get_clean; 52852ede8cSGreg Roachuse function ob_start; 53852ede8cSGreg Roachuse function preg_match_all; 54852ede8cSGreg Roachuse function preg_replace; 55852ede8cSGreg Roachuse function redirect; 56852ede8cSGreg Roachuse function route; 57852ede8cSGreg Roachuse function str_replace; 58852ede8cSGreg Roachuse function strpos; 59852ede8cSGreg Roach 60852ede8cSGreg Roach/** 61852ede8cSGreg Roach * Show an individual's page. 62852ede8cSGreg Roach */ 63852ede8cSGreg Roachclass IndividualPage implements RequestHandlerInterface 64852ede8cSGreg Roach{ 65852ede8cSGreg Roach use ViewResponseTrait; 66852ede8cSGreg Roach 67852ede8cSGreg Roach /** @var ClipboardService */ 68852ede8cSGreg Roach private $clipboard_service; 69852ede8cSGreg Roach 70852ede8cSGreg Roach /** @var ModuleService */ 71852ede8cSGreg Roach private $module_service; 72852ede8cSGreg Roach 73852ede8cSGreg Roach /** @var UserService */ 74852ede8cSGreg Roach private $user_service; 75852ede8cSGreg Roach 76852ede8cSGreg Roach /** 77*aba707cdSGreg Roach * IndividualPage constructor. 78852ede8cSGreg Roach * 79852ede8cSGreg Roach * @param ClipboardService $clipboard_service 80852ede8cSGreg Roach * @param ModuleService $module_service 81852ede8cSGreg Roach * @param UserService $user_service 82852ede8cSGreg Roach */ 83852ede8cSGreg Roach public function __construct(ClipboardService $clipboard_service, ModuleService $module_service, UserService $user_service) 84852ede8cSGreg Roach { 85852ede8cSGreg Roach $this->clipboard_service = $clipboard_service; 86852ede8cSGreg Roach $this->module_service = $module_service; 87852ede8cSGreg Roach $this->user_service = $user_service; 88852ede8cSGreg Roach } 89852ede8cSGreg Roach 90852ede8cSGreg Roach /** 91852ede8cSGreg Roach * @param ServerRequestInterface $request 92852ede8cSGreg Roach * 93852ede8cSGreg Roach * @return ResponseInterface 94852ede8cSGreg Roach */ 95852ede8cSGreg Roach public function handle(ServerRequestInterface $request): ResponseInterface 96852ede8cSGreg Roach { 97852ede8cSGreg Roach $tree = $request->getAttribute('tree'); 98852ede8cSGreg Roach assert($tree instanceof Tree); 99852ede8cSGreg Roach 100852ede8cSGreg Roach $xref = $request->getAttribute('xref'); 101852ede8cSGreg Roach assert(is_string($xref)); 102852ede8cSGreg Roach 103852ede8cSGreg Roach $individual = Individual::getInstance($xref, $tree); 104852ede8cSGreg Roach $individual = Auth::checkIndividualAccess($individual); 105852ede8cSGreg Roach 106852ede8cSGreg Roach // Redirect to correct xref/slug 107852ede8cSGreg Roach if ($individual->xref() !== $xref || $request->getAttribute('slug') !== $individual->slug()) { 108852ede8cSGreg Roach return redirect($individual->url()); 109852ede8cSGreg Roach } 110852ede8cSGreg Roach 111852ede8cSGreg Roach // What is (was) the age of the individual 112852ede8cSGreg Roach $bdate = $individual->getBirthDate(); 113852ede8cSGreg Roach $ddate = $individual->getDeathDate(); 114852ede8cSGreg Roach if ($bdate->isOK() && !$individual->isDead()) { 115852ede8cSGreg Roach // If living display age 116852ede8cSGreg Roach $age = ' (' . I18N::translate('age') . ' ' . FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, new Date(strtoupper(date('d M Y'))))) . ')'; 117852ede8cSGreg Roach } elseif ($bdate->isOK() && $ddate->isOK()) { 118852ede8cSGreg Roach // If dead, show age at death 119852ede8cSGreg Roach $age = ' (' . I18N::translate('age') . ' ' . FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($bdate, $ddate)) . ')'; 120852ede8cSGreg Roach } else { 121852ede8cSGreg Roach $age = ''; 122852ede8cSGreg Roach } 123852ede8cSGreg Roach 124852ede8cSGreg Roach // What images are linked to this individual 125852ede8cSGreg Roach $individual_media = new Collection(); 126852ede8cSGreg Roach foreach ($individual->facts(['OBJE']) as $fact) { 127852ede8cSGreg Roach $media_object = $fact->target(); 128852ede8cSGreg Roach if ($media_object instanceof Media) { 129852ede8cSGreg Roach $media_file = $media_object->firstImageFile(); 130852ede8cSGreg Roach if ($media_file instanceof MediaFile) { 131852ede8cSGreg Roach $individual_media->add($media_file); 132852ede8cSGreg Roach } 133852ede8cSGreg Roach } 134852ede8cSGreg Roach } 135852ede8cSGreg Roach 136852ede8cSGreg Roach $name_records = new Collection(); 137852ede8cSGreg Roach foreach ($individual->facts(['NAME']) as $n => $name_fact) { 138852ede8cSGreg Roach $name_records->add($this->formatNameRecord($tree, $n, $name_fact)); 139852ede8cSGreg Roach } 140852ede8cSGreg Roach 141852ede8cSGreg Roach $sex_records = new Collection(); 142852ede8cSGreg Roach foreach ($individual->facts(['SEX']) as $n => $sex_fact) { 143852ede8cSGreg Roach $sex_records->add($this->formatSexRecord($sex_fact)); 144852ede8cSGreg Roach } 145852ede8cSGreg Roach 146852ede8cSGreg Roach // If this individual is linked to a user account, show the link 147852ede8cSGreg Roach $user_link = ''; 148852ede8cSGreg Roach if (Auth::isAdmin()) { 149852ede8cSGreg Roach $users = $this->user_service->findByIndividual($individual); 150852ede8cSGreg Roach foreach ($users as $user) { 151852ede8cSGreg Roach $user_link = ' — <a href="' . e(route('admin-users', ['filter' => $user->email()])) . '">' . e($user->userName()) . '</a>'; 152852ede8cSGreg Roach } 153852ede8cSGreg Roach } 154852ede8cSGreg Roach 155852ede8cSGreg Roach return $this->viewResponse('individual-page', [ 156852ede8cSGreg Roach 'age' => $age, 157852ede8cSGreg Roach 'clipboard_facts' => $this->clipboard_service->pastableFacts($individual, new Collection()), 158852ede8cSGreg Roach 'count_media' => $this->countFacts($individual, ['OBJE']), 159852ede8cSGreg Roach 'count_names' => $this->countFacts($individual, ['NAME']), 160852ede8cSGreg Roach 'count_sex' => $this->countFacts($individual, ['SEX']), 161852ede8cSGreg Roach 'individual' => $individual, 162852ede8cSGreg Roach 'individual_media' => $individual_media, 163852ede8cSGreg Roach 'meta_robots' => 'index,follow', 164852ede8cSGreg Roach 'name_records' => $name_records, 165852ede8cSGreg Roach 'sex_records' => $sex_records, 166852ede8cSGreg Roach 'sidebars' => $this->getSidebars($individual), 167852ede8cSGreg Roach 'tabs' => $this->getTabs($individual), 168852ede8cSGreg Roach 'significant' => $this->significant($individual), 169852ede8cSGreg Roach 'title' => $individual->fullName() . ' ' . $individual->getLifeSpan(), 170852ede8cSGreg Roach 'tree' => $tree, 171852ede8cSGreg Roach 'user_link' => $user_link, 172852ede8cSGreg Roach ]); 173852ede8cSGreg Roach } 174852ede8cSGreg Roach 175852ede8cSGreg Roach /** 176852ede8cSGreg Roach * Count the (non-pending-delete) name records for an individual. 177852ede8cSGreg Roach * 178852ede8cSGreg Roach * @param Individual $individual 179852ede8cSGreg Roach * @param string[] $tags 180852ede8cSGreg Roach * 181852ede8cSGreg Roach * @return int 182852ede8cSGreg Roach */ 183852ede8cSGreg Roach private function countFacts(Individual $individual, array $tags): int 184852ede8cSGreg Roach { 185852ede8cSGreg Roach $count = 0; 186852ede8cSGreg Roach 187852ede8cSGreg Roach foreach ($individual->facts($tags) as $fact) { 188852ede8cSGreg Roach if (!$fact->isPendingDeletion()) { 189852ede8cSGreg Roach $count++; 190852ede8cSGreg Roach } 191852ede8cSGreg Roach } 192852ede8cSGreg Roach 193852ede8cSGreg Roach return $count; 194852ede8cSGreg Roach } 195852ede8cSGreg Roach 196852ede8cSGreg Roach /** 197852ede8cSGreg Roach * Format a name record 198852ede8cSGreg Roach * 199852ede8cSGreg Roach * @param Tree $tree 200852ede8cSGreg Roach * @param int $n 201852ede8cSGreg Roach * @param Fact $fact 202852ede8cSGreg Roach * 203852ede8cSGreg Roach * @return string 204852ede8cSGreg Roach */ 205852ede8cSGreg Roach private function formatNameRecord(Tree $tree, $n, Fact $fact): string 206852ede8cSGreg Roach { 207852ede8cSGreg Roach $individual = $fact->record(); 208852ede8cSGreg Roach 209852ede8cSGreg Roach // Create a dummy record, so we can extract the formatted NAME value from it. 210852ede8cSGreg Roach $dummy = new Individual( 211852ede8cSGreg Roach 'xref', 212852ede8cSGreg Roach "0 @xref@ INDI\n1 DEAT Y\n" . $fact->gedcom(), 213852ede8cSGreg Roach null, 214852ede8cSGreg Roach $individual->tree() 215852ede8cSGreg Roach ); 216852ede8cSGreg Roach $dummy->setPrimaryName(0); // Make sure we use the name from "1 NAME" 217852ede8cSGreg Roach 218852ede8cSGreg Roach $container_class = 'card'; 219852ede8cSGreg Roach $content_class = 'collapse'; 220852ede8cSGreg Roach $aria = 'false'; 221852ede8cSGreg Roach 222852ede8cSGreg Roach if ($n === 0) { 223852ede8cSGreg Roach $content_class = 'collapse show'; 224852ede8cSGreg Roach $aria = 'true'; 225852ede8cSGreg Roach } 226852ede8cSGreg Roach if ($fact->isPendingDeletion()) { 227852ede8cSGreg Roach $container_class .= ' wt-old'; 228852ede8cSGreg Roach } elseif ($fact->isPendingAddition()) { 229852ede8cSGreg Roach $container_class .= ' wt-new'; 230852ede8cSGreg Roach } 231852ede8cSGreg Roach 232852ede8cSGreg Roach ob_start(); 233852ede8cSGreg Roach echo '<dl><dt class="label">', I18N::translate('Name'), '</dt>'; 234852ede8cSGreg Roach echo '<dd class="field">', $dummy->fullName(), '</dd>'; 235852ede8cSGreg Roach $ct = preg_match_all('/\n2 (\w+) (.*)/', $fact->gedcom(), $nmatch, PREG_SET_ORDER); 236852ede8cSGreg Roach for ($i = 0; $i < $ct; $i++) { 237852ede8cSGreg Roach $tag = $nmatch[$i][1]; 238852ede8cSGreg Roach if ($tag !== 'SOUR' && $tag !== 'NOTE' && $tag !== 'SPFX') { 239852ede8cSGreg Roach echo '<dt class="label">', GedcomTag::getLabel($tag, $individual), '</dt>'; 240852ede8cSGreg Roach echo '<dd class="field">'; // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element 241852ede8cSGreg Roach if (isset($nmatch[$i][2])) { 242852ede8cSGreg Roach $name = e($nmatch[$i][2]); 243852ede8cSGreg Roach $name = str_replace('/', '', $name); 244852ede8cSGreg Roach $name = preg_replace('/(\S*)\*/', '<span class="starredname">\\1</span>', $name); 245852ede8cSGreg Roach switch ($tag) { 246852ede8cSGreg Roach case 'TYPE': 247852ede8cSGreg Roach echo GedcomCodeName::getValue($name, $individual); 248852ede8cSGreg Roach break; 249852ede8cSGreg Roach case 'SURN': 250852ede8cSGreg Roach // The SURN field is not necessarily the surname. 251852ede8cSGreg Roach // Where it is not a substring of the real surname, show it after the real surname. 252852ede8cSGreg Roach $surname = e($dummy->getAllNames()[0]['surname']); 253852ede8cSGreg Roach $surns = preg_replace('/, */', ' ', $nmatch[$i][2]); 254852ede8cSGreg Roach if (strpos($dummy->getAllNames()[0]['surname'], $surns) !== false) { 255852ede8cSGreg Roach echo '<span dir="auto">' . $surname . '</span>'; 256852ede8cSGreg Roach } else { 257852ede8cSGreg Roach echo I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $surname . '</span>', '<span dir="auto">' . $name . '</span>'); 258852ede8cSGreg Roach } 259852ede8cSGreg Roach break; 260852ede8cSGreg Roach default: 261852ede8cSGreg Roach echo '<span dir="auto">' . $name . '</span>'; 262852ede8cSGreg Roach break; 263852ede8cSGreg Roach } 264852ede8cSGreg Roach } 265852ede8cSGreg Roach echo '</dd>'; 266852ede8cSGreg Roach } 267852ede8cSGreg Roach } 268852ede8cSGreg Roach echo '</dl>'; 269852ede8cSGreg Roach if (strpos($fact->gedcom(), "\n2 SOUR") !== false) { 270852ede8cSGreg Roach echo '<div id="indi_sour" class="clearfix">', FunctionsPrintFacts::printFactSources($tree, $fact->gedcom(), 2), '</div>'; 271852ede8cSGreg Roach } 272852ede8cSGreg Roach if (strpos($fact->gedcom(), "\n2 NOTE") !== false) { 273852ede8cSGreg Roach echo '<div id="indi_note" class="clearfix">', FunctionsPrint::printFactNotes($tree, $fact->gedcom(), 2), '</div>'; 274852ede8cSGreg Roach } 275852ede8cSGreg Roach $content = ob_get_clean(); 276852ede8cSGreg Roach 277852ede8cSGreg Roach if ($fact->canEdit()) { 278852ede8cSGreg Roach $edit_links = 279852ede8cSGreg Roach '<a class="btn btn-link" href="#" data-confirm="' . I18N::translate('Are you sure you want to delete this fact?') . '" data-post-url="' . e(route(DeleteFact::class, ['tree' => $individual->tree()->name(), 'xref' => $individual->xref(), 'fact_id' => $fact->id()])) . '" title="' . I18N::translate('Delete this name') . '">' . view('icons/delete') . '<span class="sr-only">' . I18N::translate('Delete this name') . '</span></a>' . 280852ede8cSGreg Roach '<a class="btn btn-link" href="' . e(route('edit-name', ['xref' => $individual->xref(), 'fact_id' => $fact->id(), 'tree' => $individual->tree()->name()])) . '" title="' . I18N::translate('Edit the name') . '">' . view('icons/edit') . '<span class="sr-only">' . I18N::translate('Edit the name') . '</span></a>'; 281852ede8cSGreg Roach } else { 282852ede8cSGreg Roach $edit_links = ''; 283852ede8cSGreg Roach } 284852ede8cSGreg Roach 285852ede8cSGreg Roach return ' 286852ede8cSGreg Roach <div class="' . $container_class . '"> 287852ede8cSGreg Roach <div class="card-header" role="tab" id="name-header-' . $n . '"> 288852ede8cSGreg Roach <a data-toggle="collapse" data-parent="#individual-names" href="#name-content-' . $n . '" aria-expanded="' . $aria . '" aria-controls="name-content-' . $n . '">' . $dummy->fullName() . '</a> 289852ede8cSGreg Roach ' . $edit_links . ' 290852ede8cSGreg Roach </div> 291852ede8cSGreg Roach <div id="name-content-' . $n . '" class="' . $content_class . '" role="tabpanel" aria-labelledby="name-header-' . $n . '"> 292852ede8cSGreg Roach <div class="card-body">' . $content . '</div> 293852ede8cSGreg Roach </div> 294852ede8cSGreg Roach </div>'; 295852ede8cSGreg Roach } 296852ede8cSGreg Roach 297852ede8cSGreg Roach /** 298852ede8cSGreg Roach * print information for a sex record 299852ede8cSGreg Roach * 300852ede8cSGreg Roach * @param Fact $fact 301852ede8cSGreg Roach * 302852ede8cSGreg Roach * @return string 303852ede8cSGreg Roach */ 304852ede8cSGreg Roach private function formatSexRecord(Fact $fact): string 305852ede8cSGreg Roach { 306852ede8cSGreg Roach $individual = $fact->record(); 307852ede8cSGreg Roach 308852ede8cSGreg Roach switch ($fact->value()) { 309852ede8cSGreg Roach case 'M': 310852ede8cSGreg Roach $sex = I18N::translate('Male'); 311852ede8cSGreg Roach break; 312852ede8cSGreg Roach case 'F': 313852ede8cSGreg Roach $sex = I18N::translate('Female'); 314852ede8cSGreg Roach break; 315852ede8cSGreg Roach default: 316852ede8cSGreg Roach $sex = I18N::translateContext('unknown gender', 'Unknown'); 317852ede8cSGreg Roach break; 318852ede8cSGreg Roach } 319852ede8cSGreg Roach 320852ede8cSGreg Roach $container_class = 'card'; 321852ede8cSGreg Roach if ($fact->isPendingDeletion()) { 322852ede8cSGreg Roach $container_class .= ' wt-old'; 323852ede8cSGreg Roach } elseif ($fact->isPendingAddition()) { 324852ede8cSGreg Roach $container_class .= ' wt-new'; 325852ede8cSGreg Roach } 326852ede8cSGreg Roach 327852ede8cSGreg Roach if ($individual->canEdit()) { 328852ede8cSGreg Roach $edit_links = '<a class="btn btn-link" href="' . e(route(EditFact::class, ['xref' => $individual->xref(), 'fact_id' => $fact->id(), 'tree' => $individual->tree()->name()])) . '" title="' . I18N::translate('Edit the gender') . '">' . view('icons/edit') . '<span class="sr-only">' . I18N::translate('Edit the gender') . '</span></a>'; 329852ede8cSGreg Roach } else { 330852ede8cSGreg Roach $edit_links = ''; 331852ede8cSGreg Roach } 332852ede8cSGreg Roach 333852ede8cSGreg Roach return ' 334852ede8cSGreg Roach <div class="' . $container_class . '"> 335852ede8cSGreg Roach <div class="card-header" role="tab" id="name-header-add"> 336852ede8cSGreg Roach <div class="card-title mb-0"> 337852ede8cSGreg Roach <b>' . I18N::translate('Gender') . '</b> ' . $sex . $edit_links . ' 338852ede8cSGreg Roach </div> 339852ede8cSGreg Roach </div> 340852ede8cSGreg Roach </div>'; 341852ede8cSGreg Roach } 342852ede8cSGreg Roach 343852ede8cSGreg Roach /** 344852ede8cSGreg Roach * Which tabs should we show on this individual's page. 345852ede8cSGreg Roach * We don't show empty tabs. 346852ede8cSGreg Roach * 347852ede8cSGreg Roach * @param Individual $individual 348852ede8cSGreg Roach * 349852ede8cSGreg Roach * @return Collection 350852ede8cSGreg Roach */ 351852ede8cSGreg Roach public function getSidebars(Individual $individual): Collection 352852ede8cSGreg Roach { 353852ede8cSGreg Roach return $this->module_service->findByComponent(ModuleSidebarInterface::class, $individual->tree(), Auth::user()) 354852ede8cSGreg Roach ->filter(static function (ModuleSidebarInterface $sidebar) use ($individual): bool { 355852ede8cSGreg Roach return $sidebar->hasSidebarContent($individual); 356852ede8cSGreg Roach }); 357852ede8cSGreg Roach } 358852ede8cSGreg Roach 359852ede8cSGreg Roach /** 360852ede8cSGreg Roach * Which tabs should we show on this individual's page. 361852ede8cSGreg Roach * We don't show empty tabs. 362852ede8cSGreg Roach * 363852ede8cSGreg Roach * @param Individual $individual 364852ede8cSGreg Roach * 365852ede8cSGreg Roach * @return Collection 366852ede8cSGreg Roach */ 367852ede8cSGreg Roach public function getTabs(Individual $individual): Collection 368852ede8cSGreg Roach { 369852ede8cSGreg Roach return $this->module_service->findByComponent(ModuleTabInterface::class, $individual->tree(), Auth::user()) 370852ede8cSGreg Roach ->filter(static function (ModuleTabInterface $tab) use ($individual): bool { 371852ede8cSGreg Roach return $tab->hasTabContent($individual); 372852ede8cSGreg Roach }); 373852ede8cSGreg Roach } 374852ede8cSGreg Roach 375852ede8cSGreg Roach /** 376852ede8cSGreg Roach * What are the significant elements of this page? 377852ede8cSGreg Roach * The layout will need them to generate URLs for charts and reports. 378852ede8cSGreg Roach * 379852ede8cSGreg Roach * @param Individual $individual 380852ede8cSGreg Roach * 381852ede8cSGreg Roach * @return stdClass 382852ede8cSGreg Roach */ 383852ede8cSGreg Roach private function significant(Individual $individual): stdClass 384852ede8cSGreg Roach { 385852ede8cSGreg Roach [$surname] = explode(',', $individual->sortName()); 386852ede8cSGreg Roach 387852ede8cSGreg Roach $family = $individual->childFamilies()->merge($individual->spouseFamilies())->first(); 388852ede8cSGreg Roach 389852ede8cSGreg Roach return (object) [ 390852ede8cSGreg Roach 'family' => $family, 391852ede8cSGreg Roach 'individual' => $individual, 392852ede8cSGreg Roach 'surname' => $surname, 393852ede8cSGreg Roach ]; 394852ede8cSGreg Roach } 395852ede8cSGreg Roach} 396