diff options
| author | Greg Roach <greg@subaqua.co.uk> | 2021-02-11 13:44:01 +0000 |
|---|---|---|
| committer | Greg Roach <greg@subaqua.co.uk> | 2021-02-11 13:47:39 +0000 |
| commit | 31fd4d4144a406cbee12959609e922a7a960533e (patch) | |
| tree | 2123a9df5ccd6f0b0a60af0dc4d5b8a80efdd298 /app | |
| parent | b36a1d8f963505706aa27f2412284902cf771d19 (diff) | |
| download | webtrees-31fd4d4144a406cbee12959609e922a7a960533e.tar.gz webtrees-31fd4d4144a406cbee12959609e922a7a960533e.tar.bz2 webtrees-31fd4d4144a406cbee12959609e922a7a960533e.zip | |
Fix: #2829 - update external URLs for AFN fields
Diffstat (limited to 'app')
| -rw-r--r-- | app/Elements/AncestralFileNumber.php | 4 | ||||
| -rw-r--r-- | app/Elements/GovId.php | 21 |
2 files changed, 22 insertions, 3 deletions
diff --git a/app/Elements/AncestralFileNumber.php b/app/Elements/AncestralFileNumber.php index dd48f87d6b..4ed8bd2862 100644 --- a/app/Elements/AncestralFileNumber.php +++ b/app/Elements/AncestralFileNumber.php @@ -32,7 +32,7 @@ use function strtoupper; */ class AncestralFileNumber extends AbstractElement { - protected const FAMILY_SEARCH_URL = 'https://www.familysearch.org/search/family-trees/results?q.afnId='; + protected const EXTERNAL_URL = 'https://www.familysearch.org/search/family-trees/results?q.afnId='; protected const MAX_LENGTH = 12; @@ -59,7 +59,7 @@ class AncestralFileNumber extends AbstractElement public function value(string $value, Tree $tree): string { $canonical = $this->canonical($value); - $url = static::FAMILY_SEARCH_URL . rawurlencode($canonical); + $url = static::EXTERNAL_URL . rawurlencode($canonical); return '<a dir="ltr" href="' . e($url) . '" rel="nofollow">' . e($canonical) . '</a>'; } diff --git a/app/Elements/GovId.php b/app/Elements/GovId.php index f1c8fe88cc..852f01bab8 100644 --- a/app/Elements/GovId.php +++ b/app/Elements/GovId.php @@ -22,12 +22,30 @@ namespace Fisharebest\Webtrees\Elements; use Fisharebest\Webtrees\Tree; use function e; +use function rawurlencode; +use function strtoupper; /** * A custom field used in _LOC records */ class GovId extends AbstractElement { + protected const EXTERNAL_URL = 'https://gov.genealogy.net/item/show/'; + + protected const MAX_LENGTH = 12; + + /** + * Convert a value to a canonical form. + * + * @param string $value + * + * @return string + */ + public function canonical(string $value): string + { + return strtoupper(parent::canonical($value)); + } + /** * Display the value of this type of element. * @@ -39,7 +57,8 @@ class GovId extends AbstractElement public function value(string $value, Tree $tree): string { $canonical = $this->canonical($value); + $url = static::EXTERNAL_URL . rawurlencode($canonical); - return '<a dir="ltr" href="https://gov.genealogy.net/item/show/' . e($canonical) . '">' . e($canonical) . '</a>'; + return '<a dir="ltr" href="' . e($url) . '" rel="nofollow">' . e($canonical) . '</a>'; } } |
