1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2022 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 strtoupper; 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 public const VALUE_AUDIO = 'AUDIO'; 37 public const VALUE_BOOK = 'BOOK'; 38 public const VALUE_CARD = 'CARD'; 39 public const VALUE_CERTIFICATE = 'CERTIFICATE'; 40 public const VALUE_COAT = 'COAT'; 41 public const VALUE_DOCUMENT = 'DOCUMENT'; 42 public const VALUE_ELECTRONIC = 'ELECTRONIC'; 43 public const VALUE_FICHE = 'FICHE'; 44 public const VALUE_FILM = 'FILM'; 45 public const VALUE_MAGAZINE = 'MAGAZINE'; 46 public const VALUE_MANUSCRIPT = 'MANUSCRIPT'; 47 public const VALUE_MAP = 'MAP'; 48 public const VALUE_NEWSPAPER = 'NEWSPAPER'; 49 public const VALUE_OTHER = 'OTHER'; 50 public const VALUE_PAINTING = 'PAINTING'; 51 public const VALUE_PHOTO = 'PHOTO'; 52 public const VALUE_TOMBSTONE = 'TOMBSTONE'; 53 public const VALUE_VIDEO = 'VIDEO'; 54 55 protected const MAXIMUM_LENGTH = 15; 56 57 /** 58 * Convert a value to a canonical form. 59 * 60 * @param string $value 61 * 62 * @return string 63 */ 64 public function canonical(string $value): string 65 { 66 return strtoupper(parent::canonical($value)); 67 } 68 69 /** 70 * A list of controlled values for this element 71 * 72 * @return array<int|string,string> 73 */ 74 public function values(): array 75 { 76 // *** indicates custom values 77 $values = [ 78 '' => '', 79 self::VALUE_AUDIO => /* I18N: Type of media object */ I18N::translate('Audio'), 80 self::VALUE_BOOK => /* I18N: Type of media object */ I18N::translate('Book'), 81 self::VALUE_CARD => /* I18N: Type of media object */ I18N::translate('Card'), 82 self::VALUE_CERTIFICATE => /* I18N: Type of media object */ I18N::translate('Certificate'), 83 self::VALUE_COAT => /* I18N: Type of media object */ I18N::translate('Coat of arms'), 84 self::VALUE_DOCUMENT => /* I18N: Type of media object */ I18N::translate('Document'), 85 self::VALUE_ELECTRONIC => /* I18N: Type of media object */ I18N::translate('Electronic'), 86 self::VALUE_FICHE => /* I18N: Type of media object */ I18N::translate('Microfiche'), 87 self::VALUE_FILM => /* I18N: Type of media object */ I18N::translate('Microfilm'), 88 self::VALUE_MAGAZINE => /* I18N: Type of media object */ I18N::translate('Magazine'), 89 self::VALUE_MANUSCRIPT => /* I18N: Type of media object */ I18N::translate('Manuscript'), 90 self::VALUE_MAP => /* I18N: Type of media object */ I18N::translate('Map'), 91 self::VALUE_NEWSPAPER => /* I18N: Type of media object */ I18N::translate('Newspaper'), 92 self::VALUE_OTHER => /* I18N: Type of media object */ I18N::translate('Other'), 93 self::VALUE_PAINTING => /* I18N: Type of media object */ I18N::translate('Painting'), 94 self::VALUE_PHOTO => /* I18N: Type of media object */ I18N::translate('Photo'), 95 self::VALUE_TOMBSTONE => /* I18N: Type of media object */ I18N::translate('Tombstone'), 96 self::VALUE_VIDEO => /* I18N: Type of media object */ I18N::translate('Video'), 97 ]; 98 99 uasort($values, I18N::comparator()); 100 101 return $values; 102 } 103} 104