Update MDTlLoader and MDAllowedValueSets

phpcs-errors:226 phpunit-status:successful phpstan-errors:209
This commit is contained in:
Joshua Ramon Enslin 2020-10-29 20:45:59 +01:00 committed by Stefan Rohde-Enslin
parent 36b8fec24b
commit a8f73a4b86
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
8 changed files with 97 additions and 71 deletions

6
.gitmodules vendored
View File

@ -13,3 +13,9 @@
[submodule "classes/MDMailer"] [submodule "classes/MDMailer"]
path = classes/MDMailer path = classes/MDMailer
url = /var/www/vhosts/museum-digital.de/git-base/MDMailer url = /var/www/vhosts/museum-digital.de/git-base/MDMailer
[submodule "l10n/musdb"]
path = l10n/musdb
url = /var/www/vhosts/museum-digital.de/translation.museum-digital.de/backend_approved
[submodule "l10n/importer"]
path = l10n/importer
url = /var/www/vhosts/museum-digital.de/translation.museum-digital.de/importer_approved

@ -1 +1 @@
Subproject commit a300538188f6367eac129934b058417adab05d69 Subproject commit d8bfca1df6031da2500d346426c53ebb7d932796

@ -1 +1 @@
Subproject commit ae0886e34702794f0841cdb6e35f052cc8989b1a Subproject commit 7721ad60fc607d76de4932cc184727249726590e

View File

