xref: /webtrees/app/Elements/SourceMediaType.php (revision 60e0106f6fee03a93efbbbb46c01b401e38c7694)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Elements;
21
22use Fisharebest\Webtrees\I18N;
23
24use function strtolower;
25use function uasort;
26
27/**
28 * SOURCE_MEDIA_TYPE := {Size=1:15}
29 * [ audio | book | card | electronic | fiche | film | magazine |
30 * manuscript | map | newspaper | photo | tombstone | video ]
31 * A code, selected from one of the media classifications choices above, that indicates the type of
32 * material in which the referenced source is stored.
33 */
34class SourceMediaType extends AbstractElement
35{
36    protected const MAXIMUM_LENGTH = 15;
37
38    /**
39     * Convert a value to a canonical form.
40     *
41     * @param string $value
42     *
43     * @return string
44     */
45    public function canonical(string $value): string
46    {
47        return strtolower(parent::canonical($value));
48    }
49
50    /**
51     * A list of controlled values for this element
52     *
53     * @return array<int|string,string>
54     */
55    public function values(): array
56    {
57        // *** indicates custom values
58        $values = [
59            ''            => '',
60            'audio'       => /* I18N: Type of media object */ I18N::translate('Audio'),
61            'book'        => /* I18N: Type of media object */ I18N::translate('Book'),
62            'card'        => /* I18N: Type of media object */ I18N::translate('Card'),
63            'certificate' => /* I18N: Type of media object */ I18N::translate('Certificate'),
64            'coat'        => /* I18N: Type of media object */ I18N::translate('Coat of arms'),
65            'document'    => /* I18N: Type of media object */ I18N::translate('Document'),
66            'electronic'  => /* I18N: Type of media object */ I18N::translate('Electronic'),
67            'fiche'       => /* I18N: Type of media object */ I18N::translate('Microfiche'),
68            'film'        => /* I18N: Type of media object */ I18N::translate('Microfilm'),
69            'magazine'    => /* I18N: Type of media object */ I18N::translate('Magazine'),
70            'manuscript'  => /* I18N: Type of media object */ I18N::translate('Manuscript'),
71            'map'         => /* I18N: Type of media object */ I18N::translate('Map'),
72            'newspaper'   => /* I18N: Type of media object */ I18N::translate('Newspaper'),
73            'other'       => /* I18N: Type of media object */ I18N::translate('Other'),
74            'photo'       => /* I18N: Type of media object */ I18N::translate('Photo'),
75            'painting'    => /* I18N: Type of media object */ I18N::translate('Painting'),
76            'tombstone'   => /* I18N: Type of media object */ I18N::translate('Tombstone'),
77            'video'       => /* I18N: Type of media object */ I18N::translate('Video'),
78        ];
79
80        uasort($values, '\Fisharebest\Webtrees\I18N::strcasecmp');
81
82        return $values;
83    }
84}
85