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