11635452cSGreg Roach<?php 21635452cSGreg Roach 31635452cSGreg Roach/** 41635452cSGreg Roach * webtrees: online genealogy 5a091ac74SGreg Roach * Copyright (C) 2020 webtrees development team 61635452cSGreg Roach * This program is free software: you can redistribute it and/or modify 71635452cSGreg Roach * it under the terms of the GNU General Public License as published by 81635452cSGreg Roach * the Free Software Foundation, either version 3 of the License, or 91635452cSGreg Roach * (at your option) any later version. 101635452cSGreg Roach * This program is distributed in the hope that it will be useful, 111635452cSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 121635452cSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 131635452cSGreg Roach * GNU General Public License for more details. 141635452cSGreg Roach * You should have received a copy of the GNU General Public License 151635452cSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 161635452cSGreg Roach */ 171635452cSGreg Roach 181635452cSGreg Roachdeclare(strict_types=1); 191635452cSGreg Roach 201635452cSGreg Roachnamespace Fisharebest\Webtrees; 211635452cSGreg Roach 221635452cSGreg Roachuse Closure; 231635452cSGreg Roachuse Exception; 241635452cSGreg Roachuse Fisharebest\Webtrees\Http\RequestHandlers\HeaderPage; 251635452cSGreg Roachuse Illuminate\Database\Capsule\Manager as DB; 261635452cSGreg Roach 271635452cSGreg Roach/** 281635452cSGreg Roach * A GEDCOM header (HEAD) object. 291635452cSGreg Roach */ 301635452cSGreg Roachclass Header extends GedcomRecord 311635452cSGreg Roach{ 321635452cSGreg Roach public const RECORD_TYPE = 'HEAD'; 331635452cSGreg Roach 341635452cSGreg Roach protected const ROUTE_NAME = HeaderPage::class; 351635452cSGreg Roach 361635452cSGreg Roach /** 371635452cSGreg Roach * A closure which will create a record from a database row. 381635452cSGreg Roach * 39bb03c9f0SGreg Roach * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::header() 40bb03c9f0SGreg Roach * 411635452cSGreg Roach * @param Tree $tree 421635452cSGreg Roach * 431635452cSGreg Roach * @return Closure 441635452cSGreg Roach */ 451635452cSGreg Roach public static function rowMapper(Tree $tree): Closure 461635452cSGreg Roach { 47bb03c9f0SGreg Roach return Factory::header()->mapper($tree); 481635452cSGreg Roach } 491635452cSGreg Roach 501635452cSGreg Roach /** 511635452cSGreg Roach * Get an instance of a header object. For single records, 521635452cSGreg Roach * we just receive the XREF. For bulk records (such as lists 531635452cSGreg Roach * and search results) we can receive the GEDCOM data as well. 541635452cSGreg Roach * 55bb03c9f0SGreg Roach * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::header() 56bb03c9f0SGreg Roach * 571635452cSGreg Roach * @param string $xref 581635452cSGreg Roach * @param Tree $tree 591635452cSGreg Roach * @param string|null $gedcom 601635452cSGreg Roach * 611635452cSGreg Roach * @return Header|null 621635452cSGreg Roach */ 631635452cSGreg Roach public static function getInstance(string $xref, Tree $tree, string $gedcom = null): ?Header 641635452cSGreg Roach { 65bb03c9f0SGreg Roach return Factory::header()->make($xref, $tree, $gedcom); 661635452cSGreg Roach } 671635452cSGreg Roach 681635452cSGreg Roach /** 691635452cSGreg Roach * Generate a private version of this record 701635452cSGreg Roach * 711635452cSGreg Roach * @param int $access_level 721635452cSGreg Roach * 731635452cSGreg Roach * @return string 741635452cSGreg Roach */ 751635452cSGreg Roach protected function createPrivateGedcomRecord(int $access_level): string 761635452cSGreg Roach { 77bb03c9f0SGreg Roach return '0 HEAD' . $this->xref . "@ SUBM\n1 NAME " . I18N::translate('Private'); 781635452cSGreg Roach } 791635452cSGreg Roach 801635452cSGreg Roach /** 811635452cSGreg Roach * Extract names from the GEDCOM record. 821635452cSGreg Roach * 831635452cSGreg Roach * @return void 841635452cSGreg Roach */ 851635452cSGreg Roach public function extractNames(): void 861635452cSGreg Roach { 871635452cSGreg Roach $this->getAllNames[] = [ 88*02467d32SGreg Roach 'type' => static::RECORD_TYPE, 891635452cSGreg Roach 'sort' => I18N::translate('Header'), 901635452cSGreg Roach 'full' => I18N::translate('Header'), 911635452cSGreg Roach 'fullNN' => I18N::translate('Header'), 921635452cSGreg Roach ]; 931635452cSGreg Roach } 941635452cSGreg Roach} 95