From bfb30c7032fea34c68d14d2cc3d852f5f9a8bb5f Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Wed, 13 Nov 2019 15:14:07 +0100 Subject: [PATCH] Add multiplier so that csv check can accept values beyond the publicly listed ones phpcs-errors:253 phpunit-status:successful --- csv_check.php | 3 +- values/availableFields.php | 89 ++++++++++++++++++++------------------ 2 files changed, 48 insertions(+), 44 deletions(-) diff --git a/csv_check.php b/csv_check.php index 12b3166..c150f08 100644 --- a/csv_check.php +++ b/csv_check.php @@ -26,7 +26,8 @@ $lang = $_SESSION['lang']; $filename = $_GET['fnam']; $csv_datei = 'csv/' . $filename; -// Get allowed values +// Get allowed values * $fieldNoMultiplicator +$fieldNoMultiplicator = 5; require __DIR__ . "/values/availableFields.php"; $allowed = $eventpart = $eventpartsure = $fieldsWithDependency = $fieldsWithAllowedValueSet = []; diff --git a/values/availableFields.php b/values/availableFields.php index 91c3978..8994337 100644 --- a/values/availableFields.php +++ b/values/availableFields.php @@ -21,6 +21,9 @@ require __DIR__ . "/commonservices/$lang/search_all_fields.php"; require __DIR__ . "/commonservices/units.php"; require __DIR__ . "/commonservices/$lang/eventtype_name.php"; +if (empty($fieldNoMultiplicator) or !is_numeric($fieldNoMultiplicator)) { + $fieldNoMultiplicator = 1; +} $availableFields = [ @@ -720,7 +723,7 @@ $availableFields = [ * Repeat fields */ -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$overview['links']] = array_merge($availableFields[$overview['links']], [ @@ -744,7 +747,7 @@ for ($i = 1; $i <= 2; $i++) { } -for ($i = 1; $i <= 5; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['literature']] = array_merge($availableFields[$basis['literature']], [ @@ -842,7 +845,7 @@ for ($i = 1; $i <= 5; $i++) { // Collection names -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$csvxml_overview['object_base_data']]["collection_name{$i}"] = [ "required" => false, @@ -855,7 +858,7 @@ for ($i = 1; $i <= 2; $i++) { } -for ($i = 1; $i <= 5; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['objectgroup']] = array_merge($availableFields[$basis['objectgroup']], [ @@ -887,7 +890,7 @@ for ($i = 1; $i <= 5; $i++) { } -for ($i = 1; $i <= 15; $i++) { +for ($i = 1; $i <= 10 * $fieldNoMultiplicator; $i++) { $availableFields[$overview['tags']]["tag{$i}"] = [ "required" => false, @@ -899,7 +902,7 @@ for ($i = 1; $i <= 15; $i++) { } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$eventname[22]] = array_merge($availableFields[$eventname[22]], [ @@ -923,7 +926,7 @@ for ($i = 1; $i <= 2; $i++) { } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$eventname[23]] = array_merge($availableFields[$eventname[23]], [ @@ -955,7 +958,7 @@ for ($i = 1; $i <= 2; $i++) { } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$eventname[24]] = array_merge($availableFields[$eventname[24]], [ @@ -979,7 +982,7 @@ for ($i = 1; $i <= 2; $i++) { } -for ($i = 1; $i <= 5; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$overview['images']] = array_merge($availableFields[$overview['images']], [ @@ -1057,7 +1060,7 @@ for ($i = 1; $i <= 5; $i++) { } -for ($i = 1; $i <= 5; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['resource']] = array_merge($availableFields[$basis['resource']], [ @@ -1206,35 +1209,35 @@ function generateGenericFullEvent(array $event, array $csvxml_overview, string $ } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[1]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[1]], generateGenericFullEvent($event, $csvxml_overview, $eventname[1], "production", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[2]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[2]], generateGenericFullEvent($event, $csvxml_overview, $eventname[2], "finding", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[3]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[3]], generateGenericFullEvent($event, $csvxml_overview, $eventname[3], "publication", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[4]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[4]], generateGenericFullEvent($event, $csvxml_overview, $eventname[4], "template_creation", $i) ); } -for ($i = 1; $i <= 15; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[5]] = array_merge($availableFields[$basis['event'] . ': ' . $eventname[5]], [ @@ -1258,7 +1261,7 @@ for ($i = 1; $i <= 15; $i++) { } -for ($i = 1; $i <= 10; $i++) { +for ($i = 1; $i <= 5 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[36]] = array_merge($availableFields[$basis['event'] . ': ' . $eventname[36]], [ @@ -1282,189 +1285,189 @@ for ($i = 1; $i <= 10; $i++) { } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[6]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[6]], generateGenericFullEvent($event, $csvxml_overview, $eventname[6], "was_used", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[7]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[7]], generateGenericFullEvent($event, $csvxml_overview, $eventname[7], "written", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[8]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[8]], generateGenericFullEvent($event, $csvxml_overview, $eventname[8], "collected", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[9]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[9]], generateGenericFullEvent($event, $csvxml_overview, $eventname[9], "painted", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[10]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[10]], generateGenericFullEvent($event, $csvxml_overview, $eventname[10], "taken", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[11]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[11]], generateGenericFullEvent($event, $csvxml_overview, $eventname[11], "received", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[12]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[12]], generateGenericFullEvent($event, $csvxml_overview, $eventname[12], "printing_plate_produced", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[13]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[13]], generateGenericFullEvent($event, $csvxml_overview, $eventname[13], "sent", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[14]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[14]], generateGenericFullEvent($event, $csvxml_overview, $eventname[14], "issued", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[15]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[15]], generateGenericFullEvent($event, $csvxml_overview, $eventname[15], "signed", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[16]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[16]], generateGenericFullEvent($event, $csvxml_overview, $eventname[16], "type_described", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[19]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[19]], generateGenericFullEvent($event, $csvxml_overview, $eventname[19], "drawn", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[20]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[20]], generateGenericFullEvent($event, $csvxml_overview, $eventname[20], "copied", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[25]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[25]], generateGenericFullEvent($event, $csvxml_overview, $eventname[25], "commissioned", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[26]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[26]], generateGenericFullEvent($event, $csvxml_overview, $eventname[26], "printed", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[27]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[27]], generateGenericFullEvent($event, $csvxml_overview, $eventname[27], "spoken", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[28]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[28]], generateGenericFullEvent($event, $csvxml_overview, $eventname[28], "sung", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[29]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[29]], generateGenericFullEvent($event, $csvxml_overview, $eventname[29], "decor_designed", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[30]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[30]], generateGenericFullEvent($event, $csvxml_overview, $eventname[30], "form_designed", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[31]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[31]], generateGenericFullEvent($event, $csvxml_overview, $eventname[31], "modelled", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[32]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[32]], generateGenericFullEvent($event, $csvxml_overview, $eventname[32], "signed_artwork", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[33]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[33]], generateGenericFullEvent($event, $csvxml_overview, $eventname[33], "was_mentioned", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[34]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[34]], generateGenericFullEvent($event, $csvxml_overview, $eventname[34], "buried", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[35]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[35]], generateGenericFullEvent($event, $csvxml_overview, $eventname[35], "intellectual_creation", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[37]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[37]], generateGenericFullEvent($event, $csvxml_overview, $eventname[37], "painted_on", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[38]] = array_merge( $availableFields[$basis['event'] . ': ' . $eventname[38]], generateGenericFullEvent($event, $csvxml_overview, $eventname[38], "illustrated", $i) ); } -for ($i = 1; $i <= 2; $i++) { +for ($i = 1; $i <= 2 * $fieldNoMultiplicator; $i++) { $availableFields[$basis['event'] . ': ' . $eventname[21]] = array_merge($availableFields[$basis['event'] . ': ' . $eventname[21]], [