Compare commits

..

8 Commits

11 changed files with 484 additions and 2 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020-2021 museum-digital
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

2
l18n

Submodule l18n updated: 2c74a458f3...b4a7e98654

52
src/MDColorsSet.php Normal file
View File

@ -0,0 +1,52 @@
<?PHP
/**
* Contains a class for controlling the list of base colors.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class containing available colors.
*/
final class MDColorsSet extends MDValueSet {
const COLOR_NAMES = [
"black",
"green",
"silver",
"lime",
"gray",
"olive",
"white",
"yellow",
"maroon",
"navy",
"red",
"blue",
"purple",
"teal",
"fuchsia",
"aqua",
];
const COLORS_RGB = [
"black" => [0, 0, 0],
"green" => [0, 128, 0],
"silver" => [192, 192, 192],
"lime" => [0, 255, 0],
"gray" => [128, 0, 128],
"olive" => [128, 128, 0],
"white" => [255, 255, 255],
"yellow" => [255, 255, 0],
"maroon" => [128, 0, 0],
"navy" => [0, 0, 128],
"red" => [255, 0, 0],
"blue" => [0, 0, 255],
"purple" => [128, 0, 128],
"teal" => [0, 128, 128],
"fuchsia" => [255, 0, 255],
"aqua" => [0, 255, 255],
];
}

View File

@ -0,0 +1,30 @@
<?PHP
/**
* Contains a class for controlling the list of available subjects for data history writing.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class containing available options for data history subjects.
*/
final class MDDataHistorySubjectsSet extends MDValueSet {
const AVAILABLE_SUBJECTS = [
'appointment',
'collection',
'contact',
'exhibition',
'literature',
'loan',
'museum',
'object',
'podcast',
'podcast_episode',
'sammlung',
'series',
'user',
];
}

View File

@ -0,0 +1,20 @@
<?PHP
/**
* Contains a class for controlling the list of available external sources.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class containing available external sources.
*/
final class MDExternalHostingSet extends MDValueSet {
const DEFAULT_EXTERNAL_HOSTING = 'Archive.org';
const EXTERNAL_SOURCES = [
'Archive.org',
];
}

View File

