18eaf8709SGreg Roach<?php 2*3976b470SGreg Roach 38eaf8709SGreg Roach/** 48eaf8709SGreg Roach * webtrees: online genealogy 58eaf8709SGreg Roach * Copyright (C) 2019 webtrees development team 68eaf8709SGreg Roach * This program is free software: you can redistribute it and/or modify 78eaf8709SGreg Roach * it under the terms of the GNU General Public License as published by 88eaf8709SGreg Roach * the Free Software Foundation, either version 3 of the License, or 98eaf8709SGreg Roach * (at your option) any later version. 108eaf8709SGreg Roach * This program is distributed in the hope that it will be useful, 118eaf8709SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128eaf8709SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138eaf8709SGreg Roach * GNU General Public License for more details. 148eaf8709SGreg Roach * You should have received a copy of the GNU General Public License 158eaf8709SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 168eaf8709SGreg Roach */ 178eaf8709SGreg Roachdeclare(strict_types=1); 188eaf8709SGreg Roach 198eaf8709SGreg Roachnamespace Fisharebest\Webtrees\Module; 208eaf8709SGreg Roach 218eaf8709SGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsPrintFacts; 228eaf8709SGreg Roachuse Fisharebest\Webtrees\I18N; 238eaf8709SGreg Roachuse Fisharebest\Webtrees\Individual; 248eaf8709SGreg Roachuse Illuminate\Support\Collection; 258eaf8709SGreg Roach 268eaf8709SGreg Roach/** 278eaf8709SGreg Roach * Class ExtraInformationModule 288eaf8709SGreg Roach * A sidebar to show non-genealogy information about an individual 298eaf8709SGreg Roach */ 308eaf8709SGreg Roachclass IndividualMetadataModule extends AbstractModule implements ModuleSidebarInterface 318eaf8709SGreg Roach{ 328eaf8709SGreg Roach use ModuleSidebarTrait; 338eaf8709SGreg Roach 348eaf8709SGreg Roach // A list of facts that are handled by this module. 358eaf8709SGreg Roach protected const HANDLED_FACTS = [ 368eaf8709SGreg Roach 'AFN', 378eaf8709SGreg Roach 'CHAN', 388eaf8709SGreg Roach 'IDNO', 398eaf8709SGreg Roach 'REFN', 408eaf8709SGreg Roach 'RESN', 418eaf8709SGreg Roach 'RFN', 428eaf8709SGreg Roach 'RIN', 438eaf8709SGreg Roach 'SSN', 448eaf8709SGreg Roach '_UID', 458eaf8709SGreg Roach ]; 468eaf8709SGreg Roach 478eaf8709SGreg Roach /** 480cfd6963SGreg Roach * How should this module be identified in the control panel, etc.? 498eaf8709SGreg Roach * 508eaf8709SGreg Roach * @return string 518eaf8709SGreg Roach */ 528eaf8709SGreg Roach public function title(): string 538eaf8709SGreg Roach { 548eaf8709SGreg Roach /* I18N: Name of a module/sidebar */ 558eaf8709SGreg Roach return I18N::translate('Extra information'); 568eaf8709SGreg Roach } 578eaf8709SGreg Roach 588eaf8709SGreg Roach /** 598eaf8709SGreg Roach * A sentence describing what this module does. 608eaf8709SGreg Roach * 618eaf8709SGreg Roach * @return string 628eaf8709SGreg Roach */ 638eaf8709SGreg Roach public function description(): string 648eaf8709SGreg Roach { 658eaf8709SGreg Roach /* I18N: Description of the “Extra information” module */ 668eaf8709SGreg Roach return I18N::translate('A sidebar showing non-genealogy information about an individual.'); 678eaf8709SGreg Roach } 688eaf8709SGreg Roach 698eaf8709SGreg Roach /** 708eaf8709SGreg Roach * The default position for this sidebar. It can be changed in the control panel. 718eaf8709SGreg Roach * 728eaf8709SGreg Roach * @return int 738eaf8709SGreg Roach */ 748eaf8709SGreg Roach public function defaultSidebarOrder(): int 758eaf8709SGreg Roach { 768eaf8709SGreg Roach return 1; 778eaf8709SGreg Roach } 788eaf8709SGreg Roach 798eaf8709SGreg Roach /** {@inheritdoc} */ 808eaf8709SGreg Roach public function hasSidebarContent(Individual $individual): bool 818eaf8709SGreg Roach { 82d697893cSGreg Roach return $individual->facts(static::HANDLED_FACTS)->isNotEmpty(); 838eaf8709SGreg Roach } 848eaf8709SGreg Roach 858eaf8709SGreg Roach /** 868eaf8709SGreg Roach * Load this sidebar synchronously. 878eaf8709SGreg Roach * 888eaf8709SGreg Roach * @param Individual $individual 898eaf8709SGreg Roach * 908eaf8709SGreg Roach * @return string 918eaf8709SGreg Roach */ 928eaf8709SGreg Roach public function getSidebarContent(Individual $individual): string 938eaf8709SGreg Roach { 948eaf8709SGreg Roach ob_start(); 95d697893cSGreg Roach 96d697893cSGreg Roach foreach ($individual->facts(static::HANDLED_FACTS) as $fact) { 978eaf8709SGreg Roach FunctionsPrintFacts::printFact($fact, $individual); 988eaf8709SGreg Roach } 998eaf8709SGreg Roach 100d697893cSGreg Roach $html = ob_get_clean(); 1018eaf8709SGreg Roach 102d697893cSGreg Roach return strip_tags($html, '<a><div><span>'); 1038eaf8709SGreg Roach } 1048eaf8709SGreg Roach 1058eaf8709SGreg Roach /** 1068eaf8709SGreg Roach * This module handles the following facts - so don't show them on the "Facts and events" tab. 1078eaf8709SGreg Roach * 10854c7f8dfSGreg Roach * @return Collection 1098eaf8709SGreg Roach */ 1108eaf8709SGreg Roach public function supportedFacts(): Collection 1118eaf8709SGreg Roach { 1128eaf8709SGreg Roach return new Collection(static::HANDLED_FACTS); 1138eaf8709SGreg Roach } 1148eaf8709SGreg Roach} 115