From 85ea42724288e5f33c4b4dbed0c6b11e0e39d9a6 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 7 Nov 2022 00:31:57 +0100 Subject: [PATCH] Clean up outdated scripts See #16 --- TODO.md | 17 - classes/CSVXMLValidator.php | 54 --- functions/functions.php | 170 +--------- public/assets/js/csvxml-overview.js | 6 - public/assets/js/csvxml-overview.min.js | 5 - public/assets/js/newToolTip.js | 73 ---- public/csv.php | 83 ----- public/index.php | 132 +++----- public/index3.php | 420 ------------------------ public/index6.php | 92 ------ public/index_new.php | 87 ----- public/upload.php | 35 -- public/zipit.php | 43 --- 13 files changed, 52 insertions(+), 1165 deletions(-) delete mode 100644 TODO.md delete mode 100644 classes/CSVXMLValidator.php delete mode 100644 public/assets/js/csvxml-overview.js delete mode 100644 public/assets/js/csvxml-overview.min.js delete mode 100644 public/assets/js/newToolTip.js delete mode 100644 public/csv.php delete mode 100644 public/index3.php delete mode 100644 public/index6.php delete mode 100644 public/index_new.php delete mode 100644 public/upload.php delete mode 100644 public/zipit.php diff --git a/TODO.md b/TODO.md deleted file mode 100644 index 7cebd9a..0000000 --- a/TODO.md +++ /dev/null @@ -1,17 +0,0 @@ -# Project: Rewrite CSVXML with Rust - -## Step 1: Rewriting classes/CsvxmlAvailableFields.php - -- New class for fieldentries -- use tlloader: $eventname[1] -> $tlLoader->tl("eventtype-name", "eventname", "1") -- __toArray(){} - -## Step 2: Rewrite Validationprocess in index3.php - -### FFI with Rust - -- https://www.php.net/manual/en/class.ffi.php -- https://www.php.net/manual/en/ffi.examples-basic.php -- https://platform.sh/blog/2020/php-fun-with-ffi-getting-rust-ic/ - -## Step 3: Remove fnam Parameter \ No newline at end of file diff --git a/classes/CSVXMLValidator.php b/classes/CSVXMLValidator.php deleted file mode 100644 index 4447e3e..0000000 --- a/classes/CSVXMLValidator.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -declare(strict_types = 1); -/** - * Class holding the information about various errors - * that can occur during validation - */ -final class CSVXMLValidator { - - public array $error_msgs; - public array $inv_errors; - public array $depcon_errors; - - public function addError(String $error) - { - $this->error_msgs[] = $error; - - } - - public function addInvError(String $error) - { - $this->inv_errors[] = $error; - - } - - public function addDepconError(String $error) - { - $this->depcon_errors[] = $error; - - } - - public function overallErrorCount(): int - { - return count($this->error_msgs) - + count($this->inv_errors) - + count($this->depcon_errors); - - } - - /** - * Constructor - */ - public function __construct() - { - $this->error_msgs = []; - $this->inv_errors = []; - $this->depcon_errors = []; - - } -} diff --git a/functions/functions.php b/functions/functions.php index 88c9976..a84f32b 100644 --- a/functions/functions.php +++ b/functions/functions.php @@ -9,11 +9,11 @@ declare(strict_types = 1); // Set autoloader -# \error_reporting(E_ALL); -# \ini_set('display_errors', "1"); +\error_reporting(E_ALL); +\ini_set('display_errors', "1"); \spl_autoload_register("mdCsvxmlAutoloader"); -\set_exception_handler("mdExceptionHandler"); -\set_error_handler("mdErrorHandler", E_ALL); +# \set_exception_handler("mdExceptionHandler"); +# \set_error_handler("mdErrorHandler", E_ALL); require_once __DIR__ . '/../inc/constants.php'; require_once __DIR__ . '/../vendor/autoload.php'; @@ -177,165 +177,3 @@ function mdExceptionHandler(Throwable $exception):void { } } - -/** - * Function for generating the HTML head. - * - * @param string $injected Additional code to inject into the head, e.g. a - * reference to JS files. - * - * @return string - */ -function printHTMLHead(string $injected = ""):string { - - $output = ' - - - - - - - - - - - - - - CSVXML :: museum-digital - - -'; - - $output .= $injected; - - $output .= ' - - - - -

- - museum-digital:csvxml -

