132a5d3c7SGreg Roach<?php 232a5d3c7SGreg Roach 332a5d3c7SGreg Roach/** 432a5d3c7SGreg Roach * webtrees: online genealogy 5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 632a5d3c7SGreg Roach * This program is free software: you can redistribute it and/or modify 732a5d3c7SGreg Roach * it under the terms of the GNU General Public License as published by 832a5d3c7SGreg Roach * the Free Software Foundation, either version 3 of the License, or 932a5d3c7SGreg Roach * (at your option) any later version. 1032a5d3c7SGreg Roach * This program is distributed in the hope that it will be useful, 1132a5d3c7SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1232a5d3c7SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1332a5d3c7SGreg Roach * GNU General Public License for more details. 1432a5d3c7SGreg Roach * You should have received a copy of the GNU General Public License 1532a5d3c7SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1632a5d3c7SGreg Roach */ 1732a5d3c7SGreg Roach 1832a5d3c7SGreg Roachdeclare(strict_types=1); 1932a5d3c7SGreg Roach 2032a5d3c7SGreg Roachnamespace Fisharebest\Webtrees\Elements; 2132a5d3c7SGreg Roach 2232a5d3c7SGreg Roachuse Fisharebest\Webtrees\Tree; 2332a5d3c7SGreg Roach 2432a5d3c7SGreg Roachuse function e; 2532a5d3c7SGreg Roach 2632a5d3c7SGreg Roach/** 27f7c88e25SGreg Roach * Events which can be linked to content at another website. 2832a5d3c7SGreg Roach */ 2932a5d3c7SGreg Roachclass AbstractExternalLink extends AbstractElement 3032a5d3c7SGreg Roach{ 317920629bSGreg Roach protected const EXTERNAL_URL = 'https://www.example.com/{ID}'; 327920629bSGreg Roach 3332a5d3c7SGreg Roach /** 3432a5d3c7SGreg Roach * Display the value of this type of element. 3532a5d3c7SGreg Roach * 3632a5d3c7SGreg Roach * @param string $value 3732a5d3c7SGreg Roach * @param Tree $tree 3832a5d3c7SGreg Roach * 3932a5d3c7SGreg Roach * @return string 4032a5d3c7SGreg Roach */ 4132a5d3c7SGreg Roach public function value(string $value, Tree $tree): string 4232a5d3c7SGreg Roach { 4332a5d3c7SGreg Roach $canonical = $this->canonical($value); 4432a5d3c7SGreg Roach $url = strtr(static::EXTERNAL_URL, ['{ID}' => rawurlencode($canonical)]); 4532a5d3c7SGreg Roach 4632a5d3c7SGreg Roach return '<a dir="ltr" href="' . e($url) . '" rel="nofollow">' . e($canonical) . '</a>'; 4732a5d3c7SGreg Roach } 4832a5d3c7SGreg Roach} 49