xref: /webtrees/app/Repository.php (revision 1062a1429914c995339f502856821457aa975a5a)
1a25f0a04SGreg Roach<?php
2a25f0a04SGreg Roach/**
3a25f0a04SGreg Roach * webtrees: online genealogy
4*1062a142SGreg Roach * Copyright (C) 2018 webtrees development team
5a25f0a04SGreg Roach * This program is free software: you can redistribute it and/or modify
6a25f0a04SGreg Roach * it under the terms of the GNU General Public License as published by
7a25f0a04SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8a25f0a04SGreg Roach * (at your option) any later version.
9a25f0a04SGreg Roach * This program is distributed in the hope that it will be useful,
10a25f0a04SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a25f0a04SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12a25f0a04SGreg Roach * GNU General Public License for more details.
13a25f0a04SGreg Roach * You should have received a copy of the GNU General Public License
14a25f0a04SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15a25f0a04SGreg Roach */
1676692c8bSGreg Roachnamespace Fisharebest\Webtrees;
17a25f0a04SGreg Roach
18a25f0a04SGreg Roach/**
1976692c8bSGreg Roach * A GEDCOM repository (REPO) object.
20a25f0a04SGreg Roach */
21a25f0a04SGreg Roachclass Repository extends GedcomRecord {
22a25f0a04SGreg Roach	const RECORD_TYPE = 'REPO';
23a25f0a04SGreg Roach	const URL_PREFIX  = 'repo.php?rid=';
24a25f0a04SGreg Roach
2576692c8bSGreg Roach	/**
2676692c8bSGreg Roach	 * Fetch data from the database
2776692c8bSGreg Roach	 *
2876692c8bSGreg Roach	 * @param string $xref
2976692c8bSGreg Roach	 * @param int    $tree_id
3076692c8bSGreg Roach	 *
3176692c8bSGreg Roach	 * @return null|string
3276692c8bSGreg Roach	 */
3364d9078aSGreg Roach	protected static function fetchGedcomRecord($xref, $tree_id) {
3464d9078aSGreg Roach		return Database::prepare(
3564d9078aSGreg Roach			"SELECT o_gedcom FROM `##other` WHERE o_id = :xref AND o_file = :tree_id AND o_type = 'REPO'"
3613abd6f3SGreg Roach		)->execute([
3764d9078aSGreg Roach			'xref'    => $xref,
3864d9078aSGreg Roach			'tree_id' => $tree_id,
3913abd6f3SGreg Roach		])->fetchOne();
40a25f0a04SGreg Roach	}
41a25f0a04SGreg Roach
4276692c8bSGreg Roach	/**
4376692c8bSGreg Roach	 * Generate a private version of this record
4476692c8bSGreg Roach	 *
4576692c8bSGreg Roach	 * @param int $access_level
4676692c8bSGreg Roach	 *
4776692c8bSGreg Roach	 * @return string
4876692c8bSGreg Roach	 */
49a25f0a04SGreg Roach	protected function createPrivateGedcomRecord($access_level) {
50a25f0a04SGreg Roach		return '0 @' . $this->xref . "@ REPO\n1 NAME " . I18N::translate('Private');
51a25f0a04SGreg Roach	}
52a25f0a04SGreg Roach
5376692c8bSGreg Roach	/**
5476692c8bSGreg Roach	 * Extract names from the GEDCOM record.
5576692c8bSGreg Roach	 */
56a25f0a04SGreg Roach	public function extractNames() {
5736a0c51dSGreg Roach		parent::extractNamesFromFacts(1, 'NAME', $this->getFacts('NAME'));
58a25f0a04SGreg Roach	}
59a25f0a04SGreg Roach}
60