-'; - - return $output; - -} - -/** - * Function generateHelpTooltip returns a tooltip for hovering over using the common settings. - * - * @param string $identifier ID attribute of the tooltip. - * @param string $title Title of the tooltip. - * @param string $explica More in-depth explanation: body of the tooltip. - * @param boolean $setParagraph If set to true (default), the content of the tooltip will be put into a

element. Optional. - * - * @return array - */ -function generateHelpTooltip(string $identifier, string $title, string $explica, bool $setParagraph = true):array { - - $outputTag = ''; - $output = ''; - if ($setParagraph) $output .= '

'; - $output .= $explica; - if ($setParagraph) $output .= '

'; - $output .= ''; - - return [$output, $outputTag]; - -} - -/** - * Outputs a DOMDocument with correct header and then aborts. - * Used mainly for debugging. - * - * @param DOMDocument $xmlDoc XML object. - * - * @return string - */ -function printDOMDocToXML(DOMDocument $xmlDoc):string { - - return '' . $xmlDoc->saveXML($xmlDoc->documentElement); - -} - -/** - * Function for creating a DOMElement with a text node inside. - * - * @param DOMDocument $xmlDoc XML document. - * @param string $tag Tag. - * @param string $content Text content. - * - * @return DOMElement - */ -function createTextDomElement(DOMDocument $xmlDoc, string $tag, string $content):DOMElement { - - try { - $element = $xmlDoc->createElement($tag); - } - catch (DOMException $e) { - echo "Error at " . __FILE__ . ", line #" . __LINE__ . PHP_EOL . "
"; - echo "Cannot create DOM element for $tag / $content"; - exit; - } - - $element->appendChild($xmlDoc->createTextNode($content)); - - return $element; - -} - -/** - * Function for creating a DOMDocument record channel. - * - * @return array - */ -function getBlankRecordChannel():array { - - $xmlDoc = new DOMDocument("1.0", "UTF-8"); - $xmlMainElem = $xmlDoc->createElement("record"); - $record_node = $xmlDoc->appendChild($xmlMainElem); //add RSS element to XML node - - return [$xmlDoc, $record_node]; - -} - -/** - * Function for removing a directory with all its contents. - * - * @param string $dir File path of the directory to remove. - * - * @return void - */ -function rrmdir(string $dir):void { - if (is_dir($dir)) { - $objects = scandir($dir); - foreach ($objects as $object) { - if ($object != "." && $object != "..") { - if (filetype($dir . "/" . $object) == "dir") rrmdir($dir . "/" . $object); - else unlink($dir . "/" . $object); - } - } - reset($objects); - rmdir($dir); - } - -} - -/** - * Function for checking if two arrays have identical values / contents. - * - * @param array $arrayA First array to compare. - * @param array $arrayB Second array to compare. - * - * @return boolean - */ -function identical_values(array $arrayA, array $arrayB):bool { - sort($arrayA); - sort($arrayB); - return $arrayA == $arrayB; - -} - diff --git a/public/assets/js/csvxml-overview.js b/public/assets/js/csvxml-overview.js deleted file mode 100644 index 7dcf067..0000000 --- a/public/assets/js/csvxml-overview.js +++ /dev/null @@ -1,6 +0,0 @@ -(function() { - - let csvBySelectionButton = document.getElementById("csvBySelection"); - let unsetSelectionButton = document.getElementById("unsetSelection"); - -})(); diff --git a/public/assets/js/csvxml-overview.min.js b/public/assets/js/csvxml-overview.min.js deleted file mode 100644 index 7a858d3..0000000 --- a/public/assets/js/csvxml-overview.min.js +++ /dev/null @@ -1,5 +0,0 @@ -(function(){let csvBySelectionButton=document.getElementById("csvBySelection");let unsetSelectionButton=document.getElementById("unsetSelection");function checkCSVBySelectionAccessibility(){let selected=document.getElementsByClassName("humanTLToggled");if(selected.length===0){csvBySelectionButton.classList.add("invisible");unsetSelection.classList.add("invisible")}else{csvBySelectionButton.classList.remove("invisible");unsetSelection.classList.remove("invisible")}} -function doForFieldList(callback){let fieldLists=document.getElementsByClassName("fieldList");for(let i=0,max=fieldLists.length;i - */ - -function generateToolTips() { - - /** - * Function for setting the alignment of an element. - * - * @param {Event} e Event triggering the execution of this function. - * @param {DOMElement} elem Dom element to position. - * - * @return {void} - */ - function getDirection(e, elem) { - - if (window.innerHeight < e.clientY + elem.clientHeight) { - elem.style.top = ""; - elem.style.bottom = (window.innerHeight - e.clientY) + "px"; - } - else { - elem.style.bottom = ""; - elem.style.top = (e.clientY + 2) + "px"; - } - if (window.innerWidth < e.clientX + elem.clientWidth) { - elem.style.left = ""; - elem.style.right = (window.innerWidth - e.clientX) + "px"; - } else { - elem.style.right = ""; - elem.style.left = (e.clientX + 2) + "px"; - } - - } - - let triggers = document.getElementsByClassName("newToolTipTag"); - for (let i = 0, max = triggers.length; i < max; i++) { - - let trigger = triggers[i]; - let dataTarget = trigger.getAttribute("data-for"); - let target = document.getElementById("tooltip_" + dataTarget); - - trigger.addEventListener("mouseover", function(e) { - let newMain = document.getElementById("newToolTipMain"); - if (newMain !== null) return; - newMain = target.cloneNode(true); - newMain.id = "newToolTipMain"; - document.getElementsByTagName("body")[0].appendChild(newMain); - newMain.classList.add("visible"); - getDirection(e, newMain); - }); - trigger.addEventListener("mousemove", function(e) { - let newMain = document.getElementById("newToolTipMain"); - getDirection(e, newMain); - }); - trigger.addEventListener("mouseout", function(e) { - let newMain = document.getElementById("newToolTipMain"); - if (newMain.classList.contains("sticked")) return; - newMain.classList.remove("visible"); - document.getElementsByTagName("body")[0].removeChild(newMain); - }); - /* - trigger.addEventListener("click", function(e) { - document.getElementById("newToolTipMain").classList.toggle("sticked"); - }); - */ - - } - -} - -generateToolTips(); diff --git a/public/csv.php b/public/csv.php deleted file mode 100644 index 80a878c..0000000 --- a/public/csv.php +++ /dev/null @@ -1,83 +0,0 @@ - - */ -declare(strict_types = 1); -require_once __DIR__ . "/../functions/functions.php"; - -if (session_status() != PHP_SESSION_ACTIVE) { - session_start(); -} - -// This array contains all available languages -$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt']; - -// Some languages are in translation. They will only be available for logged in users. - -if (isset($_GET['navlang'])) { - $_SESSION['lang'] = $_GET['navlang']; - if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de'; -} -else if (!isset($_SESSION['lang'])) { - $_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false); -} -$lang = $_SESSION['lang']; - -if (!empty($_POST) and !empty($_POST['selectedFields'])) { - $selectionActive = true; - $selectedFields = explode(",", trim($_POST['selectedFields'], ",")); -} -else { - $selectionActive = false; - $selectedFields = []; -} - -$fieldsGetter = new CsvxmlAvailableFields($lang); -$availableFields = $fieldsGetter->getFields(); - -$line1 = $line2 = $line3 = $line4 = []; - -foreach ($availableFields as $headline => $fields) { - - $i = 0; - $tLine1 = $tLine2 = $tLine3 = $tLine4 = []; - $tLine1[] = $headline; - - foreach($fields as $fieldName => $field) { - - if ($selectionActive === true and !in_array($fieldName, $selectedFields)) { - continue; - } - - if ($i !== 0) $tLine1[] = ""; - $tLine2[] = $fieldName; - $tLine3[] = $field->name_human_readable; - # $tLine4[] = $field->remark; - if (!empty($field->allowedValues)) $tLine4[] = end($field->allowedValues); - else $tLine4[] = $field->name_human_readable; - - $i++; - } - - if (empty($tLine2) or count($tLine2) === 0) continue; - - for ($i = 1; $i <= 4; $i++) { - ${"line$i"} = array_merge(${"line$i"}, ${"tLine$i"}); - } - -} - -header('Content-Type: text/csv; charset=utf-8'); -if ($selectionActive === true) { - header("Content-Disposition: attachment; filename=csvxml_museum-digital_template-{$lang}_selection.csv"); -} -else { - header("Content-Disposition: attachment; filename=csvxml_museum-digital_template-{$lang}.csv"); -} - -for ($i = 2; $i <= 4; $i++) { - echo '"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL; - # echo mb_convert_encoding('"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL, 'utf-16', 'utf-8'); -} diff --git a/public/index.php b/public/index.php index 0548ea2..db2edde 100644 --- a/public/index.php +++ b/public/index.php @@ -9,32 +9,17 @@ declare(strict_types = 1); require_once __DIR__ . "/../functions/functions.php"; -if (session_status() != PHP_SESSION_ACTIVE) { - session_start(); -} - -// This array contains all available languages $allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt']; - -// Some languages are in translation. They will only be available for logged in users. - -if (isset($_GET['navlang'])) { - $_SESSION['lang'] = $_GET['navlang']; - if (!in_array($_SESSION['lang'], $allowed_langs)) $_SESSION['lang'] = 'de'; -} -else if (!isset($_SESSION['lang'])) { - $_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false); -} -$lang = $_SESSION['lang']; +$lang = MD_STD::get_user_lang($allowed_langs, "en"); +$tlLoader = new MDTlLoader("csxml_start_v2", $lang); $outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']); -$tlLoader = new MDTlLoader("csxml_start", $lang); - -$fieldsGetter = new CsvxmlAvailableFields($lang); -$availableFields = $fieldsGetter->getFields(); - if ($outFormat === 'json') { + + $fieldsGetter = new CsvxmlAvailableFields($lang); + $availableFields = $fieldsGetter->getFields(); + header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); // HTTP/1.1 header('Pragma: no-cache'); // HTTP/1.0 header("Access-Control-Allow-Origin: *"); @@ -46,78 +31,57 @@ if ($outFormat === 'json') { return; } -$toInject = ' - -'; -echo printHTMLHead($toInject); echo ' + + + -
-
- - - - -
-
+ + + + -
-

' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags') . '

