csvxml/new.php

96 lines
2.7 KiB
PHP
Raw Normal View History

2019-08-27 00:32:24 +02:00
<?PHP
/**
* New start page for CSVXML.
*
* @link https://groupit.museum-digital.de/csvxml/
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
error_reporting(E_ALL);
ini_set('display_errors', "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'] = lang_getfrombrowser($allowed_langs, 'en', "", false);
}
$lang = $_SESSION['lang'];
$toInject = '
<link rel="stylesheet" type="text/css" href="assets/css/editMenu.css" />
<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">
<label for="fileToUpload">Please select a CSV-file to create xml-files</label>
<input name="uploaded" type="file" id="fileToUpload" required />
<button type="submit">Upload</button>
</form>
</div>
<div>
<h2>Currently approved tags (column names) for md:import</h2>
<div class="options">
<a href="csv.php" class="buttonLike">Download CSV template with all fields</a>
<a class="buttonLike invisible" id="csvBySelection">Download CSV template based on selection</a>
<br />
<a class="buttonLike" id="selectRequired">Select required fields</a>
<a class="buttonLike" id="selectAll">Select all fields</a>
<a class="buttonLike invisible" id="unsetSelection">Unset selection</a>
</div>
';
require __DIR__ . "/values/availableFields.php";
$tooltips = [];
foreach ($availableFields as $headline => $fields) {
echo "<h3>{$headline}</h3>
<ul class='fieldList'>
";
foreach($fields as $fieldName => $field) {
echo "
<li data-alt='{$field['name_human_readable']}' data-value='{$fieldName}' data-for='{$fieldName}' class='newToolTipTag";
if ($field['required'] === true) echo " requiredField";
echo "'>{$fieldName}";
$toolTip = generateHelpTooltip($fieldName, $field['name_human_readable'], "{$field['remark']}</p><h5>General</h5><p>" . $field['explica']);
$tooltips[] = $toolTip[0];
echo "</li>";
}
echo '</ul>';
}
echo '
</div>
';
echo implode($tooltips);
echo '
</body>
</html>
';