Compare commits
135 Commits
25f6694a92
...
master
Author | SHA1 | Date | |
---|---|---|---|
86f6a6c26d
|
|||
da950073e9
|
|||
29879ac02f
|
|||
5ec93ba619
|
|||
1403f75447
|
|||
04c378675c
|
|||
60483d897b
|
|||
a0348b135a
|
|||
45d7c3d455
|
|||
22a30fd52b
|
|||
2e9d0aeff3
|
|||
9fb9e45893
|
|||
4d16367266
|
|||
1b922ce973
|
|||
b01fb98108 | |||
12689d24fa
|
|||
7f22538085
|
|||
9d139f9154
|
|||
fb92b6b84c
|
|||
426e6b11ac
|
|||
eec67dd866
|
|||
61edc14240
|
|||
dbd15ea26b
|
|||
1b34e49ff8
|
|||
709a5d5cc3
|
|||
f1d0435eef
|
|||
abb41ed32c
|
|||
3c2d1ca856
|
|||
d0b325e73e
|
|||
8c73338758
|
|||
f938c66ab6
|
|||
7fc57353a8
|
|||
fa8bc6dac0
|
|||
f8a8fd901c
|
|||
5142a57cfe
|
|||
71e05e7eab
|
|||
333340da3e
|
|||
d22db5bd95
|
|||
f19973d20e
|
|||
dc1c72aeda
|
|||
bdb9bb16f5
|
|||
7826b7d891
|
|||
be2da00759
|
|||
47763d1998
|
|||
99e0f9b655
|
|||
32a1e8b1be
|
|||
db46255f87
|
|||
c560a5581f
|
|||
d3ff111750
|
|||
e55e4c210a
|
|||
25e5e954b4
|
|||
8c8ead0a02
|
|||
3ecbb1f774
|
|||
c907c1b085
|
|||
69c2c7cbf9
|
|||
9ddb461491
|
|||
9c80957709
|
|||
d68c114905
|
|||
493ef9f721
|
|||
6772476f9b
|
|||
4c1916247b
|
|||
c63692fb6c
|
|||
ed7feb8963
|
|||
11f36fa202
|
|||
3717bc9da2
|
|||
8d126d112d
|
|||
22f5efddd5
|
|||
2259012d42
|
|||
0aef8c3116
|
|||
9c65921f5c
|
|||
497807267b
|
|||
6c8ca3ac8e
|
|||
ad237490a3
|
|||
10b9c58a1b
|
|||
65bbd03e2e
|
|||
c371d1d821
|
|||
91ccbd6683
|
|||
22e9ce56a3
|
|||
7912066f71
|
|||
dcfba67422
|
|||
c43cc7e42a
|
|||
71d34b37ca
|
|||
8e0be0f80c
|
|||
be2f42677b
|
|||
1108398437
|
|||
1dedb86d5b
|
|||
06b2d13c6f
|
|||
d2dd24baee
|
|||
7c7fb58a0d
|
|||
f14d7edc6e
|
|||
8f32c30fbd
|
|||
c57d180aa1
|
|||
d9f3f875e0
|
|||
1d1a690e0f
|
|||
da6e40282d
|
|||
68f453f5f3
|
|||
d6e3c3208b
|
|||
fe73fc7267
|
|||
ea5a186e8f
|
|||
3fb3ee4edd
|
|||
446dd78bec
|
|||
4e3877a4fb
|
|||
887f06f70e
|
|||
d295e16049
|
|||
609931eb26
|
|||
2f765e183e
|
|||
0f64939def
|
|||
f79afa4ed7
|
|||
9bca8f400e
|
|||
7fb7bb83c1
|
|||
c082ca685f
|
|||
651362c65e
|
|||
9e44fcac49
|
|||
f5673c69fd
|
|||
0e86361968
|
|||
17f1e162f8
|
|||
8090b95f49
|
|||
8e81d31466
|
|||
f73c729dff
|
|||
d47490f217
|
|||
8684933c9c
|
|||
06cc1d4c10
|
|||
1de413b3fb
|
|||
b55ea34950
|
|||
628acd4b53
|
|||
f9366b686e
|
|||
c3d4f3f03a
|
|||
a437f1b57b
|
|||
077eaeb3e3
|
|||
9b6534de4e
|
|||
0698b6e487 | |||
8e151e793f
|
|||
10aedafad1
|
|||
fbc50d8198
|
|||
82a8805363
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2021 museum-digital
|
||||
Copyright (c) 2020-2025 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
|
||||
|
@ -12,3 +12,7 @@ museum-digital.
|
||||
## Enums
|
||||
|
||||
As of PHP 8.1, PHP now supports enums. A new folder has been added in /src/enums to gather those types of new entries, that can be better expressed using enums at no direct loss (mainly in listing translated options).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for the full license text.
|
||||
|
18
exceptions/MDInvalidNodaLinkException.php
Normal file
18
exceptions/MDInvalidNodaLinkException.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case a controlled vocabulary is to be linked using an invalid ID.
|
||||
*/
|
||||
class MDInvalidNodaLinkException extends MDgenericInvalidInputsException {
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage() {
|
||||
//error message
|
||||
return 'Inputs are not valid.';
|
||||
|
||||
}
|
||||
}
|
20
exceptions/MDInvalidNodaLinkLcshIdIsGeneralLoc.php
Normal file
20
exceptions/MDInvalidNodaLinkLcshIdIsGeneralLoc.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case a library of congress subject headings link refers
|
||||
* to the other authority files of the Library of Congress.
|
||||
*/
|
||||
final class MDInvalidNodaLinkLcshIdIsGeneralLoc extends MDInvalidNodaLinkException {
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage() {
|
||||
//error message
|
||||
return 'Inputs are not valid.';
|
||||
|
||||
}
|
||||
}
|
||||
|
21
exceptions/MDInvalidNodaLinkLocIdIsSh.php
Normal file
21
exceptions/MDInvalidNodaLinkLocIdIsSh.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Exception thrown in case a library of congress link refers to the subject
|
||||
* headings (subject headings are a dedicated, full vocabulary according to
|
||||
* md's definition).
|
||||
*/
|
||||
final class MDInvalidNodaLinkLocIdIsSh extends MDInvalidNodaLinkException {
|
||||
/**
|
||||
* Error message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function errorMessage() {
|
||||
//error message
|
||||
return 'Inputs are not valid.';
|
||||
|
||||
}
|
||||
}
|
||||
|
2
l18n
2
l18n
Submodule l18n updated: 8272c3c186...a7e3056f09
14
phpunit.xml
Normal file
14
phpunit.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" backupGlobals="false" beStrictAboutChangesToGlobalState="true" beStrictAboutOutputDuringTests="true" bootstrap="tests/bootstrap.php" cacheResult="false" colors="true" enforceTimeLimit="true" failOnWarning="true" processIsolation="true" stopOnError="true" stopOnFailure="true" stopOnIncomplete="true" stopOnSkipped="true" stopOnRisky="true" testdox="false" timeoutForSmallTests="1" timeoutForMediumTests="10" timeoutForLargeTests="60" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false" beStrictAboutCoverageMetadata="false">
|
||||
<testsuites>
|
||||
<testsuite name="tests">
|
||||
<directory>tests/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage/>
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">src</directory>
|
||||
</include>
|
||||
</source>
|
||||
</phpunit>
|
@ -13,7 +13,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDActorVariantTypesSet extends MDValueSet {
|
||||
|
||||
const ACTOR_VARIANT_TYPES = [
|
||||
public const ACTOR_VARIANT_TYPES = [
|
||||
'',
|
||||
'birth_name',
|
||||
'civil_name',
|
||||
|
@ -12,13 +12,13 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDAppointmentAttendanceModeSet extends MDValueSet {
|
||||
|
||||
const MODES = [
|
||||
public const MODES = [
|
||||
'offline',
|
||||
'online',
|
||||
'mixed',
|
||||
];
|
||||
|
||||
const MODES_TO_SCHEMA_ORG = [
|
||||
public const MODES_TO_SCHEMA_ORG = [
|
||||
'offline' => 'https://schema.org/OfflineEventAttendanceMode',
|
||||
'online' => 'https://schema.org/OnlineEventAttendanceMode',
|
||||
'mixed' => 'https://schema.org/MixedEventAttendanceMode',
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDAppointmentContributorsSet extends MDValueSet {
|
||||
|
||||
const AVAILABLE_ROLES = [
|
||||
public const AVAILABLE_ROLES = [
|
||||
'organizer',
|
||||
'presenter',
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDAppointmentRecordingSet extends MDValueSet {
|
||||
|
||||
const AVAILABLE_RECORDING_TYPES = ['video'];
|
||||
const EXTERNAL_SOURCES = ['Archive.org' => 'https://archive.org/details/'];
|
||||
public const AVAILABLE_RECORDING_TYPES = ['video'];
|
||||
public const EXTERNAL_SOURCES = ['Archive.org' => 'https://archive.org/details/'];
|
||||
|
||||
}
|
||||
|
@ -11,14 +11,14 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDAppointmentStatusSet extends MDValueSet {
|
||||
|
||||
const STATUS = [
|
||||
public const STATUS = [
|
||||
'scheduled',
|
||||
'cancelled',
|
||||
'moved_online',
|
||||
'postponed',
|
||||
];
|
||||
|
||||
const STATUS_TO_SCHEMA_ORG = [
|
||||
public const STATUS_TO_SCHEMA_ORG = [
|
||||
'scheduled' => 'https://schema.org/EventScheduled',
|
||||
'cancelled' => 'https://schema.org/EventCancelled',
|
||||
'moved_online' => 'https://schema.org/EventMovedOnline',
|
||||
|
@ -13,7 +13,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDBlockedMailserverSet extends MDValueSet {
|
||||
|
||||
const BLOCKED_DOMAINS = [
|
||||
public const BLOCKED_DOMAINS = [
|
||||
"@magenta.de",
|
||||
"@t-online.de",
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDCloserLocationTypesSet extends MDValueSet {
|
||||
|
||||
const CLOSER_LOCATION_TYPES = [
|
||||
public const CLOSER_LOCATION_TYPES = [
|
||||
"0", // ''
|
||||
"1", // Place of recording
|
||||
"2", // Place of finding
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDColorsSet extends MDValueSet {
|
||||
|
||||
const COLOR_NAMES = [
|
||||
public const COLOR_NAMES = [
|
||||
"black",
|
||||
"green",
|
||||
"silver",
|
||||
@ -30,7 +30,7 @@ final class MDColorsSet extends MDValueSet {
|
||||
"aqua",
|
||||
];
|
||||
|
||||
const COLOR_NAMES_AND_EMPTY = [
|
||||
public const COLOR_NAMES_AND_EMPTY = [
|
||||
'',
|
||||
"black",
|
||||
"green",
|
||||
@ -50,7 +50,7 @@ final class MDColorsSet extends MDValueSet {
|
||||
"aqua",
|
||||
];
|
||||
|
||||
const COLORS_RGB = [
|
||||
public const COLORS_RGB = [
|
||||
"black" => [0, 0, 0],
|
||||
"green" => [0, 128, 0],
|
||||
"silver" => [192, 192, 192],
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDConservationReportTypeSet extends MDValueSet {
|
||||
|
||||
const REPORT_TYPES = [
|
||||
public const REPORT_TYPES = [
|
||||
'damage',
|
||||
'conservation',
|
||||
'condition',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDConservationStatusSet extends MDValueSet {
|
||||
|
||||
const STATUS_LEVELS = [
|
||||
public const STATUS_LEVELS = [
|
||||
1 => '',
|
||||
34 => 'markedBad',
|
||||
67 => 'markedMedium',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDCurrenciesSet extends MDValueSet {
|
||||
|
||||
const CURRENCIES = [
|
||||
public const CURRENCIES = [
|
||||
'',
|
||||
'by-BYN',
|
||||
'ch-CHF', // Swiss Franc
|
||||
@ -31,6 +31,7 @@ final class MDCurrenciesSet extends MDValueSet {
|
||||
'ru-RUB',
|
||||
'su-SUR',
|
||||
'ua-UAH',
|
||||
'ua-UAK',
|
||||
'uk-GBP',
|
||||
'us-USD',
|
||||
];
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDDataHistorySubjectsSet extends MDValueSet {
|
||||
|
||||
const AVAILABLE_SUBJECTS = [
|
||||
public const AVAILABLE_SUBJECTS = [
|
||||
'appointment',
|
||||
'collection',
|
||||
'contact',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDDisposalMethodSet extends MDValueSet {
|
||||
|
||||
const METHODS = [
|
||||
public const METHODS = [
|
||||
'',
|
||||
'sold',
|
||||
'destroyed',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDEntryTypesSet extends MDValueSet {
|
||||
|
||||
const ENTRY_TYPES = [
|
||||
public const ENTRY_TYPES = [
|
||||
'0', //
|
||||
'1', // Schenkung
|
||||
'2', // Kauf
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDEventsSet extends MDValueSet {
|
||||
|
||||
const EVENT_IDS = [
|
||||
public const EVENT_IDS = [
|
||||
'1', // => Created
|
||||
'2', // => Found
|
||||
'3', // => Published
|
||||
@ -48,8 +48,8 @@ final class MDEventsSet extends MDValueSet {
|
||||
'36', // => Was depicted
|
||||
'37', // => Painted on
|
||||
'38', // => Illustrated
|
||||
'39', // "wurde zusammengefügt" (Finale Herstellung, z.B. Bild in Rahmen, Montage eines Omnibusses)
|
||||
'40', // "wurde versteigert" (Objekt war im Auktionshandel)
|
||||
'39', // => Assembled / "wurde zusammengefügt" (Finale Herstellung, z.B. Bild in Rahmen, Montage eines Omnibusses)
|
||||
'40', // => Auctioned "wurde versteigert" (Objekt war im Auktionshandel)
|
||||
'41', // "wurde gekauft" (Hier kann man jeden Kauf des Objektes vermerken)
|
||||
'42', // "wurde besessen" (Hier kann man jeden Besitz des Objektes vermerken)
|
||||
'43', // "wurde verkauft" (Hier kann man jeden Verkauf des Objektes vermerken)
|
||||
@ -60,29 +60,36 @@ final class MDEventsSet extends MDValueSet {
|
||||
'48', // "wurde herausgegeben"
|
||||
'49', // "gespendet / verschenkt"
|
||||
'50', // "vererbt"
|
||||
'51', // is subject of
|
||||
'52', // Emerged
|
||||
'53', // Production of material
|
||||
'54', // Mentioned place
|
||||
'55', // Mentioned time
|
||||
'56', // Received ownership
|
||||
'57', // Transfered ownership
|
||||
|
||||
];
|
||||
|
||||
const EVENTS_PRODUCTION = [1, 7, 9, 10, 19, 20, 26, 38, 39, 48];
|
||||
public const EVENTS_PRODUCTION = [1, 7, 9, 10, 19, 20, 26, 27, 28, 38, 39, 48, 52];
|
||||
|
||||
// Array enthält solche Ereignisse, die nach der Herstellung passiert sein müssen
|
||||
const EVENTS_POST_PRODUCTION = [2, 3, 6, 8, 11, 13, 14, 15, 32, 34, 37, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50];
|
||||
public const EVENTS_POST_PRODUCTION = [2, 3, 6, 8, 11, 13, 14, 15, 32, 34, 37, 40, 41, 42, 43, 44, 45, 46, 47, 49, 50, 56, 57];
|
||||
|
||||
// Array enthält solche Ereignisse, die vor der Herstellung passiert sein müssen
|
||||
const EVENTS_PRE_PRODUCTION = [4, 12, 25, 29, 30, 31, 35];
|
||||
public const EVENTS_PRE_PRODUCTION = [4, 12, 25, 29, 30, 31, 35, 53];
|
||||
|
||||
// Array enthält solche Ereignisse, die sich auf Objekte beziehen, die nicht hergestellt wurden
|
||||
const EVENTS_NO_PRODUCTION = [21];
|
||||
public const EVENTS_NO_PRODUCTION = [16, 21, 33, 51, 54, 55];
|
||||
|
||||
// Array enthält Ereignistypen, die auf Korrespondenzen hinweisen
|
||||
const EVENTS_CORRESPONDENCE = [11, 13];
|
||||
public const EVENTS_CORRESPONDENCE = [11, 13];
|
||||
|
||||
/*
|
||||
* Constants for event types without places, times, actors
|
||||
*/
|
||||
const EVENTS_NO_TIME = [5, 22, 23, 36];
|
||||
const EVENTS_NO_ACTOR = [21, 22, 24, 36];
|
||||
const EVENTS_NO_PLACE = [5, 23, 24];
|
||||
public const EVENTS_NO_TIME = [5, 22, 23, 33, 36];
|
||||
public const EVENTS_NO_ACTOR = [21, 22, 24, 36, 52];
|
||||
public const EVENTS_NO_PLACE = [5, 23, 24, 33];
|
||||
|
||||
/**
|
||||
* Gets a list of the entries in a translated version.
|
||||
@ -95,4 +102,46 @@ final class MDEventsSet extends MDValueSet {
|
||||
return parent::getTlSortedList($tlLoader, self::EVENT_IDS, "eventtype_name", "eventname");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the entries in a translated version (actor focus).
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedListActors(MDTlLoader $tlLoader):array {
|
||||
$output = parent::getTlSortedList($tlLoader, self::EVENT_IDS, "eventtype_persinst", "event_persinst");
|
||||
foreach (self::EVENTS_NO_ACTOR as $id) unset($output[$id]);
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the entries in a translated version (place focus).
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedListPlaces(MDTlLoader $tlLoader):array {
|
||||
$output = parent::getTlSortedList($tlLoader, self::EVENT_IDS, "eventtype_place", "event_place");
|
||||
foreach (self::EVENTS_NO_PLACE as $id) unset($output[$id]);
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getSortedListTimes(MDTlLoader $tlLoader):array {
|
||||
$output = parent::getTlSortedList($tlLoader, self::EVENT_IDS, "eventtype_time", "event_time");
|
||||
foreach (self::EVENTS_NO_TIME as $id) unset($output[$id]);
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDExhibitionContributorsSet extends MDValueSet {
|
||||
|
||||
const AVAILABLE_ROLES = [
|
||||
public const AVAILABLE_ROLES = [
|
||||
'concept',
|
||||
'curator',
|
||||
'design',
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDExternalHostingSet extends MDValueSet {
|
||||
|
||||
const DEFAULT_EXTERNAL_HOSTING = 'Archive.org';
|
||||
public const DEFAULT_EXTERNAL_HOSTING = 'Archive.org';
|
||||
|
||||
const EXTERNAL_SOURCES = [
|
||||
public const EXTERNAL_SOURCES = [
|
||||
'Archive.org',
|
||||
];
|
||||
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDGenderSet extends MDValueSet {
|
||||
|
||||
const GENDERS = [
|
||||
public const GENDERS = [
|
||||
'',
|
||||
'female',
|
||||
'male',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDLanguagesSet {
|
||||
|
||||
const AVAILABLE_LANGUAGES_SHORT = [
|
||||
public const AVAILABLE_LANGUAGES_SHORT = [
|
||||
'aa',
|
||||
'ab',
|
||||
'ae',
|
||||
@ -39,6 +39,7 @@ final class MDLanguagesSet {
|
||||
'ch',
|
||||
'co',
|
||||
'cr',
|
||||
'crh',
|
||||
'cs',
|
||||
'cu',
|
||||
'cv',
|
||||
@ -129,6 +130,7 @@ final class MDLanguagesSet {
|
||||
'na',
|
||||
'nb',
|
||||
'nd',
|
||||
'nds',
|
||||
'ne',
|
||||
'ng',
|
||||
'nl',
|
||||
@ -143,6 +145,7 @@ final class MDLanguagesSet {
|
||||
'or',
|
||||
'os',
|
||||
'pa',
|
||||
'pdt',
|
||||
'pi',
|
||||
'pl',
|
||||
'ps',
|
||||
@ -203,7 +206,7 @@ final class MDLanguagesSet {
|
||||
'zu',
|
||||
];
|
||||
|
||||
const AVAILABLE_LANGUAGES = [
|
||||
public const AVAILABLE_LANGUAGES = [
|
||||
'aa' => 'Afar-áf',
|
||||
'ab' => 'аҧсуа бызшәа',
|
||||
'ae' => 'Avestan',
|
||||
@ -231,6 +234,7 @@ final class MDLanguagesSet {
|
||||
'ch' => 'Chamorro',
|
||||
'co' => 'Corsican',
|
||||
'cr' => 'Cree',
|
||||
'crh' => 'Qırımtatar tili',
|
||||
'cs' => 'čeština',
|
||||
'cu' => 'словѣньскъ ѩзыкъ',
|
||||
'cv' => 'Chuvash',
|
||||
@ -291,7 +295,7 @@ final class MDLanguagesSet {
|
||||
'kk' => 'Kazakh',
|
||||
'kl' => 'Kalaallisut, Greenlandic',
|
||||
'km' => 'Khmer',
|
||||
'kn' => 'Kannada',
|
||||
'kn' => 'ಕನ್ನಡ',
|
||||
'ko' => 'Korean',
|
||||
'kr' => 'Kanuri',
|
||||
'ks' => 'Kashmiri',
|
||||
@ -321,6 +325,7 @@ final class MDLanguagesSet {
|
||||
'na' => 'Nauru',
|
||||
'nb' => 'Bokmål',
|
||||
'nd' => 'North Ndebele',
|
||||
'nds' => 'Niederdeutsch',
|
||||
'ne' => 'Nepali',
|
||||
'ng' => 'Ndonga',
|
||||
'nl' => 'Nederlands',
|
||||
@ -335,6 +340,7 @@ final class MDLanguagesSet {
|
||||
'or' => 'Oriya',
|
||||
'os' => 'Ossetian, Ossetic',
|
||||
'pa' => 'Panjabi, Punjabi',
|
||||
'pdt' => 'Plautdietsch',
|
||||
'pi' => 'Pali',
|
||||
'pl' => 'Polski',
|
||||
'ps' => 'Pashto, Pushto',
|
||||
@ -395,7 +401,7 @@ final class MDLanguagesSet {
|
||||
'zu' => 'Zulu',
|
||||
];
|
||||
|
||||
const LANGUAGES_ISO639_2B = [
|
||||
public const LANGUAGES_ISO639_2B = [
|
||||
'aa' => 'aar', # 'Afar-áf',
|
||||
'ab' => 'abk', # 'аҧсуа бызшәа',
|
||||
'ae' => 'ave', # 'Avestan',
|
||||
@ -423,6 +429,7 @@ final class MDLanguagesSet {
|
||||
'ch' => 'cha', # 'Chamorro',
|
||||
'co' => 'cos', # 'Corsican',
|
||||
'cr' => 'cre', # 'Cree',
|
||||
'crh' => 'crh', # 'Crimean Tatar',
|
||||
'cs' => 'cze', # 'čeština',
|
||||
'cu' => 'chu', # 'словѣньскъ ѩзыкъ',
|
||||
'cv' => 'chv', # 'Chuvash',
|
||||
@ -513,6 +520,7 @@ final class MDLanguagesSet {
|
||||
'na' => 'nau', # 'Nauru',
|
||||
'nb' => 'nob', # 'Bokmål',
|
||||
'nd' => 'nde', # 'North Ndebele',
|
||||
'nds' => 'nds', # 'Niederdeutsch',
|
||||
'ne' => 'nep', # 'Nepali',
|
||||
'ng' => 'ndo', # 'Ndonga',
|
||||
'nl' => 'dut', # 'Nederlands',
|
||||
@ -527,6 +535,7 @@ final class MDLanguagesSet {
|
||||
'or' => 'ori', # 'Oriya',
|
||||
'os' => 'oss', # 'Ossetian, Ossetic',
|
||||
'pa' => 'pan', # 'Panjabi, Punjabi',
|
||||
'pdt' => 'pdt', # Plautdietsch
|
||||
'pi' => 'pli', # 'Pali',
|
||||
'pl' => 'pol', # 'Polish',
|
||||
'ps' => 'pus', # 'Pashto, Pushto',
|
||||
|
@ -11,10 +11,10 @@ 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';
|
||||
public const DEFAULT_LICENSE_IMGS = 'CC BY-NC-SA';
|
||||
public const DEFAULT_LICENSE_METADATA = 'CC BY-NC-SA';
|
||||
|
||||
const AVAILABLE_LICENSES_NAMES = [
|
||||
public const AVAILABLE_LICENSES_NAMES = [
|
||||
|
||||
'CC BY-NC-SA',
|
||||
'CC BY-NC-ND',
|
||||
@ -31,7 +31,7 @@ final class MDLicensesSet extends MDValueSet {
|
||||
|
||||
];
|
||||
|
||||
const AVAILABLE_LICENSES = [
|
||||
public const AVAILABLE_LICENSES = [
|
||||
|
||||
'CC BY-NC-SA' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
|
||||
'CC BY-NC-ND' => 'https://creativecommons.org/licenses/by-nc-nd/4.0/',
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDLoanTypesSet extends MDValueSet {
|
||||
|
||||
const DEFAULT_LOAN_TYPE = 'outgoing';
|
||||
public const DEFAULT_LOAN_TYPE = 'outgoing';
|
||||
|
||||
const LOAN_TYPES = [
|
||||
public const LOAN_TYPES = [
|
||||
'outgoing',
|
||||
'incoming',
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDMarkingTypesSet extends MDValueSet {
|
||||
|
||||
const MARKING_TYPES = [
|
||||
public const MARKING_TYPES = [
|
||||
'signature',
|
||||
'engraving',
|
||||
'watermark',
|
||||
@ -31,6 +31,8 @@ final class MDMarkingTypesSet extends MDValueSet {
|
||||
'cast',
|
||||
'sewn',
|
||||
'glued',
|
||||
'painted',
|
||||
'drawn',
|
||||
];
|
||||
|
||||
/**
|
||||
|
21
src/MDMeasurementUnitInterface.php
Normal file
21
src/MDMeasurementUnitInterface.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Describes an interface for a measurement units.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Describes an interface for a measurement units.
|
||||
*/
|
||||
interface MDMeasurementUnitInterface {
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit (e.g. mm for lengths).
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float;
|
||||
}
|
@ -11,19 +11,19 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDNodaRepositoriesSet extends MDValueSet {
|
||||
|
||||
const REPOSITORIES_ACTOR = [
|
||||
public const REPOSITORIES_ACTOR = [
|
||||
'allgemein',
|
||||
'bne',
|
||||
'bnf',
|
||||
'edition humboldt digital',
|
||||
'gnd',
|
||||
'iconclass',
|
||||
'kl-bb',
|
||||
'lcsh',
|
||||
'loc',
|
||||
'MBL',
|
||||
'NDB/ADB',
|
||||
'ndl',
|
||||
'ndp-ikmk',
|
||||
'ndp-ikmk-persons',
|
||||
'nomisma',
|
||||
'npg',
|
||||
'orcid',
|
||||
@ -32,10 +32,9 @@ final class MDNodaRepositoriesSet extends MDValueSet {
|
||||
'ulan',
|
||||
'viaf',
|
||||
'wikidata',
|
||||
'Wikipedia',
|
||||
];
|
||||
|
||||
const REPOSITORIES_PLACE = [
|
||||
public const REPOSITORIES_PLACE = [
|
||||
'allgemein',
|
||||
'bne',
|
||||
'bnf',
|
||||
@ -52,10 +51,9 @@ final class MDNodaRepositoriesSet extends MDValueSet {
|
||||
'rkd',
|
||||
'viaf',
|
||||
'wikidata',
|
||||
'Wikipedia',
|
||||
];
|
||||
|
||||
const REPOSITORIES_TAG = [
|
||||
public const REPOSITORIES_TAG = [
|
||||
'aat',
|
||||
'ackerbau',
|
||||
'allgemein',
|
||||
@ -75,7 +73,6 @@ final class MDNodaRepositoriesSet extends MDValueSet {
|
||||
'rkd',
|
||||
'viaf',
|
||||
'wikidata',
|
||||
'Wikipedia',
|
||||
];
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDObjectFormSet extends MDValueSet {
|
||||
|
||||
const FORMS = [
|
||||
public const FORMS = [
|
||||
'',
|
||||
'cube',
|
||||
'cuboid',
|
||||
|
@ -11,8 +11,13 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDObjectPositionsSet extends MDValueSet {
|
||||
|
||||
const POSITIONS = [
|
||||
'left', 'top_left', 'top', 'top_right', 'right', 'bottom_right', 'bottom', 'bottom_left', 'center', 'rear_side', 'edge', 'other',
|
||||
public const POSITIONS = [
|
||||
'front_front',
|
||||
'left', 'top_left', 'top', 'top_right', 'right', 'bottom_right', 'bottom', 'bottom_left', 'center',
|
||||
'rear_side',
|
||||
'rear_left', 'rear_top_left', 'rear_top', 'rear_top_right', 'rear_right', 'rear_bottom_right', 'rear_bottom', 'rear_bottom_left', 'rear_center',
|
||||
'underside', 'topside',
|
||||
'edge', 'inside', 'other',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDObjectPublicationBackgrounds extends MDValueSet {
|
||||
|
||||
const PUBLICATION_BACKGROUNDS = [
|
||||
public const PUBLICATION_BACKGROUNDS = [
|
||||
'0', // Image published
|
||||
'1', // Transcript published
|
||||
'2', // Discussed
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDObjectStatusSet extends MDValueSet {
|
||||
|
||||
const DEFAULT_OBJECT_STATUS = 'owned';
|
||||
public const DEFAULT_OBJECT_STATUS = 'owned';
|
||||
|
||||
const OBJECT_STATUS = [
|
||||
public const OBJECT_STATUS = [
|
||||
'owned',
|
||||
'permanent_loan',
|
||||
'third_party_property',
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDObjectSyndicationSet extends MDValueSet {
|
||||
|
||||
const REPOSITORIES = [
|
||||
public const REPOSITORIES = [
|
||||
|
||||
'ddb' => [
|
||||
'url' => 'https://www.deutsche-digitale-bibliothek.de/',
|
||||
|
@ -17,9 +17,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDPhoneTypesSet extends MDValueSet {
|
||||
|
||||
const DEFAULT_PHONE_TYPE = 'work';
|
||||
public const DEFAULT_PHONE_TYPE = 'work';
|
||||
|
||||
const PHONE_TYPES = [
|
||||
public const PHONE_TYPES = [
|
||||
'work',
|
||||
'home',
|
||||
'mobile',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDPlacetypesSet extends MDValueSet {
|
||||
|
||||
const PLACE_TYPE_IDS = [
|
||||
public const PLACE_TYPE_IDS = [
|
||||
'0', // => Administrativ
|
||||
'1', // => Historisch
|
||||
'2', // => Region - Landschaft - Naturpark
|
||||
|
@ -12,7 +12,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDPodcastContributorsSet extends MDValueSet {
|
||||
|
||||
const AVAILABLE_ROLES = [
|
||||
public const AVAILABLE_ROLES = [
|
||||
'onair',
|
||||
'organization',
|
||||
'recording',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDProcessTypesSet extends MDValueSet {
|
||||
|
||||
const TYPES = [
|
||||
public const TYPES = [
|
||||
'project',
|
||||
'grant_application',
|
||||
'exhibition',
|
||||
|
@ -11,9 +11,9 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDRecordingTypesSet extends MDValueSet {
|
||||
|
||||
const DEFAULT_RECORDING_TYPE = 'audio';
|
||||
public const DEFAULT_RECORDING_TYPE = 'audio';
|
||||
|
||||
const RECORDING_TYPES = [
|
||||
public const RECORDING_TYPES = [
|
||||
'audio',
|
||||
'video',
|
||||
];
|
||||
|
@ -15,41 +15,48 @@ final class MDRequirementsSet {
|
||||
// the given timespan. If they are not, the account will be ignored
|
||||
// and deleted.
|
||||
// 60 * 60 * 24 * 6 = 518400. 6 days.
|
||||
const MAX_AGE_AFTER_USER_INVITE = 518400;
|
||||
public const MAX_AGE_AFTER_USER_INVITE = 518400;
|
||||
|
||||
// Object images need to be at least 500 px wide
|
||||
const MIN_OBJECT_IMAGE_WIDTH = 540;
|
||||
public const MIN_OBJECT_IMAGE_WIDTH = 540;
|
||||
|
||||
// Object images need to be at least 500 px wide
|
||||
const MIN_OBJECT_IMAGE_HEIGHT = 540;
|
||||
public const MIN_OBJECT_IMAGE_HEIGHT = 540;
|
||||
|
||||
const TIME_EARLIEST_YEAR = -6000000000;
|
||||
const TIME_LATEST_YEAR = 2099;
|
||||
public const MAX_FILESIZE_PDF = 20000000;
|
||||
|
||||
const MIMETYPES_USER_PROFILE_IMG = ['image/jpeg', 'image/jpg'];
|
||||
public const TIME_EARLIEST_YEAR = -6000000000;
|
||||
public const TIME_EARLIEST_DATE = '0001-01-01';
|
||||
public const TIME_LATEST_YEAR = 2099;
|
||||
public const TIME_LATEST_DATE = '9999-12-31';
|
||||
public const TIME_DEFAULT_DATE = '0001-01-01'; // Date to ignore in indexing
|
||||
|
||||
const MIMETYPES_OBJECT_IMAGE = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'];
|
||||
const MIMETYPES_OBJECT_PDF = ['application/pdf'];
|
||||
const MIMETYPES_OBJECT_PROVENANCE_REPORT = ['application/pdf'];
|
||||
const MIMETYPES_OBJECT_RESTORATION_REPORT = ['application/pdf', 'image/jpeg', 'image/png'];
|
||||
const MIMETYPES_OBJECT_CONDITION_REPORT = ['application/pdf', 'image/jpeg', 'image/png'];
|
||||
public const MIMETYPES_USER_PROFILE_IMG = ['image/jpeg', 'image/jpg'];
|
||||
|
||||
const MIMETYPES_COLLECTION_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
const MIMETYPES_INSTITUTION_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
const MIMETYPES_EXHIBITION_IMAGE = ['image/jpeg', 'image/jpg', 'image/png'];
|
||||
public const MIMETYPES_OBJECT_IMAGE = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'];
|
||||
public const MIMETYPES_OBJECT_PDF = ['application/pdf'];
|
||||
public const MIMETYPES_OBJECT_PROVENANCE_REPORT = ['application/pdf'];
|
||||
public const MIMETYPES_OBJECT_RESTORATION_REPORT = ['application/pdf', 'image/jpeg', 'image/png'];
|
||||
public const MIMETYPES_OBJECT_CONDITION_REPORT = ['application/pdf', 'image/jpeg', 'image/png'];
|
||||
|
||||
const MIMETYPES_ARTICLE_ASSET = ['image/jpeg', 'image/jpg', 'image/png'];
|
||||
public const MIMETYPES_OBJECT_DOCUMENT = ['image/jpeg', 'image/jpg', 'application/pdf'];
|
||||
|
||||
const MIMETYPES_APPOINTMENT_IMAGE = ['image/jpeg', 'image/jpg', 'image/png'];
|
||||
const MIMETYPES_APPOINTMENT_DOC_ASSET = ['application/pdf', 'image/jpeg', 'image/jpg', 'image/png'];
|
||||
public const MIMETYPES_COLLECTION_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_INSTITUTION_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_EXHIBITION_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
|
||||
const MIMETYPES_PODCAST_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
const MIMETYPES_PODCAST_EPISODE_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
const MIMETYPES_TOUR_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_ARTICLE_ASSET = ['image/jpeg', 'image/jpg', 'image/png'];
|
||||
|
||||
const MIMETYPES_CATALOGUE_WORK_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
const MIMETYPES_CATALOGUE_OBJECT_SUMMARY_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_APPOINTMENT_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_APPOINTMENT_DOC_ASSET = ['application/pdf', 'image/jpeg', 'image/jpg', 'image/png'];
|
||||
|
||||
const EXTENSIONS_THREE_D_ZIP = ['obj', 'mtl', 'jpg', 'jpeg', 'png'];
|
||||
public const MIMETYPES_PODCAST_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_PODCAST_EPISODE_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_TOUR_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
|
||||
public const MIMETYPES_CATALOGUE_WORK_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
public const MIMETYPES_CATALOGUE_OBJECT_SUMMARY_IMAGE = ['image/jpeg', 'image/jpg'];
|
||||
|
||||
public const EXTENSIONS_THREE_D_ZIP = ['obj', 'mtl', 'jpg', 'jpeg', 'png'];
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDResearchStatusSet extends MDValueSet {
|
||||
|
||||
const RESEARCH_STATUS = [
|
||||
public const RESEARCH_STATUS = [
|
||||
'bad',
|
||||
'medium',
|
||||
'good',
|
||||
|
173
src/MDSourceType.php
Normal file
173
src/MDSourceType.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of source.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of source.
|
||||
*/
|
||||
enum MDSourceType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case article;
|
||||
case inbook;
|
||||
case book;
|
||||
case phdthesis;
|
||||
case electronical;
|
||||
case patent;
|
||||
case unpublished;
|
||||
case misc;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSourceType
|
||||
*/
|
||||
public static function fromString(string $input):MDSourceType {
|
||||
|
||||
return match($input) {
|
||||
"article" => self::article,
|
||||
"inbook" => self::inbook,
|
||||
"book" => self::book,
|
||||
"phdthesis" => self::phdthesis,
|
||||
"electronical" => self::electronical,
|
||||
"patent" => self::patent,
|
||||
"unpublished" => self::unpublished,
|
||||
"misc" => self::misc,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown source type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSourceType
|
||||
*/
|
||||
public static function fromInt(int $input):MDSourceType {
|
||||
|
||||
return match($input) {
|
||||
0 => self::article,
|
||||
1 => self::inbook,
|
||||
2 => self::book,
|
||||
3 => self::phdthesis,
|
||||
4 => self::electronical,
|
||||
5 => self::patent,
|
||||
6 => self::unpublished,
|
||||
7 => self::misc,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown source type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "source_type_set", "source_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "source_type_set", "source_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::article => 0,
|
||||
self::inbook => 1,
|
||||
self::book => 2,
|
||||
self::phdthesis => 3,
|
||||
self::electronical => 4,
|
||||
self::patent => 5,
|
||||
self::unpublished => 6,
|
||||
self::misc => 7,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("source_type_set", "source_type_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDSourceTypeSet extends MDValueSet {
|
||||
|
||||
const SOURCE_TYPES = [
|
||||
public const SOURCE_TYPES = [
|
||||
'article',
|
||||
'inbook',
|
||||
'book',
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDSpaceAccessStatusSet extends MDValueSet {
|
||||
|
||||
const STATUS = [
|
||||
public const STATUS = [
|
||||
'enter',
|
||||
'leave',
|
||||
];
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDSpaceTypesSet extends MDValueSet {
|
||||
|
||||
const TYPES = [
|
||||
public const TYPES = [
|
||||
'building',
|
||||
'floor',
|
||||
'depot',
|
||||
@ -23,6 +23,7 @@ final class MDSpaceTypesSet extends MDValueSet {
|
||||
'shelf',
|
||||
'box',
|
||||
'folder',
|
||||
'outdoor_area',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDTitleTypesSet extends MDValueSet {
|
||||
|
||||
const TITLE_TYPES = [
|
||||
public const TITLE_TYPES = [
|
||||
"",
|
||||
"Science",
|
||||
"Everyday speech",
|
||||
|
@ -11,10 +11,10 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class MDUnitsSet extends MDValueSet {
|
||||
|
||||
const UNITS_LENGTH = ['', 'm', 'dm', 'cm', 'mm', 'ft', 'in'];
|
||||
const UNITS_WEIGHT = ['', 't', 'kg', 'g'];
|
||||
public const UNITS_LENGTH = ['', 'm', 'dm', 'cm', 'mm', 'ft', 'in'];
|
||||
public const UNITS_WEIGHT = ['', 't', 'kg', 'g'];
|
||||
|
||||
const UNITS_LENGTH_TO_MILLIMETER = [
|
||||
public const UNITS_LENGTH_TO_MILLIMETER = [
|
||||
'm' => 1000,
|
||||
'ft' => 304.8,
|
||||
'dm' => 100,
|
||||
@ -23,7 +23,7 @@ final class MDUnitsSet extends MDValueSet {
|
||||
'mm' => 1,
|
||||
];
|
||||
|
||||
const UNITS_WEIGHT_TO_GRAMM = [
|
||||
public const UNITS_WEIGHT_TO_GRAMM = [
|
||||
't' => 1000000,
|
||||
'kg' => 1000,
|
||||
'g' => 1,
|
||||
|
75
src/classes/MDMeasurement.php
Normal file
75
src/classes/MDMeasurement.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Describes a measurement of an object.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Describes a measurement of an object.
|
||||
*/
|
||||
final class MDMeasurement implements JsonSerializable {
|
||||
|
||||
public readonly int $object_id;
|
||||
public readonly MDMeasurementType $type;
|
||||
public float $value;
|
||||
public MDLengthUnit|MDCountCopiesUnit|MDWeightUnit|MDCountPartsUnit|MDDieAxisUnit $unit;
|
||||
public bool $exactness;
|
||||
public string $note;
|
||||
public string $updated_by = "";
|
||||
public int $update_timestamp = 0;
|
||||
|
||||
/**
|
||||
* Returns array for forming JSON representation.
|
||||
*
|
||||
* @return array{type: MDMeasurementType, value: float, unit: MDLengthUnit|MDCountCopiesUnit|MDWeightUnit|MDCountPartsUnit|MDDieAxisUnit, exactness: bool, note: string}|array{type: MDMeasurementType, value: float, unit: MDLengthUnit|MDCountCopiesUnit|MDWeightUnit|MDCountPartsUnit|MDDieAxisUnit, exactness: bool, note: string, updated_by: string, update_timestamp: int}
|
||||
*/
|
||||
public function jsonSerialize():array {
|
||||
|
||||
$output = [
|
||||
'type' => $this->type,
|
||||
'value' => $this->value,
|
||||
'unit' => $this->unit,
|
||||
'exactness' => $this->exactness,
|
||||
'note' => $this->note,
|
||||
];
|
||||
|
||||
if ($this->update_timestamp !== 0) {
|
||||
$output['updated_by'] = $this->updated_by;
|
||||
$output['update_timestamp'] = $this->update_timestamp;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param integer $object_id Object ID.
|
||||
* @param MDMeasurementType $type Type.
|
||||
* @param float $value Value.
|
||||
* @param MDLengthUnit|MDCountCopiesUnit|MDWeightUnit|MDCountPartsUnit|MDDieAxisUnit $unit Unit.
|
||||
* @param boolean $exactness Exactness.
|
||||
* @param string $note Note.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(int $object_id, MDMeasurementType $type, float $value, MDLengthUnit|MDCountCopiesUnit|MDWeightUnit|MDCountPartsUnit|MDDieAxisUnit $unit, bool $exactness, string $note) {
|
||||
|
||||
$this->object_id = $object_id;
|
||||
$this->type = $type;
|
||||
|
||||
// Validate unit
|
||||
if (get_class($unit) !== $this->type->getMeasurementUnit()) {
|
||||
throw new Exception("Invalid unit selected");
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
$this->unit = $unit;
|
||||
$this->exactness = $exactness;
|
||||
$this->note = $note;
|
||||
|
||||
}
|
||||
}
|
@ -14,6 +14,17 @@ final class MDNodaLink {
|
||||
public readonly MDNodaRepository $source;
|
||||
public readonly string $id;
|
||||
|
||||
/**
|
||||
* Returns the link to the current entity.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEntityLink():string {
|
||||
|
||||
return $this->source->getEntityLink($this->id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@ -25,8 +36,8 @@ final class MDNodaLink {
|
||||
public function __construct(MDNodaRepository $source, string $id) {
|
||||
|
||||
$this->source = $source;
|
||||
if (($validatedId = $this->source->validateId(trim($id))) === false) {
|
||||
throw new MDInvalidNodaLink("Invalid noda ID / link: " . $id . " [Repository: " . $this->source->toDbName() . "]");
|
||||
if (($validatedId = $this->source->validateId(strtr(trim($id), [" " => "", "\t" => "", "\n" => ""]))) === false) {
|
||||
throw new MDInvalidNodaLink("Invalid norm data ID / link: \"" . $id . "\" [Repository: " . $this->source->toDbName() . "]");
|
||||
}
|
||||
$this->id = $validatedId;
|
||||
|
||||
|
122
src/enums/MDCopyrightCollective.php
Normal file
122
src/enums/MDCopyrightCollective.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a copyright collective.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of check an object may be subject to (completeness, condition, general audit).
|
||||
*/
|
||||
enum MDCopyrightCollective implements JsonSerializable {
|
||||
|
||||
case vg_bildkunst;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDCopyrightCollective
|
||||
*/
|
||||
public static function fromString(string $input):MDCopyrightCollective {
|
||||
|
||||
return match($input) {
|
||||
'vg_bildkunst' => self::vg_bildkunst,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copyright collective"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDCopyrightCollective
|
||||
*/
|
||||
public static function fromInt(int $input):MDCopyrightCollective {
|
||||
|
||||
return match($input) {
|
||||
1 => self::vg_bildkunst,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copyright collective"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the human-readable name of the copyright collective.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string {
|
||||
|
||||
return match($this) {
|
||||
self::vg_bildkunst => "VG Bildkunst",
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copyright collective"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::vg_bildkunst => 1,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copyright collective"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to the contact form.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContactForm():string {
|
||||
|
||||
return match($this) {
|
||||
self::vg_bildkunst => "https://www.bildkunst.de/service/formulare-fuer-nutzer/anfrage-online-nutzung",
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copyright collective"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
148
src/enums/MDCountCopiesUnit.php
Normal file
148
src/enums/MDCountCopiesUnit.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDCountCopiesUnit implements MDValueEnumInterface, JsonSerializable, MDMeasurementUnitInterface {
|
||||
|
||||
case copies;
|
||||
case specimen;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDCountCopiesUnit
|
||||
*/
|
||||
public static function fromString(string $input):MDCountCopiesUnit {
|
||||
|
||||
return match($input) {
|
||||
'copies' => self::copies,
|
||||
'specimen' => self::specimen,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copies count unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDCountCopiesUnit
|
||||
*/
|
||||
public static function fromInt(int $input):MDCountCopiesUnit {
|
||||
|
||||
return match($input) {
|
||||
1 => self::copies,
|
||||
2 => self::specimen,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown copies count unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::copies => 1,
|
||||
self::specimen => 2,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit.
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float {
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "units_count_copies_set", "units_count_copies_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "units_count_copies_set", "units_count_copies_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("units_count_copies_set", "units_count_copies_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
152
src/enums/MDCountPartsUnit.php
Normal file
152
src/enums/MDCountPartsUnit.php
Normal file
@ -0,0 +1,152 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDCountPartsUnit implements MDValueEnumInterface, JsonSerializable, MDMeasurementUnitInterface {
|
||||
|
||||
case parts;
|
||||
case sheets;
|
||||
case pages;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDCountPartsUnit
|
||||
*/
|
||||
public static function fromString(string $input):MDCountPartsUnit {
|
||||
|
||||
return match($input) {
|
||||
'parts' => self::parts,
|
||||
'pages' => self::pages,
|
||||
'sheets' => self::sheets,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown parts counting unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDCountPartsUnit
|
||||
*/
|
||||
public static function fromInt(int $input):MDCountPartsUnit {
|
||||
|
||||
return match($input) {
|
||||
1 => self::parts,
|
||||
2 => self::pages,
|
||||
3 => self::sheets,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown parts counting unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::parts => 1,
|
||||
self::pages => 2,
|
||||
self::sheets => 3,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit.
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float {
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "units_count_parts_set", "units_count_parts_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "units_count_parts_set", "units_count_parts_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("units_count_parts_set", "units_count_parts_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
144
src/enums/MDDieAxisUnit.php
Normal file
144
src/enums/MDDieAxisUnit.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDDieAxisUnit implements MDValueEnumInterface, JsonSerializable, MDMeasurementUnitInterface {
|
||||
|
||||
case h;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDDieAxisUnit
|
||||
*/
|
||||
public static function fromString(string $input):MDDieAxisUnit {
|
||||
|
||||
return match($input) {
|
||||
'h' => self::h,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown h counting unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDDieAxisUnit
|
||||
*/
|
||||
public static function fromInt(int $input):MDDieAxisUnit {
|
||||
|
||||
return match($input) {
|
||||
1 => self::h,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown h counting unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::h => 1,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit.
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float {
|
||||
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "units_die_axis_set", "units_die_axis_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "units_die_axis_set", "units_die_axis_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("units_die_axis_set", "units_die_axis_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
177
src/enums/MDExhibitionContributorRole.php
Normal file
177
src/enums/MDExhibitionContributorRole.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of contribution to an exhibition.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of contribution to an exhibition.
|
||||
*/
|
||||
enum MDExhibitionContributorRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case concept;
|
||||
case curator;
|
||||
case design;
|
||||
case coordinator;
|
||||
case protagonist;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDExhibitionContributorRole
|
||||
*/
|
||||
public static function fromString(string $input):MDExhibitionContributorRole {
|
||||
|
||||
return match($input) {
|
||||
"concept" => self::concept,
|
||||
"curator" => self::curator,
|
||||
"design" => self::design,
|
||||
"coordinator" => self::coordinator,
|
||||
"protagonist" => self::protagonist,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown exhibition contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDExhibitionContributorRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDExhibitionContributorRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::concept,
|
||||
1 => self::curator,
|
||||
2 => self::design,
|
||||
3 => self::coordinator,
|
||||
4 => self::protagonist,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown exhibition contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "exhibition_contributor_roles", "exhibition_contributor_roles");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "exhibition_contributor_roles", "exhibition_contributor_roles");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::concept => 0,
|
||||
self::curator => 1,
|
||||
self::design => 2,
|
||||
self::coordinator => 3,
|
||||
self::protagonist => 4,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns canonical string representation of object record status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString():string {
|
||||
|
||||
return match($this) {
|
||||
self::concept => 'concept',
|
||||
self::curator => 'curator',
|
||||
self::design => 'design',
|
||||
self::coordinator => 'coordinator',
|
||||
self::protagonist => 'protagonist',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("exhibition_contributor_roles", "exhibition_contributor_roles", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
176
src/enums/MDGender.php
Normal file
176
src/enums/MDGender.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a gender.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a gender.
|
||||
*/
|
||||
enum MDGender implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case none;
|
||||
case female;
|
||||
case male;
|
||||
case other;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDGender
|
||||
*/
|
||||
public static function fromString(string $input):MDGender {
|
||||
|
||||
return match($input) {
|
||||
"" => self::none,
|
||||
"none" => self::none,
|
||||
"female" => self::female,
|
||||
"male" => self::male,
|
||||
"other" => self::other,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown gender"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDGender
|
||||
*/
|
||||
public static function fromInt(int $input):MDGender {
|
||||
|
||||
return match($input) {
|
||||
0 => self::none,
|
||||
1 => self::female,
|
||||
2 => self::male,
|
||||
3 => self::other,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown gender"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toString();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "gender_set", "gender_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "gender_set", "gender_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::none => 0,
|
||||
self::female => 1,
|
||||
self::male => 2,
|
||||
self::other => 3,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString():string {
|
||||
|
||||
return match($this) {
|
||||
self::none => '',
|
||||
self::female => 'female',
|
||||
self::male => 'male',
|
||||
self::other => 'other',
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
if ($this === self::none) return '';
|
||||
return $tlLoader->tl("gender_set", "gender_set", $this->toString());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->toString();
|
||||
|
||||
}
|
||||
}
|
165
src/enums/MDInstitutionBasicCategory.php
Normal file
165
src/enums/MDInstitutionBasicCategory.php
Normal file
@ -0,0 +1,165 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a most basic categorization of institutions using museum-digital.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a most basic categorization of institutions using museum-digital.
|
||||
*/
|
||||
enum MDInstitutionBasicCategory implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case museum;
|
||||
case archive;
|
||||
case library;
|
||||
case memorial_site;
|
||||
case private_collection;
|
||||
case university_collection;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionBasicCategory
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionBasicCategory {
|
||||
|
||||
return match($input) {
|
||||
"museum" => self::museum,
|
||||
"archive" => self::archive,
|
||||
"library" => self::library,
|
||||
"memorial_site" => self::memorial_site,
|
||||
"private_collection" => self::private_collection,
|
||||
"university_collection" => self::university_collection,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown institution category"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionBasicCategory
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionBasicCategory {
|
||||
|
||||
return match($input) {
|
||||
0 => self::museum,
|
||||
1 => self::archive,
|
||||
2 => self::library,
|
||||
3 => self::memorial_site,
|
||||
4 => self::private_collection,
|
||||
5 => self::university_collection,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown institution category"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "institution_basic_category_set", "institution_basic_category_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "institution_basic_category_set", "institution_basic_category_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::museum => 0,
|
||||
self::archive => 1,
|
||||
self::library => 2,
|
||||
self::memorial_site => 3,
|
||||
self::private_collection => 4,
|
||||
self::university_collection => 5,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("institution_basic_category_set", "institution_basic_category_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
254
src/enums/MDInstitutionCollectionArea.php
Normal file
254
src/enums/MDInstitutionCollectionArea.php
Normal file
@ -0,0 +1,254 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of collection focus a museum (or similar institution) may have.
|
||||
* This can be useful for statistics and be used in line with institutions' self-
|
||||
* categorization.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of collection focus a museum (or similar institution) may have.
|
||||
* This can be useful for statistics and be used in line with institutions' self-
|
||||
* categorization.
|
||||
*/
|
||||
enum MDInstitutionCollectionArea implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case everyday_life;
|
||||
case archaeology;
|
||||
case architecture;
|
||||
case history_of_mining;
|
||||
case botany;
|
||||
case history_of_film;
|
||||
case political_history;
|
||||
case arts;
|
||||
case applied_arts;
|
||||
case agriculture;
|
||||
case literature;
|
||||
case history_of_medicine;
|
||||
case military_history;
|
||||
case mineralogy;
|
||||
case music;
|
||||
case numismatics;
|
||||
case paleontology;
|
||||
case personalia;
|
||||
case regional_history;
|
||||
case religion;
|
||||
case technology;
|
||||
case ethnography;
|
||||
case zoology;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionCollectionArea
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionCollectionArea {
|
||||
|
||||
return match($input) {
|
||||
"everyday_life" => self::everyday_life,
|
||||
"archaeology" => self::archaeology,
|
||||
"architecture" => self::architecture,
|
||||
"history_of_mining" => self::history_of_mining,
|
||||
"botany" => self::botany,
|
||||
"history_of_film" => self::history_of_film,
|
||||
"political_history" => self::political_history,
|
||||
"arts" => self::arts,
|
||||
"applied_arts" => self::applied_arts,
|
||||
"agriculture" => self::agriculture,
|
||||
"literature" => self::literature,
|
||||
"history_of_medicine" => self::history_of_medicine,
|
||||
"military_history" => self::military_history,
|
||||
"mineralogy" => self::mineralogy,
|
||||
"music" => self::music,
|
||||
"numismatics" => self::numismatics,
|
||||
"paleontology" => self::paleontology,
|
||||
"personalia" => self::personalia,
|
||||
"regional_history" => self::regional_history,
|
||||
"religion" => self::religion,
|
||||
"technology" => self::technology,
|
||||
"ethnography" => self::ethnography,
|
||||
"zoology" => self::zoology,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown collection focus area"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns instances of MDInstitutionCollectionArea based on list of strings.
|
||||
*
|
||||
* @param list<string> $input Input to get a value from.
|
||||
*
|
||||
* @return list<MDInstitutionCollectionArea>
|
||||
*/
|
||||
public static function fromStrings(array $input):array {
|
||||
|
||||
$output = [];
|
||||
foreach ($input as $value) {
|
||||
$output[] = self::fromString($value);
|
||||
}
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionCollectionArea
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionCollectionArea {
|
||||
|
||||
return match($input) {
|
||||
0 => self::everyday_life,
|
||||
1 => self::archaeology,
|
||||
2 => self::architecture,
|
||||
3 => self::history_of_mining,
|
||||
4 => self::botany,
|
||||
5 => self::history_of_film,
|
||||
6 => self::political_history,
|
||||
7 => self::arts,
|
||||
8 => self::applied_arts,
|
||||
9 => self::agriculture,
|
||||
10 => self::literature,
|
||||
11 => self::history_of_medicine,
|
||||
12 => self::military_history,
|
||||
13 => self::mineralogy,
|
||||
14 => self::music,
|
||||
15 => self::numismatics,
|
||||
16 => self::paleontology,
|
||||
17 => self::personalia,
|
||||
18 => self::regional_history,
|
||||
19 => self::religion,
|
||||
20 => self::technology,
|
||||
21 => self::ethnography,
|
||||
22 => self::zoology,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown collection focus area"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "institution_collection_area_set", "institution_collection_area_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "institution_collection_area_set", "institution_collection_area_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::everyday_life => 0,
|
||||
self::archaeology => 1,
|
||||
self::architecture => 2,
|
||||
self::history_of_mining => 3,
|
||||
self::botany => 4,
|
||||
self::history_of_film => 5,
|
||||
self::political_history => 6,
|
||||
self::arts => 7,
|
||||
self::applied_arts => 8,
|
||||
self::agriculture => 9,
|
||||
self::literature => 10,
|
||||
self::history_of_medicine => 11,
|
||||
self::military_history => 12,
|
||||
self::mineralogy => 13,
|
||||
self::music => 14,
|
||||
self::numismatics => 15,
|
||||
self::paleontology => 16,
|
||||
self::personalia => 17,
|
||||
self::regional_history => 18,
|
||||
self::religion => 19,
|
||||
self::technology => 20,
|
||||
self::ethnography => 21,
|
||||
self::zoology => 22,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("institution_collection_area_set", "institution_collection_area_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@ enum MDInstitutionExternalIdRepository implements MDValueEnumInterface, JsonSeri
|
||||
|
||||
case hu_ksh; // https://en.wikipedia.org/wiki/Hungarian_Central_Statistical_Office
|
||||
|
||||
const VALIDATION_PATTERN_HTML = [
|
||||
private const VALIDATION_PATTERN_HTML = [
|
||||
'hu_ksh' => '[0-9]{8}-[0-9]{4}-[0-9]{3}-[0-9]{2}',
|
||||
];
|
||||
|
||||
const VALIDATION_PATTERN_PHP = [
|
||||
private const VALIDATION_PATTERN_PHP = [
|
||||
'hu_ksh' => '/^[0-9]{8}-[0-9]{4}-[0-9]{3}-[0-9]{2}$/',
|
||||
];
|
||||
|
||||
|
157
src/enums/MDInstitutionPublicPrivateStatus.php
Normal file
157
src/enums/MDInstitutionPublicPrivateStatus.php
Normal file
@ -0,0 +1,157 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents the status of an institution as a public or privately-run one.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents the status of an institution as a public or privately-run one.
|
||||
*/
|
||||
enum MDInstitutionPublicPrivateStatus implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case public;
|
||||
case private;
|
||||
case religious;
|
||||
case mixed;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionPublicPrivateStatus
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionPublicPrivateStatus {
|
||||
|
||||
return match($input) {
|
||||
"public" => self::public,
|
||||
"private" => self::private,
|
||||
"religious" => self::religious,
|
||||
"mixed" => self::mixed,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown public / private status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionPublicPrivateStatus
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionPublicPrivateStatus {
|
||||
|
||||
return match($input) {
|
||||
0 => self::public,
|
||||
1 => self::private,
|
||||
2 => self::religious,
|
||||
3 => self::mixed,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown public / private status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "institution_public_private_category_set", "institution_public_private_category_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "institution_public_private_category_set", "institution_public_private_category_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::public => 0,
|
||||
self::private => 1,
|
||||
self::religious => 2,
|
||||
self::mixed => 3,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("institution_public_private_category_set", "institution_public_private_category_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
153
src/enums/MDInstitutionUseCase.php
Normal file
153
src/enums/MDInstitutionUseCase.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents the use case an institution uses museum-digital's tools for.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents the use case an institution uses museum-digital's tools for.
|
||||
*/
|
||||
enum MDInstitutionUseCase implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case collection_management;
|
||||
case publication;
|
||||
case collection_management_and_publication;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionUseCase
|
||||
*/
|
||||
public static function fromString(string $input):MDInstitutionUseCase {
|
||||
|
||||
return match($input) {
|
||||
"collection_management" => self::collection_management,
|
||||
"publication" => self::publication,
|
||||
"collection_management_and_publication" => self::collection_management_and_publication,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDInstitutionUseCase
|
||||
*/
|
||||
public static function fromInt(int $input):MDInstitutionUseCase {
|
||||
|
||||
return match($input) {
|
||||
0 => self::collection_management,
|
||||
1 => self::publication,
|
||||
2 => self::collection_management_and_publication,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown use case for museum-digital"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "institution_musdb_use_case_set", "institution_musdb_use_case_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "institution_musdb_use_case_set", "institution_musdb_use_case_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::collection_management => 0,
|
||||
self::publication => 1,
|
||||
self::collection_management_and_publication => 2,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("institution_musdb_use_case_set", "institution_musdb_use_case_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
173
src/enums/MDLengthUnit.php
Normal file
173
src/enums/MDLengthUnit.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDLengthUnit implements MDValueEnumInterface, JsonSerializable, MDMeasurementUnitInterface {
|
||||
|
||||
case m;
|
||||
case dm;
|
||||
case cm;
|
||||
case mm;
|
||||
case ft;
|
||||
case in;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDLengthUnit
|
||||
*/
|
||||
public static function fromString(string $input):MDLengthUnit {
|
||||
|
||||
return match($input) {
|
||||
'm' => self::m,
|
||||
'dm' => self::dm,
|
||||
'cm' => self::cm,
|
||||
'mm' => self::mm,
|
||||
'ft' => self::ft,
|
||||
'in' => self::in,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown length unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDLengthUnit
|
||||
*/
|
||||
public static function fromInt(int $input):MDLengthUnit {
|
||||
|
||||
return match($input) {
|
||||
1 => self::m,
|
||||
2 => self::dm,
|
||||
3 => self::cm,
|
||||
4 => self::mm,
|
||||
5 => self::ft,
|
||||
6 => self::in,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown length unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::m => 1,
|
||||
self::dm => 2,
|
||||
self::cm => 3,
|
||||
self::mm => 4,
|
||||
self::ft => 5,
|
||||
self::in => 6,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit (e.g. mm for lengths).
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float {
|
||||
|
||||
$multiplier = match($this) {
|
||||
self::m => 1000,
|
||||
self::ft => 304.8,
|
||||
self::dm => 100,
|
||||
self::in => 25.4,
|
||||
self::cm => 10,
|
||||
self::mm => 1,
|
||||
};
|
||||
|
||||
return floatval($value * $multiplier);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "units_length_set", "units_length_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "units_length_set", "units_length_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("units_length_set", "units_length_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
237
src/enums/MDLicense.php
Normal file
237
src/enums/MDLicense.php
Normal file
@ -0,0 +1,237 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a license.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a license.
|
||||
*/
|
||||
enum MDLicense implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case CC_BY_NC_SA;
|
||||
case CC_BY_NC_ND;
|
||||
case CC_BY_NC;
|
||||
case CC_BY_ND;
|
||||
case CC_BY_SA;
|
||||
case CC_BY;
|
||||
case CC0;
|
||||
case RR_F;
|
||||
case RR_P;
|
||||
case RR_R;
|
||||
case Public_Domain_Mark;
|
||||
case Orphan_Work;
|
||||
|
||||
public const AVAILABLE_LICENSES = [
|
||||
|
||||
'CC BY-NC-SA' => 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
|
||||
'CC BY-NC-ND' => 'https://creativecommons.org/licenses/by-nc-nd/4.0/',
|
||||
'CC BY-NC' => 'https://creativecommons.org/licenses/by-nc/4.0/',
|
||||
'CC BY-ND' => 'https://creativecommons.org/licenses/by-nd/4.0/',
|
||||
'CC BY-SA' => 'https://creativecommons.org/licenses/by-sa/4.0/',
|
||||
'CC BY' => 'https://creativecommons.org/licenses/by/4.0/',
|
||||
'CC0' => 'https://creativecommons.org/publicdomain/zero/1.0/',
|
||||
'RR-F' => 'https://www.europeana.eu/rights/rr-f/',
|
||||
'RR-P' => 'https://www.europeana.eu/rights/rr-p/',
|
||||
'RR-R' => 'https://www.europeana.eu/rights/rr-r/',
|
||||
'Public Domain Mark' => 'https://creativecommons.org/publicdomain/mark/1.0/',
|
||||
'Orphan Work' => 'https://www.europeana.eu/rights/orphan-work-eu/',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDLicense
|
||||
*/
|
||||
public static function fromString(string $input):MDLicense {
|
||||
|
||||
return match($input) {
|
||||
'CC BY-NC-SA' => self::CC_BY_NC_SA,
|
||||
'CC BY-NC-ND' => self::CC_BY_NC_ND,
|
||||
'CC BY-NC' => self::CC_BY_NC,
|
||||
'CC BY-ND' => self::CC_BY_ND,
|
||||
'CC BY-SA' => self::CC_BY_SA,
|
||||
'CC BY' => self::CC_BY,
|
||||
'CC0' => self::CC0,
|
||||
'RR-F' => self::RR_F,
|
||||
'RR-P' => self::RR_P,
|
||||
'RR-R' => self::RR_R,
|
||||
'Public Domain Mark' => self::Public_Domain_Mark,
|
||||
'Orphan Work' => self::Orphan_Work,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown license role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDLicense
|
||||
*/
|
||||
public static function fromInt(int $input):MDLicense {
|
||||
|
||||
return match($input) {
|
||||
1 => self::CC_BY_NC_SA,
|
||||
2 => self::CC_BY_NC_ND,
|
||||
3 => self::CC_BY_NC,
|
||||
4 => self::CC_BY_ND,
|
||||
5 => self::CC_BY_SA,
|
||||
6 => self::CC_BY,
|
||||
7 => self::CC0,
|
||||
8 => self::RR_F,
|
||||
9 => self::RR_P,
|
||||
10 => self::RR_R,
|
||||
11 => self::Public_Domain_Mark,
|
||||
12 => self::Orphan_Work,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown license role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toString();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
|
||||
$output = [];
|
||||
foreach (self::caseNames() as $name) $output[$name] = $name;
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
|
||||
$output = self::getUnsortedList($tlLoader);
|
||||
asort($output);
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::CC_BY_NC_SA => 1,
|
||||
self::CC_BY_NC_ND => 2,
|
||||
self::CC_BY_NC => 3,
|
||||
self::CC_BY_ND => 4,
|
||||
self::CC_BY_SA => 5,
|
||||
self::CC_BY => 6,
|
||||
self::CC0 => 7,
|
||||
self::RR_F => 8,
|
||||
self::RR_P => 9,
|
||||
self::RR_R => 10,
|
||||
self::Public_Domain_Mark => 11,
|
||||
self::Orphan_Work => 12,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString():string {
|
||||
|
||||
return match($this) {
|
||||
self::CC_BY_NC_SA => 'CC BY-NC-SA',
|
||||
self::CC_BY_NC_ND => 'CC BY-NC-ND',
|
||||
self::CC_BY_NC => 'CC BY-NC',
|
||||
self::CC_BY_ND => 'CC BY-ND',
|
||||
self::CC_BY_SA => 'CC BY-SA',
|
||||
self::CC_BY => 'CC BY',
|
||||
self::CC0 => 'CC0',
|
||||
self::RR_F => 'RR-F',
|
||||
self::RR_P => 'RR-P',
|
||||
self::RR_R => 'RR-R',
|
||||
self::Public_Domain_Mark => 'Public Domain Mark',
|
||||
self::Orphan_Work => 'Orphan Work',
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $this->toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->toString();
|
||||
|
||||
}
|
||||
}
|
143
src/enums/MDLoanType.php
Normal file
143
src/enums/MDLoanType.php
Normal file
@ -0,0 +1,143 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of loan.
|
||||
*/
|
||||
enum MDLoanType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case outgoing;
|
||||
case incoming;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDLoanType
|
||||
*/
|
||||
public static function fromString(string $input):MDLoanType {
|
||||
|
||||
return match($input) {
|
||||
"outgoing" => self::outgoing,
|
||||
"incoming" => self::incoming,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown loan type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDLoanType
|
||||
*/
|
||||
public static function fromInt(int $input):MDLoanType {
|
||||
|
||||
return match($input) {
|
||||
0 => self::outgoing,
|
||||
1 => self::incoming,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown loan type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "loan_types", "loan_types");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "loan_types", "loan_types");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::outgoing => 0,
|
||||
self::incoming => 1,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("loan_types", "loan_types", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
317
src/enums/MDMeasurementType.php
Normal file
317
src/enums/MDMeasurementType.php
Normal file
@ -0,0 +1,317 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
// Main types
|
||||
|
||||
case length;
|
||||
case height;
|
||||
case width;
|
||||
case weight;
|
||||
case diameter;
|
||||
case wall;
|
||||
case die_axis;
|
||||
case number_of_copies; // copies, specimen
|
||||
case number_of_parts;
|
||||
|
||||
// Sub-types
|
||||
|
||||
case length_socle;
|
||||
case height_socle;
|
||||
case width_socle;
|
||||
case length_sheet_size;
|
||||
case height_sheet_size;
|
||||
case width_sheet_size;
|
||||
case length_image_size;
|
||||
case height_image_size;
|
||||
case width_image_size;
|
||||
case length_frame;
|
||||
case height_frame;
|
||||
case width_frame;
|
||||
case diameter_frame;
|
||||
case length_min;
|
||||
case length_max;
|
||||
case height_min;
|
||||
case height_max;
|
||||
case width_min;
|
||||
case width_max;
|
||||
case diameter_min;
|
||||
case diameter_max;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDMeasurementType
|
||||
*/
|
||||
public static function fromString(string $input):MDMeasurementType {
|
||||
|
||||
return match($input) {
|
||||
'length' => self::length,
|
||||
'height' => self::height,
|
||||
'width' => self::width,
|
||||
'number_of_copies' => self::number_of_copies,
|
||||
'weight' => self::weight,
|
||||
'diameter' => self::diameter,
|
||||
'wall' => self::wall,
|
||||
'number_of_parts' => self::number_of_parts,
|
||||
'die_axis' => self::die_axis,
|
||||
'length_socle' => self::length_socle,
|
||||
'height_socle' => self::height_socle,
|
||||
'width_socle' => self::width_socle,
|
||||
'length_sheet_size' => self::length_sheet_size,
|
||||
'height_sheet_size' => self::height_sheet_size,
|
||||
'width_sheet_size' => self::width_sheet_size,
|
||||
'length_image_size' => self::length_image_size,
|
||||
'height_image_size' => self::height_image_size,
|
||||
'width_image_size' => self::width_image_size,
|
||||
'length_frame' => self::length_frame,
|
||||
'height_frame' => self::height_frame,
|
||||
'width_frame' => self::width_frame,
|
||||
'length_min' => self::length_min,
|
||||
'length_max' => self::length_max,
|
||||
'height_min' => self::height_min,
|
||||
'height_max' => self::height_max,
|
||||
'width_min' => self::width_min,
|
||||
'width_max' => self::width_max,
|
||||
'diameter_min' => self::diameter_min,
|
||||
'diameter_max' => self::diameter_max,
|
||||
'diameter_frame' => self::diameter_frame,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDMeasurementType
|
||||
*/
|
||||
public static function fromInt(int $input):MDMeasurementType {
|
||||
|
||||
return match($input) {
|
||||
1 => self::length,
|
||||
2 => self::height,
|
||||
3 => self::width,
|
||||
4 => self::number_of_copies,
|
||||
5 => self::weight,
|
||||
6 => self::diameter,
|
||||
7 => self::wall,
|
||||
8 => self::number_of_parts,
|
||||
9 => self::die_axis,
|
||||
10 => self::length_socle,
|
||||
11 => self::height_socle,
|
||||
12 => self::width_socle,
|
||||
13 => self::length_sheet_size,
|
||||
14 => self::height_sheet_size,
|
||||
15 => self::width_sheet_size,
|
||||
16 => self::length_image_size,
|
||||
17 => self::height_image_size,
|
||||
18 => self::width_image_size,
|
||||
19 => self::length_frame,
|
||||
20 => self::height_frame,
|
||||
21 => self::width_frame,
|
||||
22 => self::length_min,
|
||||
23 => self::length_max,
|
||||
24 => self::height_min,
|
||||
25 => self::height_max,
|
||||
26 => self::width_min,
|
||||
27 => self::width_max,
|
||||
28 => self::diameter_min,
|
||||
29 => self::diameter_max,
|
||||
30 => self::diameter_frame,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the highest level measurement type relative to the provided one.
|
||||
*
|
||||
* @return MDMeasurementType
|
||||
*/
|
||||
public function getHighestSuperordinate():MDMeasurementType {
|
||||
|
||||
return match($this) {
|
||||
self::length => self::length,
|
||||
self::height => self::height,
|
||||
self::width => self::width,
|
||||
self::number_of_copies => self::number_of_copies,
|
||||
self::weight => self::weight,
|
||||
self::diameter => self::diameter,
|
||||
self::wall => self::wall,
|
||||
self::number_of_parts => self::number_of_parts,
|
||||
self::die_axis => self::die_axis,
|
||||
self::length_socle => self::length,
|
||||
self::height_socle => self::height,
|
||||
self::width_socle => self::width,
|
||||
self::length_sheet_size => self::length,
|
||||
self::height_sheet_size => self::height,
|
||||
self::width_sheet_size => self::width,
|
||||
self::length_image_size => self::length,
|
||||
self::height_image_size => self::height,
|
||||
self::width_image_size => self::width,
|
||||
self::length_frame => self::length,
|
||||
self::height_frame => self::height,
|
||||
self::width_frame => self::width,
|
||||
self::length_min => self::length,
|
||||
self::length_max => self::length,
|
||||
self::height_min => self::height,
|
||||
self::height_max => self::height,
|
||||
self::width_min => self::width,
|
||||
self::width_max => self::width,
|
||||
self::diameter_min => self::diameter,
|
||||
self::diameter_max => self::diameter,
|
||||
self::diameter_frame => self::diameter,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::length => 1,
|
||||
self::height => 2,
|
||||
self::width => 3,
|
||||
self::number_of_copies => 4,
|
||||
self::weight => 5,
|
||||
self::diameter => 6,
|
||||
self::wall => 7,
|
||||
self::number_of_parts => 8,
|
||||
self::die_axis => 9,
|
||||
self::length_socle => 10,
|
||||
self::height_socle => 11,
|
||||
self::width_socle => 12,
|
||||
self::length_sheet_size => 13,
|
||||
self::height_sheet_size => 14,
|
||||
self::width_sheet_size => 15,
|
||||
self::length_image_size => 16,
|
||||
self::height_image_size => 17,
|
||||
self::width_image_size => 18,
|
||||
self::length_frame => 19,
|
||||
self::height_frame => 20,
|
||||
self::width_frame => 21,
|
||||
self::length_min => 22,
|
||||
self::length_max => 23,
|
||||
self::height_min => 24,
|
||||
self::height_max => 25,
|
||||
self::width_min => 26,
|
||||
self::width_max => 27,
|
||||
self::diameter_min => 28,
|
||||
self::diameter_max => 29,
|
||||
self::diameter_frame => 30,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns suitable measurement type.
|
||||
*
|
||||
* @return class-string
|
||||
*/
|
||||
public function getMeasurementUnit():string {
|
||||
|
||||
return match($this->getHighestSuperordinate()) {
|
||||
self::length,
|
||||
self::height,
|
||||
self::width,
|
||||
self::wall,
|
||||
self::diameter => MDLengthUnit::Class,
|
||||
self::number_of_copies => MDCountCopiesUnit::Class,
|
||||
self::weight => MDWeightUnit::Class,
|
||||
self::number_of_parts => MDCountPartsUnit::Class,
|
||||
self::die_axis => MDDieAxisUnit::Class,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "measurement_type_set", "measurement_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "measurement_type_set", "measurement_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("measurement_type_set", "measurement_type_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
@ -21,14 +21,15 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
case gnd;
|
||||
case grobsystematik;
|
||||
case iconclass;
|
||||
case klbb;
|
||||
case lcsh;
|
||||
case loc; // Duplicate?
|
||||
case mbl;
|
||||
case mindatorg;
|
||||
case moebeltypologie;
|
||||
case ndb_adb;
|
||||
case ndl;
|
||||
case ndp_ikmk;
|
||||
case ndp_ikmk_persons;
|
||||
case nomisma;
|
||||
case npg;
|
||||
case oberbegriffsdatei;
|
||||
@ -40,7 +41,6 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
case ulan;
|
||||
case viaf;
|
||||
case wikidata;
|
||||
case wikipedia;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
@ -53,26 +53,46 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
return match($input) {
|
||||
'allgemein' => self::allgemein, // General link to a good source
|
||||
'aat' => self::aat,
|
||||
'AAT-ID',
|
||||
'aat' => self::aat,
|
||||
'ackerbau' => self::ackerbau,
|
||||
'bne' => self::bne,
|
||||
'bnf' => self::bnf,
|
||||
'cona' => self::cona,
|
||||
'edition humboldt digital' => self::editionhumboldtdigital,
|
||||
'gnd' => self::gnd,
|
||||
'gnd',
|
||||
'GND',
|
||||
'o-gnd',
|
||||
'O-GND',
|
||||
'GND-Identnummer',
|
||||
'GND-Nummer',
|
||||
'pnd',
|
||||
'http://d-nb.info/', // This is technically wrong, but used in practice...
|
||||
'http://d-nb.info/gnd',
|
||||
'http://d-nb.info/gnd/',
|
||||
'd-nb.info',
|
||||
'd-nb',
|
||||
'https://portal.dnb.de',
|
||||
'https://explore.gnd.network/gnd/' => self::gnd,
|
||||
'grobsystematik' => self::grobsystematik,
|
||||
'iconclass' => self::iconclass,
|
||||
'Iconclass' => self::iconclass,
|
||||
'http://iconclass.org' => self::iconclass,
|
||||
'https://iconclass.org' => self::iconclass,
|
||||
'klbb' => self::klbb,
|
||||
'kl-bb' => self::klbb,
|
||||
'lcsh' => self::lcsh,
|
||||
'loc' => self::loc, // Duplicate?
|
||||
'mbl' => self::mbl,
|
||||
'MBL' => self::mbl,
|
||||
'mindat.org' => self::mindatorg,
|
||||
'moebeltypologie' => self::moebeltypologie,
|
||||
'ndb/adb',
|
||||
'NDB/ADB' => self::ndb_adb,
|
||||
'ndl' => self::ndl,
|
||||
'ndp-ikmk' => self::ndp_ikmk,
|
||||
'nomisma' => self::nomisma,
|
||||
'npg' => self::npg,
|
||||
'ndp-ikmk-persons' => self::ndp_ikmk_persons,
|
||||
'nomisma',
|
||||
'nomisma.org' => self::nomisma,
|
||||
'npg' => self::npg,
|
||||
'oberbegriffsdatei' => self::oberbegriffsdatei,
|
||||
'orcid' => self::orcid,
|
||||
'osm' => self::osm,
|
||||
@ -80,14 +100,41 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
'pleiades' => self::pleiades,
|
||||
'rkd' => self::rkd,
|
||||
'ulan' => self::ulan,
|
||||
'viaf' => self::viaf,
|
||||
'wikidata' => self::wikidata,
|
||||
'Wikidata' => self::wikipedia,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown noda repository: " . $input),
|
||||
'ULAN' => self::ulan,
|
||||
'viaf',
|
||||
'VIAF' => self::viaf,
|
||||
'wikidata',
|
||||
'Wikidata',
|
||||
'www.wikidata.org',
|
||||
'WIKIDATA' => self::wikidata,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown norm data repository: '" . $input . "'"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get a repository based on a provided link. This function is rather expensive
|
||||
* and should be avoided as much as possible.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDNodaRepository
|
||||
*/
|
||||
public static function fromUrl(string $input):MDNodaRepository {
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
|
||||
if ($case === self::allgemein) continue;
|
||||
$output = $case->validateId($input);
|
||||
if ($output !== false) return $case;
|
||||
|
||||
}
|
||||
|
||||
throw new MDInvalidNodaLink("Failed to get norm data repository based on the provided link");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name as stored in the DB.
|
||||
*
|
||||
@ -106,14 +153,15 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
self::gnd => 'gnd',
|
||||
self::grobsystematik => 'grobsystematik',
|
||||
self::iconclass => 'iconclass',
|
||||
self::klbb => 'kl-bb',
|
||||
self::lcsh => 'lcsh',
|
||||
self::loc => 'loc',
|
||||
self::mbl => 'MBL',
|
||||
self::mindatorg => 'mindat.org',
|
||||
self::moebeltypologie => 'moebeltypologie',
|
||||
self::ndb_adb => 'NDB/ADB',
|
||||
self::ndl => 'ndl',
|
||||
self::ndp_ikmk => 'ndp-ikmk',
|
||||
self::ndp_ikmk_persons => 'ndp-ikmk-persons',
|
||||
self::nomisma => 'nomisma',
|
||||
self::npg => 'npg',
|
||||
self::oberbegriffsdatei => 'oberbegriffsdatei',
|
||||
@ -125,7 +173,90 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
self::ulan => 'ulan',
|
||||
self::viaf => 'viaf',
|
||||
self::wikidata => 'wikidata',
|
||||
self::wikipedia => 'Wikidata',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name as stored in the DB.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toFullName():string {
|
||||
|
||||
return match($this) {
|
||||
self::allgemein => 'General', // General link to a good source
|
||||
self::aat => 'Art & Architecture Thesaurus (AAT)',
|
||||
self::ackerbau => 'Ackerbau-Thesaurus',
|
||||
self::bne => 'Biblioteca Nacional de España (BNE)',
|
||||
self::bnf => 'Bibliothèque nationale de France (BNF)',
|
||||
self::cona => 'Cultural Objects Name Authority (CONA)',
|
||||
self::editionhumboldtdigital => 'Edition Humboldt Digital',
|
||||
self::gnd => 'GND (Gemeinsame Normdatei)',
|
||||
self::grobsystematik => 'Grobsystematik',
|
||||
self::iconclass => 'Iconclass',
|
||||
self::klbb => 'Berlin-Brandenburgisches Künstlerlexikon',
|
||||
self::lcsh => 'Library of Congress Subject Headings (LCSH)',
|
||||
self::loc => 'Library of Congress (LOC)',
|
||||
self::mindatorg => 'mindat.org',
|
||||
self::moebeltypologie => 'Möbeltypologie',
|
||||
self::ndb_adb => 'Neue / Allgemeine Deutsche Biographie',
|
||||
self::ndl => 'National Diet Library, Japan (NDL)',
|
||||
self::ndp_ikmk => 'IKMK (Places)',
|
||||
self::ndp_ikmk_persons => 'IKMK (Persons)',
|
||||
self::nomisma => 'Nomisma',
|
||||
self::npg => 'National Portrait Gallery',
|
||||
self::oberbegriffsdatei => 'Oberbegriffsdatei',
|
||||
self::orcid => 'ORCID (Open Researcher and Contributor ID)',
|
||||
self::osm => 'OpenStreetMap',
|
||||
self::pim => 'Petőfi Irodalmi Múzeum',
|
||||
self::pleiades => 'Pleiades',
|
||||
self::rkd => 'RKDartists ID',
|
||||
self::ulan => 'Union List of Artist Names',
|
||||
self::viaf => 'VIAF (Virtual International Authority File)',
|
||||
self::wikidata => 'Wikidata',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL prefix for the current repository.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUrlPrefix():string {
|
||||
|
||||
return match($this) {
|
||||
self::allgemein => '',
|
||||
self::aat => 'https://vocab.getty.edu/page/aat/',
|
||||
self::ackerbau => 'https://term.museum-digital.de/ackerbau/tag/',
|
||||
self::bne => 'http://datos.bne.es/persona/',
|
||||
self::bnf => "https://catalogue.bnf.fr/ark:/12148/cb",
|
||||
self::cona => 'https://vocab.getty.edu/page/cona/',
|
||||
self::editionhumboldtdigital => 'https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/',
|
||||
self::gnd => 'https://d-nb.info/gnd/',
|
||||
self::grobsystematik => 'https://term.museum-digital.de/grobsystematik/tag/',
|
||||
self::iconclass => 'http://iconclass.org/rkd/',
|
||||
self::klbb => 'https://www.kl-bb.de/artist/',
|
||||
self::lcsh => 'http://id.loc.gov/authorities/names/',
|
||||
self::loc => 'http://id.loc.gov/authorities/names/',
|
||||
self::mindatorg => 'https://www.mindat.org/min-', // Has suffix
|
||||
self::moebeltypologie => 'https://term.museum-digital.de/moebel/tag/',
|
||||
self::ndb_adb => 'https://www.deutsche-biographie.de/pnd',
|
||||
self::ndl => 'https://id.ndl.go.jp/auth/ndlna/',
|
||||
self::ndp_ikmk => 'https://ikmk.smb.museum/ndp/',
|
||||
self::ndp_ikmk_persons => 'https://ikmk.smb.museum/ndp/person/',
|
||||
self::nomisma => 'http://nomisma.org/id/',
|
||||
self::npg => 'https://www.npg.org.uk/collections/search/person/',
|
||||
self::oberbegriffsdatei => 'https://term.museum-digital.de/oberbegriffsdatei/tag/',
|
||||
self::orcid => 'https://orcid.org/',
|
||||
self::osm => 'https://www.openstreetmap.org/relation/',
|
||||
self::pim => 'https://opac-nevter.pim.hu/en/record/-/record/',
|
||||
self::pleiades => 'https://pleiades.stoa.org/places/',
|
||||
self::rkd => 'https://rkd.nl/explore/artists/',
|
||||
self::ulan => 'https://vocab.getty.edu/page/ulan/',
|
||||
self::viaf => 'https://viaf.org/viaf/',
|
||||
self::wikidata => 'https://www.wikidata.org/entity/',
|
||||
};
|
||||
|
||||
}
|
||||
@ -139,41 +270,87 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
*/
|
||||
public function getEntityLink(string $id):string {
|
||||
|
||||
return match($this) {
|
||||
self::allgemein => $id,
|
||||
self::aat => 'https://vocab.getty.edu/page/aat/' . $id,
|
||||
self::ackerbau => 'https://term.museum-digital.de/ackerbau/tag/' . $id,
|
||||
self::bne => 'http://datos.bne.es/persona/' . $id,
|
||||
self::bnf => "https://catalogue.bnf.fr/ark:/12148/cb" . $id,
|
||||
self::cona => 'https://vocab.getty.edu/page/cona/' . $id,
|
||||
self::editionhumboldtdigital => 'https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/' . $id,
|
||||
self::gnd => 'https://d-nb.info/gnd/' . $id,
|
||||
self::grobsystematik => 'https://term.museum-digital.de/grobsystematik/tag/' . $id,
|
||||
self::iconclass => 'http://iconclass.org/rkd/' . $id,
|
||||
self::lcsh => 'http://id.loc.gov/authorities/names/' . $id,
|
||||
self::loc => 'http://id.loc.gov/authorities/names/' . $id,
|
||||
self::mbl => 'http://www.uni-magdeburg.de/mbl/PHP_Skripte/mbl_verwaltung/mbl_verw_anzeige_biog.php?auswahl=3&liste_biog_name=' . $id,
|
||||
self::mindatorg => 'https://www.mindat.org/min-' . $id . '.html',
|
||||
self::moebeltypologie => 'https://term.museum-digital.de/moebel/tag/' . $id,
|
||||
return match ($this) {
|
||||
self::ndb_adb => 'https://www.deutsche-biographie.de/pnd' . $id . '.html',
|
||||
self::ndl => 'https://id.ndl.go.jp/auth/ndlna/' . $id,
|
||||
self::ndp_ikmk => 'https://ikmk.smb.museum/ndp/land/' . $id,
|
||||
self::nomisma => 'http://nomisma.org/id/' . $id,
|
||||
self::npg => 'https://www.npg.org.uk/collections/search/person/' . $id,
|
||||
self::oberbegriffsdatei => 'https://term.museum-digital.de/oberbegriffsdatei/tag/' . $id,
|
||||
self::orcid => 'https://orcid.org/' . $id,
|
||||
self::osm => 'https://www.openstreetmap.org/relation/' . $id,
|
||||
self::pim => 'https://opac-nevter.pim.hu/en/record/-/record/' . $id,
|
||||
self::pleiades => 'https://pleiades.stoa.org/places/' . $id,
|
||||
self::rkd => 'https://rkd.nl/explore/artists/' . $id,
|
||||
self::ulan => 'https://vocab.getty.edu/page/ulan/' . $id,
|
||||
self::viaf => 'https://viaf.org/viaf/' . $id,
|
||||
self::wikidata => 'https://www.wikidata.org/wiki/' . $id,
|
||||
self::wikipedia => 'https://de.wikipedia.org/wiki/' . $id,
|
||||
self::mindatorg => 'https://www.mindat.org/min-' . $id . '.html',
|
||||
default => $this->getUrlPrefix() . $id,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link to search for a given search term.
|
||||
*
|
||||
* @param string $searchTerm Search term.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSearchLink(string $searchTerm):string {
|
||||
|
||||
return match($this) {
|
||||
self::allgemein => 'https://www.google.de/search?q=' . urlencode($searchTerm),
|
||||
self::aat => 'https://www.getty.edu/vow/AATServlet?english=N&find=' . urlencode($searchTerm) . '&page=1¬e=',
|
||||
self::ackerbau => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|ackerbau',
|
||||
self::bne => 'http://datos.bne.es/persona/' . urlencode($searchTerm),
|
||||
self::bnf => 'https://catalogue.bnf.fr/resultats-auteur.do?nomAuteur=' . urlencode($searchTerm) . '+&filtre=1&pageRech=rau',
|
||||
self::cona => 'http://vocab.getty.edu/page/cona/' . urlencode($searchTerm),
|
||||
self::editionhumboldtdigital => 'https://edition-humboldt.de/suche/ergebnisRegistersuche.xql?indexType=&q_text=' . urlencode($searchTerm),
|
||||
self::gnd => 'https://explore.gnd.network/search?term=' . urlencode($searchTerm),
|
||||
self::grobsystematik => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|grobsystematik',
|
||||
self::iconclass => 'http://iconclass.org/rkd/48C51/?q=' . urlencode($searchTerm) . '&q_s=1',
|
||||
self::lcsh => 'https://id.loc.gov/search/?q=cs:http://id.loc.gov/authorities/subjects&q=' . urlencode($searchTerm),
|
||||
self::klbb => 'https://www.kl-bb.de/gezielte-suche?page=gezielte-suche&artist_name=' . urlencode($searchTerm),
|
||||
self::loc => 'http://id.loc.gov/authorities/names/' . urlencode($searchTerm),
|
||||
self::mindatorg => 'https://www.mindat.org/search.php?search=' . urlencode($searchTerm) . '&q_s=1',
|
||||
self::moebeltypologie => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|moebel',
|
||||
self::ndb_adb => 'https://www.deutsche-biographie.de/search?name=' . urlencode($searchTerm),
|
||||
self::ndl => 'https://id.ndl.go.jp/auth/ndlna/' . urlencode($searchTerm),
|
||||
self::ndp_ikmk => 'https://ikmk.smb.museum/ndp/list?lang=de&q=' . urlencode($searchTerm),
|
||||
self::ndp_ikmk_persons => 'https://ikmk.smb.museum/ndp/list?lang=de&q=' . urlencode($searchTerm),
|
||||
self::nomisma => 'http://nomisma.org/browse?q=' . urlencode($searchTerm),
|
||||
self::npg => 'https://www.npg.org.uk/collections/search/person/' . urlencode($searchTerm),
|
||||
self::oberbegriffsdatei => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|oberbegriffsdatei',
|
||||
self::orcid => 'https://orcid.org/' . urlencode($searchTerm),
|
||||
self::osm => 'https://www.openstreetmap.org/relation/' . urlencode($searchTerm),
|
||||
self::pim => 'https://opac-nevter.pim.hu/en/record/-/results/' . urlencode($searchTerm),
|
||||
self::pleiades => 'https://pleiades.stoa.org/search?SearchableText=' . urlencode($searchTerm),
|
||||
self::rkd => 'https://rkd.nl/en/explore#query=' . urlencode($searchTerm),
|
||||
self::ulan => 'http://www.getty.edu/vow/ULANServlet?english=Y&find=' . urlencode($searchTerm) . '&role=&page=1&nation=',
|
||||
self::viaf => 'https://viaf.org/viaf/search?query=local.names+all+' . urlencode('"' . $searchTerm . '"') . '"&sortKeys=holdingscount&recordSchema=BriefVIAF',
|
||||
self::wikidata => 'https://www.wikidata.org/w/index.php?search=&search=' . urlencode($searchTerm) . '&ns0=1&ns120=1',
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension of PHP's built-in is_numeric() that also supports large numbers.
|
||||
*
|
||||
* @param string $value Input to check.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private static function _is_numeric(string $value):bool {
|
||||
|
||||
// Strings starting with 0 are quite often linked, notably with the NDL.
|
||||
// PHP's FILTER_VALIDATE_INT does not accept a leading 0 however, so it
|
||||
// is stripped before checking.
|
||||
if (filter_var(ltrim($value, '0'), FILTER_VALIDATE_INT) !== false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// FILTER_VALIDATE_INT fails on overly large IDs (e.g. VIAF IDs having
|
||||
// more than 20 digits).
|
||||
// In these cases, simply check for the existence of non-numeric characters.
|
||||
if (strlen($value) > 9) {
|
||||
if (empty(trim($value, '0123456789'))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a numeric ID, returning a string or false.
|
||||
*
|
||||
@ -186,14 +363,15 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$toRemove = [];
|
||||
foreach ($prefixes as $prefix) $toRemove[$prefix] = "";
|
||||
$id = strtr($id, $toRemove);
|
||||
foreach ($prefixes as $prefix) {
|
||||
$toRemove[$prefix] = "";
|
||||
}
|
||||
$id = trim(strtr($id, $toRemove), '/');
|
||||
}
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_INT) === false) {
|
||||
if (!self::_is_numeric($id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
@ -217,6 +395,21 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a BNE ID, returning a string or false. The BNE is basically equalivalent to the
|
||||
* GND, just that the X character can be prepended to the number.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
* @param string[] $prefixes Prefixes to strip off.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validateBneId(string $id, array $prefixes):string|false {
|
||||
|
||||
return self::validateGndId($id, $prefixes);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a GND ID, returning a string or false.
|
||||
*
|
||||
@ -227,13 +420,23 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
*/
|
||||
private static function validateGndId(string $id, array $prefixes):string|false {
|
||||
|
||||
if (str_contains($id, ' ')) {
|
||||
$id = strtr($id, [' ' => '', "\t" => '']);
|
||||
}
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$toRemove = [];
|
||||
foreach ($prefixes as $prefix) $toRemove[$prefix] = "";
|
||||
$id = strtr($id, $toRemove);
|
||||
}
|
||||
|
||||
if (preg_match("/^[0-9-X]*$/", $id) === false) return false;
|
||||
// There is an issue with this regex
|
||||
if (preg_match("/^[0-9-X]*$/", $id) === false) {
|
||||
return false;
|
||||
}
|
||||
if (self::_is_numeric(strtr($id, ['-' => '', 'X' => ''])) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
@ -249,18 +452,26 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
private static function validateLocId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = strtr($id, ['http://id.loc.gov/authorities/names/' => '']);
|
||||
$id = strtr($id, [
|
||||
'http://id.loc.gov/authorities/names/' => '',
|
||||
'https://id.loc.gov/authorities/names/' => '',
|
||||
'http://id.loc.gov/authorities/subjects/' => '',
|
||||
'https://id.loc.gov/authorities/subjects/' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
if (substr($id, 0, 1) !== 'n') {
|
||||
throw new MDgenericInvalidInputsException("LOC IDs must start with n");
|
||||
if (in_array(substr($id, 0, 2), ['nr', 'nb', 'no'], true)) {
|
||||
if (filter_var(trim(substr($id, 2), '0'), FILTER_VALIDATE_INT) === false) return false;
|
||||
}
|
||||
|
||||
if (filter_var(substr($id, 1), FILTER_VALIDATE_INT) === false) {
|
||||
return false;
|
||||
else if (substr($id, 0, 1) === 'n') {
|
||||
if (filter_var(trim(substr($id, 1), '0'), FILTER_VALIDATE_INT) === false) return false;
|
||||
}
|
||||
else if (substr($id, 0, 2) === 'sh') {
|
||||
throw new MDInvalidNodaLinkLocIdIsSh("The link to the Library of Congress authority files refers to the LOC Subject Headings. The subject headings are listed as a separate vocabulary.");
|
||||
}
|
||||
else throw new MDInvalidNodaLinkException("LOC IDs must start with n or nr or nb (provided: " . strip_tags($id) . ")");
|
||||
|
||||
return $id;
|
||||
return (string)$id;
|
||||
|
||||
}
|
||||
|
||||
@ -274,11 +485,20 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
private static function validateLcshId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = strtr($id, ['http://id.loc.gov/authorities/names/' => '']);
|
||||
$id = strtr($id, [
|
||||
'http://id.loc.gov/authorities/names/' => '',
|
||||
'https://id.loc.gov/authorities/names/' => '',
|
||||
'http://id.loc.gov/authorities/subjects/' => '',
|
||||
'https://id.loc.gov/authorities/subjects/' => '',
|
||||
'.html' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
if (substr($id, 0, 2) !== 'sh') {
|
||||
throw new MDgenericInvalidInputsException("LCSH IDs must start with sh");
|
||||
if (str_starts_with(substr($id, 0, 1), 'n')) {
|
||||
throw new MDInvalidNodaLinkLcshIdIsGeneralLoc("LCSH IDs must start with sh. ID started with n. Use general LOC link instead.");
|
||||
}
|
||||
throw new MDInvalidNodaLinkException("LCSH IDs must start with sh. ID provided is: " . $id);
|
||||
}
|
||||
|
||||
if (filter_var(ltrim(substr($id, 2), "0"), FILTER_VALIDATE_INT) === false) {
|
||||
@ -289,6 +509,111 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an NDP-IKMK ID. The IKMK vocabularies for places are actually quite
|
||||
* numerous, identifying places, countries, regions separately.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validateNdpIkmkForPlaces(string $id):string|false {
|
||||
|
||||
$id = str_replace("https://ikmk.smb.museum/ndp/", "", trim($id, '/'));
|
||||
|
||||
$parts = explode('/', $id);
|
||||
if (count($parts) !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array($parts[0], ['ort', 'land', 'region'], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// There is an issue with this regex
|
||||
if (self::_is_numeric($parts[1]) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $parts[0] . '/' . $parts[1];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates OrCID IDs.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validateOrcidId(string $id):string|false {
|
||||
|
||||
$id = strtr(trim($id, '/'), [
|
||||
"http://orcid.org/" => "",
|
||||
"https://orcid.org/" => "",
|
||||
]);
|
||||
|
||||
return preg_match('/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$/', $id) ? $id : false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a PIM ID, returning a string or false.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validatePimId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$toRemove = [];
|
||||
foreach ([
|
||||
'https://opac-nevter.pim.hu/en/record/-/record/',
|
||||
'https://resolver.pim.hu/auth/',
|
||||
] as $prefix) {
|
||||
$toRemove[$prefix] = "";
|
||||
}
|
||||
$id = strtr($id, $toRemove);
|
||||
}
|
||||
|
||||
// There is an issue with this regex
|
||||
if (preg_match("/^[0-9-PIM]*$/", $id) === false) {
|
||||
return false;
|
||||
}
|
||||
if (self::_is_numeric(substr($id, 3)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an NPG ID, returning a string or false.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
private static function validateNpgId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = strtr($id, ['https://www.npg.org.uk/collections/search/person/' => '']);
|
||||
}
|
||||
|
||||
if (substr($id, 0, 2) === 'mp' && self::_is_numeric(substr($id, 2))) {
|
||||
return $id;
|
||||
}
|
||||
|
||||
if (self::_is_numeric($id) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a wikidata ID, returning a string or false.
|
||||
*
|
||||
@ -299,14 +624,27 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
private static function validateWikidataId(string $id):string|false {
|
||||
|
||||
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
|
||||
$id = strtr($id, ['https://www.wikidata.org/wiki/' => '']);
|
||||
$id = strtr($id, [
|
||||
'http://www.wikidata.org/wiki/' => '',
|
||||
'http://www.wikidata.org/entity/' => '',
|
||||
'https://www.wikidata.org/wiki/' => '',
|
||||
'https://www.wikidata.org/entity/' => '',
|
||||
'https://www.wikidata.org/w/index.php?search=&search=' => '',
|
||||
]);
|
||||
|
||||
if (str_starts_with($id, 'https://www.wikidata.org/w/index.php?title=')) {
|
||||
$id = str_replace('https://www.wikidata.org/w/index.php?title=', '', $id);
|
||||
if (($endPos = strpos($id, '&')) !== false) {
|
||||
$id = substr($id, 0, $endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (substr($id, 0, 1) !== 'Q') {
|
||||
throw new MDgenericInvalidInputsException("Wikidata IDs must be Q IDs - and start with that letter");
|
||||
throw new MDInvalidNodaLinkException("Wikidata IDs must be Q IDs - and start with that letter (provided: $id)");
|
||||
}
|
||||
|
||||
if (filter_var(substr($id, 1), FILTER_VALIDATE_INT) === false) {
|
||||
if (self::_is_numeric(substr($id, 1)) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -314,6 +652,26 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a BNF ID. BNF IDs are either fully numeric or end on a single non-numeric character.
|
||||
*
|
||||
* @param string $id ID to validate.
|
||||
*
|
||||
* @return string|false
|
||||
*/
|
||||
public static function validateBnfId(string $id):string|false {
|
||||
|
||||
if (!is_numeric(substr($id, -1))) {
|
||||
$validation = self::validateNumericId(substr($id, 0, -1), ["https://catalogue.bnf.fr/ark:/12148/cb"]);
|
||||
}
|
||||
else $validation = self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]);
|
||||
|
||||
if ($validation === false) return false;
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an ID.
|
||||
*
|
||||
@ -325,35 +683,52 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
return match($this) {
|
||||
self::allgemein => filter_var($id, FILTER_VALIDATE_URL),
|
||||
self::aat => self::validateNumericId($id, ['https://vocab.getty.edu/page/aat/']),
|
||||
self::aat => self::validateNumericId($id, [
|
||||
'http://vocab.getty.edu/aat/',
|
||||
'http://vocab.getty.edu/page/aat/',
|
||||
'https://vocab.getty.edu/aat/',
|
||||
'https://vocab.getty.edu/page/aat/',
|
||||
]),
|
||||
self::ackerbau => self::validateNumericId($id, ['https://term.museum-digital.de/ackerbau/tag/']),
|
||||
self::bne => self::validateNumericId($id, ['http://datos.bne.es/persona/']),
|
||||
self::bnf => self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]),
|
||||
self::cona => self::validateNumericId($id, ['https://vocab.getty.edu/page/cona/']),
|
||||
self::bne => self::validateBneId($id, ['http://datos.bne.es/persona/', 'https://datos.bne.es/persona/']),
|
||||
self::bnf => self::validateBnfId($id),
|
||||
self::cona => self::validateNumericId($id, ['http://vocab.getty.edu/page/cona/', 'https://vocab.getty.edu/page/cona/']),
|
||||
self::editionhumboldtdigital => self::validateGndId($id, ['https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/']),
|
||||
self::gnd => self::validateGndId($id, ['https://d-nb.info/gnd/']),
|
||||
self::gnd => self::validateGndId($id, ['http://d-nb.info/gnd/', 'https://d-nb.info/gnd/', 'https://explore.gnd.network/gnd/']),
|
||||
self::grobsystematik => self::validateNumericId($id, ['https://term.museum-digital.de/grobsystematik/tag/']),
|
||||
self::iconclass => self::validateIconclassId($id),
|
||||
self::klbb => self::validateNumericId($id, ['https://www.kl-bb.de/artist/', 'https://www.kl-bb.de/?page=actor&subPage=']),
|
||||
self::lcsh => self::validateLcshId($id),
|
||||
self::loc => self::validateLocId($id),
|
||||
self::mbl => self::validateNumericId($id, ['http://www.uni-magdeburg.de/mbl/PHP_Skripte/mbl_verwaltung/mbl_verw_anzeige_biog.php?auswahl=3&liste_biog_name=']),
|
||||
self::mindatorg => self::validateNumericId($id, ['https://www.mindat.org/min-', '.html']),
|
||||
self::moebeltypologie => self::validateNumericId($id, ['https://term.museum-digital.de/moebel/tag/']),
|
||||
self::ndb_adb => self::validateGndId($id, ['https://www.deutsche-biographie.de/pnd', '.html']),
|
||||
self::ndl => self::validateNumericId($id, ['https://id.ndl.go.jp/auth/ndlna/']),
|
||||
self::ndp_ikmk => self::validateNumericId($id, ['https://ikmk.smb.museum/ndp/land/']),
|
||||
self::nomisma => self::validateNumericId($id, ['http://nomisma.org/id/']),
|
||||
self::npg => self::validateNumericId($id, ['https://www.npg.org.uk/collections/search/person/']),
|
||||
self::ndb_adb => self::validateGndId($id, ['https://www.deutsche-biographie.de/pnd', '.html', '#adbcontent', '#ndbcontent', '#indexcontent']),
|
||||
self::ndl => self::validateNumericId($id, [
|
||||
'http://id.ndl.go.jp/auth/ndlna/',
|
||||
'https://id.ndl.go.jp/auth/ndlna/',
|
||||
]),
|
||||
self::ndp_ikmk => self::validateNdpIkmkForPlaces($id),
|
||||
self::ndp_ikmk_persons => self::validateNumericId($id, ['https://ikmk.smb.museum/ndp/person/']),
|
||||
self::nomisma => str_replace('http://nomisma.org/id/', '', $id),
|
||||
self::npg => self::validateNpgId($id),
|
||||
self::oberbegriffsdatei => self::validateNumericId($id, ['https://term.museum-digital.de/oberbegriffsdatei/tag/']),
|
||||
self::orcid => preg_match('/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$/', $id) ? $id : false,
|
||||
self::orcid => self::validateOrcidId($id),
|
||||
self::osm => self::validateNumericId($id, ['https://www.openstreetmap.org/relation/']),
|
||||
self::pim => self::validateNumericId($id, ['https://opac-nevter.pim.hu/en/record/-/record/']),
|
||||
self::pim => self::validatePimId($id),
|
||||
self::pleiades => self::validateNumericId($id, ['https://pleiades.stoa.org/places/']),
|
||||
self::rkd => self::validateNumericId($id, ['http://rkd.nl/explore/artists/', 'https://rkd.nl/explore/artists/']),
|
||||
self::ulan => self::validateNumericId($id, ['http://vocab.getty.edu/ulan/', 'http://vocab.getty.edu/page/ulan/', 'https://vocab.getty.edu/page/ulan/']),
|
||||
self::viaf => self::validateNumericId($id, ['https://viaf.org/viaf/']),
|
||||
self::ulan => self::validateNumericId($id, [
|
||||
'http://vocab.getty.edu/ulan/',
|
||||
'http://vocab.getty.edu/page/ulan/',
|
||||
'https://vocab.getty.edu/page/ulan/',
|
||||
'http://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=',
|
||||
'https://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=',
|
||||
]),
|
||||
self::viaf => self::validateNumericId($id, [
|
||||
'https://viaf.org/viaf/',
|
||||
'http://viaf.org/viaf/',
|
||||
]),
|
||||
self::wikidata => self::validateWikidataId($id),
|
||||
self::wikipedia => str_replace('https://de.wikipedia.org/wiki/', '', $id),
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ enum MDObjectCheckType implements MDValueEnumInterface, JsonSerializable {
|
||||
case condition_check;
|
||||
case completeness_check;
|
||||
case data_correctness_check;
|
||||
case location_accuracy_check;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
@ -28,6 +29,7 @@ enum MDObjectCheckType implements MDValueEnumInterface, JsonSerializable {
|
||||
'condition_check' => self::condition_check,
|
||||
'completeness_check' => self::completeness_check,
|
||||
'data_correctness_check' => self::data_correctness_check,
|
||||
'location_accuracy_check' => self::location_accuracy_check,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown check type"),
|
||||
};
|
||||
|
||||
|
@ -13,6 +13,7 @@ enum MDObjectDamageType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case water_damage;
|
||||
case breakage;
|
||||
case desiccation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
@ -26,6 +27,7 @@ enum MDObjectDamageType implements MDValueEnumInterface, JsonSerializable {
|
||||
return match($input) {
|
||||
'water_damage' => self::water_damage,
|
||||
'breakage' => self::breakage,
|
||||
'desiccation' => self::desiccation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown damage type"),
|
||||
};
|
||||
|
||||
|
169
src/enums/MDObjectDocumentType.php
Normal file
169
src/enums/MDObjectDocumentType.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of document published alongside an object.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of document published alongside an object.
|
||||
*/
|
||||
enum MDObjectDocumentType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case undefined;
|
||||
case provenance_report;
|
||||
case purchase_contract;
|
||||
case restoration_report;
|
||||
case assessment;
|
||||
case correspondence;
|
||||
case legacy_documentation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectDocumentType
|
||||
*/
|
||||
public static function fromString(string $input):MDObjectDocumentType {
|
||||
|
||||
return match($input) {
|
||||
"undefined" => self::undefined,
|
||||
"provenance_report" => self::provenance_report,
|
||||
"purchase_contract" => self::purchase_contract,
|
||||
"restoration_report" => self::restoration_report,
|
||||
"assessment" => self::assessment,
|
||||
"correspondence" => self::correspondence,
|
||||
"legacy_documentation" => self::legacy_documentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown document type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectDocumentType
|
||||
*/
|
||||
public static function fromInt(int $input):MDObjectDocumentType {
|
||||
|
||||
return match($input) {
|
||||
0 => self::undefined,
|
||||
1 => self::provenance_report,
|
||||
2 => self::purchase_contract,
|
||||
3 => self::restoration_report,
|
||||
4 => self::assessment,
|
||||
5 => self::correspondence,
|
||||
6 => self::legacy_documentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown document type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "object_document_type_set", "object_document_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "object_document_type_set", "object_document_type_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::undefined => 0,
|
||||
self::provenance_report => 1,
|
||||
self::purchase_contract => 2,
|
||||
self::restoration_report => 3,
|
||||
self::assessment => 4,
|
||||
self::correspondence => 5,
|
||||
self::legacy_documentation => 6,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("object_document_type_set", "object_document_type_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
221
src/enums/MDObjectRecordStatus.php
Normal file
221
src/enums/MDObjectRecordStatus.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a status an object record is currently in, e.g. for determining
|
||||
* whether the object record can be edited or is locked.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of link between tag and object (e.g. the tag being the object
|
||||
* type, a material used for creating the object, etc.).
|
||||
*/
|
||||
enum MDObjectRecordStatus implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case unlocked;
|
||||
case locked;
|
||||
case revision;
|
||||
case archived;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectRecordStatus
|
||||
*/
|
||||
public static function fromString(string $input):MDObjectRecordStatus {
|
||||
|
||||
return match($input) {
|
||||
'unlocked' => self::unlocked,
|
||||
'locked' => self::locked,
|
||||
'revision' => self::revision,
|
||||
'archived' => self::archived,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDObjectRecordStatus
|
||||
*/
|
||||
public static function fromInt(int $input):MDObjectRecordStatus {
|
||||
|
||||
return match($input) {
|
||||
0 => self::unlocked,
|
||||
1 => self::locked,
|
||||
2 => self::revision,
|
||||
3 => self::archived,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default status.
|
||||
*
|
||||
* @return MDObjectRecordStatus
|
||||
*/
|
||||
public static function getDefault():MDObjectRecordStatus {
|
||||
|
||||
return self::unlocked;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::unlocked => 0,
|
||||
self::locked => 1,
|
||||
self::revision => 2,
|
||||
self::archived => 3,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string representation of object record status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toString():string {
|
||||
|
||||
return match($this) {
|
||||
self::unlocked => "unlocked",
|
||||
self::locked => "locked",
|
||||
self::revision => "revision",
|
||||
self::archived => "archived",
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns CSS icon class for record status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toCssIconClass():string {
|
||||
|
||||
return match($this) {
|
||||
self::unlocked => "iconsLockOpen",
|
||||
self::locked => "iconsLock",
|
||||
self::revision => "iconsFolderDelete",
|
||||
self::archived => "iconsEmojiSymbols",
|
||||
// default => throw new MDpageParameterNotFromListException("Unknown tag relation type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "object_record_status", "object_record_status");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "object_record_status", "object_record_status");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("object_record_status", "object_record_status", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the status permits an updating of the object record.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkWritingIsEnabled():bool {
|
||||
|
||||
return match($this) {
|
||||
self::unlocked => true,
|
||||
self::locked => false,
|
||||
self::revision => false,
|
||||
self::archived => false,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
221
src/enums/MDSeriesContributorRole.php
Normal file
221
src/enums/MDSeriesContributorRole.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of contribution to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of contribution to an object group.
|
||||
*/
|
||||
enum MDSeriesContributorRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case author;
|
||||
case director;
|
||||
case dramaturg;
|
||||
case production_designer;
|
||||
case costumer;
|
||||
case musician;
|
||||
case choreographer;
|
||||
case make_up_artist;
|
||||
case speech_trainer;
|
||||
case puppet_maker;
|
||||
case technician;
|
||||
case inspector;
|
||||
case assistant;
|
||||
case actor;
|
||||
case painter;
|
||||
case creator;
|
||||
case equipment_supplier;
|
||||
case contributing_institution;
|
||||
case event_organizer;
|
||||
case movement_trainer;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesContributorRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesContributorRole {
|
||||
|
||||
return match($input) {
|
||||
"author" => self::author,
|
||||
"director" => self::director,
|
||||
"dramaturg" => self::dramaturg,
|
||||
"production_designer" => self::production_designer,
|
||||
"costumer" => self::costumer,
|
||||
"musician" => self::musician,
|
||||
"choreographer" => self::choreographer,
|
||||
"make_up_artist" => self::make_up_artist,
|
||||
"speech_trainer" => self::speech_trainer,
|
||||
"puppet_maker" => self::puppet_maker,
|
||||
"technician" => self::technician,
|
||||
"inspector" => self::inspector,
|
||||
"assistant" => self::assistant,
|
||||
"actor" => self::actor,
|
||||
"painter" => self::painter,
|
||||
"creator" => self::creator,
|
||||
"equipment_supplier" => self::equipment_supplier,
|
||||
"contributing_institution" => self::contributing_institution,
|
||||
"event_organizer" => self::event_organizer,
|
||||
"movement_trainer" => self::movement_trainer,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesContributorRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDSeriesContributorRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::author,
|
||||
1 => self::director,
|
||||
2 => self::dramaturg,
|
||||
3 => self::production_designer,
|
||||
4 => self::costumer,
|
||||
5 => self::musician,
|
||||
6 => self::choreographer,
|
||||
7 => self::make_up_artist,
|
||||
8 => self::speech_trainer,
|
||||
9 => self::puppet_maker,
|
||||
10 => self::technician,
|
||||
11 => self::inspector,
|
||||
12 => self::assistant,
|
||||
13 => self::actor,
|
||||
14 => self::painter,
|
||||
15 => self::creator,
|
||||
16 => self::equipment_supplier,
|
||||
17 => self::contributing_institution,
|
||||
18 => self::event_organizer,
|
||||
19 => self::movement_trainer,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series contributor role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "series_contributor_role", "series_contributor_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "series_contributor_role", "series_contributor_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::author => 0,
|
||||
self::director => 1,
|
||||
self::dramaturg => 2,
|
||||
self::production_designer => 3,
|
||||
self::costumer => 4,
|
||||
self::musician => 5,
|
||||
self::choreographer => 6,
|
||||
self::make_up_artist => 7,
|
||||
self::speech_trainer => 8,
|
||||
self::puppet_maker => 9,
|
||||
self::technician => 10,
|
||||
self::inspector => 11,
|
||||
self::assistant => 12,
|
||||
self::actor => 13,
|
||||
self::painter => 14,
|
||||
self::creator => 15,
|
||||
self::equipment_supplier => 16,
|
||||
self::contributing_institution => 17,
|
||||
self::event_organizer => 18,
|
||||
self::movement_trainer => 19,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("series_contributor_role", "series_contributor_role", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
153
src/enums/MDSeriesPlaceRole.php
Normal file
153
src/enums/MDSeriesPlaceRole.php
Normal file
@ -0,0 +1,153 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of place related to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of place related to an object group.
|
||||
*/
|
||||
enum MDSeriesPlaceRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case place_of_production;
|
||||
case performance_space;
|
||||
case rehearsal_space;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesPlaceRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesPlaceRole {
|
||||
|
||||
return match($input) {
|
||||
"place_of_production" => self::place_of_production,
|
||||
"performance_space" => self::performance_space,
|
||||
"rehearsal_space" => self::rehearsal_space,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series place role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesPlaceRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDSeriesPlaceRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::place_of_production,
|
||||
1 => self::performance_space,
|
||||
2 => self::rehearsal_space,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series place role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "series_place_role", "series_place_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "series_place_role", "series_place_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::place_of_production => 0,
|
||||
self::performance_space => 1,
|
||||
self::rehearsal_space => 2,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("series_place_role", "series_place_role", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
149
src/enums/MDSeriesTimeRole.php
Normal file
149
src/enums/MDSeriesTimeRole.php
Normal file
@ -0,0 +1,149 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of time related to an object group.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of time related to an object group.
|
||||
*/
|
||||
enum MDSeriesTimeRole implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case premiere;
|
||||
case time_of_presentation;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesTimeRole
|
||||
*/
|
||||
public static function fromString(string $input):MDSeriesTimeRole {
|
||||
|
||||
return match($input) {
|
||||
"premiere" => self::premiere,
|
||||
"time_of_presentation" => self::time_of_presentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series time role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDSeriesTimeRole
|
||||
*/
|
||||
public static function fromInt(int $input):MDSeriesTimeRole {
|
||||
|
||||
return match($input) {
|
||||
0 => self::premiere,
|
||||
1 => self::time_of_presentation,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown series time role"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "series_time_role", "series_time_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "series_time_role", "series_time_role");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::premiere => 0,
|
||||
self::time_of_presentation => 1,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("series_time_role", "series_time_role", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
174
src/enums/MDTagRelationType.php
Normal file
174
src/enums/MDTagRelationType.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a type of link between tag and object (e.g. the tag being the object
|
||||
* type, a material used for creating the object, etc.).
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of link between tag and object (e.g. the tag being the object
|
||||
* type, a material used for creating the object, etc.).
|
||||
*/
|
||||
enum MDTagRelationType implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case tag;
|
||||
case object_type;
|
||||
case material;
|
||||
case technique;
|
||||
case display_subject;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDTagRelationType
|
||||
*/
|
||||
public static function fromString(string $input):MDTagRelationType {
|
||||
|
||||
return match($input) {
|
||||
'tag' => self::tag,
|
||||
'object_type' => self::object_type,
|
||||
'material' => self::material,
|
||||
'technique' => self::technique,
|
||||
'display_subject' => self::display_subject,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown tag relation type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDTagRelationType
|
||||
*/
|
||||
public static function fromInt(int $input):MDTagRelationType {
|
||||
|
||||
return match($input) {
|
||||
0 => self::tag,
|
||||
1 => self::object_type,
|
||||
2 => self::material,
|
||||
3 => self::technique,
|
||||
4 => self::display_subject,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown tag relation type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default status.
|
||||
*
|
||||
* @return MDTagRelationType
|
||||
*/
|
||||
public static function getDefault():MDTagRelationType {
|
||||
|
||||
return self::tag;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of tag relations.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::tag => 0,
|
||||
self::object_type => 1,
|
||||
self::material => 2,
|
||||
self::technique => 3,
|
||||
self::display_subject => 4,
|
||||
// default => throw new MDpageParameterNotFromListException("Unknown tag relation type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "tag_relation_type", "tag_relation_type");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "tag_relation_type", "tag_relation_type");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("tag_relation_type", "tag_relation_type", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
174
src/enums/MDVocabularyRedactionLevel.php
Normal file
174
src/enums/MDVocabularyRedactionLevel.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a redaction level for vocabulary entries (checked, unchecked, questionable).
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a type of contribution to an object group.
|
||||
*/
|
||||
enum MDVocabularyRedactionLevel implements MDValueEnumInterface, JsonSerializable {
|
||||
|
||||
case checked;
|
||||
case unchecked;
|
||||
case questionable;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDVocabularyRedactionLevel
|
||||
*/
|
||||
public static function fromString(string $input):MDVocabularyRedactionLevel {
|
||||
|
||||
return match($input) {
|
||||
"+" => self::checked,
|
||||
"checked" => self::checked,
|
||||
|
||||
"-" => self::unchecked,
|
||||
"unchecked" => self::unchecked,
|
||||
|
||||
"" => self::questionable,
|
||||
"questionable" => self::questionable,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown vocabulary redaction level"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDVocabularyRedactionLevel
|
||||
*/
|
||||
public static function fromInt(int $input):MDVocabularyRedactionLevel {
|
||||
|
||||
return match($input) {
|
||||
0 => self::checked,
|
||||
1 => self::unchecked,
|
||||
2 => self::questionable,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown vocabulary redaction level"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "vocabulary_redaction_level", "vocabulary_redaction_level");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "vocabulary_redaction_level", "vocabulary_redaction_level");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<integer>
|
||||
*/
|
||||
public static function caseInts():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->toInt();
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns name as noted in DB.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toDbString():string {
|
||||
|
||||
return match($this) {
|
||||
self::checked => '+',
|
||||
self::unchecked => '-',
|
||||
self::questionable => '',
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns integer representation of object record status.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::checked => 0,
|
||||
self::unchecked => 1,
|
||||
self::questionable => 2,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown object record status"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("vocabulary_redaction_level", "vocabulary_redaction_level", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->toDbString();
|
||||
|
||||
}
|
||||
}
|
158
src/enums/MDWeightUnit.php
Normal file
158
src/enums/MDWeightUnit.php
Normal file
@ -0,0 +1,158 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*
|
||||
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
||||
*/
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Represents a measurement type.
|
||||
*/
|
||||
enum MDWeightUnit implements MDValueEnumInterface, JsonSerializable, MDMeasurementUnitInterface {
|
||||
|
||||
case t;
|
||||
case kg;
|
||||
case g;
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on a string.
|
||||
*
|
||||
* @param string $input Input to get a value from.
|
||||
*
|
||||
* @return MDWeightUnit
|
||||
*/
|
||||
public static function fromString(string $input):MDWeightUnit {
|
||||
|
||||
return match($input) {
|
||||
't' => self::t,
|
||||
'kg' => self::kg,
|
||||
'g' => self::g,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown length unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a value of this type based on an integer.
|
||||
*
|
||||
* @param integer $input Input to get a value from.
|
||||
*
|
||||
* @return MDWeightUnit
|
||||
*/
|
||||
public static function fromInt(int $input):MDWeightUnit {
|
||||
|
||||
return match($input) {
|
||||
1 => self::t,
|
||||
2 => self::kg,
|
||||
3 => self::g,
|
||||
default => throw new MDpageParameterNotFromListException("Unknown length unit"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Lists all available names.
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function caseNames():array {
|
||||
|
||||
$output = [];
|
||||
|
||||
$cases = self::cases();
|
||||
foreach ($cases as $case) {
|
||||
$output[] = $case->name;
|
||||
}
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an integer representation of the collective (for storage in DB).
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function toInt():int {
|
||||
|
||||
return match($this) {
|
||||
self::t => 1,
|
||||
self::kg => 2,
|
||||
self::g => 3,
|
||||
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measurement calculated down to the base unit (e.g. mm for lengths).
|
||||
*
|
||||
* @param float $value Measurement value.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function convertToBaseUnit(float $value):float {
|
||||
|
||||
$multiplier = match($this) {
|
||||
self::t => 1000000,
|
||||
self::kg => 1000,
|
||||
self::g => 1,
|
||||
};
|
||||
|
||||
return floatval($value * $multiplier);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an unsorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getUnsortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "units_weight_set", "units_weight_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a sorted list of the entries in a translated version.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function getSortedList(MDTlLoader $tlLoader):array {
|
||||
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "units_weight_set", "units_weight_set");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the current value in translation.
|
||||
*
|
||||
* @param MDTlLoader $tlLoader Translation loader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTledName(MDTlLoader $tlLoader):string {
|
||||
|
||||
return $tlLoader->tl("units_weight_set", "units_weight_set", $this->name);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the option to serialize as a string during json_encode().
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function jsonSerialize():string {
|
||||
|
||||
return $this->name;
|
||||
|
||||
}
|
||||
}
|
84
tests/MDNodaRepositoryTest.php
Normal file
84
tests/MDNodaRepositoryTest.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?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_once __DIR__ . '/../src/enums/MDValueEnumInterface.php';
|
||||
require_once __DIR__ . '/../src/enums/MDNodaRepository.php';
|
||||
|
||||
/**
|
||||
* Tests for home page.
|
||||
*/
|
||||
final class MDNodaRepositoryTest extends TestCase {
|
||||
/**
|
||||
* Tests that valid IDs actually validate as valid.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testValidIdsValidate():void {
|
||||
|
||||
self::assertEquals("Q834961", MDNodaRepository::wikidata->validateId("https://www.wikidata.org/w/index.php?title=Q834961&oldid=2256125706"));
|
||||
|
||||
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("http://datos.bne.es/persona/XX5034943"));
|
||||
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("https://datos.bne.es/persona/XX5034943"));
|
||||
self::assertEquals("XX5034943", MDNodaRepository::bne->validateId("XX5034943"));
|
||||
self::assertEquals(false, MDNodaRepository::bne->validateId("XX503494safdsaf;3"));
|
||||
|
||||
// GND (Germany)
|
||||
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("https://d-nb.info/gnd/102423008"));
|
||||
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/102423008"));
|
||||
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/ 102423008"));
|
||||
self::assertEquals("1037602218", MDNodaRepository::gnd->validateId("http://d-nb.info/gnd/1037602218"));
|
||||
self::assertEquals("1037602218", MDNodaRepository::gnd->validateId("https://explore.gnd.network/gnd/1037602218"));
|
||||
self::assertEquals("102423008", MDNodaRepository::gnd->validateId("102423008"));
|
||||
self::assertEquals(false, MDNodaRepository::gnd->validateId("fkld;s102423008"));
|
||||
|
||||
// NDL (Japan)
|
||||
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("https://id.ndl.go.jp/auth/ndlna/00967046"));
|
||||
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("http://id.ndl.go.jp/auth/ndlna/00967046"));
|
||||
self::assertEquals("00967046", MDNodaRepository::ndl->validateId("00967046"));
|
||||
self::assertEquals(false, MDNodaRepository::ndl->validateId("http://id.ndl.go.jp/auth/ndlna/0096704;43s6"));
|
||||
|
||||
// NPG: National Portrait Gallery
|
||||
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp01751"));
|
||||
self::assertEquals('mp01751', MDNodaRepository::npg->validateId("mp01751"));
|
||||
self::assertEquals(false, MDNodaRepository::npg->validateId("https://www.npg.org.uk/collections/search/person/mp017;51"));
|
||||
|
||||
// Library of Congress
|
||||
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("https://id.loc.gov/authorities/names/n2022014604"));
|
||||
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("http://id.loc.gov/authorities/names/n2022014604"));
|
||||
self::assertEquals("n2022014604", MDNodaRepository::loc->validateId("n2022014604"));
|
||||
self::assertEquals(false, MDNodaRepository::loc->validateId("n20220146;04"));
|
||||
|
||||
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("https://id.loc.gov/authorities/names/sh2022014604"));
|
||||
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/names/sh2022014604"));
|
||||
self::assertEquals("sh85081569", MDNodaRepository::lcsh->validateId("http://id.loc.gov/authorities/subjects/sh85081569.html"));
|
||||
self::assertEquals("sh2022014604", MDNodaRepository::lcsh->validateId("sh2022014604"));
|
||||
self::assertEquals(false, MDNodaRepository::lcsh->validateId("sh20220146;;04"));
|
||||
|
||||
// PRIM
|
||||
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("https://opac-nevter.pim.hu/en/record/-/record/PIM71684"));
|
||||
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("https://resolver.pim.hu/auth/PIM71684"));
|
||||
self::assertEquals("PIM71684", MDNodaRepository::pim->validateId("PIM71684"));
|
||||
self::assertEquals(false, MDNodaRepository::pim->validateId("PIM7168;;4"));
|
||||
|
||||
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("https://viaf.org/viaf/248941990"));
|
||||
self::assertEquals("248941990", MDNodaRepository::viaf->validateId("http://viaf.org/viaf/248941990"));
|
||||
self::assertEquals("42893419", MDNodaRepository::viaf->validateId("https://viaf.org/viaf/42893419/"));
|
||||
self::assertEquals("86145857811423020454", MDNodaRepository::viaf->validateId("86145857811423020454"));
|
||||
self::assertEquals("2869150688328112660005", MDNodaRepository::viaf->validateId("2869150688328112660005"));
|
||||
self::assertEquals(false, MDNodaRepository::viaf->validateId("2869150688328112;;660005"));
|
||||
|
||||
# NDP-IKMK (Places)
|
||||
self::assertEquals("ort/2847", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/ort/2847"));
|
||||
self::assertEquals("land/123", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/land/123"));
|
||||
self::assertEquals("region/123", MDNodaRepository::ndp_ikmk->validateId("https://ikmk.smb.museum/ndp/region/123"));
|
||||
self::assertEquals("land/123", MDNodaRepository::ndp_ikmk->validateId("land/123"));
|
||||
self::assertEquals(false, MDNodaRepository::ndp_ikmk->validateId("123123"));
|
||||
|
||||
}
|
||||
}
|
34
tests/bootstrap.php
Normal file
34
tests/bootstrap.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?PHP
|
||||
declare(strict_types = 1);
|
||||
|
||||
/**
|
||||
* Autoloader for musdb.
|
||||
*
|
||||
* @param string $className Name of the class to load.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
\spl_autoload_register(function(string $className):void {
|
||||
|
||||
// Try using class map as defined through /scripts/buildClassMap.php
|
||||
|
||||
foreach (array_merge([__DIR__ . '/../tests',
|
||||
__DIR__ . '/../src',
|
||||
__DIR__ . '/../src/enums',
|
||||
__DIR__ . '/../src/classes',
|
||||
__DIR__ . '/../exceptions',
|
||||
__DIR__ . '/../../MD_STD/src',
|
||||
__DIR__ . '/../../MDErrorReporter',
|
||||
__DIR__ . '/../../MDErrorReporter/exceptions',
|
||||
__DIR__ . '/../../MDErrorReporter/exceptions/generic',
|
||||
__DIR__ . '/../../MDErrorReporter/exceptions/updates',
|
||||
]) as $classDir) {
|
||||
|
||||
if (\file_exists("$classDir/$className.php")) {
|
||||
include "$classDir/$className.php";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user