- -'; + + + + -$tooltips = []; -foreach ($availableFields as $headline => $fields) { + CSVXML :: museum-digital - echo " -

{$headline}

-
    -"; + - foreach($fields as $fieldName => $field) { - if (!empty($field->remark) or !empty($field->explica)) $hasTooltip = true; - else $hasTooltip = false; + + $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'), + 'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'), + 'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'), + 'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'), + 'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'), + 'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'), + 'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'), + 'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'), + 'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'), + 'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'), + 'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'), + 'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'), + 'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'), + 'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'), + 'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'), + 'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'), +])) . '"> - echo " -
  • dependsOn)) { - echo " data-dependencies='" . htmlspecialchars(implode(";", $field->dependsOn)) . "'"; - } - echo ">{$fieldName}"; +

    + + museum-digital:csvxml +

    - if (!empty($field->explica)) $toolTipExplica = "

    General

    " . $field->explica; - else $toolTipExplica = ""; - $toolTip = generateHelpTooltip($fieldName, "{$field->name_human_readable}", "{$field->remark}{$toolTipExplica}"); - if ($hasTooltip) $tooltips[] = $toolTip[0]; - echo "

  • "; - } - - echo ' -
-'; - -} - -echo ' -
- -'; -echo implode($tooltips); - -echo ' + - -'; +'; + diff --git a/public/index3.php b/public/index3.php deleted file mode 100644 index 6c05132..0000000 --- a/public/index3.php +++ /dev/null @@ -1,420 +0,0 @@ -getFields(); -$validator = new CSVXMLValidator(); - -$allowed = $eventpart = $eventpartsure = $fieldsWithDependency = $fieldsWithAllowedValueSet = []; - -foreach ($availableFields as $categoryName => $fieldCategory) { - $allowed = array_merge($allowed, array_keys($fieldCategory)); - - // Extended operations for events - if (strpos($categoryName, $tlLoader->tl("basis", "basis", 'event')) !== false) { - foreach ($fieldCategory as $key => $value) { - if (strpos($key, "_annotation") !== false or strpos($key, "_gnd") !== false) continue; - if (strpos($key, "_sure") !== false) $eventpartsure[] = $key; - else $eventpart[] = $key; - } - } - - foreach ($fieldCategory as $key => $value) { - if (!empty($value->dependsOn)) { - $fieldsWithDependency[$key] = $value->dependsOn; - } - if (!empty($value->allowedValues)) { - $fieldsWithAllowedValueSet[$key] = $value->allowedValues; - } - } - -} - -$allowed_inclusion_kind_of = ['inclusion_kind_of', 'Schenkung', 'Kauf', 'Grabung', 'Notbergung', 'Erbschaft', 'Stiftung', 'Enteignung', 'Ursprungsbestand', 'Ajándékozás','Vétel','Feltárás','Hivatalos átadás','Csere','Gyűjtés','Saját előállítás','Törzsanyag','Letét', 'endowment', 'dispossession', 'old stock', '']; - -echo printHTMLHead(); - -echo '
'; -echo 'Please wait ... (checking validity)'; -echo '
'; -echo ''; -echo '
'; - -///// Check #1 -//echo '
';print_r($allowed);echo '
'; -echo '1: Only allowed tags (column names) used?'; -$fp = fopen($csv_datei, 'r'); -$y = 0; -while ($zeile = fgetcsv($fp, 100000, ';')) { - - $y++; - $maxLoopLen = count($zeile); - for ($x = 0; $x < $maxLoopLen; $x++) { - $inhalt[$y][$x] = str_replace("'", "\'", $zeile[$x]); - if ($y == 1) { - // remove byte order mark - $inhalt[$y][$x] = str_replace("\xEF\xBB\xBF", "", $inhalt[$y][$x]); - if (!in_array($inhalt[$y][$x], $allowed)) { - $validator->addError( - '
ERROR in column ' . $x - . ' created by value: ' . $inhalt[$y][$x] . '' - ); - } - } - } -} -fclose($fp); - -$erstezeile = $inhalt[1]; -if (count($validator->error_msgs) != 0) { - echo '
Not allowed tags found !'; -} else { - echo '
Only allowed tags used !'; -} - -//// Check #2 -echo '

2: Not allowed multiple use of tags (column names)?'; -$compare = array_unique($erstezeile); - -if (count($erstezeile) != count($compare)) { - $validator->addError( - '
There are duplicate column names !' - ); -} else { - echo '
No duplicate column names !'; -} - -///// Check #3 -echo '

3: Mandatory tags available and always filled in?'; -unset($inv_array); - -/** - * Function for finding duplicates?. - * - * @param array $array Input array. - * - * @return array - */ -function Get_duplicates(array $array):array -{ - return array_unique(array_diff_assoc($array, array_unique($array))); - -} - -$mandatory = ['inventory_number','object_type','object_title','object_description']; -foreach ($mandatory as $tMandatoryField) { - if (!in_array($tMandatoryField, $erstezeile)) { - $validator->addInvError( - '
Mandatory: Column ' - . $tMandatoryField . ' missing' - ); - } else { - $spaltenr = array_search($tMandatoryField, $erstezeile); - for ($j = 0; $j < $y; $j++) { - if ($inhalt[$j + 1][$spaltenr] == '') { - $validator->addInvError( - '
Missing value for ' - . $tMandatoryField . ' in row ' . ($j + 1) . '' - ); - } - if ($tMandatoryField == 'inventory_number') { - $inv_array[] = $inhalt[$j + 1][$spaltenr]; - } - } - } -} - -if (count($validator->inv_errors) == 0) { - echo '
All mandatory tags available and with values !'; -} - - -///// Check #4 -echo '

4: Inventory_number unique ?'; -if (in_array('inventory_number', $erstezeile)) { - $doppelte_inv = Get_duplicates($inv_array); - $doppelte_inv = array_values($doppelte_inv); - if (!empty($doppelte_inv)) { - foreach ($doppelte_inv as $tDublicateInvNo) { - $validator->addError( - '
Multiple use of inventory_number ' - . $tDublicateInvNo . '' - ); - } - } else { - echo '
All inventory_numbers are unique !'; - } -} else { - $validator->addError( - '
Aborted, column inventory_number is missing' - ); -} - -///// Check #5 -echo '

5: Dependent colums observed ?
'; - - -// Check for correct handling of dependent fields -foreach ($fieldsWithDependency as $tField => $tDependentFields) { - if (array_search($tField, $erstezeile) !== false) { - foreach ($tDependentFields as $tDependentField) { - if (array_search($tDependentField, $erstezeile) === false) { - $depencymessage[] = "Dependency issue at column $tField: Corresponding column $tDependentField is missing"; - } - } - } -} - -if (!empty($depencymessage)) { - echo 'Dependent columns were not observed !'; - foreach ($depencymessage as $tDepMsg) { - $validator->addError('
' . $tDepMsg); - } -} else { - echo 'Dependent columns were observed !'; -} - -///// Check #6 -echo '

6: Dependency of content observed?'; - -//TODO: get the values for these arrays dynamically? -// JRE: Maybe we can merge them into availablefields -$crosscheck1 = ['object_other_title','detailed_description','detailed_description','inscription','inscription','dimensions_separate_length_value', 'dimensions_separate_width_value', 'dimensions_separate_height_value', 'dimensions_separate_diameter_value', 'dimensions_separate_wall_thickness_value', 'dimensions_separate_weight_value','closer_location','bought_for','worth_value','worth_insurance_value']; -$crosscheck2 = ['object_other_title_kind_of','detailed_description_md','detailed_description_extern','inscription_md','inscription_extern','dimensions_separate_length_unit', 'dimensions_separate_width_unit', 'dimensions_separate_height_unit', 'dimensions_separate_diameter_unit', 'dimensions_separate_wall_thickness_unit', 'dimensions_separate_weight_unit','closer_location_as','bought_for_currency','worth_unit','worth_insurance_unit']; - -foreach ($crosscheck1 as $l => $tCrossCheck) { - - if (in_array($tCrossCheck, $erstezeile)) { - - for ($j = 1; $j < ($y + 1); $j++) { - if ($inhalt[$j][array_search($crosscheck2[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tCrossCheck, $erstezeile)] == '') { - $validator->addDepconError( - '
Tag ' . $crosscheck2[$l] . ' given but no entry for ' - . $tCrossCheck . ' (row ' . $j . ')' - ); - } - } - - } - -} - -foreach ($eventpart as $l => $tEventPart) { - if (in_array($tEventPart, $erstezeile)) { - for ($j = 1; $j < ($y + 1); $j++) { - if ($inhalt[$j][array_search($eventpartsure[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tEventPart, $erstezeile)] == '') { - $validator->addDepconError( - '
Tag ' . $eventpartsure[$l] . ' given but no entry for ' - . $tEventPart . ' (row ' . $j . ')' - ); - } - } - } -} - -if (in_array('dimensions_separate_show_md', $erstezeile)) { - for ($j = 1; $j < ($y + 1); $j++) { - if ($inhalt[$j][array_search('dimensions_separate_show_md', $erstezeile)] !== '' and ($inhalt[$j][array_search('dimensions_separate_length_value', $erstezeile)] == '') and $inhalt[$j][array_search('dimensions_separate_width_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_heigt_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_weight_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_diameter_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_wall_thickness_value', $erstezeile)] == '') { - $validator->addDepconError( - '
Tag dimensions_separate_show_md given but no separate values available (row ' - . $j . ')' - ); - } - } -} - -if (in_array('dimensions_separate_show_extern', $erstezeile)) { - for ($j = 1; $j < ($y + 1); $j++) { - if ($inhalt[$j][array_search('dimensions_separate_show_extern', $erstezeile)] !== '' and ($inhalt[$j][array_search('dimensions_separate_length_value', $erstezeile)] == '') and $inhalt[$j][array_search('dimensions_separate_width_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_heigt_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_weight_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_diameter_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_wall_thickness_value', $erstezeile)] == '') { - $validator->addDepconError( - '
Tag dimensions_separate_show_extern given but no separate values available (row ' - . $j . ')' - ); - } - } -} -/* -for ($im=1;$im<11;$im++) -{ - if (in_array('image_name'.$im,$erstezeile)) - { - for ($j=1;$j<($y+1);$j++) - { - if ($inhalt[$j][array_search('image_rights'.$im,$erstezeile)]!=='') - { - echo '
TAG image_name'.$im.' given but no value available for image_rights'.$im.' (row '.$j.')'; - $depcon_error=$depcon_error+1; - } - if ($inhalt[$j][array_search('image_visible'.$im,$erstezeile)]!=='') - { - echo '
TAG image_name'.$im.' given but no value available for image_visible'.$im.' (row '.$j.')'; - $depcon_error=$depcon_error+1; - } - } - } -} -*/ -if (count($validator->depcon_errors) == 0) { - echo '
Dependency of content was observed !'; -} - -///// Check #7 -echo '

7: Not allowed values in controlled lists?
'; -for ($i = 2; $i <= $y; $i++) { - - foreach ($inhalt[$i] as $key => $value) { - - $columnName = $inhalt[1][$key]; - // Only do the check if the field is not restricted - if (isset($fieldsWithAllowedValueSet[$columnName])) { - - // For others: check if the value is from the list of allowed values. - if (!in_array($value, $fieldsWithAllowedValueSet[$columnName])) { - - // It may be that the value is empty together with all dependent fields, - // because it's in a repeat field that was needed earlier. - if (empty($value) && !empty($fieldsWithDependency[$columnName])) { - - $allDependentsEmpty = true; - foreach ($fieldsWithDependency[$columnName] as $depField) { - // Find keys of dependent field - $depFieldKey = array_search($depField, $inhalt[1]); - if (!empty($inhalt[$i][$depFieldKey])) { - $allDependentsEmpty = false; - break; - } - } - - if ($allDependentsEmpty !== true) { - $errormessage[] = "Disallowed value in column {$columnName} on row {$i}: " - . $value . " (allowed values: " - . implode(", ", $fieldsWithAllowedValueSet[$columnName]) - . ")"; - } - - } - - } - - } - } -} - -if (!empty($errormessage)) { - echo 'Columns with controlled values contain invalid values !'; - foreach ($errormessage as $tMsg) { - $validator->addError('
' . $tMsg); - } -} else { - echo 'Values in controlled fields are all valid !'; -} - -///// Check #8 -unset($errormessage); -echo '

8: Main image or main resource given?
'; -$hasanyimage = 0; -for ($im = 1; $im < 29; $im++) { - if (array_search('image_name' . $im, $erstezeile) != '') { - $imagemain[$im]['name'] = array_search('image_name' . $im, $erstezeile);$hasanyimage++; - } - if (array_search('image_visible' . $im, $erstezeile) != '') { - $imagemain[$im]['visible'] = array_search('image_visible' . $im, $erstezeile); - } - if (array_search('image_main' . $im, $erstezeile) != '') { - $imagemain[$im]['main'] = array_search('image_main' . $im, $erstezeile); - } -} - -if ($hasanyimage > 0) { - $imagemain = array_values($imagemain); - for ($i = 1; $i <= $y; $i++) { - if ($i > 1) { - //check if in a row any image_name is given - $maimg = $hatimg = 0; - foreach ($imagemain as $im => $tMainImage) { - if ($inhalt[$i][$tMainImage["name"]] != '') $hatimg++; - } - if ($hatimg > 0) { - // first check: how many main-images? - foreach ($imagemain as $im => $tMainImage) { - if ($inhalt[$i][$imagemain[$im]['main']] == 'y') { - $maimg++; - $merk = $im; - } - } - // if there is exacly one main-image, is it visible? - if ($maimg == 1) { - if ($inhalt[$i][$imagemain[$merk]['visible']] == 'n') { - $errormessage[] = 'Main image in row ' . $i . ' is not visible'; - } - } - } - if ($maimg == 0 and $hatimg > 0) { - $errormessage[] = 'There is no visible main image given in row ' . $i . ''; - } - if ($maimg > 1 and $hatimg > 0) { - $errormessage[] = 'There are ' . $maimg . ' main images given in row ' . $i . ''; - } - } - } - - if (!empty($errormessage)) { - echo 'There is not one main image for each object !'; - foreach ($errormessage as $tMsg) { - $validator->addError('
' . $tMsg); - } - } else { - echo 'For each object that has images attached exactly one main image is given !'; - } -} else { - echo 'No images to be imported !'; -} - -echo '
'; - -if ($validator->overallErrorCount() > 0) { - echo ' -

Error(s) found: ' . $validator->overallErrorCount() . '

'; - foreach ($validator->error_msgs as $msg) { - echo $msg; - } - foreach ($validator->inv_errors as $msg) { - echo $msg; - } - foreach ($validator->depcon_errors as $msg) { - echo $msg; - } - echo 'Create XML for md:import (utf8)
'; -} else { - echo 'Create XML for md:import (utf8)
'; -} -echo '
'; -echo ' - - - -'; diff --git a/public/index6.php b/public/index6.php deleted file mode 100644 index fd0b8af..0000000 --- a/public/index6.php +++ /dev/null @@ -1,92 +0,0 @@ -preserveWhiteSpace = false; - $xmlDoc->formatOutput = true; - # $xmlDoc->encoding = 'utf-8'; - $xmlMainElem = $xmlDoc->createElement("record"); - $record_node = $xmlDoc->appendChild($xmlMainElem); //add record element to XML node - # $rss_node->setAttribute("version", "2.0"); //set RSS version - - if (empty($lineCount)) $lineCount = count($zeile); - - for ($x = 0; $x < $lineCount; $x++) { - $inhalt[$y][$x] = $zeile[$x]; - if ($inhalt[$y][$x] == '') $inhalt[$y][$x] = 'ERSATZ'; - - if (!isset($inhalt[1][$x])) { - echo "Error at position $x"; - } - - $record_node->appendChild(createTextDomElement($xmlDoc, trim($inhalt[1][$x] ?? ""), trim($inhalt[$y][$x] ?? ""))); - - } - - $somecontent = '' . $xmlDoc->saveXML($xmlDoc->documentElement); - - # $somecontent .= ''; - //if ($y>1) - //{ - if (fwrite($handle, $somecontent) === false) { - echo "Cannot write to file ($filename)"; - exit; - } - - fclose($handle); -} -fclose($fp); - - -echo printHTMLHead(); - -echo ' -
- ' . ($y - 1) . ' files created
-
- Download as ZIP -
'; diff --git a/public/index_new.php b/public/index_new.php deleted file mode 100644 index db2edde..0000000 --- a/public/index_new.php +++ /dev/null @@ -1,87 +0,0 @@ - - */ -declare(strict_types = 1); -require_once __DIR__ . "/../functions/functions.php"; - -$allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl', 'pt']; -$lang = MD_STD::get_user_lang($allowed_langs, "en"); -$tlLoader = new MDTlLoader("csxml_start_v2", $lang); - -$outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']); - -if ($outFormat === 'json') { - - $fieldsGetter = new CsvxmlAvailableFields($lang); - $availableFields = $fieldsGetter->getFields(); - - header('Cache-Control: no-cache, no-store, must-revalidate, max-age=0'); // HTTP/1.1 - header('Pragma: no-cache'); // HTTP/1.0 - header("Access-Control-Allow-Origin: *"); - header("Access-Control-Allow-Methods: GET"); - header("Access-Control-Allow-Headers: X-PINGOTHER, Content-Type, Accept-Encoding, cache-control"); - header("Access-Control-Max-Age: 86400"); - header('content-type: application/json'); - echo json_encode($availableFields); - return; -} - - -echo ' - - - - - - - - - - - - - - - CSVXML :: museum-digital - - - - - - $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'), - 'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'), - 'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'), - 'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'), - 'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'), - 'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'), - 'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'), - 'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'), - 'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'), - 'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'), - 'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'), - 'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'), - 'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'), - 'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'), - 'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'), - 'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'), -])) . '"> - -

- - museum-digital:csvxml -

- - - - -'; - diff --git a/public/upload.php b/public/upload.php deleted file mode 100644 index a9148aa..0000000 --- a/public/upload.php +++ /dev/null @@ -1,35 +0,0 @@ - 40000000) { - echo "Your file is too large.
"; - return; -} - -//Here we check that $ok was not set to 0 by an error -//If everything is ok we try to upload it -if(!move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { - echo "Sorry, there was a problem uploading your file."; - return; -} - -header("Location: index3.php?fnam=" . basename($_FILES['uploaded']['name'])); diff --git a/public/zipit.php b/public/zipit.php deleted file mode 100644 index 75ccab0..0000000 --- a/public/zipit.php +++ /dev/null @@ -1,43 +0,0 @@ -setComment("Example Zip file.\nCreated on " . date('l jS \of F Y h:i:s A')); - -if ($handle = opendir($fileDir)) { - /* This is the correct way to loop over the directory. */ - while (false !== ($file = readdir($handle))) { - if (strpos($file, ".xml") !== false) { - $pathData = pathinfo($fileDir . $file); - $fileName = $pathData['filename']; - if ($file != '1.xml') - $zip->addFile(MD_STD::file_get_contents($fileDir . $file), $file, filectime($fileDir . $file)); - } - } -} - -if (ini_get('zlib.output_compression')) { - ini_set('zlib.output_compression', 'Off'); -} - -$zip->finalize(); // Not scrictly necessary, the next line will call it anyway. -$zipData = $zip->getZipData(); -$length = strlen($zipData); - -header('Pragma: public'); -header("Last-Modified: " . $fileTime); -header("Expires: 0"); -header("Accept-Ranges: bytes"); -header("Connection: close"); -header("Content-Type: application/zip"); -header('Content-Disposition: attachment; filename="csv_xml.zip";' ); -header("Content-Transfer-Encoding: binary"); -header("Content-Length: " . $length); -echo $zipData; - -rrmdir(__DIR__ . '/../xml'); -