@ -200,7 +200,199 @@ final class MDLanguagesSet {
'yo' => 'Yoruba',
'za' => 'Zhuang, Chuang',
'zh' => 'Chinese',
'zu' => 'Zulu'
'zu' => 'Zulu',
];
const LANGUAGES_ISO639_2B = [
'aa' => 'aar', # 'Afar-áf',
'ab' => 'abk', # 'аҧсуа бызшәа',
'ae' => 'ave', # 'Avestan',
'af' => 'afr', # 'Afrikaans',
'ak' => 'aka', # 'Akan',
'am' => 'amh', # 'Amharic',
'an' => 'arg', # 'Aragonese',
'ar' => 'ara', # 'العربية',
'as' => 'asm', # 'Assamese',
'av' => 'ava', # 'Avaric',
'ay' => 'aym', # 'Aymara',
'az' => 'aze', # 'Azerbaijani',
'ba' => 'bak', # 'Bashkir',
'be' => 'bel', # 'беларуская мова',
'bg' => 'bul', # 'български език',
'bh' => 'bih', # 'Bihari',
'bi' => 'bis', # 'Bislama',
'bm' => 'bam', # 'Bambara',
'bn' => 'ben', # 'Bengali',
'bo' => 'tib', # 'བོད་སྐད',
'br' => 'bre', # 'Breton',
'bs' => 'bos', # 'Bosnian',
'ca' => 'cat', # 'català',
'ce' => 'che', # 'Chechen',
'ch' => 'cha', # 'Chamorro',
'co' => 'cos', # 'Corsican',
'cr' => 'cre', # 'Cree',
'cs' => 'cze', # 'čeština',
'cu' => 'chu', # 'словѣньскъ ѩзыкъ',
'cv' => 'chv', # 'Chuvash',
'cy' => 'wel', # 'Welsh',
'da' => 'dan', # 'Danish',
'de' => 'ger', # 'Deutsch',
'dsb' => 'dsb', # 'Dolnoserbšćina',
'dv' => 'div', # 'Divehi; Dhivehi; Maldivian;',
'dz' => 'dzo', # 'Dzongkha',
'ee' => 'ewe', # 'Ewe',
'egy' => 'egy', # 'Egyptian language',
'el' => 'gre', # 'ελληνικά',
'en' => 'eng', # 'English',
'eo' => 'epo', # 'Esperanto',
'es' => 'spa', # 'Spanish; Castilian',
'et' => 'est', # 'Estonian',
'eu' => 'baq', # 'Basque',
'fa' => 'per', # 'Persian',
'ff' => 'ful', # 'Fula; Fulah; Pulaar; Pular',
'fi' => 'fin', # 'Finnish',
'fj' => 'fij', # 'Fijian',
'fo' => 'fao', # 'Faroese',
'fr' => 'fre', # 'French',
'fy' => 'fry', # 'Western Frisian',
'ga' => 'gle', # 'Irish',
'gd' => 'gla', # 'Scottish Gaelic; Gaelic',
'gl' => 'glg', # 'Galician',
'gn' => 'grn', # 'Guaraní',
'grc' => 'grc', # 'Ancient Greek',
'gu' => 'guj', # 'Gujarati',
'gv' => 'glv', # 'Manx',
'ha' => 'hau', # 'Hausa',
'he' => 'heb', # 'Hebrew (modern)',
'hi' => 'hin', # 'Hindi',
'ho' => 'hmo', # 'Hiri Motu',
'hr' => 'hrv', # 'Croatian',
'hsb' => 'hsb', # 'Hornjoserbšćina',
'ht' => 'hat', # 'Haitian; Haitian Creole',
'hu' => 'hun', # 'Magyar',
'hy' => 'arm', # 'Armenian',
'hz' => 'her', # 'Herero',
'ia' => 'ina', # 'Interlingua',
'id' => 'ind', # 'Bahasa Indonesia',
'ie' => 'ile', # 'Interlingue',
'ig' => 'ibo', # 'Igbo',
'ii' => 'iii', # 'Nuosu',
'ik' => 'ipk', # 'Inupiaq',
'io' => 'ido', # 'Ido',
'is' => 'ice', # 'Icelandic',
'it' => 'ita', # 'Italian',
'iu' => 'iku', # 'Inuktitut',
'ja' => 'jpn', # 'Japanese (ja)',
'jv' => 'jav', # 'Javanese (jv)',
'ka' => 'geo', # 'Georgian',
'kg' => 'kon', # 'Kongo',
'ki' => 'kik', # 'Kikuyu, Gikuyu',
'kj' => 'kua', # 'Kwanyama, Kuanyama',
'kk' => 'kaz', # 'Kazakh',
'kl' => 'kal', # 'Kalaallisut, Greenlandic',
'km' => 'khm', # 'Khmer',
'kn' => 'kan', # 'Kannada',
'ko' => 'kor', # 'Korean',
'kr' => 'kau', # 'Kanuri',
'ks' => 'kas', # 'Kashmiri',
'ku' => 'kur', # 'Kurdish',
'kv' => 'kom', # 'Komi',
'kw' => 'cor', # 'Cornish',
'ky' => 'kir', # 'Kirghiz, Kyrgyz',
'la' => 'lat', # 'Latin',
'lb' => 'ltz', # 'Lëtzebuergesch',
'lg' => 'lug', # 'Luganda',
'li' => 'lim', # 'Limburgish, Limburgan, Limburger',
'ln' => 'lin', # 'Lingala',
'lo' => 'lao', # 'Lao',
'lt' => 'lit', # 'lietuvių kalba',
'lu' => 'lub', # 'Luba-Katanga',
'lv' => 'lav', # 'Latvian',
'mg' => 'mlg', # 'Malagasy',
'mh' => 'mah', # 'Marshallese',
'mi' => 'mao', # 'Maori',
'mk' => 'mac', # 'Macedonian',
'ml' => 'mal', # 'Malayalam',
'mn' => 'mon', # 'Mongolian',
'mr' => 'mar', # 'Marathi (Mara?hi)',
'ms' => 'may', # 'Malay',
'mt' => 'mlt', # 'Maltese',
'my' => 'bur', # 'Burmese',
'na' => 'nau', # 'Nauru',
'nb' => 'nob', # 'Bokmål',
'nd' => 'nde', # 'North Ndebele',
'ne' => 'nep', # 'Nepali',
'ng' => 'ndo', # 'Ndonga',
'nl' => 'dut', # 'Nederlands',
'nn' => 'nno', # 'Nynorsk',
'no' => 'nor', # 'Norsk',
'nr' => 'nbl', # 'South Ndebele',
'nv' => 'nav', # 'Navajo, Navaho',
'ny' => 'nya', # 'Chichewa; Chewa; Nyanja',
'oc' => 'oci', # 'Occitan',
'oj' => 'oji', # 'Ojibwe, Ojibwa',
'om' => 'orm', # 'Oromo',
'or' => 'ori', # 'Oriya',
'os' => 'oss', # 'Ossetian, Ossetic',
'pa' => 'pan', # 'Panjabi, Punjabi',
'pi' => 'pli', # 'Pali',
'pl' => 'pol', # 'Polish',
'ps' => 'pus', # 'Pashto, Pushto',
'pt' => 'por', # 'Português',
'qu' => 'que', # 'Quechua',
'rm' => 'roh', # 'Romansh',
'rn' => 'run', # 'Kirundi',
'ro' => 'rum', # 'Română',
'ru' => 'rus', # 'Russian',
'rw' => 'kin', # 'Kinyarwanda',
'sa' => 'san', # 'Sanskrit (संस्कृत)',
'sc' => 'srd', # 'Sardinian',
'sd' => 'snd', # 'Sindhi',
'se' => 'sme', # 'Northern Sami',
'sg' => 'sag', # 'Sango',
'si' => 'sin', # 'Sinhala, Sinhalese',
'sk' => 'slo', # 'Slovenčina',
'sl' => 'slv', # 'Slovenščina',
'sm' => 'smo', # 'Samoan',
'sn' => 'sna', # 'Shona',
'so' => 'som', # 'Somali',
'sq' => 'alb', # 'Albanian',
'sr' => 'srp', # 'Serbian',
'ss' => 'ssw', # 'Swati',
'st' => 'sot', # 'Southern Sotho',
'su' => 'sun', # 'Sundanese',
'sv' => 'swe', # 'Swedish',
'sw' => 'swa', # 'Swahili',
'ta' => 'tam', # 'Tamil',
'te' => 'tel', # 'Telugu',
'tg' => 'tgk', # 'Tajik',
'th' => 'tha', # 'ภาษาไทย',
'ti' => 'tir', # 'Tigrinya',
'tk' => 'tuk', # 'Turkmen',
'tl' => 'tgl', # 'Tagalog',
'tn' => 'tsn', # 'Tswana',
'to' => 'ton', # 'Tonga (Tonga Islands)',
'tr' => 'tur', # 'Türkçe',
'ts' => 'tso', # 'Tsonga',
'tt' => 'tat', # 'Tatar',
'tw' => 'twi', # 'Twi',
'ty' => 'tah', # 'Tahitian',
'ug' => 'uig', # 'Uighur, Uyghur',
'uk' => 'ukr', # 'Ukrainian',
'ur' => 'urd', # 'اردو',
'uz' => 'uzb', # 'Uzbek',
've' => 'ven', # 'Venda',
'vi' => 'vie', # 'Vietnamese',
'vo' => 'vol', # 'Volapük',
'wa' => 'wln', # 'Walloon',
'wen' => 'wen', # 'Sorbisch',
'wo' => 'wol', # 'Wolof',
'xh' => 'xho', # 'Xhosa',
'yi' => 'yid', # 'Yiddish',
'yo' => 'yor', # 'Yoruba',
'za' => 'zha', # 'Zhuang, Chuang',
'zh' => 'chi', # 'Chinese',
'zu' => 'zul', # 'Zulu',
];
}

