1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2016 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees; 17 18/** 19 * A GEDCOM repository (REPO) object. 20 */ 21class Repository extends GedcomRecord { 22 const RECORD_TYPE = 'REPO'; 23 const URL_PREFIX = 'repo.php?rid='; 24 25 /** 26 * Fetch data from the database 27 * 28 * @param string $xref 29 * @param int $tree_id 30 * 31 * @return null|string 32 */ 33 protected static function fetchGedcomRecord($xref, $tree_id) { 34 return Database::prepare( 35 "SELECT o_gedcom FROM `##other` WHERE o_id = :xref AND o_file = :tree_id AND o_type = 'REPO'" 36 )->execute(array( 37 'xref' => $xref, 38 'tree_id' => $tree_id, 39 ))->fetchOne(); 40 } 41 42 /** 43 * Generate a private version of this record 44 * 45 * @param int $access_level 46 * 47 * @return string 48 */ 49 protected function createPrivateGedcomRecord($access_level) { 50 return '0 @' . $this->xref . "@ REPO\n1 NAME " . I18N::translate('Private'); 51 } 52 53 /** 54 * Extract names from the GEDCOM record. 55 */ 56 public function extractNames() { 57 parent::extractNamesFromFacts(1, 'NAME', $this->getFacts('NAME')); 58 } 59} 60