2019-08-25 21:45:52 +02:00
|
|
|
<?PHP
|
2019-09-01 20:49:16 +02:00
|
|
|
/**
|
|
|
|
* New start page for CSVXML.
|
|
|
|
*
|
|
|
|
* @link https://groupit.museum-digital.de/csvxml/
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
2020-10-31 00:00:26 +01:00
|
|
|
require_once __DIR__ . "/../functions/functions.php";
|
2019-09-01 20:49:16 +02:00
|
|
|
|
|
|
|
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'])) {
|
2020-08-10 20:13:16 +02:00
|
|
|
$_SESSION['lang'] = MD_STD::lang_getfrombrowser($allowed_langs, 'en', "", false);
|
2019-09-01 20:49:16 +02:00
|
|
|
}
|
|
|
|
$lang = $_SESSION['lang'];
|
|
|
|
|
2021-02-16 12:08:55 +01:00
|
|
|
$outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']);
|
|
|
|
|
2020-10-29 21:09:20 +01:00
|
|
|
$tlLoader = new MDTlLoader("csxml_start", $lang);
|
2019-09-01 20:49:16 +02:00
|
|
|
|
2021-02-16 12:08:55 +01:00
|
|
|
$fieldsGetter = new CsvxmlAvailableFields($lang);
|
|
|
|
$availableFields = $fieldsGetter->getFields();
|
|
|
|
|
|
|
|
if ($outFormat === 'json') {
|
|
|
|
header('content-type: application/json');
|
|
|
|
echo json_encode($availableFields);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-01 20:49:16 +02:00
|
|
|
$toInject = '
|
|
|
|
<script src="assets/js/newToolTip.js" type="text/javascript" defer></script>
|
|
|
|
';
|
|
|
|
echo printHTMLHead($toInject);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
|
|
|
<div class="uploader">
|
|
|
|
<form enctype="multipart/form-data" action="upload.php" method="POST">
|
2020-12-10 00:49:46 +01:00
|
|
|
<input type="hidden" id="csrf-token" name="csrf-token" aria-label="Anti-CSRF Token" value="' . htmlspecialchars(MD_STD_SEC::getAntiCsrfToken()) . '" />
|
2020-10-29 21:09:20 +01:00
|
|
|
<label for="fileToUpload">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload') . '</label>
|
2019-09-01 20:49:16 +02:00
|
|
|
<input name="uploaded" type="file" accept=".csv" id="fileToUpload" required />
|
2020-10-29 21:09:20 +01:00
|
|
|
<button type="submit">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload') . '</button>
|
2019-09-01 20:49:16 +02:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
2020-10-29 21:09:20 +01:00
|
|
|
<h2>' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags') . '</h2>
|
2019-09-01 20:49:16 +02:00
|
|
|
<div class="options">
|
2020-10-29 21:09:20 +01:00
|
|
|
<a href="csv.php" class="buttonLike">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all') . '</a>
|
|
|
|
<a class="buttonLike invisible" id="csvBySelection">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection') . '</a>
|
2019-09-01 20:49:16 +02:00
|
|
|
<br />
|
2020-10-29 21:09:20 +01:00
|
|
|
<a class="buttonLike" id="selectRequired">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields') . '</a>
|
|
|
|
<a class="buttonLike" id="selectAll">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields') . '</a>
|
|
|
|
<a class="buttonLike invisible" id="unsetSelection">' . $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection') . '</a>
|
2019-09-01 20:49:16 +02:00
|
|
|
</div>
|
|
|
|
';
|
|
|
|
|
|
|
|
$tooltips = [];
|
|
|
|
foreach ($availableFields as $headline => $fields) {
|
|
|
|
|
2019-09-01 21:16:37 +02:00
|
|
|
echo "
|
|
|
|
<h3>{$headline}</h3>
|
2019-09-01 20:49:16 +02:00
|
|
|
<ul class='fieldList'>
|
|
|
|
";
|
|
|
|
|
|
|
|
foreach($fields as $fieldName => $field) {
|
2019-09-01 20:59:25 +02:00
|
|
|
|
|
|
|
if (!empty($field['remark']) or !empty($field['explica'])) $hasTooltip = true;
|
|
|
|
else $hasTooltip = false;
|
|
|
|
|
2019-09-01 20:49:16 +02:00
|
|
|
echo "
|
2019-09-01 21:16:37 +02:00
|
|
|
<li id='{$fieldName}' data-alt='{$field['name_human_readable']}' data-value='{$fieldName}' data-for='{$fieldName}' class='";
|
2019-09-01 20:59:25 +02:00
|
|
|
if ($hasTooltip === true) echo " newToolTipTag";
|
2019-11-11 12:13:52 +01:00
|
|
|
if (!empty($field['required']) and $field['required'] === true) echo " requiredField";
|
2019-09-01 21:16:37 +02:00
|
|
|
echo "'";
|
|
|
|
if (!empty($field['dependsOn'])) {
|
|
|
|
echo " data-dependencies='" . htmlspecialchars(implode(";", $field['dependsOn'])) . "'";
|
|
|
|
}
|
|
|
|
echo ">{$fieldName}";
|
2019-09-01 20:59:25 +02:00
|
|
|
|
|
|
|
if (!empty($field['explica'])) $toolTipExplica = "</p><h5>General</h5><p>" . $field['explica'];
|
|
|
|
else $toolTipExplica = "";
|
|
|
|
$toolTip = generateHelpTooltip($fieldName, $field['name_human_readable'], "{$field['remark']}{$toolTipExplica}");
|
|
|
|
if ($hasTooltip) $tooltips[] = $toolTip[0];
|
2019-09-01 20:49:16 +02:00
|
|
|
echo "</li>";
|
|
|
|
}
|
|
|
|
|
2019-09-01 21:16:37 +02:00
|
|
|
echo '
|
|
|
|
</ul>
|
|
|
|
';
|
2019-09-01 20:49:16 +02:00
|
|
|
|
2019-08-25 21:45:52 +02:00
|
|
|
}
|
2019-09-01 20:49:16 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</div>
|
|
|
|
|
|
|
|
';
|
|
|
|
echo implode($tooltips);
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
';
|