mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-26 00:29:18 +02:00
Refactor about.php
- Hardcode source code URL and credits in about template, remove from DB/admin interface; only contacts remains editable - Merge apropos editables into one À propos section, remove charte, add editable source code URL
This commit is contained in:
@@ -9,8 +9,8 @@ if (empty($_SESSION["csrf_token"])) {
|
||||
$_SESSION["csrf_token"] = bin2hex(random_bytes(32));
|
||||
}
|
||||
|
||||
$allowedPageSlugs = ["about", "licenses", "charte"];
|
||||
$allowedApropos = ["contacts", "credits"];
|
||||
$allowedPageSlugs = ["about", "licenses"];
|
||||
$allowedApropos = ["contacts"];
|
||||
|
||||
$pageSlug = $_GET["slug"] ?? "";
|
||||
$aproposKey = $_GET["apropos"] ?? "";
|
||||
@@ -40,7 +40,13 @@ try {
|
||||
die("Page introuvable.");
|
||||
}
|
||||
$editTitle = $page["title"];
|
||||
$editType = "page";
|
||||
if ($pageSlug === 'about') {
|
||||
$editType = 'about_page';
|
||||
$aboutContacts = $db->getAproposContent('contacts');
|
||||
$aboutContacts = is_array($aboutContacts) ? $aboutContacts : [];
|
||||
} else {
|
||||
$editType = "page";
|
||||
}
|
||||
} elseif ($formHelpKey) {
|
||||
$editType = "form_help";
|
||||
$formHelpContent = $db->getFormHelpBlock($formHelpKey);
|
||||
@@ -50,7 +56,6 @@ try {
|
||||
$value = $db->getAproposContent($aproposKey);
|
||||
$editTitle = match($aproposKey) {
|
||||
'contacts' => 'Contacts',
|
||||
'credits' => 'Crédits',
|
||||
};
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
@@ -58,8 +63,15 @@ try {
|
||||
}
|
||||
|
||||
$pageTitle = "Éditer : " . $editTitle;
|
||||
$extraJs = ["/assets/js/overtype.min.js"];
|
||||
$extraJsInline = <<<'JS'
|
||||
|
||||
$initialContent = '';
|
||||
$extraJs = [];
|
||||
$extraJsInline = '';
|
||||
|
||||
if ($editType === 'page' || $editType === 'about_page') {
|
||||
$initialContent = $page["content"] ?? "";
|
||||
$extraJs = ["/assets/js/overtype.min.js"];
|
||||
$extraJsInline = <<<'JS'
|
||||
var OT = window.OverType.default || window.OverType;
|
||||
var hidden = document.getElementById('content');
|
||||
var editor = new OT(document.getElementById('editor'), {
|
||||
@@ -69,12 +81,19 @@ var editor = new OT(document.getElementById('editor'), {
|
||||
onChange: function(value) { hidden.value = value; }
|
||||
});
|
||||
JS;
|
||||
|
||||
$initialContent = '';
|
||||
if ($editType === 'page') {
|
||||
$initialContent = $page["content"] ?? "";
|
||||
} elseif ($editType === 'form_help') {
|
||||
$initialContent = $formHelpContent;
|
||||
$extraJs = ["/assets/js/overtype.min.js"];
|
||||
$extraJsInline = <<<'JS'
|
||||
var OT = window.OverType.default || window.OverType;
|
||||
var hidden = document.getElementById('content');
|
||||
var editor = new OT(document.getElementById('editor'), {
|
||||
value: hidden.value,
|
||||
minHeight: '400px',
|
||||
spellcheck: false,
|
||||
onChange: function(value) { hidden.value = value; }
|
||||
});
|
||||
JS;
|
||||
}
|
||||
|
||||
$isAdmin = true;
|
||||
|
||||
Reference in New Issue
Block a user