Compare commits

...

137 Commits

Author SHA1 Message Date
86f6a6c26d Update translation files 2025-05-08 16:52:12 +02:00
da950073e9 Add https:// variant for iconclass 2025-05-08 16:17:43 +02:00
29879ac02f Add new event types
- Production of material
- Mentioned place
- Mentioned time
- Received ownership
- Transfered ownershi
2025-05-05 22:56:07 +02:00
5ec93ba619 Add enums for loan types, exhiibition contributor roles 2025-04-04 17:20:16 +02:00
1403f75447 Add new measurement type for diameter of frame 2025-03-19 15:20:46 +01:00
04c378675c Add new measurement types for min / max length, width, etc.
Close #35
2025-03-19 15:03:29 +01:00
60483d897b Disallow setting anything but actors for mentioned events in MDEventsSet 2025-03-14 18:24:59 +01:00
a0348b135a Update MDNodaRepository 2025-03-12 02:44:20 +01:00
45d7c3d455 Map http://d-nb.info/ to the GND 2025-03-11 17:43:43 +01:00
22a30fd52b Update translation files 2025-03-03 17:46:29 +01:00
2e9d0aeff3 Update translation files 2025-02-20 16:07:23 +01:00
9fb9e45893 Add language: Crimean Tatar 2025-02-18 17:43:27 +01:00
4d16367266 Update translation files 2025-02-14 18:16:32 +01:00
1b922ce973 Update translation files 2025-02-14 17:36:48 +01:00
b01fb98108 Merge branch 'master' of gitea:museum-digital/MDAllowedValueSets 2025-02-14 10:33:08 +01:00
12689d24fa Add bootstrapping for tests, parse additional wikidata ID format 2025-02-14 10:32:25 +01:00
7f22538085 Add Kannada spelling for Kannada for language selection 2025-02-13 13:17:27 +01:00
9d139f9154 Update translation files 2025-02-13 00:23:22 +01:00
fb92b6b84c Update translation files 2025-02-12 19:47:41 +01:00
426e6b11ac Update translation files 2025-02-03 17:41:04 +01:00
eec67dd866 Update translation files 2025-01-31 23:23:00 +01:00
61edc14240 Update years covered in license 2025-01-22 15:18:55 +01:00
dbd15ea26b Update translation files 2025-01-22 15:07:18 +01:00
1b34e49ff8 Add number of sheets as a unit for number of parts 2025-01-14 11:12:40 +01:00
709a5d5cc3 Update translation files 2025-01-12 21:49:09 +01:00
f1d0435eef Add new, more specific measurement types 2024-12-18 17:00:13 +01:00
abb41ed32c Update translation files 2024-12-10 22:06:24 +01:00
3c2d1ca856 Update translation files 2024-12-09 23:19:01 +01:00
d0b325e73e Add marking type "drawn", more specific marking positions mainly on rear side 2024-12-09 14:57:45 +01:00
8c73338758 Update translation files 2024-12-01 22:28:09 +01:00
f938c66ab6 Prevent using general URL field in MDNodaRepository::fromUrl() 2024-11-28 09:28:43 +01:00
7fc57353a8 Extend MDMeasurement with surrounding enums to cover measurements of
objects
2024-11-21 21:46:24 +01:00
fa8bc6dac0 Extend list of languages by nds / Niederdeutsch 2024-11-15 17:21:27 +01:00
f8a8fd901c Add language Plattdeutsch 2024-11-14 17:52:57 +01:00
5142a57cfe Add enum for controlling source types 2024-11-06 16:19:58 +01:00
71e05e7eab Update translation files 2024-10-21 01:24:17 +02:00
333340da3e Improve validation of ORCID IDs 2024-10-03 16:36:01 +02:00
d22db5bd95 Add enum to control levels of redaction in controlled vocabularies 2024-09-27 17:08:08 +02:00
f19973d20e Remove noda repository MBL, add list of full names to the vocabs for
improved frontend display

Close #33
2024-09-25 14:33:45 +02:00
dc1c72aeda Use /entity/ links for referencing Wikidata over /wiki/; allow linking
from GND explorer

Close #32
2024-09-12 17:06:30 +02:00
bdb9bb16f5 Allow wikidata IDs exceeding the size of INT32 2024-08-10 17:05:44 +02:00
7826b7d891 Fix missing parameter being passed on 2024-07-30 00:53:30 +02:00
be2da00759 Use ->toString() over ->name in json serialization of MDGender,
MDLicense

This is important for backwards compatibility
2024-07-30 00:51:04 +02:00
47763d1998 Fix error messages 2024-07-29 17:50:36 +02:00
99e0f9b655 Implement enums for genders and licenses
See #31, see #30
2024-07-29 13:59:17 +02:00
32a1e8b1be Remove noda repository wikipedia, use GND Explorer for lookups/searches
in external norm data repository GND

