2022-11-07 02:55:54 +01:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* Compiles the client-side application from PHP parts.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
require_once __DIR__ . "/../functions/functions.php";
|
|
|
|
|
2023-01-18 01:31:36 +01:00
|
|
|
const GET_PARAM_JS_CSS = "v000009";
|
2022-11-28 14:27:46 +01:00
|
|
|
|
2022-11-07 02:55:54 +01:00
|
|
|
/**
|
|
|
|
* Generates the json for a translation file.
|
|
|
|
*
|
|
|
|
* @param string $lang Language.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateFieldsIndex(string $lang):string {
|
|
|
|
|
|
|
|
$fieldsGetter = new CsvxmlAvailableFields($lang);
|
|
|
|
$availableFields = $fieldsGetter->getFields();
|
|
|
|
return MD_STD::json_encode($availableFields);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates the json for a translation file.
|
|
|
|
*
|
|
|
|
* @param string $lang Language.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateTranslationFile(string $lang):string {
|
|
|
|
|
|
|
|
$tlLoader = new MDTlLoader("csvxml_tl_cache", $lang);
|
|
|
|
|
|
|
|
return MD_STD::json_encode([
|
|
|
|
'remarks' => $tlLoader->tl('basis', 'basis', 'remarks'),
|
|
|
|
'download' => $tlLoader->tl('export', 'export', 'download'),
|
|
|
|
'upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'upload'),
|
|
|
|
'select_csv_file_for_upload' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_csv_file_for_upload'),
|
|
|
|
'currently_approved_tags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'currently_approved_tags'),
|
|
|
|
'download_csv_all' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_all'),
|
|
|
|
'download_csv_by_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'download_csv_by_selection'),
|
|
|
|
'select_required_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_required_fields'),
|
|
|
|
'select_all_fields' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'select_all_fields'),
|
|
|
|
'unset_selection' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'unset_selection'),
|
|
|
|
'file_format' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_format'),
|
|
|
|
'validation_errors' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'validation_errors'),
|
|
|
|
'errors_parsing' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_parsing'),
|
|
|
|
'errors_mandatoryTags' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mandatoryTags'),
|
|
|
|
'errors_duplicateInvNos' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_duplicateInvNos'),
|
|
|
|
'errors_dependentColumns' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_dependentColumns'),
|
|
|
|
'errors_controlledLists' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_controlledLists'),
|
|
|
|
'errors_mainImageResource' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'errors_mainImageResource'),
|
|
|
|
'allowed_values' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'allowed_values'),
|
2022-11-07 21:11:34 +01:00
|
|
|
|
|
|
|
'privacy_policy' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'privacy_policy'),
|
|
|
|
'contact' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'contact'),
|
|
|
|
'news' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'news'),
|
|
|
|
'imprint' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'imprint'),
|
|
|
|
'about' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'about'),
|
2022-11-17 17:56:23 +01:00
|
|
|
|
|
|
|
'help_where_am_i' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_where_am_i'),
|
|
|
|
'help_where_am_i_content' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_where_am_i_content'),
|
2022-11-18 02:04:24 +01:00
|
|
|
'help_what_is_csv' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_what_is_csv'),
|
|
|
|
'help_what_is_csv_content' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_what_is_csv_content'),
|
|
|
|
'help_how_to_format_csv' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_how_to_format_csv'),
|
|
|
|
'help_how_to_format_csv_content' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'help_how_to_format_csv_content'),
|
2022-11-28 14:27:46 +01:00
|
|
|
|
|
|
|
'file_encoding_is_not_utf8' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'file_encoding_is_not_utf8'),
|
|
|
|
'non_utf8_file_instruction' => $tlLoader->tl("csvxml-overview", "csvxml_overview", 'non_utf8_file_instruction'),
|
|
|
|
|
2022-11-07 02:55:54 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate index.htm.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function generateAppShell():string {
|
|
|
|
|
|
|
|
return '<!DOCTYPE HTML>
|
|
|
|
<html data-allowed-langs="' . htmlspecialchars(implode(',', ALLOWED_LANGS)) . '">
|
|
|
|
<head>
|
|
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
2022-11-28 14:27:46 +01:00
|
|
|
<link rel="stylesheet" type="text/css" href="assets/css/csvxml.min.css?' . GET_PARAM_JS_CSS . '" />
|
2022-11-07 03:55:07 +01:00
|
|
|
<link rel="manifest" href="/manifest.json" />
|
2022-11-07 02:55:54 +01:00
|
|
|
<meta name="theme-color" content="#aa4400" />
|
|
|
|
|
|
|
|
<title>CSVXML :: museum-digital</title>
|
2022-11-07 03:55:07 +01:00
|
|
|
<meta name="twitter:title" content="CSVXML :: museum-digital" />
|
|
|
|
<meta property="og:title" content="CSVXML :: museum-digital" />
|
|
|
|
|
|
|
|
<meta name="twitter:card" content="summary" />
|
|
|
|
<meta name="twitter:site" content="@museumdigital" />
|
|
|
|
|
|
|
|
<meta name="description" content="Validate import CSV files for museum-digital" />
|
2022-11-07 02:55:54 +01:00
|
|
|
|
|
|
|
<meta name="keywords" content="Imports, museum-digital" />
|
|
|
|
|
2022-11-07 03:55:07 +01:00
|
|
|
<link rel="shortcut icon" sizes="128x128" href="assets/img/mdlogo-csvxml.svg" />
|
2022-11-07 04:09:59 +01:00
|
|
|
<link rel="apple-touch-icon" sizes="192x192" href="assets/img/mdlogo-csvxml-192px.png" />
|
2022-11-07 03:55:07 +01:00
|
|
|
<meta property="twitter:image" content="assets/img/mdlogo-csvxml.svg" />
|
|
|
|
<meta property="og:image" content="assets/img/mdlogo-csvxml.svg" />
|
|
|
|
|
2022-11-07 02:55:54 +01:00
|
|
|
</head>
|
|
|
|
<body class="loading">
|
|
|
|
|
2022-11-28 14:27:46 +01:00
|
|
|
<script src="assets/js/csvxmlV2.min.js?' . GET_PARAM_JS_CSS . '" type="text/javascript" async></script>
|
2022-11-07 02:55:54 +01:00
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const SERVED_ROOT = __DIR__ . '/../public/';
|
|
|
|
const SERVED_JSON_ROOT = __DIR__ . '/../public/json/';
|
|
|
|
|
2022-11-17 17:56:23 +01:00
|
|
|
if (!is_dir(SERVED_JSON_ROOT)) {
|
|
|
|
echo "Will generate JSON root directory (" . SERVED_JSON_ROOT . ")" . PHP_EOL;
|
|
|
|
MD_STD::mkdir(SERVED_JSON_ROOT);
|
|
|
|
}
|
2022-11-07 02:55:54 +01:00
|
|
|
|
|
|
|
foreach (ALLOWED_LANGS as $lang) {
|
2022-11-17 17:56:23 +01:00
|
|
|
echo "Will generate JSON list of fields for language: " . $lang . PHP_EOL;
|
2022-11-07 02:55:54 +01:00
|
|
|
file_put_contents(SERVED_JSON_ROOT . 'fields.' . $lang . '.json', generateFieldsIndex($lang));
|
2022-11-17 17:56:23 +01:00
|
|
|
echo "Will generate JSON list of translations for language: " . $lang . PHP_EOL;
|
2022-11-07 02:55:54 +01:00
|
|
|
file_put_contents(SERVED_JSON_ROOT . 'tls.' . $lang . '.json', generateTranslationFile($lang));
|
|
|
|
}
|
|
|
|
|
2022-11-17 17:56:23 +01:00
|
|
|
echo "Will generate app shell" . PHP_EOL;
|
2022-11-07 02:55:54 +01:00
|
|
|
file_put_contents(SERVED_ROOT . 'index.htm', generateAppShell());
|
2022-11-07 21:11:34 +01:00
|
|
|
|
2022-11-17 17:56:23 +01:00
|
|
|
echo "Will minify CSS" . PHP_EOL;
|
2022-11-07 21:11:34 +01:00
|
|
|
exec("minify \\
|
|
|
|
-o " . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.min.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/../public/assets/css/editMenu.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/../public/assets/css/dialogue.css') . '\\
|
|
|
|
' . escapeshellarg(__DIR__ . '/../public/assets/css/csvxml.css'));
|
|
|
|
|
2022-11-17 17:56:23 +01:00
|
|
|
echo "Will minify JS" . PHP_EOL;
|
2022-11-07 21:11:34 +01:00
|
|
|
exec("minify \\
|
|
|
|
-o " . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.min.js') . '\
|
|
|
|
' . escapeshellarg(__DIR__ . '/../public/assets/js/csvxmlV2.js'));
|