xref: /webtrees/app/Elements/HierarchicalRelationship.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1ae0043b7SGreg Roach<?php
2ae0043b7SGreg Roach
3ae0043b7SGreg Roach/**
4ae0043b7SGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6ae0043b7SGreg Roach * This program is free software: you can redistribute it and/or modify
7ae0043b7SGreg Roach * it under the terms of the GNU General Public License as published by
8ae0043b7SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9ae0043b7SGreg Roach * (at your option) any later version.
10ae0043b7SGreg Roach * This program is distributed in the hope that it will be useful,
11ae0043b7SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12ae0043b7SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13ae0043b7SGreg Roach * GNU General Public License for more details.
14ae0043b7SGreg Roach * You should have received a copy of the GNU General Public License
15ae0043b7SGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16ae0043b7SGreg Roach */
17ae0043b7SGreg Roach
18ae0043b7SGreg Roachdeclare(strict_types=1);
19ae0043b7SGreg Roach
20ae0043b7SGreg Roachnamespace Fisharebest\Webtrees\Elements;
21ae0043b7SGreg Roach
22ae0043b7SGreg Roachuse Fisharebest\Webtrees\I18N;
23ae0043b7SGreg Roach
24ae0043b7SGreg Roachuse function strtoupper;
25ae0043b7SGreg Roach
26ae0043b7SGreg Roach/**
27ae0043b7SGreg Roach * <HIERARCHICAL_RELATIONSHIP>:= [POLI|RELI|GEOG|CULT]
28ae0043b7SGreg Roach * Used to differentiate political (administrative), religious, geographical
29ae0043b7SGreg Roach * or cultural associations. For the superior location object the details of
30ae0043b7SGreg Roach * its type are defined by the <TYPE_OF_LOCATION> in its record.
31ae0043b7SGreg Roach */
32ae0043b7SGreg Roachclass HierarchicalRelationship extends AbstractElement
33ae0043b7SGreg Roach{
34ae0043b7SGreg Roach    /**
35ae0043b7SGreg Roach     * Convert a value to a canonical form.
36ae0043b7SGreg Roach     *
37ae0043b7SGreg Roach     * @param string $value
38ae0043b7SGreg Roach     *
39ae0043b7SGreg Roach     * @return string
40ae0043b7SGreg Roach     */
41ae0043b7SGreg Roach    public function canonical(string $value): string
42ae0043b7SGreg Roach    {
43ae0043b7SGreg Roach        return strtoupper(parent::canonical($value));
44ae0043b7SGreg Roach    }
45ae0043b7SGreg Roach
46ae0043b7SGreg Roach    /**
47ae0043b7SGreg Roach     * A list of controlled values for this element
48ae0043b7SGreg Roach     *
49ae0043b7SGreg Roach     * @return array<int|string,string>
50ae0043b7SGreg Roach     */
51ae0043b7SGreg Roach    public function values(): array
52ae0043b7SGreg Roach    {
53ae0043b7SGreg Roach        $values = [
54ae0043b7SGreg Roach            ''     => '',
55b049d7caSGreg Roach            'POLI' => /* I18N: Type of location hierarchy */ I18N::translate('political'),
56b049d7caSGreg Roach            'RELI' => /* I18N: Type of location hierarchy */ I18N::translate('religious'),
57b049d7caSGreg Roach            'GEOG' => /* I18N: Type of location hierarchy */ I18N::translate('geographic'),
58b049d7caSGreg Roach            'CULT' => /* I18N: Type of location hierarchy */ I18N::translate('cultural'),
59ae0043b7SGreg Roach        ];
60ae0043b7SGreg Roach
6137646143SGreg Roach        uasort($values, I18N::comparator());
62ae0043b7SGreg Roach
63ae0043b7SGreg Roach        return $values;
64ae0043b7SGreg Roach    }
65ae0043b7SGreg Roach}
66