Add a lot of new fields with improved and more integrated checks for

dependencies and allowed values
This commit is contained in:
2019-09-01 19:54:01 +02:00
committed by Stefan Rohde-Enslin
parent b8a03e1509
commit 13395387a0
11 changed files with 556 additions and 693 deletions

15
csv.php
View File

@ -38,10 +38,10 @@ require __DIR__ . "/values/availableFields.php";
$line1 = $line2 = $line3 = $line4 = [];
$tLine1 = $tLine2 = $tLine3 = $tLine4 = [];
foreach ($availableFields as $headline => $fields) {
$i = 0;
$tLine1 = $tLine2 = $tLine3 = $tLine4 = [];
$tLine1[] = $headline;
foreach($fields as $fieldName => $field) {
@ -53,11 +53,14 @@ foreach ($availableFields as $headline => $fields) {
if ($i !== 0) $tLine1[] = "";
$tLine2[] = $fieldName;
$tLine3[] = $field['name_human_readable'];
$tLine4[] = $field['remark'];
# $tLine4[] = $field['remark'];
if (!empty($field['allowedValues'])) $tLine4[] = end($field['allowedValues']);
else $tLine4[] = $field['name_human_readable'];
$i++;
}
if (empty($tLine2)) continue;
if (empty($tLine2) or count($tLine2) === 0) continue;
for ($i = 1; $i <= 4; $i++) {
${"line$i"} = array_merge(${"line$i"}, ${"tLine$i"});
@ -65,12 +68,12 @@ foreach ($availableFields as $headline => $fields) {
}
header('Content-Type: text/csv');
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 = 1; $i <= 4; $i++) {
echo '"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL;
for ($i = 2; $i <= 4; $i++) {
echo mb_convert_encoding('"' . implode("\";\"", ${"line$i"}) . '"' . PHP_EOL, 'utf-16','utf-8');;
}