View File

@ -11,6 +11,9 @@ declare(strict_types = 1);
*/
final class MDLicensesSet extends MDValueSet {
const DEFAULT_LICENSE_IMGS = 'CC BY-NC-SA';
const DEFAULT_LICENSE_METADATA = 'CC BY-NC-SA';
const AVAILABLE_LICENSES = [
'CC BY-NC-SA' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',

54
src/MDPhoneTypesSet.php Normal file
View File

@ -0,0 +1,54 @@
<?PHP
/**
* Contains a class for controlling the list of available phone types.
* Phone types (e.g. mobile, work, fax) are mainly used for contact pages in
* musdb.
* The list aims to be roughly similar to common implementations of the vCard standard.
*
* @see https://tools.ietf.org/html/rfc2426
* @see https://tools.ietf.org/html/rfc6350
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class containing available place types.
*/
final class MDPhoneTypesSet extends MDValueSet {
const DEFAULT_PHONE_TYPE = 'work';
const PHONE_TYPES = [
'work',
'home',
'mobile',
'work mobile',
'fax',
'fax work',
];
/**
* Gets an unsorted list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string>
*/
public static function getUnsortedList(MDTlLoader $tlLoader):array {
return parent::getTlUnsortedList($tlLoader, self::PHONE_TYPES, "phone_types", "phone_types");
}
/**
* Gets a list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string>
*/
public static function getSortedList(MDTlLoader $tlLoader):array {
return parent::getTlSortedList($tlLoader, self::PHONE_TYPES, "phone_types", "phone_types");
}
}

View File

@ -0,0 +1,32 @@
<?PHP
/**
* Contains a class for controlling the list of available recording types.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Class containing available recording types.
*/
final class MDRecordingTypesSet extends MDValueSet {
const DEFAULT_RECORDING_TYPE = 'audio';
const RECORDING_TYPES = [
'audio',
'video',
];
/**
* Gets a list of the entries in a translated version.
*
* @param MDTlLoader $tlLoader Translation loader.
*
* @return array<string>
*/
public static function getSortedList(MDTlLoader $tlLoader):array {
return parent::getTlSortedList($tlLoader, self::RECORDING_TYPES, "recording_types_set", "recording_types_set");
}
}

View File

@ -0,0 +1,38 @@
<?PHP
/**
* This script contains tests for the home page.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
use PHPUnit\Framework\TestCase;
require __DIR__ . '/../src/MDLanguagesSet.php';
/**
* Tests for home page.
*/
final class MDLanguagesSetTest extends TestCase {
/**
* Test to check whether the HTML page is correctly generated.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
* @group ValidOutput
*
* @return void
*/
public function testIso639ListIsCorrect():void {
foreach (MDLanguagesSet::AVAILABLE_LANGUAGES as $language_code => $language_name) {
self::assertArrayHasKey($language_code, MDLanguagesSet::LANGUAGES_ISO639_2B, 'Language ' . $language_code . ' (' . $language_name . ') has no entry in ISO639-2b language code list');
self::assertEquals(3, strlen(MDLanguagesSet::LANGUAGES_ISO639_2B[$language_code]), 'ISO639-2b entry for language ' . $language_code . ' (' . $language_name . ') is not = 3');
}
foreach (MDLanguagesSet::LANGUAGES_ISO639_2B as $language_code => $language_name) {
self::assertArrayHasKey($language_code, MDLanguagesSet::AVAILABLE_LANGUAGES, 'Language ' . $language_code . ' (' . $language_name . ') has an entry in ISO639-2b language code list, but not in the main list.');
}
}
}

40
tests/config.xml Normal file
View File

@ -0,0 +1,40 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/|version|/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutChangesToGlobalState="false"
beStrictAboutOutputDuringTests="false"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTodoAnnotatedTests="true"
beStrictAboutCoversAnnotation="false"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertDeprecationsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
enforceTimeLimit="true"
failOnWarning="true"
forceCoversAnnotation="false"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
processIsolation="true"
stopOnError="true"
stopOnFailure="true"
stopOnIncomplete="true"
stopOnSkipped="true"
stopOnRisky="true"
testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="true">
<!-- <file>/path/to/file</file>
<exclude>
<directory suffix=".php">/path/to/files</directory>
<file>/path/to/file</file>
preserveGlobalState="false"
runTestInSeparateProcess="true"
</exclude>-->
</phpunit>