@ -9,12 +9,13 @@
declare(strict_types = 1); declare(strict_types = 1);
// Set autoloader // Set autoloader
error_reporting(E_ALL); \error_reporting(E_ALL);
ini_set('display_errors', "1"); \ini_set('display_errors', "1");
spl_autoload_register("mdCsvxmlAutoloader"); \spl_autoload_register("mdCsvxmlAutoloader");
set_exception_handler("mdExceptionHandler"); \set_exception_handler("mdExceptionHandler");
set_error_handler("mdErrorHandler", E_ALL); \set_error_handler("mdErrorHandler", E_ALL);
require_once __DIR__ . '/../inc/constants.php';
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';
/** /**
@ -26,22 +27,11 @@ require_once __DIR__ . '/../vendor/autoload.php';
*/ */
function mdCsvxmlAutoloader(string $className):void { function mdCsvxmlAutoloader(string $className):void {
$classDirs = [ $classDirs = AUTOLOAD_DIRS;
__DIR__ . "/../classes/MDTlLoader",
__DIR__ . "/../classes/MD_STD",
__DIR__ . "/../classes/MDAllowedValueSets/src",
__DIR__ . "/../classes/MDExportFormats/src",
__DIR__ . "/../classes/MDErrorReporter",
__DIR__ . "/../classes/MDMailer/src",
__DIR__ . "/../conf",
__DIR__ . "/../classes/MDErrorReporter/exceptions/generic",
__DIR__ . "/../classes/MDErrorReporter/exceptions/page",
__DIR__ . "/../classes/MDErrorReporter/exceptions/updates",
];
foreach ($classDirs as $classDir) { foreach ($classDirs as $classDir) {
if (file_exists("$classDir/$className.php")) { if (\file_exists("$classDir/$className.php")) {
include "$classDir/$className.php"; include "$classDir/$className.php";
return; return;
} }

28
inc/constants.php Normal file
View File

@ -0,0 +1,28 @@
<?PHP
/**
* This file collects global constants to the code of the frontend.
*
* @file
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
const TL_FILE_DIRS = [
__DIR__ . "/../l10n/musdb/",
__DIR__ . "/../classes/MDAllowedValueSets/l18n/",
];
const AUTOLOAD_DIRS = [
__DIR__ . "/../classes/MDTlLoader/src",
__DIR__ . "/../classes/MD_STD",
__DIR__ . "/../classes/MDAllowedValueSets/src",
__DIR__ . "/../classes/MDExportFormats/src",
__DIR__ . "/../classes/MDErrorReporter",
__DIR__ . "/../classes/MDMailer/src",
__DIR__ . "/../conf",
__DIR__ . "/../classes/MDErrorReporter/exceptions/generic",
__DIR__ . "/../classes/MDErrorReporter/exceptions/page",
__DIR__ . "/../classes/MDErrorReporter/exceptions/updates",
__DIR__ . "/../classes/MDTlLoader/exceptions",
];

1
l10n/importer Submodule

@ -0,0 +1 @@
Subproject commit c59afb70be28488deab5f280546a88c4b17552e3

1
l10n/musdb Submodule

@ -0,0 +1 @@
Subproject commit 8ec3c886c7a19b7cf73864b817f7eb10083c1e6e

View File

@ -13,9 +13,9 @@ require __DIR__ . "/../translation-importer/$lang/csvxml-overview.php";
$tlLoader = new MDTlLoader("available_fields", $lang); $tlLoader = new MDTlLoader("available_fields", $lang);
foreach (array_diff(scandir(__DIR__ . "/langfiles/$lang/"), ['.', '..']) as $fileName) { foreach (MD_STD::scandir(__DIR__ . "/../l10n/musdb/$lang/") as $fileName) {
if (in_array($fileName, ['start.php', 'start2.php'])) continue; if (in_array($fileName, ['start.php', 'start2.php'])) continue;
include __DIR__ . "/langfiles/{$lang}/{$fileName}"; include __DIR__ . "/../l10n/musdb/{$lang}/{$fileName}";
} }
require __DIR__ . "/commonservices/$lang/search_all_fields.php"; require __DIR__ . "/commonservices/$lang/search_all_fields.php";
@ -36,48 +36,48 @@ $availableFields = [
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'Only unique values allowed', "remark" => 'Only unique values allowed',
"name_human_readable" => $object_basis['inventory_number'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'inventory_number'),
"explica" => $object_basis['inv_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'inv_explica'),
], ],
"object_type" => [ "object_type" => [
"required" => true, "required" => true,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'Keep it short! Field is needed to create valid LIDO from museum-digital entries', "remark" => 'Keep it short! Field is needed to create valid LIDO from museum-digital entries',
"name_human_readable" => $object_basis['object_type'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'object_type'),
"explica" => $object_basis['oart_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'oart_explica'),
], ],
"object_title" => [ "object_title" => [
"required" => true, "required" => true,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'Best is not to repeat the title again and again for many objects, e.g. vase, vase, vase ... better: Green vase, Blue vase, Yellow vase, ...', "remark" => 'Best is not to repeat the title again and again for many objects, e.g. vase, vase, vase ... better: Green vase, Blue vase, Yellow vase, ...',
"name_human_readable" => $object_basis['object_name'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'object_name'),
"explica" => $object_basis['oname_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'oname_explica'),
], ],
"object_description" => [ "object_description" => [
"required" => true, "required" => true,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'A good description of the objects is fundamental to make the objects searchable in the internet', "remark" => 'A good description of the objects is fundamental to make the objects searchable in the internet',
"name_human_readable" => $object_basis['description'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'description'),
"explica" => $object_basis['obesch_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'obesch_explica'),
], ],
"object_material_technique" => [ "object_material_technique" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'This is a cummulative field for material and technique. It is also possible to additionally save the information separate in the fields: <i>material_separate</i> and <i>technique_separate</i>', "remark" => 'This is a cummulative field for material and technique. It is also possible to additionally save the information separate in the fields: <i>material_separate</i> and <i>technique_separate</i>',
"name_human_readable" => $object_basis['mattech'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'mattech'),
"explica" => $object_basis['mattech_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'mattech_explica'),
], ],
"object_dimensions" => [ "object_dimensions" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => 'This is a cummulative field for dimensions (values and units). It is also possible to additionally save the information separate. See the block: <i>separate dimensions</i>', "remark" => 'This is a cummulative field for dimensions (values and units). It is also possible to additionally save the information separate. See the block: <i>separate dimensions</i>',
"name_human_readable" => $object_basis['measurements'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'measurements'),
"explica" => $object_basis['ausmass_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'ausmass_explica'),
], ],
"object_publication" => [ "object_publication" => [
"required" => false, "required" => false,
@ -245,7 +245,7 @@ $availableFields = [
"dependsOn" => ['dimensions_separate_width_value', 'dimensions_separate_show_md', 'dimensions_separate_show_extern'], "dependsOn" => ['dimensions_separate_width_value', 'dimensions_separate_show_md', 'dimensions_separate_show_extern'],
"remark" => 'If a separated value is given an entry for the respective unit is necessary. If a separated dimension entry is given, <i>dimensions_separate_show_md</i> and <i>dimensions_separate_show_extern</i> need to be filled in, too.', "remark" => 'If a separated value is given an entry for the respective unit is necessary. If a separated dimension entry is given, <i>dimensions_separate_show_md</i> and <i>dimensions_separate_show_extern</i> need to be filled in, too.',
"name_human_readable" => $export['exact_measurements_weight_unit'], "name_human_readable" => $export['exact_measurements_weight_unit'],
"explica" => $object_basis['inv_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'inv_explica'),
], ],
"dimensions_separate_diameter_value" => [ "dimensions_separate_diameter_value" => [
"required" => false, "required" => false,
@ -289,7 +289,7 @@ $availableFields = [
"dimensions_separate_diameter_unit", "dimensions_separate_wall_thickness_value", "dimensions_separate_wall_thickness_unit" "dimensions_separate_diameter_unit", "dimensions_separate_wall_thickness_value", "dimensions_separate_wall_thickness_unit"
], ],
"remark" => 'If one or more separate dimension-value (and -unit) is given it has to be specified if the separated entries should be made visible at museum-digital', "remark" => 'If one or more separate dimension-value (and -unit) is given it has to be specified if the separated entries should be made visible at museum-digital',
"name_human_readable" => $object_basis['inventory_number'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'inventory_number'),
"explica" => "", "explica" => "",
], ],
"dimensions_separate_show_extern" => [ "dimensions_separate_show_extern" => [
@ -302,7 +302,7 @@ $availableFields = [
"dimensions_separate_diameter_unit", "dimensions_separate_wall_thickness_value", "dimensions_separate_wall_thickness_unit" "dimensions_separate_diameter_unit", "dimensions_separate_wall_thickness_value", "dimensions_separate_wall_thickness_unit"
], ],
"remark" => 'If one or more separate dimension-value (and -unit) is given it has to be specified if the separated entries should be included in a later export from museum-digital', "remark" => 'If one or more separate dimension-value (and -unit) is given it has to be specified if the separated entries should be included in a later export from museum-digital',
"name_human_readable" => $object_basis['inventory_number'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'inventory_number'),
"explica" => "", "explica" => "",
], ],
"number_of_pieces" => [ "number_of_pieces" => [
@ -422,7 +422,7 @@ $availableFields = [
"allowedValues" => '', "allowedValues" => '',
"remark" => '', "remark" => '',
"name_human_readable" => $searchvar[19][0], "name_human_readable" => $searchvar[19][0],
"explica" => $object_basis['inv_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'inv_explica'),
], ],
"inclusion_kind_of" => [ "inclusion_kind_of" => [
"required" => false, "required" => false,
@ -481,7 +481,7 @@ $availableFields = [
"dependsOn" => ["bought_for_currency"], "dependsOn" => ["bought_for_currency"],
"remark" => '', "remark" => '',
"name_human_readable" => "{$searchvar[19][0]}, {$object_add['for']}", "name_human_readable" => "{$searchvar[19][0]}, {$object_add['for']}",
"explica" => $object_basis['inv_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'inv_explica'),
], ],
"bought_for_currency" => [ "bought_for_currency" => [
"required" => false, "required" => false,
@ -807,40 +807,40 @@ for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) {
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"], "dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $object_basis['object_type'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'object_type'),
"explica" => $object_basis['oart_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'oart_explica'),
], ],
"obj_trans_object_title{$i}" => [ "obj_trans_object_title{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"], "dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $object_basis['object_name'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'object_name'),
"explica" => $object_basis['oname_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'oname_explica'),
], ],
"obj_trans_object_description{$i}" => [ "obj_trans_object_description{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"], "dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $object_basis['description'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'description'),
"explica" => $object_basis['obesch_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'obesch_explica'),
], ],
"obj_trans_object_material_technique{$i}" => [ "obj_trans_object_material_technique{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"], "dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $object_basis['mattech'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'mattech'),
"explica" => $object_basis['mattech_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'mattech_explica'),
], ],
"obj_trans_object_dimensions{$i}" => [ "obj_trans_object_dimensions{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"], "dependsOn" => ["obj_trans_language{$i}", "obj_trans_object_type{$i}", "obj_trans_object_title{$i}", "obj_trans_object_description{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $object_basis['measurements'], "name_human_readable" => $tlLoader->tl("object_basis", "object_basis", 'measurements'),
"explica" => $object_basis['ausmass_explica'], "explica" => $tlLoader->tl("object_basis", "object_basis", 'ausmass_explica'),
], ],
]); ]);
@ -855,88 +855,88 @@ for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) {
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['author'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'author'),
"explica" => $literature['autor_explica'], "explica" => $tlLoader->tl("literature", "literature", 'autor_explica'),
], ],
"literature_year{$i}" => [ "literature_year{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['year'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'year'),
"explica" => $literature['jahr_explica'], "explica" => $tlLoader->tl("literature", "literature", 'jahr_explica'),
], ],
"literature_title{$i}" => [ "literature_title{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => [], "dependsOn" => [],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['title'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'title'),
"explica" => $literature['titel_explica'], "explica" => $tlLoader->tl("literature", "literature", 'titel_explica'),
], ],
"literature_place{$i}" => [ "literature_place{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['place'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'place'),
"explica" => $literature['ort_explica'], "explica" => $tlLoader->tl("literature", "literature", 'ort_explica'),
], ],
"literature_abbreviation{$i}" => [ "literature_abbreviation{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['abbr'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'abbr'),
"explica" => $literature['abbr_explica'], "explica" => $tlLoader->tl("literature", "literature", 'abbr_explica'),
], ],
"literature_gnd{$i}" => [ "literature_gnd{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['gnd'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'gnd'),
"explica" => $literature['gnd_explica'], "explica" => $tlLoader->tl("literature", "literature", 'gnd_explica'),
], ],
"literature_isbn{$i}" => [ "literature_isbn{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['isbn'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'isbn'),
"explica" => $literature['isbn_explica'], "explica" => $tlLoader->tl("literature", "literature", 'isbn_explica'),
], ],
"literature_signature{$i}" => [ "literature_signature{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['id_in_museum'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'id_in_museum'),
"explica" => $literature['id_in_museum_explica'], "explica" => $tlLoader->tl("literature", "literature", 'id_in_museum_explica'),
], ],
"literature_online{$i}" => [ "literature_online{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['online'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'online'),
"explica" => $literature['online_explica'], "explica" => $tlLoader->tl("literature", "literature", 'online_explica'),
], ],
"literature_annotation{$i}" => [ "literature_annotation{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['annotation'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'annotation'),
"explica" => $literature['annotation_explica'], "explica" => $tlLoader->tl("literature", "literature", 'annotation_explica'),
], ],
"literature_inlit{$i}" => [ "literature_inlit{$i}" => [
"required" => false, "required" => false,
"allowedValues" => [], "allowedValues" => [],
"dependsOn" => ["literature_title{$i}"], "dependsOn" => ["literature_title{$i}"],
"remark" => '', "remark" => '',
"name_human_readable" => $literature['where_inside'], "name_human_readable" => $tlLoader->tl("literature", "literature", 'where_inside'),
"explica" => $literature['where_in_explica'], "explica" => $tlLoader->tl("literature", "literature", 'where_in_explica'),
], ],
]); ]);