mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
- pages-edit.php: EasyMDE CDN JS URL moved to $extraJs (rendered by footer.php before </body>); inline EasyMDE init block moved to $extraJsInline, emitted by footer.php via new `<?php if (!empty($extraJsInline))` guard - fixes invalid <script> floating in <body> (WCAG 4.1.1) - pages-edit.php: add <small> keyboard-trap hint below the editor textarea: 'Appuyez sur Échap pour quitter l'éditeur au clavier.' (WCAG 2.1.2) - templates/admin/footer.php: extend to support $extraJsInline (raw inline script string) - index.php: add <h1 class="sr-only">Mémoires de l'ERG</h1> inside <main> so the page has a document heading (WCAG 2.4.6; h2 columns in search.php already had a sr-only h1) - TODO.md: mark completed items as [x]: skip links (2.4.1), focus-visible / outline:none removal (2.4.7), search.php h1 + index.php h1 (2.4.6), pages-edit.php invalid HTML (4.1.1), EasyMDE keyboard trap hint (2.1.2)
68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
require_once __DIR__ . "/../../config/bootstrap.php";
|
|
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
if (empty($_SESSION['csrf_token'])) {
|
|
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
|
}
|
|
|
|
require_once __DIR__ . '/../../src/Database.php';
|
|
|
|
$allowedSlugs = ['about', 'licenses', 'charte', 'contact'];
|
|
$slug = $_GET['slug'] ?? '';
|
|
|
|
if (!in_array($slug, $allowedSlugs)) {
|
|
header('Location: /admin/pages.php');
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db = new Database();
|
|
$page = $db->getPage($slug);
|
|
if (!$page) {
|
|
die("Page introuvable.");
|
|
}
|
|
} catch (Exception $e) {
|
|
die("Erreur: " . htmlspecialchars($e->getMessage()));
|
|
}
|
|
|
|
$pageTitle = "Éditer : " . htmlspecialchars($page['title']);
|
|
$extraCss = ['https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css'];
|
|
$extraJs = ['https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js'];
|
|
$extraJsInline = <<<'JS'
|
|
var easyMDE = new EasyMDE({
|
|
element: document.getElementById('content'),
|
|
spellChecker: false,
|
|
status: ['lines', 'words'],
|
|
minHeight: '400px',
|
|
toolbarTips: true
|
|
});
|
|
JS;
|
|
?>
|
|
<?php require_once APP_ROOT . '/templates/admin/head.php'; ?>
|
|
|
|
<main class="admin-main" id="main-content">
|
|
<h1 class="admin-page-title">Éditer : <?= htmlspecialchars($page['title']) ?></h1>
|
|
|
|
<form action="/admin/actions/page.php" method="post" class="admin-form">
|
|
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
|
<input type="hidden" name="slug" value="<?= htmlspecialchars($slug) ?>">
|
|
|
|
<div class="admin-form-row" style="align-items:start;">
|
|
<label class="admin-label" for="content">Contenu (Markdown) :</label>
|
|
<div>
|
|
<textarea class="admin-textarea" id="content" name="content"
|
|
rows="20"><?= htmlspecialchars($page['content'] ?? '') ?></textarea>
|
|
<small class="admin-hint">Appuyez sur <kbd>Échap</kbd> pour quitter l'éditeur au clavier.</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="admin-submit-wrap">
|
|
<button type="submit" class="admin-btn">Enregistrer</button>
|
|
<a href="/admin/pages.php" class="admin-btn-secondary" style="margin-left:.75rem;">Annuler</a>
|
|
</div>
|
|
</form>
|
|
</main>
|
|
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
|