From 1f766c7eca5b25316488ff703bcc73beb53067a5 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Sun, 1 Sep 2019 19:58:23 +0200 Subject: [PATCH] Remove obsolete files for generating iso8859 XML files --- csv.php | 4 ++-- csv_check.php | 33 +++++++++++++++------------------ csv_laden.php | 43 ------------------------------------------- index2.php | 2 +- index4.php | 4 ++-- index5.php | 16 ---------------- 6 files changed, 20 insertions(+), 82 deletions(-) delete mode 100644 csv_laden.php delete mode 100644 index5.php diff --git a/csv.php b/csv.php index c4a1592..01196e2 100644 --- a/csv.php +++ b/csv.php @@ -56,7 +56,7 @@ foreach ($availableFields as $headline => $fields) { # $tLine4[] = $field['remark']; if (!empty($field['allowedValues'])) $tLine4[] = end($field['allowedValues']); else $tLine4[] = $field['name_human_readable']; - + $i++; } @@ -75,5 +75,5 @@ else header("Content-Disposition: attachment; filename=csvxml_museum-digital_template-{$lang}.csv"); for ($i = 2; $i <= 4; $i++) { - echo mb_convert_encoding('"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL, 'utf-16','utf-8');; + echo mb_convert_encoding('"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL, 'utf-16', 'utf-8');; } diff --git a/csv_check.php b/csv_check.php index 97759e7..97df1a2 100644 --- a/csv_check.php +++ b/csv_check.php @@ -33,7 +33,7 @@ $allowed = $eventpart = $eventpartsure = $fieldsWithDependency = $fieldsWithAllo foreach ($availableFields as $categoryName => $fieldCategory) { $allowed = array_merge($allowed, array_keys($fieldCategory)); - + // Extended operations for events if (strpos($categoryName, $basis['event']) !== false) { foreach ($fieldCategory as $key => $value) { @@ -42,7 +42,7 @@ foreach ($availableFields as $categoryName => $fieldCategory) { else $eventpart[] = $key; } } - + foreach ($fieldCategory as $key => $value) { if (!empty($value["dependsOn"])) { $fieldsWithDependency[$key] = $value['dependsOn']; @@ -51,7 +51,7 @@ foreach ($availableFields as $categoryName => $fieldCategory) { $fieldsWithAllowedValueSet[$key] = $value['allowedValues']; } } - + } $allowed_object_other_title_kind_of = array('object_other_title_kind_of', 'Wissenschaft', 'Alltagssprache', 'Umgangssprache', 'Dialekt', 'Tudományos', 'Köznyelvi', 'Nyelvjárás'); @@ -73,8 +73,8 @@ $fp = fopen ( $csv_datei, 'r' ); $y = 1; $error = 0; $zeile = fgetcsv ( $fp, 100000, ';' ); -for ($x = 0; $x < count ( $zeile ); $x++) -{ +for ($x = 0; $x < count($zeile); $x++) { + $zeile[$x] = str_replace("\xEF\xBB\xBF", "", $zeile[$x]); $inhalt[$y][$x] = $zeile[$x]; if (!in_array($inhalt[1][$x], $allowed)) { @@ -187,15 +187,15 @@ echo '

5: Dependent colums observed ?
'; // Check for correct handling of dependent fields foreach ($fieldsWithDependency as $tField => $tDependentFields) { - + if (array_search($tField, $erstezeile) === false) continue; - + foreach ($tDependentFields as $tDependentField) { if (array_search($tDependentField, $erstezeile) === false) { $depencymessage[] = "Dependency issue at column $tField: Corresponding column $tDependentField is missing"; } } - + } if (isset($depencymessage) and $depencymessage != '') { @@ -281,18 +281,18 @@ if ($depcon_error == 0) echo '
De ///// 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]; // If the field is not restricted, then continue if (!isset($fieldsWithAllowedValueSet[$columnName])) continue; - + // For others: check if the value is from the list of allowed values. if (!in_array($value, $fieldsWithAllowedValueSet[$columnName])) { $errormessage[] = "Disallowed value in column {$columnName} on row {$i}: " . $value . " (allowed values: " . implode(", ", $fieldsWithAllowedValueSet[$columnName]) . ")"; } - + } } @@ -354,8 +354,7 @@ if ($hasanyimage > 0) { if (isset($errormessage) and $errormessage != '') { echo 'There is not one main image for each object !'; - for ($i = 0; $i < count ($errormessage); $i++) - { + for ($i = 0; $i < count($errormessage); $i++) { echo '
' . $errormessage[$i]; $error++; } @@ -364,8 +363,7 @@ if ($hasanyimage > 0) { echo 'For each object that has images attached exactly one main image is given !'; } } -else -{ +else { echo 'No images to be imported !'; } @@ -375,6 +373,5 @@ if ($error + $depcon_error > 0) {

Error(s) found: ' . ($error + $depcon_error) . '

'; } else { - echo ' Create XML for md:import (iso 8859-1)
'; - echo ' Create XML for md:import (utf8)
'; + echo 'Create XML for md:import (utf8)
'; } diff --git a/csv_laden.php b/csv_laden.php deleted file mode 100644 index fe04b6b..0000000 --- a/csv_laden.php +++ /dev/null @@ -1,43 +0,0 @@ -Zeile='.$y.' Anzahl in Zeile: '.count ( $zeile ).'
'; - $zieldatei = 'xml/' . $y . '.xml'; - if (!$handle = fopen($zieldatei, 'w')) { - echo "Cannot open file ($zieldatei)";exit; - } - $somecontent = '' . "\n"; // normal - $somecontent = $somecontent . '' . "\n"; - - for ($x = 0; $x < count ( $zeile ); $x++) - { - $inhalt[$y][$x] = $zeile[$x]; - //echo ''.$inhalt[1][$x].' --> '.$zeile[$x].'
'; - if ($inhalt[$y][$x] == '') $inhalt[$y][$x] = 'ERSATZ'; - //$somecontent=$somecontent.'<'.tagify(transform($inhalt[1][$x])).'>'.utf8_decode(transform($inhalt[$y][$x])).''."\n"; // für utf8 - //$somecontent=$somecontent.'<'.tagify(transform($inhalt[1][$x])).'>'.(($inhalt[$y][$x])).''."\n"; //für ungarn sonst weg ////////////////////////////////////////////////////////////// - - $somecontent = $somecontent . '<' . tagify(transform($inhalt[1][$x])) . '>' . transform($inhalt[$y][$x]) . '' . "\n"; //normaleinstellung - } - $somecontent = $somecontent . '
'; - //if ($y>1) - //{ - if (fwrite($handle, $somecontent) === FALSE) { - echo "Cannot write to file ($filename)";exit; - } - // echo "Success, wrote to file ($filename)

"; - //} - fclose($handle); -} -fclose($fp); -echo ($y - 1) . ' files created'; -echo '
Download as zip'; diff --git a/index2.php b/index2.php index 662a174..328cd48 100644 --- a/index2.php +++ b/index2.php @@ -40,7 +40,7 @@ mkdir("xml", 0755); $fp = fopen ( $csv_datei, 'r' ); $y = 0; while ($zeile = fgetcsv($fp, 100000, ';')) { - + $y++; $zieldatei = 'xml/' . $y . '.xml'; if (!$handle = fopen($zieldatei, 'w')) { diff --git a/index4.php b/index4.php index df738c8..40a0c50 100644 --- a/index4.php +++ b/index4.php @@ -35,7 +35,7 @@ mkdir("xml", 0755); $fp = fopen ($csv_datei, 'r'); $y = 0; while ($zeile = fgetcsv($fp, 100000, ';')) { - + $y++; $zieldatei = 'xml/' . $y . '.xml'; if (!$handle = fopen($zieldatei, 'w')) { @@ -58,7 +58,7 @@ while ($zeile = fgetcsv($fp, 100000, ';')) { echo "Cannot write to file ($filename)";exit; } fclose($handle); - + } fclose($fp); diff --git a/index5.php b/index5.php deleted file mode 100644 index b49820e..0000000 --- a/index5.php +++ /dev/null @@ -1,16 +0,0 @@ -'; -echo '
'; -echo 'museum-digital CSV to XML converter'; -echo '
'; -echo '
'; -$semikoma = $_GET['semikoma']; -echo ''; -echo ''; - echo ''; -echo ''; -echo '
'; - echo 'Please wait ... (transforming)
'; - require 'csv_laden.php'; - echo '
'; -echo '
';