18 Commits

Author SHA1 Message Date
jrenslin 7f882de3ae Fix 2026-06-04 00:42:16 +02:00
jrenslin d255317d84 Add controlled lists for recording types and accepted hosters 2026-06-03 23:23:12 +02:00
jrenslin 834d06b70a Fix bug in BNF ID validation 2026-06-01 13:43:42 +02:00
jrenslin 8a1c33fbc3 Update translation files 2026-05-31 18:01:44 +02:00
jrenslin c693fff212 Add MDAppointmentImageCategory
See museum-digital/musdb#1526
2026-05-31 18:00:58 +02:00
jrenslin bb4640ae2c Add MDAppointmentContributorRole 2026-05-21 15:06:43 +02:00
jrenslin a01cf57162 Support parsing IDs from VIAF's German interface URLs 2026-05-19 18:54:47 +02:00
jrenslin 88c357c00f Add measurement types for box and general packaging sizes 2026-05-15 22:55:56 +02:00
jrenslin 07434d41b1 Fix unhandled match cases 2026-05-15 20:12:35 +02:00
jrenslin 9a45e7bbf4 Add sizes of image mount, plate 2026-05-15 18:16:02 +02:00
jrenslin 51ae4c4737 Add list of ownership events 2026-05-08 16:57:12 +02:00
jrenslin 49ebf6fd63 Extend transformable string representations of MDGender 2026-05-04 10:15:38 +02:00
jrenslin 28ca68d0d7 Actually implement getTledName in MDNodaRepository 2026-05-03 20:34:05 +02:00
jrenslin c680cd0f9a Add measurement types for length/width/height of handle, label, scabbard 2026-04-29 14:52:57 +02:00
jrenslin efbb62c6ae Add ENUM for ASC/DESC sort order 2026-04-20 10:24:08 +02:00
jrenslin 2fc774430c Update translation files 2026-04-16 14:21:12 +02:00
jrenslin 611e0bf54f Update translation files 2026-04-14 19:03:06 +02:00
jrenslin a93d763ebb Update translation files 2026-04-09 22:36:23 +02:00
12 changed files with 745 additions and 12 deletions
+1 -1
Submodule l18n updated: ca88e040b6...38eb44046b
+3
View File
@@ -84,6 +84,9 @@ final class MDEventsSet extends MDValueSet {
// Array enthält Ereignistypen, die auf Korrespondenzen hinweisen
public const EVENTS_CORRESPONDENCE = [11, 13];
// List of array types that contain ownership information.
public const EVENTS_OWNERSHIP_RELATED = [40, 41, 42, 43, 49, 50, 56, 57, 58];
/*
* Constants for event types without places, times, actors
*/
+162
View File
@@ -0,0 +1,162 @@
<?PHP
/**
* Represents a type of contribution to an appointment.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
* Represents a type of contribution to an appointment.
*/
enum MDAppointmentContributorRole implements MDValueEnumInterface, JsonSerializable {
case organizer;
case presenter;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppointmentContributorRole
*/
public static function fromString(string $input):MDAppointmentContributorRole {
return match($input) {
"organizer" => self::organizer,
"presenter" => self::presenter,
default => throw new MDpageParameterNotFromListException("Unknown appointment contributor role"),
};
}
/**
* Returns a value of this type based on an integer.
*
* @param integer $input Input to get a value from.
*
* @return MDAppointmentContributorRole
*/
public static function fromInt(int $input):MDAppointmentContributorRole {
return match($input) {
0 => self::organizer,
1 => self::presenter,
default => throw new MDpageParameterNotFromListException("Unknown appointment 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(), "appointment_contributor_roles", "appointment_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(), "appointment_contributor_roles", "appointment_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::organizer => 0,
self::presenter => 1,
};
}
/**
* Returns canonical string representation of object record status.
*
* @return string
*/
public function toString():string {
return match($this) {
self::organizer => 'organizer',
self::presenter => 'presenter',
};
}
/**
* 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("appointment_contributor_roles", "appointment_contributor_roles", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}
+94
View File
@@ -0,0 +1,94 @@
<?PHP
declare(strict_types = 1);
/**
* Represents a type of appointment documentation image.
*/
enum MDAppointmentImageCategory implements MDValueEnumInterface, JsonSerializable {
case advertising_material;
case photo_documentation;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppointmentImageCategory
*/
public static function fromString(string $input):MDAppointmentImageCategory {
return match($input) {
'advertising_material' => self::advertising_material,
'photo_documentation' => self::photo_documentation,
default => throw new MDpageParameterNotFromListException("Unknown attendance 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(), "appointment_image_category", "appointment_image_category");
}
/**
* 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(), "appointment_image_category", "appointment_image_category");
}
/**
* 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("appointment_image_category", "appointment_image_category", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}
+104
View File
@@ -0,0 +1,104 @@
<?PHP
declare(strict_types = 1);
/**
* Represents an allowed hoster for videos of events.
*/
enum MDAppointmentRecordingHoster implements MDValueEnumInterface, JsonSerializable {
case archive_org;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppointmentRecordingHoster
*/
public static function fromString(string $input):MDAppointmentRecordingHoster {
return match($input) {
'archive_org' => self::archive_org,
'Archive.org' => self::archive_org,
default => throw new MDpageParameterNotFromListException("Unknown hoster"),
};
}
/**
* To string.
*
* @return string
*/
public function toString():string {
return match($this) {
self::archive_org => 'Archive.org',
};
}
/**
* 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(), "appointment_recording_hoster", "appointment_recording_hoster");
}
/**
* 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(), "appointment_recording_hoster", "appointment_recording_hoster");
}
/**
* 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("appointment_recording_hoster", "appointment_recording_hoster", $this->toString());
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->toString();
}
}
+92
View File
@@ -0,0 +1,92 @@
<?PHP
declare(strict_types = 1);
/**
* Represents an allowed type of recording for events / appointments.
*/
enum MDAppointmentRecordingType implements MDValueEnumInterface, JsonSerializable {
case video;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDAppointmentRecordingType
*/
public static function fromString(string $input):MDAppointmentRecordingType {
return match($input) {
'video' => self::video,
default => throw new MDpageParameterNotFromListException("Unknown appointment recording 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(), "appointment_recording_types", "appointment_recording_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(), "appointment_recording_types", "appointment_recording_types");
}
/**
* 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("appointment_recording_types", "appointment_recording_types", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}
-5
View File
@@ -1,9 +1,4 @@
<?PHP
/**
* Represents a type of attendance status for events / appointments: offline or online.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
/**
+146
View File
@@ -0,0 +1,146 @@
<?PHP
declare(strict_types = 1);
/**
* Represents a sort order option in DB queries (ASC, DESC).
*/
enum MDDbQueryAscDesc implements MDValueEnumInterface, JsonSerializable {
case ASC;
case DESC;
/**
* Returns a value of this type based on a string.
*
* @param string $input Input to get a value from.
*
* @return MDDbQueryAscDesc
*/
public static function fromString(string $input):MDDbQueryAscDesc {
return match($input) {
'asc' => self::ASC,
'ASC' => self::ASC,
'desc' => self::DESC,
'DESC' => self::DESC,
default => throw new MDpageParameterNotFromListException("Unknown sort order"),
};
}
/**
* Returns a value of this type based on an integer.
*
* @param integer $input Input to get a value from.
*
* @return MDDbQueryAscDesc
*/
public static function fromInt(int $input):MDDbQueryAscDesc {
return match($input) {
1 => self::ASC,
2 => self::DESC,
default => throw new MDpageParameterNotFromListException("Unknown sort order"),
};
}
/**
*
*/
/**
* 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::ASC => 1,
self::DESC => 2,
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
};
}
/**
* Returns the SQL representation of the entity.
*
* @return string
*/
public function toDbName():string {
return match ($this) {
self::ASC => 'ASC',
self::DESC => 'DESC',
};
}
/**
* 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(), "query_asc_desc", "query_asc_desc");
}
/**
* 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(), "query_asc_desc", "query_asc_desc");
}
/**
* 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("query_asc_desc", "query_asc_desc", $this->name);
}
/**
* Provides the option to serialize as a string during json_encode().
*
* @return string
*/
public function jsonSerialize():string {
return $this->name;
}
}
+4
View File
@@ -26,10 +26,14 @@ enum MDGender implements MDValueEnumInterface, JsonSerializable {
public static function fromString(string $input):MDGender {
return match($input) {
"0",
"" => self::none,
"none" => self::none,
"1",
"female" => self::female,
"2",
"male" => self::male,
"3",
"other" => self::other,
default => throw new MDpageParameterNotFromListException("Unknown gender"),
};
+110
View File
@@ -49,6 +49,16 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
case length_blade;
case height_blade;
case width_blade;
case length_handle;
case height_handle;
case width_handle;
case length_scabbard;
case height_scabbard;
case width_scabbard;
case length_label;
case height_label;
case width_label;
case number_of_sheets;
case number_of_double_pages;
@@ -61,6 +71,22 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
case width_of_base;
case diameter_of_base;
case height_image_mount_inner;
case height_image_mount_outer;
case width_image_mount_inner;
case width_image_mount_outer;
case height_plate;
case width_plate;
case length_packaging;
case height_packaging;
case width_packaging;
case length_box;
case height_box;
case width_box;
/**
* Returns a value of this type based on a string.
*
@@ -104,6 +130,15 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
'length_blade' => self::length_blade,
'height_blade' => self::height_blade,
'width_blade' => self::width_blade,
'length_handle' => self::length_handle,
'height_handle' => self::height_handle,
'width_handle' => self::width_handle,
'length_scabbard' => self::length_scabbard,
'height_scabbard' => self::height_scabbard,
'width_scabbard' => self::width_scabbard,
'length_label' => self::length_label,
'height_label' => self::height_label,
'width_label' => self::width_label,
'number_of_sheets' => self::number_of_sheets,
'number_of_double_pages' => self::number_of_double_pages,
'number_of_standalone_sheets' => self::number_of_standalone_sheets,
@@ -113,6 +148,18 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
'height_of_base' => self::height_of_base,
'width_of_base' => self::width_of_base,
'diameter_of_base' => self::diameter_of_base,
'height_image_mount_inner' => self::height_image_mount_inner,
'height_image_mount_outer' => self::height_image_mount_outer,
'width_image_mount_inner' => self::width_image_mount_inner,
'width_image_mount_outer' => self::width_image_mount_outer,
'height_plate' => self::height_plate,
'width_plate' => self::width_plate,
'length_packaging' => self::length_packaging,
'height_packaging' => self::height_packaging,
'width_packaging' => self::width_packaging,
'length_box' => self::length_box,
'height_box' => self::height_box,
'width_box' => self::width_box,
default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
};
@@ -170,6 +217,27 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
40 => self::height_of_base,
41 => self::width_of_base,
42 => self::diameter_of_base,
43 => self::length_handle,
44 => self::height_handle,
45 => self::width_handle,
46 => self::length_scabbard,
47 => self::height_scabbard,
48 => self::width_scabbard,
49 => self::length_label,
50 => self::height_label,
51 => self::width_label,
52 => self::height_image_mount_inner,
53 => self::height_image_mount_outer,
54 => self::width_image_mount_inner,
55 => self::width_image_mount_outer,
56 => self::height_plate,
57 => self::width_plate,
58 => self::length_packaging,
59 => self::height_packaging,
60 => self::width_packaging,
61 => self::length_box,
62 => self::height_box,
63 => self::width_box,
default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
};
@@ -247,6 +315,27 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
self::height_of_base => self::height,
self::width_of_base => self::width,
self::diameter_of_base => self::diameter,
self::length_handle => self::length,
self::height_handle => self::height,
self::width_handle => self::width,
self::length_scabbard => self::length,
self::height_scabbard => self::height,
self::width_scabbard => self::width,
self::length_label => self::length,
self::height_label => self::height,
self::width_label => self::width,
self::height_image_mount_inner => self::height,
self::height_image_mount_outer => self::height,
self::width_image_mount_inner => self::width,
self::width_image_mount_outer => self::width,
self::height_plate => self::height,
self::width_plate => self::width,
self::length_packaging => self::length,
self::height_packaging => self::height,
self::width_packaging => self::width,
self::length_box => self::length,
self::height_box => self::height,
self::width_box => self::width,
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
};
@@ -302,6 +391,27 @@ enum MDMeasurementType implements MDValueEnumInterface, JsonSerializable {
self::height_of_base => 40,
self::width_of_base => 41,
self::diameter_of_base => 42,
self::length_handle => 43,
self::height_handle => 44,
self::width_handle => 45,
self::length_scabbard => 46,
self::height_scabbard => 47,
self::width_scabbard => 48,
self::length_label => 49,
self::height_label => 50,
self::width_label => 51,
self::height_image_mount_inner => 52,
self::height_image_mount_outer => 53,
self::width_image_mount_inner => 54,
self::width_image_mount_outer => 55,
self::height_plate => 56,
self::width_plate => 57,
self::length_packaging => 58,
self::height_packaging => 59,
self::width_packaging => 60,
self::length_box => 61,
self::height_box => 62,
self::width_box => 63,
# default => throw new MDpageParameterNotFromListException("Unknown measurement type"),
};
+17 -6
View File
@@ -746,11 +746,13 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
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"]);
$id = self::validateNumericId(substr($id, 0, -1), ["https://catalogue.bnf.fr/ark:/12148/cb"]) . substr($id, -1);
}
else $validation = self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]);
else $id = self::validateNumericId($id, ["https://catalogue.bnf.fr/ark:/12148/cb"]);
if ($validation === false) return false;
if ($id === false) {
return false;
}
return $id;
@@ -813,6 +815,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
]),
self::viaf => self::validateNumericId($id, [
'https://viaf.org/viaf/',
'https://viaf.org/de/viaf/',
'http://viaf.org/viaf/',
]),
self::wikidata => self::validateWikidataId($id),
@@ -846,7 +849,12 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
* @return array<string, string>
*/
public static function getUnsortedList(MDTlLoader $tlLoader):array {
return MDValueSet::getTlUnsortedList($tlLoader, self::caseNames(), "attendance_status_set", "attendance_status_set");
$output = [];
foreach (self::cases() as $case) {
$output[$case->name] = $case->toFullName();
}
return $output;
}
@@ -858,7 +866,10 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
* @return array<string, string>
*/
public static function getSortedList(MDTlLoader $tlLoader):array {
return MDValueSet::getTlSortedList($tlLoader, self::caseNames(), "attendance_status_set", "attendance_status_set");
$out = self::getUnsortedList($tlLoader);
asort($out);
return $out;
}
@@ -871,7 +882,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
*/
public function getTledName(MDTlLoader $tlLoader):string {
return $tlLoader->tl("attendance_status_set", "attendance_status_set", $this->name);
return $this->toFullName();
}
+12
View File
@@ -62,6 +62,17 @@ final class MDNodaRepositoryTest extends TestCase {
}
/**
* Data provider for validating BNE IDs.
*
* @return Generator<string, array{0: string|false, 1: string}>
*/
public static function bnfIdForValidationProvider():Generator {
yield "Broken input / duplicate https" => [false, "https://catalogue.bnf.fr/ark:/12148/cbhttps://catalogue.bnf.fr/ark:/12148/cbhttps://catalogue.bnf.fr/ark:/12148/cb104183522"];
}
/**
* Ensure validating references to the BNE works.
*
@@ -257,6 +268,7 @@ final class MDNodaRepositoryTest extends TestCase {
public static function viafIdForValidationProvider():Generator {
yield "Full URL, http / 248941990" => ["248941990", "http://viaf.org/viaf/248941990"];
yield "Full URL, https, de / 34470968" => ["34470968", "https://viaf.org/de/viaf/34470968"];
yield "Full URL, https / 248941990" => ["248941990", "https://viaf.org/viaf/248941990"];
yield "Full URL, https / 42893419" => ["42893419", "https://viaf.org/viaf/42893419"];
yield "Full URL, https / 86145857811423020454" => ["86145857811423020454", "https://viaf.org/viaf/86145857811423020454"];