Close #28, close #29
2024-07-19 00:59:37 +02:00
db46255f87 Add contributor role "movement trainer" 2024-07-08 16:42:32 +02:00
c560a5581f Extend list of series contributor roles 2024-06-19 23:02:17 +02:00
d3ff111750 Add basic institution category: univ. collection 2024-06-17 15:44:29 +02:00
e55e4c210a Add enums for roles of places and times linked to series 2024-06-12 00:12:12 +02:00
25e5e954b4 Set explicit visibility on class constants 2024-06-11 22:15:59 +02:00
8c8ead0a02 Update translation files 2024-06-02 00:58:42 +02:00
3ecbb1f774 Update translation files 2024-05-24 19:38:15 +02:00
c907c1b085 Add function for loading collection areas from array 2024-05-23 00:35:57 +02:00
69c2c7cbf9 Update translation files 2024-05-22 21:41:54 +02:00
9ddb461491 Extend MDRequirementsSet with max file size allowed for PDFs 2024-05-17 10:29:17 +02:00
9c80957709 Add object/marking position "inside"
Close #16
2024-05-11 03:55:50 +02:00
d68c114905 Add new enums for object document type, institution categorization
Close #24, close #25, close #26, close #27
2024-05-10 16:22:50 +02:00
493ef9f721 Add function MDSeriesContributorRole::fromInt() 2024-05-08 00:58:48 +02:00
6772476f9b Add new enum for covering series contribution types for actors 2024-05-07 18:31:50 +02:00
4c1916247b Update translation files 2024-05-07 18:31:19 +02:00
c63692fb6c Update translation files 2024-05-03 11:12:12 +02:00
ed7feb8963 Add new space type: outdoor area 2024-04-23 13:58:50 +02:00
11f36fa202 Update translation files 2024-04-18 14:45:13 +02:00
3717bc9da2 Add start and default dates for times in MDRequirementsSet 2024-04-17 11:30:54 +02:00
8d126d112d Update translation files 2024-03-26 15:53:05 +01:00
22f5efddd5 Update translation files 2024-03-25 19:40:24 +01:00
2259012d42 Add new event types: subject of & emerged
Close #22, close #23
2024-03-25 16:29:20 +01:00
0aef8c3116 Map VIAF (capital letters) to MDNodaRepository::viaf 2024-02-28 13:02:32 +01:00
9c65921f5c Update translation files 2024-01-29 21:17:54 +01:00
497807267b Update translation files 2024-01-18 01:51:10 +01:00
6c8ca3ac8e Rename object record status "deleted" to "archived" 2024-01-14 03:19:08 +01:00
ad237490a3 Update translation files 2024-01-12 19:12:01 +01:00
10b9c58a1b Add MDObjectRecordStatus to track record status 2024-01-12 18:52:21 +01:00
65bbd03e2e Update translation files 2024-01-05 18:51:03 +01:00
c371d1d821 Update translation files 2023-12-30 22:39:30 +01:00
91ccbd6683 Disallow PNGs for exhibition and appointment images 2023-12-23 00:12:15 +01:00
22e9ce56a3 Add new currency ua-UAK / Ukrainian karbovanets 2023-12-04 01:24:15 +01:00
7912066f71 Remove trailing slashes from vocabulary links delivered as URLs 2023-12-01 16:45:49 +01:00
dcfba67422 Allow different sub-vocabs of NDP-IKMK for places 2023-11-30 22:29:25 +01:00
c43cc7e42a Allow Wikipedia links from the Chinese Wikipedia 2023-11-26 23:53:50 +01:00
71d34b37ca Also allow Ukrainian Wikipedia 2023-11-14 04:28:20 +01:00
8e0be0f80c Improve identification of lcsh links marked as loc links 2023-11-10 03:10:00 +01:00
be2f42677b Add new check type: Check of object's location 2023-11-02 00:49:13 +01:00
1108398437 Add functions for listing event actor names, time names, place names 2023-10-29 01:27:32 +02:00
1dedb86d5b Fix another invalid output value in MDMeasurementType 2023-10-19 17:20:38 +02:00
06b2d13c6f Fix expected return class 2023-10-19 17:10:21 +02:00
d2dd24baee Extend list of repository names accepted for referring to the different
MDNodaRepository cases
2023-10-19 16:11:37 +02:00
7c7fb58a0d Add MDMeasurementType for listing available measurement types 2023-10-19 03:27:07 +02:00
f14d7edc6e Add tests to ensure invalid IDs are not validated 2023-10-18 22:42:49 +02:00
8f32c30fbd Handle large numbers in GND IDs 2023-10-18 22:35:31 +02:00
c57d180aa1 Remove superfluous throw new exception 2023-10-18 02:06:06 +02:00
d9f3f875e0 Write prettier exception messages 2023-10-16 22:39:46 +02:00
1d1a690e0f Remove whitespaces from vocabulary links, add dedicated exception for
lcsh links that are actually loc links
2023-10-16 16:44:33 +02:00
da6e40282d Improve comments in MDEventsSet 2023-10-15 18:31:52 +02:00
68f453f5f3 Throw dedicated exceptions in MDNodaRepository 2023-10-15 18:30:18 +02:00
d6e3c3208b Make MDInvalidNodaLinkLocIdIsSh a final class 2023-10-15 16:14:21 +02:00
fe73fc7267 Add exceptions special to this repo 2023-10-15 16:13:53 +02:00
ea5a186e8f Explicitly make constants of MDEventsSet public 2023-10-15 13:29:12 +02:00
3fb3ee4edd Map d-nb.de/info to GND 2023-10-15 03:07:59 +02:00
446dd78bec Map WIKIDATA to MDNodaRepository::wikidata 2023-10-13 17:21:02 +02:00
4e3877a4fb Extend list of mapped noda repository names 2023-10-13 17:16:14 +02:00
887f06f70e Add new damage type: desiccation 2023-10-12 22:54:01 +02:00
d295e16049 Better validate Wikipedia links 2023-09-26 01:30:40 +02:00
609931eb26 Add kl-bb as possible controlled vocabulary for actors 2023-09-25 00:05:27 +02:00
2f765e183e Add MDCopyrightCollective to represent those 2023-09-12 01:13:54 +02:00
0f64939def Properly validate PIM IDs
Close #20
2023-09-01 12:30:47 +02:00
f79afa4ed7 Add function MDNodaLink->getEntityLink (wrapper around
mdnodarepository->getEntityLink)
2023-08-29 17:24:11 +02:00
9bca8f400e Add lowercase ndb/adb to list of readable noda repository names 2023-08-09 16:31:03 +02:00
7fb7bb83c1 Improve validation of noda repository links 2023-08-03 17:20:03 +02:00
c082ca685f Fix indentation 2023-07-31 19:42:21 +02:00
651362c65e Use correct function call for validating BNE IDs 2023-07-27 19:41:39 +02:00
9e44fcac49 Allow BNE IDs starting with XX 2023-07-27 19:24:16 +02:00
f5673c69fd Allow https links to the library of congress subject headings 2023-07-27 01:43:54 +02:00
0e86361968 Fix overly strict validation for npg, ndl 2023-07-25 22:33:57 +02:00
17f1e162f8 Add double quotes around invalid ID in error message given in
MDNodaLink
2023-07-25 22:31:18 +02:00
8090b95f49 Categorize event types 27, 28 (recorded, sung) 2023-07-24 14:30:06 +02:00
8e81d31466 Categorize event type 33 / "was mentioned" 2023-07-19 19:06:26 +02:00
f73c729dff Allow for non-numeric nomisma IDs 2023-07-19 15:59:13 +02:00
d47490f217 Categorize event type "first description" 2023-07-19 10:20:24 +02:00
8684933c9c Add function getUrlPrefix() to MDNodaRepository 2023-07-17 02:16:32 +02:00
06cc1d4c10 Split linkable noda repositories for IKMK / NDP for actors and places 2023-07-16 11:45:05 +02:00
1de413b3fb Update LICENSE date 2023-06-24 00:22:46 +02:00
b55ea34950 Update translation files 2023-06-01 16:50:57 +02:00
628acd4b53 Update translation files 2023-05-15 14:15:57 +02:00
f9366b686e Add tag relation type display_subject 2023-05-10 12:06:15 +02:00
c3d4f3f03a Fix type issues in PHPDoc comments 2023-05-07 23:37:57 +02:00
a437f1b57b Add MDTagRelationType 2023-05-07 23:24:00 +02:00
077eaeb3e3 Update translation files 2023-05-04 20:11:51 +02:00
9b6534de4e Update marking type sets, adding type "painted" 2023-04-25 16:29:14 +02:00
0698b6e487 Merge branch 'master' of gitea:museum-digital/MDAllowedValueSets 2023-04-16 19:42:27 +02:00
8e151e793f Closer approximate a fix for the validation of GND IDs 2023-04-16 19:41:55 +02:00
10aedafad1 Parse "GND" to MDNodaRepository::gnd 2023-04-16 03:23:23 +02:00
fbc50d8198 Finish writing list of search URLs for noda repositores 2023-04-16 02:56:48 +02:00
82a8805363 Fix bug in MDNodaRepository's fromString and toDbName 2023-04-16 02:45:56 +02:00
25f6694a92 Add enum MDNodaRepository and class MDNodaLink for the overarching data
structure
2023-04-16 02:06:11 +02:00
d090d82dc2 Add minimal phpstan config 2023-04-16 02:05:59 +02:00
81 changed files with 5434 additions and 103 deletions

