Replace index.php with new.php

This commit is contained in:
Joshua Ramon Enslin 2019-09-01 20:49:16 +02:00 committed by Stefan Rohde-Enslin
parent 417db62419
commit 250aac25ce
2 changed files with 94 additions and 284 deletions

281
index.php
View File

@ -1,190 +1,97 @@
<?PHP <?PHP
error_reporting(E_ALL); /**
ini_set('display_errors', 1); * New start page for CSVXML.
?> *
<head> * @link https://groupit.museum-digital.de/csvxml/
<script language="javascript" type="text/javascript"> *
var tooltips = document.querySelectorAll('.couponcode'); * @author Joshua Ramon Enslin <joshua@museum-digital.de>
for(var i = 0; i < tooltips.length; i++) {
tooltips[i].addEventListener('mousemove', function fn(e) {
var tooltip = e.target.classList.contains("coupontooltip") ?
e.target :
e.target.querySelector(':scope .coupontooltip');
tooltip.style.left =
e.pageX + tooltip.clientWidth + 10 <
document.body.clientWidth ?
e.pageX + 10 + 'px' :
document.body.clientWidth + 5 - tooltip.clientWidth + 'px';
tooltip.style.top =
e.pageY + tooltip.clientHeight + 10 <
document.body.clientHeight ?
e.pageY + 10 + 'px' :
document.body.clientHeight + 5 - tooltip.clientHeight + 'px';
});
}</script>
</head>
<?PHP
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>';
echo '<link rel="stylesheet" type="text/css" href="css/main.css">';
echo '<div class="title">';
echo 'museum-digital CSV to XML converter';
echo '</div>';
echo '<div class="maincontent">';
echo '<div class="uploader">';
echo '<form enctype="multipart/form-data" action="upload.php" method="POST" style="margin:0px;padding:0px;">';
echo 'Please choose a csv-file to create xml-files: <input name="uploaded" type="file" />';
echo '<input type="submit" value="Upload" />';
echo '</form>';
echo '</div>';
echo '<div class="main_fieldlist">';
require 'values/all_fields.php';
echo '<p>Currently approved tags (column names) for md:import:</p>';
//echo '<table>';
//echo '<th>Name</th><th>Mandatory</th><th>Allowed</th><th>Remarks</th><th>Dependencies</th>';
$categories = array('basic','other object title','detailed description','inscription','material_technique separate','separate dimensions','comparable objects','closer location','categorisation', 'object administration', 'object history', 'worth', 'state', 'location', 'rights (object)', 'remarks', 'links', 'literature', 'object_group', 'tags', 'events: related place', 'events: related actor', 'events: related time', 'images', 'resources', 'events: production', 'events: finding', 'events: publication', 'events: template creation', 'events: depiction_who', 'events: depiction_place', 'events: use', 'events: writing', 'events: colleting', 'events: painting', 'events: taking', 'events: receiving', 'events: printing plate production', 'events: sending', 'events: issuing', 'events: signing', 'events: type description', 'events:drawing', 'events: copying', 'events: has lived', 'events: commissioned', 'events: printed', 'events: spoken', 'events: sung', 'events: decor designed', 'events: form designed', 'events: modelled', 'events: signed', 'events: mentioning', 'events: burying', 'events: intellectual creation', 'events: painting on', 'events: illustrated' );
$cat_counter = 0;
for ($i = 0; $i < count($allowed); $i++)
{
//echo '<tr>';
if ($i == 0) {echo '<br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 10) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 12) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 15) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 18) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 20) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 36) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 39) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 41) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 47) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 53) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 57) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 65) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 67) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 75) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 78) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 82) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 86) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 108) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 123) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 133) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 137) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 141) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 145) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 215) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 233) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 247) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 261) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 275) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 289) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 293) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
} /**/
if ($i == 297) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 311) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 325) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 339) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 353) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 367) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 381) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 395) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 409) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 423) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 437) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 451) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 465) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 479) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 489) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 503) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 517) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 531) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 545) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 559) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 573) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 587) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 601) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 615) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 629) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 643) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
if ($i == 657) {echo '<br/><br/><b>' . $categories[$cat_counter] . '</b><br/>';$cat_counter++;
}
/*
*/ */
echo '<span class="couponcode" style="display:inline-block;padding:3px;border:1px solid #666666;border-radius:2px;margin:2px;'; declare(strict_types = 1);
if ($allowed[$i][1] == 'y') echo 'background-color:#eeee99;'; else echo 'background-color:#eeeeee;'; error_reporting(E_ALL);
echo '">'; ini_set('display_errors', "1");
echo '<span class="coupontooltip">';
echo '<p style="text-align:center;padding:0px;margin:0px;line-height:18px;">' . $allowed[$i][0] . '</p><hr>'; require_once __DIR__ . "/functions/functions.php";
if (isset($allowed[$i][1])) echo '<p>Mandatory: ' . $allowed[$i][1] . "</p>";
if (isset($allowed[$i][5])) echo '<p class="hint" style="background-color:black;">' . $allowed[$i][5] . '</p>'; if (session_status() != PHP_SESSION_ACTIVE) {
if (isset($allowed[$i][2])) echo '<p>Format: ' . $allowed[$i][2] . "</p>"; session_start();
if (isset($allowed[$i][3])) echo '<p>Allowed values: ' . $allowed[$i][3] . "</p>";
if (isset($allowed[$i][4])) echo '<p>Dependencies: ' . $allowed[$i][4] . "</p>";
echo '</span>';
echo '<a';
echo '>' . $allowed[$i][0] . '</a>';
echo '</span>';
// echo '<td>'.$allowed[$i][1].'</td>';
// echo '<td>'.$allowed[$i][2].'</td>';
// echo '<td>'.$allowed[$i][3].'</td>';
// echo '<td>'.$allowed[$i][4].'</td>';
//echo '</tr>';
} }
//echo '</table>';
//print_r($allowed); // This array contains all available languages
echo '</div>'; $allowed_langs = ['ar', 'de', 'en', 'hu', 'id', 'it', 'pl','pt'];
echo '</div>';
// 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'];
require __DIR__ . "/translation-importer/$lang/csvxml-overview.php";
$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">' . $csvxml_overview['select_csv_file_for_upload'] . '</label>
<input name="uploaded" type="file" accept=".csv" id="fileToUpload" required />
<button type="submit">' . $csvxml_overview['upload'] . '</button>
</form>
</div>
<div>
<h2>' . $csvxml_overview['currently_approved_tags'] . '</h2>
<div class="options">
<a href="csv.php" class="buttonLike">' . $csvxml_overview['download_csv_all'] . '</a>
<a class="buttonLike invisible" id="csvBySelection">' . $csvxml_overview['download_csv_by_selection'] . '</a>
<br />
<a class="buttonLike" id="selectRequired">' . $csvxml_overview['select_required_fields'] . '</a>
<a class="buttonLike" id="selectAll">' . $csvxml_overview['select_all_fields'] . '</a>
<a class="buttonLike invisible" id="unsetSelection">' . $csvxml_overview['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>
';

97
new.php
View File

@ -1,97 +0,0 @@
<?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'];
require __DIR__ . "/translation-importer/$lang/csvxml-overview.php";
$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">' . $csvxml_overview['select_csv_file_for_upload'] . '</label>
<input name="uploaded" type="file" accept=".csv" id="fileToUpload" required />
<button type="submit">' . $csvxml_overview['upload'] . '</button>
</form>
</div>
<div>
<h2>' . $csvxml_overview['currently_approved_tags'] . '</h2>
<div class="options">
<a href="csv.php" class="buttonLike">' . $csvxml_overview['download_csv_all'] . '</a>
<a class="buttonLike invisible" id="csvBySelection">' . $csvxml_overview['download_csv_by_selection'] . '</a>
<br />
<a class="buttonLike" id="selectRequired">' . $csvxml_overview['select_required_fields'] . '</a>
<a class="buttonLike" id="selectAll">' . $csvxml_overview['select_all_fields'] . '</a>
<a class="buttonLike invisible" id="unsetSelection">' . $csvxml_overview['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>
';