Add JSON API for getting list of available fields

This commit is contained in:
Joshua Ramon Enslin 2021-02-16 12:08:55 +01:00
parent b6b882f059
commit e423668d93
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -27,8 +27,19 @@ else if (!isset($_SESSION['lang'])) {
}
$lang = $_SESSION['lang'];
$outFormat = MD_STD_IN::get_http_input_text("output", "html", ['html', 'json']);
$tlLoader = new MDTlLoader("csxml_start", $lang);
$fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields();
if ($outFormat === 'json') {
header('content-type: application/json');
echo json_encode($availableFields);
return;
}
$toInject = '
<script src="assets/js/newToolTip.js" type="text/javascript" defer></script>
';
@ -57,9 +68,6 @@ echo '
</div>
';
$fieldsGetter = new CsvxmlAvailableFields($lang);
$availableFields = $fieldsGetter->getFields();
$tooltips = [];
foreach ($availableFields as $headline => $fields) {