View File

@ -1,6 +1,6 @@
MIT License 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -12,3 +12,7 @@ museum-digital.
## Enums ## 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). 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.

View 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.';
}
}

View 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.';
}
}

View 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

Submodule l18n updated: 8272c3c186...a7e3056f09

8
phpstan.neon Normal file
View File

@ -0,0 +1,8 @@
parameters:
level: 8
paths:
- src
scanDirectories:
- ../MDTlLoader
- ../MDErrorReporter
- ../MD_STD

14
phpunit.xml Normal file
View 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>

View File

@ -13,7 +13,7 @@ declare(strict_types = 1);
*/ */
final class MDActorVariantTypesSet extends MDValueSet { final class MDActorVariantTypesSet extends MDValueSet {
const ACTOR_VARIANT_TYPES = [ public const ACTOR_VARIANT_TYPES = [
'', '',
'birth_name', 'birth_name',
'civil_name', 'civil_name',

View File

@ -12,13 +12,13 @@ declare(strict_types = 1);
*/ */
final class MDAppointmentAttendanceModeSet extends MDValueSet { final class MDAppointmentAttendanceModeSet extends MDValueSet {
const MODES = [ public const MODES = [
'offline', 'offline',
'online', 'online',
'mixed', 'mixed',
]; ];
const MODES_TO_SCHEMA_ORG = [ public const MODES_TO_SCHEMA_ORG = [
'offline' => 'https://schema.org/OfflineEventAttendanceMode', 'offline' => 'https://schema.org/OfflineEventAttendanceMode',
'online' => 'https://schema.org/OnlineEventAttendanceMode', 'online' => 'https://schema.org/OnlineEventAttendanceMode',
'mixed' => 'https://schema.org/MixedEventAttendanceMode', 'mixed' => 'https://schema.org/MixedEventAttendanceMode',

View File

@ -12,7 +12,7 @@ declare(strict_types = 1);
*/ */
final class MDAppointmentContributorsSet extends MDValueSet { final class MDAppointmentContributorsSet extends MDValueSet {
const AVAILABLE_ROLES = [ public const AVAILABLE_ROLES = [
'organizer', 'organizer',
'presenter', 'presenter',
]; ];

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDAppointmentRecordingSet extends MDValueSet { final class MDAppointmentRecordingSet extends MDValueSet {
const AVAILABLE_RECORDING_TYPES = ['video']; public const AVAILABLE_RECORDING_TYPES = ['video'];
const EXTERNAL_SOURCES = ['Archive.org' => 'https://archive.org/details/']; public const EXTERNAL_SOURCES = ['Archive.org' => 'https://archive.org/details/'];
} }

View File

@ -11,14 +11,14 @@ declare(strict_types = 1);
*/ */
final class MDAppointmentStatusSet extends MDValueSet { final class MDAppointmentStatusSet extends MDValueSet {
const STATUS = [ public const STATUS = [
'scheduled', 'scheduled',
'cancelled', 'cancelled',
'moved_online', 'moved_online',
'postponed', 'postponed',
]; ];
const STATUS_TO_SCHEMA_ORG = [ public const STATUS_TO_SCHEMA_ORG = [
'scheduled' => 'https://schema.org/EventScheduled', 'scheduled' => 'https://schema.org/EventScheduled',
'cancelled' => 'https://schema.org/EventCancelled', 'cancelled' => 'https://schema.org/EventCancelled',
'moved_online' => 'https://schema.org/EventMovedOnline', 'moved_online' => 'https://schema.org/EventMovedOnline',

View File

@ -13,7 +13,7 @@ declare(strict_types = 1);
*/ */
final class MDBlockedMailserverSet extends MDValueSet { final class MDBlockedMailserverSet extends MDValueSet {
const BLOCKED_DOMAINS = [ public const BLOCKED_DOMAINS = [
"@magenta.de", "@magenta.de",
"@t-online.de", "@t-online.de",
]; ];

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDCloserLocationTypesSet extends MDValueSet { final class MDCloserLocationTypesSet extends MDValueSet {
const CLOSER_LOCATION_TYPES = [ public const CLOSER_LOCATION_TYPES = [
"0", // '' "0", // ''
"1", // Place of recording "1", // Place of recording
"2", // Place of finding "2", // Place of finding

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDColorsSet extends MDValueSet { final class MDColorsSet extends MDValueSet {
const COLOR_NAMES = [ public const COLOR_NAMES = [
"black", "black",
"green", "green",
"silver", "silver",
@ -30,7 +30,7 @@ final class MDColorsSet extends MDValueSet {
"aqua", "aqua",
]; ];
const COLOR_NAMES_AND_EMPTY = [ public const COLOR_NAMES_AND_EMPTY = [
'', '',
"black", "black",
"green", "green",
@ -50,7 +50,7 @@ final class MDColorsSet extends MDValueSet {
"aqua", "aqua",
]; ];
const COLORS_RGB = [ public const COLORS_RGB = [
"black" => [0, 0, 0], "black" => [0, 0, 0],
"green" => [0, 128, 0], "green" => [0, 128, 0],
"silver" => [192, 192, 192], "silver" => [192, 192, 192],

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDConservationReportTypeSet extends MDValueSet { final class MDConservationReportTypeSet extends MDValueSet {
const REPORT_TYPES = [ public const REPORT_TYPES = [
'damage', 'damage',
'conservation', 'conservation',
'condition', 'condition',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDConservationStatusSet extends MDValueSet { final class MDConservationStatusSet extends MDValueSet {
const STATUS_LEVELS = [ public const STATUS_LEVELS = [
1 => '', 1 => '',
34 => 'markedBad', 34 => 'markedBad',
67 => 'markedMedium', 67 => 'markedMedium',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDCurrenciesSet extends MDValueSet { final class MDCurrenciesSet extends MDValueSet {
const CURRENCIES = [ public const CURRENCIES = [
'', '',
'by-BYN', 'by-BYN',
'ch-CHF', // Swiss Franc 'ch-CHF', // Swiss Franc
@ -31,6 +31,7 @@ final class MDCurrenciesSet extends MDValueSet {
'ru-RUB', 'ru-RUB',
'su-SUR', 'su-SUR',
'ua-UAH', 'ua-UAH',
'ua-UAK',
'uk-GBP', 'uk-GBP',
'us-USD', 'us-USD',
]; ];

View File

@ -12,7 +12,7 @@ declare(strict_types = 1);
*/ */
final class MDDataHistorySubjectsSet extends MDValueSet { final class MDDataHistorySubjectsSet extends MDValueSet {
const AVAILABLE_SUBJECTS = [ public const AVAILABLE_SUBJECTS = [
'appointment', 'appointment',
'collection', 'collection',
'contact', 'contact',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDDisposalMethodSet extends MDValueSet { final class MDDisposalMethodSet extends MDValueSet {
const METHODS = [ public const METHODS = [
'', '',
'sold', 'sold',
'destroyed', 'destroyed',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDEntryTypesSet extends MDValueSet { final class MDEntryTypesSet extends MDValueSet {
const ENTRY_TYPES = [ public const ENTRY_TYPES = [
'0', // '0', //
'1', // Schenkung '1', // Schenkung
'2', // Kauf '2', // Kauf

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDEventsSet extends MDValueSet { final class MDEventsSet extends MDValueSet {
const EVENT_IDS = [ public const EVENT_IDS = [
'1', // => Created '1', // => Created
'2', // => Found '2', // => Found
'3', // => Published '3', // => Published
@ -48,8 +48,8 @@ final class MDEventsSet extends MDValueSet {
'36', // => Was depicted '36', // => Was depicted
'37', // => Painted on '37', // => Painted on
'38', // => Illustrated '38', // => Illustrated
'39', // "wurde zusammengefügt" (Finale Herstellung, z.B. Bild in Rahmen, Montage eines Omnibusses) '39', // => Assembled / "wurde zusammengefügt" (Finale Herstellung, z.B. Bild in Rahmen, Montage eines Omnibusses)
'40', // "wurde versteigert" (Objekt war im Auktionshandel) '40', // => Auctioned "wurde versteigert" (Objekt war im Auktionshandel)
'41', // "wurde gekauft" (Hier kann man jeden Kauf des Objektes vermerken) '41', // "wurde gekauft" (Hier kann man jeden Kauf des Objektes vermerken)
'42', // "wurde besessen" (Hier kann man jeden Besitz 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) '43', // "wurde verkauft" (Hier kann man jeden Verkauf des Objektes vermerken)
@ -60,29 +60,36 @@ final class MDEventsSet extends MDValueSet {
'48', // "wurde herausgegeben" '48', // "wurde herausgegeben"
'49', // "gespendet / verschenkt" '49', // "gespendet / verschenkt"
'50', // "vererbt" '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 // 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 // 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 // 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 // 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 * Constants for event types without places, times, actors
*/ */
const EVENTS_NO_TIME = [5, 22, 23, 36]; public const EVENTS_NO_TIME = [5, 22, 23, 33, 36];
const EVENTS_NO_ACTOR = [21, 22, 24, 36]; public const EVENTS_NO_ACTOR = [21, 22, 24, 36, 52];
const EVENTS_NO_PLACE = [5, 23, 24]; public const EVENTS_NO_PLACE = [5, 23, 24, 33];
/** /**
* Gets a list of the entries in a translated version. * 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"); 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;
}
} }

View File

@ -12,7 +12,7 @@ declare(strict_types = 1);
*/ */
final class MDExhibitionContributorsSet extends MDValueSet { final class MDExhibitionContributorsSet extends MDValueSet {
const AVAILABLE_ROLES = [ public const AVAILABLE_ROLES = [
'concept', 'concept',
'curator', 'curator',
'design', 'design',

View File

@ -11,9 +11,9 @@ declare(strict_types = 1);
*/ */
final class MDExternalHostingSet extends MDValueSet { 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', 'Archive.org',
]; ];

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDGenderSet extends MDValueSet { final class MDGenderSet extends MDValueSet {
const GENDERS = [ public const GENDERS = [
'', '',
'female', 'female',
'male', 'male',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDLanguagesSet { final class MDLanguagesSet {
const AVAILABLE_LANGUAGES_SHORT = [ public const AVAILABLE_LANGUAGES_SHORT = [
'aa', 'aa',
'ab', 'ab',
'ae', 'ae',
@ -39,6 +39,7 @@ final class MDLanguagesSet {
'ch', 'ch',
'co', 'co',
'cr', 'cr',
'crh',
'cs', 'cs',
'cu', 'cu',
'cv', 'cv',
@ -129,6 +130,7 @@ final class MDLanguagesSet {
'na', 'na',
'nb', 'nb',
'nd', 'nd',
'nds',
'ne', 'ne',
'ng', 'ng',
'nl', 'nl',
@ -143,6 +145,7 @@ final class MDLanguagesSet {
'or', 'or',
'os', 'os',
'pa', 'pa',
'pdt',
'pi', 'pi',
'pl', 'pl',
'ps', 'ps',
@ -203,7 +206,7 @@ final class MDLanguagesSet {
'zu', 'zu',
]; ];
const AVAILABLE_LANGUAGES = [ public const AVAILABLE_LANGUAGES = [
'aa' => 'Afar-áf', 'aa' => 'Afar-áf',
'ab' => 'аҧсуа бызшәа', 'ab' => 'аҧсуа бызшәа',
'ae' => 'Avestan', 'ae' => 'Avestan',
@ -231,6 +234,7 @@ final class MDLanguagesSet {
'ch' => 'Chamorro', 'ch' => 'Chamorro',
'co' => 'Corsican', 'co' => 'Corsican',
'cr' => 'Cree', 'cr' => 'Cree',
'crh' => 'Qırımtatar tili',
'cs' => 'čeština', 'cs' => 'čeština',
'cu' => 'словѣньскъ ѩзыкъ', 'cu' => 'словѣньскъ ѩзыкъ',
'cv' => 'Chuvash', 'cv' => 'Chuvash',
@ -291,7 +295,7 @@ final class MDLanguagesSet {
'kk' => 'Kazakh', 'kk' => 'Kazakh',
'kl' => 'Kalaallisut, Greenlandic', 'kl' => 'Kalaallisut, Greenlandic',
'km' => 'Khmer', 'km' => 'Khmer',
'kn' => 'Kannada', 'kn' => 'ಕನ್ನಡ',
'ko' => 'Korean', 'ko' => 'Korean',
'kr' => 'Kanuri', 'kr' => 'Kanuri',
'ks' => 'Kashmiri', 'ks' => 'Kashmiri',
@ -321,6 +325,7 @@ final class MDLanguagesSet {
'na' => 'Nauru', 'na' => 'Nauru',
'nb' => 'Bokmål', 'nb' => 'Bokmål',
'nd' => 'North Ndebele', 'nd' => 'North Ndebele',
'nds' => 'Niederdeutsch',
'ne' => 'Nepali', 'ne' => 'Nepali',
'ng' => 'Ndonga', 'ng' => 'Ndonga',
'nl' => 'Nederlands', 'nl' => 'Nederlands',
@ -335,6 +340,7 @@ final class MDLanguagesSet {
'or' => 'Oriya', 'or' => 'Oriya',
'os' => 'Ossetian, Ossetic', 'os' => 'Ossetian, Ossetic',
'pa' => 'Panjabi, Punjabi', 'pa' => 'Panjabi, Punjabi',
'pdt' => 'Plautdietsch',
'pi' => 'Pali', 'pi' => 'Pali',
'pl' => 'Polski', 'pl' => 'Polski',
'ps' => 'Pashto, Pushto', 'ps' => 'Pashto, Pushto',
@ -395,7 +401,7 @@ final class MDLanguagesSet {
'zu' => 'Zulu', 'zu' => 'Zulu',
]; ];
const LANGUAGES_ISO639_2B = [ public const LANGUAGES_ISO639_2B = [
'aa' => 'aar', # 'Afar-áf', 'aa' => 'aar', # 'Afar-áf',
'ab' => 'abk', # 'аҧсуа бызшәа', 'ab' => 'abk', # 'аҧсуа бызшәа',
'ae' => 'ave', # 'Avestan', 'ae' => 'ave', # 'Avestan',
@ -423,6 +429,7 @@ final class MDLanguagesSet {
'ch' => 'cha', # 'Chamorro', 'ch' => 'cha', # 'Chamorro',
'co' => 'cos', # 'Corsican', 'co' => 'cos', # 'Corsican',
'cr' => 'cre', # 'Cree', 'cr' => 'cre', # 'Cree',
'crh' => 'crh', # 'Crimean Tatar',
'cs' => 'cze', # 'čeština', 'cs' => 'cze', # 'čeština',
'cu' => 'chu', # 'словѣньскъ ѩзыкъ', 'cu' => 'chu', # 'словѣньскъ ѩзыкъ',
'cv' => 'chv', # 'Chuvash', 'cv' => 'chv', # 'Chuvash',
@ -513,6 +520,7 @@ final class MDLanguagesSet {
'na' => 'nau', # 'Nauru', 'na' => 'nau', # 'Nauru',
'nb' => 'nob', # 'Bokmål', 'nb' => 'nob', # 'Bokmål',
'nd' => 'nde', # 'North Ndebele', 'nd' => 'nde', # 'North Ndebele',
'nds' => 'nds', # 'Niederdeutsch',
'ne' => 'nep', # 'Nepali', 'ne' => 'nep', # 'Nepali',
'ng' => 'ndo', # 'Ndonga', 'ng' => 'ndo', # 'Ndonga',
'nl' => 'dut', # 'Nederlands', 'nl' => 'dut', # 'Nederlands',
@ -527,6 +535,7 @@ final class MDLanguagesSet {
'or' => 'ori', # 'Oriya', 'or' => 'ori', # 'Oriya',
'os' => 'oss', # 'Ossetian, Ossetic', 'os' => 'oss', # 'Ossetian, Ossetic',
'pa' => 'pan', # 'Panjabi, Punjabi', 'pa' => 'pan', # 'Panjabi, Punjabi',
'pdt' => 'pdt', # Plautdietsch
'pi' => 'pli', # 'Pali', 'pi' => 'pli', # 'Pali',
'pl' => 'pol', # 'Polish', 'pl' => 'pol', # 'Polish',
'ps' => 'pus', # 'Pashto, Pushto', 'ps' => 'pus', # 'Pashto, Pushto',

View File

@ -11,10 +11,10 @@ declare(strict_types = 1);
*/ */
final class MDLicensesSet extends MDValueSet { final class MDLicensesSet extends MDValueSet {
const DEFAULT_LICENSE_IMGS = 'CC BY-NC-SA'; public const DEFAULT_LICENSE_IMGS = 'CC BY-NC-SA';
const DEFAULT_LICENSE_METADATA = '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-SA',
'CC BY-NC-ND', '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-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-ND' => 'https://creativecommons.org/licenses/by-nc-nd/4.0/',

View File

@ -11,9 +11,9 @@ declare(strict_types = 1);
*/ */
final class MDLoanTypesSet extends MDValueSet { final class MDLoanTypesSet extends MDValueSet {
const DEFAULT_LOAN_TYPE = 'outgoing'; public const DEFAULT_LOAN_TYPE = 'outgoing';
const LOAN_TYPES = [ public const LOAN_TYPES = [
'outgoing', 'outgoing',
'incoming', 'incoming',
]; ];

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDMarkingTypesSet extends MDValueSet { final class MDMarkingTypesSet extends MDValueSet {
const MARKING_TYPES = [ public const MARKING_TYPES = [
'signature', 'signature',
'engraving', 'engraving',
'watermark', 'watermark',
@ -31,6 +31,8 @@ final class MDMarkingTypesSet extends MDValueSet {
'cast', 'cast',
'sewn', 'sewn',
'glued', 'glued',
'painted',
'drawn',
]; ];
/** /**

View 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;
}

View File

@ -11,19 +11,19 @@ declare(strict_types = 1);
*/ */
final class MDNodaRepositoriesSet extends MDValueSet { final class MDNodaRepositoriesSet extends MDValueSet {
const REPOSITORIES_ACTOR = [ public const REPOSITORIES_ACTOR = [
'allgemein', 'allgemein',
'bne', 'bne',
'bnf', 'bnf',
'edition humboldt digital', 'edition humboldt digital',
'gnd', 'gnd',
'iconclass', 'iconclass',
'kl-bb',
'lcsh', 'lcsh',
'loc', 'loc',
'MBL',
'NDB/ADB', 'NDB/ADB',
'ndl', 'ndl',
'ndp-ikmk', 'ndp-ikmk-persons',
'nomisma', 'nomisma',
'npg', 'npg',
'orcid', 'orcid',
@ -32,10 +32,9 @@ final class MDNodaRepositoriesSet extends MDValueSet {
'ulan', 'ulan',
'viaf', 'viaf',
'wikidata', 'wikidata',
'Wikipedia',
]; ];
const REPOSITORIES_PLACE = [ public const REPOSITORIES_PLACE = [
'allgemein', 'allgemein',
'bne', 'bne',
'bnf', 'bnf',
@ -52,10 +51,9 @@ final class MDNodaRepositoriesSet extends MDValueSet {
'rkd', 'rkd',
'viaf', 'viaf',
'wikidata', 'wikidata',
'Wikipedia',
]; ];
const REPOSITORIES_TAG = [ public const REPOSITORIES_TAG = [
'aat', 'aat',
'ackerbau', 'ackerbau',
'allgemein', 'allgemein',
@ -75,7 +73,6 @@ final class MDNodaRepositoriesSet extends MDValueSet {
'rkd', 'rkd',
'viaf', 'viaf',
'wikidata', 'wikidata',
'Wikipedia',
]; ];
} }

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDObjectFormSet extends MDValueSet { final class MDObjectFormSet extends MDValueSet {
const FORMS = [ public const FORMS = [
'', '',
'cube', 'cube',
'cuboid', 'cuboid',

View File

@ -11,8 +11,13 @@ declare(strict_types = 1);
*/ */
final class MDObjectPositionsSet extends MDValueSet { final class MDObjectPositionsSet extends MDValueSet {
const POSITIONS = [ public const POSITIONS = [
'left', 'top_left', 'top', 'top_right', 'right', 'bottom_right', 'bottom', 'bottom_left', 'center', 'rear_side', 'edge', 'other', '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',
]; ];
/** /**

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDObjectPublicationBackgrounds extends MDValueSet { final class MDObjectPublicationBackgrounds extends MDValueSet {
const PUBLICATION_BACKGROUNDS = [ public const PUBLICATION_BACKGROUNDS = [
'0', // Image published '0', // Image published
'1', // Transcript published '1', // Transcript published
'2', // Discussed '2', // Discussed

View File

@ -11,9 +11,9 @@ declare(strict_types = 1);
*/ */
final class MDObjectStatusSet extends MDValueSet { final class MDObjectStatusSet extends MDValueSet {
const DEFAULT_OBJECT_STATUS = 'owned'; public const DEFAULT_OBJECT_STATUS = 'owned';
const OBJECT_STATUS = [ public const OBJECT_STATUS = [
'owned', 'owned',
'permanent_loan', 'permanent_loan',
'third_party_property', 'third_party_property',

View File

@ -12,7 +12,7 @@ declare(strict_types = 1);
*/ */
final class MDObjectSyndicationSet extends MDValueSet { final class MDObjectSyndicationSet extends MDValueSet {
const REPOSITORIES = [ public const REPOSITORIES = [
'ddb' => [ 'ddb' => [
'url' => 'https://www.deutsche-digitale-bibliothek.de/', 'url' => 'https://www.deutsche-digitale-bibliothek.de/',

View File

@ -17,9 +17,9 @@ declare(strict_types = 1);
*/ */
final class MDPhoneTypesSet extends MDValueSet { final class MDPhoneTypesSet extends MDValueSet {
const DEFAULT_PHONE_TYPE = 'work'; public const DEFAULT_PHONE_TYPE = 'work';
const PHONE_TYPES = [ public const PHONE_TYPES = [
'work', 'work',
'home', 'home',
'mobile', 'mobile',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDPlacetypesSet extends MDValueSet { final class MDPlacetypesSet extends MDValueSet {
const PLACE_TYPE_IDS = [ public const PLACE_TYPE_IDS = [
'0', // => Administrativ '0', // => Administrativ
'1', // => Historisch '1', // => Historisch
'2', // => Region - Landschaft - Naturpark '2', // => Region - Landschaft - Naturpark

View File

@ -12,7 +12,7 @@ declare(strict_types = 1);
*/ */
final class MDPodcastContributorsSet extends MDValueSet { final class MDPodcastContributorsSet extends MDValueSet {
const AVAILABLE_ROLES = [ public const AVAILABLE_ROLES = [
'onair', 'onair',
'organization', 'organization',
'recording', 'recording',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDProcessTypesSet extends MDValueSet { final class MDProcessTypesSet extends MDValueSet {
const TYPES = [ public const TYPES = [
'project', 'project',
'grant_application', 'grant_application',
'exhibition', 'exhibition',

View File

@ -11,9 +11,9 @@ declare(strict_types = 1);
*/ */
final class MDRecordingTypesSet extends MDValueSet { final class MDRecordingTypesSet extends MDValueSet {
const DEFAULT_RECORDING_TYPE = 'audio'; public const DEFAULT_RECORDING_TYPE = 'audio';
const RECORDING_TYPES = [ public const RECORDING_TYPES = [
'audio', 'audio',
'video', 'video',
]; ];

View File

@ -15,41 +15,48 @@ final class MDRequirementsSet {
// the given timespan. If they are not, the account will be ignored // the given timespan. If they are not, the account will be ignored
// and deleted. // and deleted.
// 60 * 60 * 24 * 6 = 518400. 6 days. // 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 // 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 // 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; public const MAX_FILESIZE_PDF = 20000000;
const TIME_LATEST_YEAR = 2099;
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']; public const MIMETYPES_USER_PROFILE_IMG = ['image/jpeg', 'image/jpg'];
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'];
const MIMETYPES_COLLECTION_IMAGE = ['image/jpeg', 'image/jpg']; public const MIMETYPES_OBJECT_IMAGE = ['image/jpeg', 'image/jpg', 'image/png', 'image/webp'];
const MIMETYPES_INSTITUTION_IMAGE = ['image/jpeg', 'image/jpg']; public const MIMETYPES_OBJECT_PDF = ['application/pdf'];
const MIMETYPES_EXHIBITION_IMAGE = ['image/jpeg', 'image/jpg', 'image/png']; 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']; public const MIMETYPES_COLLECTION_IMAGE = ['image/jpeg', 'image/jpg'];
const MIMETYPES_APPOINTMENT_DOC_ASSET = ['application/pdf', 'image/jpeg', 'image/jpg', 'image/png']; 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']; public const MIMETYPES_ARTICLE_ASSET = ['image/jpeg', 'image/jpg', 'image/png'];
const MIMETYPES_PODCAST_EPISODE_IMAGE = ['image/jpeg', 'image/jpg'];
const MIMETYPES_TOUR_IMAGE = ['image/jpeg', 'image/jpg'];
const MIMETYPES_CATALOGUE_WORK_IMAGE = ['image/jpeg', 'image/jpg']; public const MIMETYPES_APPOINTMENT_IMAGE = ['image/jpeg', 'image/jpg'];
const MIMETYPES_CATALOGUE_OBJECT_SUMMARY_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'];
} }

View File

@ -14,7 +14,7 @@ declare(strict_types = 1);
*/ */
final class MDResearchStatusSet extends MDValueSet { final class MDResearchStatusSet extends MDValueSet {
const RESEARCH_STATUS = [ public const RESEARCH_STATUS = [
'bad', 'bad',
'medium', 'medium',
'good', 'good',

173
src/MDSourceType.php Normal file
View 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;
}
}

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDSourceTypeSet extends MDValueSet { final class MDSourceTypeSet extends MDValueSet {
const SOURCE_TYPES = [ public const SOURCE_TYPES = [
'article', 'article',
'inbook', 'inbook',
'book', 'book',

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDSpaceAccessStatusSet extends MDValueSet { final class MDSpaceAccessStatusSet extends MDValueSet {
const STATUS = [ public const STATUS = [
'enter', 'enter',
'leave', 'leave',
]; ];

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDSpaceTypesSet extends MDValueSet { final class MDSpaceTypesSet extends MDValueSet {
const TYPES = [ public const TYPES = [
'building', 'building',
'floor', 'floor',
'depot', 'depot',
@ -23,6 +23,7 @@ final class MDSpaceTypesSet extends MDValueSet {
'shelf', 'shelf',
'box', 'box',
'folder', 'folder',
'outdoor_area',
]; ];
/** /**

View File

@ -11,7 +11,7 @@ declare(strict_types = 1);
*/ */
final class MDTitleTypesSet extends MDValueSet { final class MDTitleTypesSet extends MDValueSet {
const TITLE_TYPES = [ public const TITLE_TYPES = [
"", "",
"Science", "Science",
"Everyday speech", "Everyday speech",

View File

@ -11,10 +11,10 @@ declare(strict_types = 1);
*/ */
final class MDUnitsSet extends MDValueSet { final class MDUnitsSet extends MDValueSet {
const UNITS_LENGTH = ['', 'm', 'dm', 'cm', 'mm', 'ft', 'in']; public const UNITS_LENGTH = ['', 'm', 'dm', 'cm', 'mm', 'ft', 'in'];
const UNITS_WEIGHT = ['', 't', 'kg', 'g']; public const UNITS_WEIGHT = ['', 't', 'kg', 'g'];
const UNITS_LENGTH_TO_MILLIMETER = [ public const UNITS_LENGTH_TO_MILLIMETER = [
'm' => 1000, 'm' => 1000,
'ft' => 304.8, 'ft' => 304.8,
'dm' => 100, 'dm' => 100,
@ -23,7 +23,7 @@ final class MDUnitsSet extends MDValueSet {
'mm' => 1, 'mm' => 1,
]; ];
const UNITS_WEIGHT_TO_GRAMM = [ public const UNITS_WEIGHT_TO_GRAMM = [
't' => 1000000, 't' => 1000000,
'kg' => 1000, 'kg' => 1000,
'g' => 1, 'g' => 1,

View 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;
}
}

View File

@ -0,0 +1,45 @@
<?PHP
/**
* Describes a reference to an external norm data repository.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Describes a reference to an external norm data repository.
*/
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.
*
* @param MDNodaRepository $source Source repository.
* @param string $id ID.
*
* @return void
*/
public function __construct(MDNodaRepository $source, string $id) {
$this->source = $source;
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;
}
}

1
src/classes/README.md Normal file
View File

@ -0,0 +1 @@
# Full-scale data types that provide further functionality but end up representing base data types

View 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;
}
}

View 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;
}
}

View 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
View 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;
}
}

View 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
View 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();
}
}

View 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;
}
}

View 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;
}
}

View File

@ -14,11 +14,11 @@ enum MDInstitutionExternalIdRepository implements MDValueEnumInterface, JsonSeri
case hu_ksh; // https://en.wikipedia.org/wiki/Hungarian_Central_Statistical_Office 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}', '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}$/', 'hu_ksh' => '/^[0-9]{8}-[0-9]{4}-[0-9]{3}-[0-9]{2}$/',
]; ];

View 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;
}
}

View 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
View 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
View 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
View 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;
}
}

View 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;
}
}

View File

@ -0,0 +1,801 @@
<?PHP
/**
* Represents an external norm data repository.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Represents an external norm data repository.
*/
enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
case allgemein; // General link to a good source
case aat;
case ackerbau;
case bne;
case bnf;
case cona;
case editionhumboldtdigital;
case gnd;
case grobsystematik;
case iconclass;
case klbb;
case lcsh;
case loc; // Duplicate?
case mindatorg;
case moebeltypologie;
case ndb_adb;
case ndl;
case ndp_ikmk;
case ndp_ikmk_persons;
case nomisma;
case npg;
case oberbegriffsdatei;
case orcid;
case osm;
case pim;
case pleiades;
case rkd;
case ulan;
case viaf;
case wikidata;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDNodaRepository
*/
public static function fromString(string $input):MDNodaRepository {
return match($input) {
'allgemein' => self::allgemein, // General link to a good source
'AAT-ID',
'aat' => self::aat,
'ackerbau' => self::ackerbau,
'bne' => self::bne,
'bnf' => self::bnf,
'cona' => self::cona,
'edition humboldt digital' => self::editionhumboldtdigital,
'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?
'mindat.org' => self::mindatorg,
'moebeltypologie' => self::moebeltypologie,
'ndb/adb',
'NDB/ADB' => self::ndb_adb,
'ndl' => self::ndl,
'ndp-ikmk' => self::ndp_ikmk,
'ndp-ikmk-persons' => self::ndp_ikmk_persons,
'nomisma',
'nomisma.org' => self::nomisma,
'npg' => self::npg,
'oberbegriffsdatei' => self::oberbegriffsdatei,
'orcid' => self::orcid,
'osm' => self::osm,
'pim' => self::pim,
'pleiades' => self::pleiades,
'rkd' => self::rkd,
'ulan' => self::ulan,
'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.
*
* @return string
*/
public function toDbName():string {
return match($this) {
self::allgemein => 'allgemein', // General link to a good source
self::aat => 'aat',
self::ackerbau => 'ackerbau',
self::bne => 'bne',
self::bnf => 'bnf',
self::cona => 'cona',
self::editionhumboldtdigital => 'edition humboldt digital',
self::gnd => 'gnd',
self::grobsystematik => 'grobsystematik',
self::iconclass => 'iconclass',
self::klbb => 'kl-bb',
self::lcsh => 'lcsh',
self::loc => 'loc',
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',
self::orcid => 'orcid',
self::osm => 'osm',
self::pim => 'pim',
self::pleiades => 'pleiades',
self::rkd => 'rkd',
self::ulan => 'ulan',
self::viaf => 'viaf',
self::wikidata => '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/',
};
}
/**
* Returns the base of the repository's entity page URLs.
*
* @param string $id Identifier to link to.
*
* @return string
*/
public function getEntityLink(string $id):string {
return match ($this) {
self::ndb_adb => 'https://www.deutsche-biographie.de/pnd' . $id . '.html',
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&note=',
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.
*
* @param string $id ID to validate.
* @param string[] $prefixes Prefixes to strip off.
*
* @return string|false
*/
private static function validateNumericId(string $id, array $prefixes):string|false {
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
$toRemove = [];
foreach ($prefixes as $prefix) {
$toRemove[$prefix] = "";
}
$id = trim(strtr($id, $toRemove), '/');
}
if (!self::_is_numeric($id)) {
return false;
}
return $id;
}
/**
* Validates a iconclass ID, returning a string or false.
*
* @param string $id ID to validate.
*
* @return string|false
*/
private static function validateIconclassId(string $id):string|false {
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
$id = strtr($id, ['http://iconclass.org/rkd/' => '', 'http://iconclass.org/' => '', 'https://iconclass.org/' => '']);
}
if (preg_match("/^[0-9a-z\/]*$/", $id) === false) return false;
return $id;
}
/**
* 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.
*
* @param string $id ID to validate.
* @param string[] $prefixes Prefixes to strip off.
*
* @return string|false
*/
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);
}
// 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;
}
/**
* Validates a Library of Congress name ID, returning a string or false.
*
* @param string $id ID to validate.
*
* @return string|false
*/
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/' => '',
'https://id.loc.gov/authorities/names/' => '',
'http://id.loc.gov/authorities/subjects/' => '',
'https://id.loc.gov/authorities/subjects/' => '',
]);
}
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;
}
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 (string)$id;
}
/**
* Validates a LCSH ID, returning a string or false.
*
* @param string $id ID to validate.
*
* @return string|false
*/
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/' => '',
'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') {
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) {
return false;
}
return $id;
}
/**
* 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.
*
* @param string $id ID to validate.
*
* @return string|false
*/
private static function validateWikidataId(string $id):string|false {
if (filter_var($id, FILTER_VALIDATE_URL) !== false) {
$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 MDInvalidNodaLinkException("Wikidata IDs must be Q IDs - and start with that letter (provided: $id)");
}
if (self::_is_numeric(substr($id, 1)) === false) {
return false;
}
return $id;
}
/**
* 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.
*
* @param string $id Identifier to link to.
*
* @return string|false
*/
public function validateId(string $id):string|false {
return match($this) {
self::allgemein => filter_var($id, FILTER_VALIDATE_URL),
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::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, ['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::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', '#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 => self::validateOrcidId($id),
self::osm => self::validateNumericId($id, ['https://www.openstreetmap.org/relation/']),
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/',
'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),
};
}
/**
* 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(), "attendance_status_set", "attendance_status_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(), "attendance_status_set", "attendance_status_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("attendance_status_set", "attendance_status_set", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}

View File

@ -14,6 +14,7 @@ enum MDObjectCheckType implements MDValueEnumInterface, JsonSerializable {
case condition_check; case condition_check;
case completeness_check; case completeness_check;
case data_correctness_check; case data_correctness_check;
case location_accuracy_check;
/** /**
* Returns a value of this type based on a string. * Returns a value of this type based on a string.
@ -28,6 +29,7 @@ enum MDObjectCheckType implements MDValueEnumInterface, JsonSerializable {
'condition_check' => self::condition_check, 'condition_check' => self::condition_check,
'completeness_check' => self::completeness_check, 'completeness_check' => self::completeness_check,
'data_correctness_check' => self::data_correctness_check, 'data_correctness_check' => self::data_correctness_check,
'location_accuracy_check' => self::location_accuracy_check,
default => throw new MDpageParameterNotFromListException("Unknown check type"), default => throw new MDpageParameterNotFromListException("Unknown check type"),
}; };

View File

@ -13,6 +13,7 @@ enum MDObjectDamageType implements MDValueEnumInterface, JsonSerializable {
case water_damage; case water_damage;
case breakage; case breakage;
case desiccation;
/** /**
* Returns a value of this type based on a string. * Returns a value of this type based on a string.
@ -26,6 +27,7 @@ enum MDObjectDamageType implements MDValueEnumInterface, JsonSerializable {
return match($input) { return match($input) {
'water_damage' => self::water_damage, 'water_damage' => self::water_damage,
'breakage' => self::breakage, 'breakage' => self::breakage,
'desiccation' => self::desiccation,
default => throw new MDpageParameterNotFromListException("Unknown damage type"), default => throw new MDpageParameterNotFromListException("Unknown damage type"),
}; };

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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
View 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;
}
}

View 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
View 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;
}
}
});