117c50b57SGreg Roach<?php 23976b470SGreg Roach 317c50b57SGreg Roach/** 417c50b57SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 617c50b57SGreg Roach * This program is free software: you can redistribute it and/or modify 717c50b57SGreg Roach * it under the terms of the GNU General Public License as published by 817c50b57SGreg Roach * the Free Software Foundation, either version 3 of the License, or 917c50b57SGreg Roach * (at your option) any later version. 1017c50b57SGreg Roach * This program is distributed in the hope that it will be useful, 1117c50b57SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1217c50b57SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1317c50b57SGreg Roach * GNU General Public License for more details. 1417c50b57SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1617c50b57SGreg Roach */ 17fcfa147eSGreg Roach 1817c50b57SGreg Roachdeclare(strict_types=1); 1917c50b57SGreg Roach 2017c50b57SGreg Roachnamespace Fisharebest\Webtrees\Module; 2117c50b57SGreg Roach 2217c50b57SGreg Roachuse Fisharebest\Webtrees\Date; 2317c50b57SGreg Roachuse Fisharebest\Webtrees\Fact; 2417c50b57SGreg Roachuse Fisharebest\Webtrees\I18N; 2517c50b57SGreg Roachuse Fisharebest\Webtrees\Individual; 2617c50b57SGreg Roachuse Illuminate\Support\Collection; 2717c50b57SGreg Roach 2817c50b57SGreg Roachtrait ModuleHistoricEventsTrait 2917c50b57SGreg Roach{ 3017c50b57SGreg Roach public function description(): string 3117c50b57SGreg Roach { 32b5e8e56bSGreg Roach return I18N::translate('Add historic events to an individual’s page.'); 3317c50b57SGreg Roach } 3417c50b57SGreg Roach 3517c50b57SGreg Roach /** 3636779af1SGreg Roach * @return Collection<int,string> 3717c50b57SGreg Roach */ 38*3ee4c7efSGreg Roach public function historicEventsAll(string $language_tag): Collection 3917c50b57SGreg Roach { 407413816eSGreg Roach return new Collection(); 4117c50b57SGreg Roach } 4217c50b57SGreg Roach 4317c50b57SGreg Roach /** 4436779af1SGreg Roach * @return Collection<int,Fact> 4517c50b57SGreg Roach */ 4617c50b57SGreg Roach public function historicEventsForIndividual(Individual $individual): Collection 4717c50b57SGreg Roach { 4817c50b57SGreg Roach $min_date = $individual->getEstimatedBirthDate(); 4917c50b57SGreg Roach $max_date = $individual->getEstimatedDeathDate(); 5017c50b57SGreg Roach 51*3ee4c7efSGreg Roach return $this->historicEventsAll(I18N::languageTag()) 52f25fc0f9SGreg Roach ->map(static fn (string $gedcom): Fact => new Fact($gedcom, $individual, 'histo')) 537413816eSGreg Roach ->filter(static fn (Fact $fact): bool => Date::compare($fact->date(), $min_date) >= 0) 547413816eSGreg Roach ->filter(static fn (Fact $fact): bool => Date::compare($fact->date(), $max_date) <= 0); 5517c50b57SGreg Roach } 5617c50b57SGreg Roach} 57