Adjusting admin static pages edit page

This commit is contained in:
Pontoporeia
2026-04-06 15:25:44 +02:00
parent 480451aa2b
commit f6e2c77d1a
2 changed files with 543 additions and 518 deletions

View File

@@ -1,20 +1,20 @@
<?php
require_once __DIR__ . "/../../config/bootstrap.php";
require_once __DIR__ . '/../../src/AdminAuth.php';
require_once __DIR__ . "/../../src/AdminAuth.php";
AdminAuth::requireLogin();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
if (empty($_SESSION["csrf_token"])) {
$_SESSION["csrf_token"] = bin2hex(random_bytes(32));
}
require_once __DIR__ . '/../../src/Database.php';
require_once __DIR__ . "/../../src/Database.php";
$allowedSlugs = ['about', 'licenses', 'charte', 'contact'];
$slug = $_GET['slug'] ?? '';
$allowedSlugs = ["about", "licenses", "charte", "contact"];
$slug = $_GET["slug"] ?? "";
if (!in_array($slug, $allowedSlugs)) {
header('Location: /admin/pages.php');
exit;
header("Location: /admin/pages.php");
exit();
}
try {
@@ -27,8 +27,8 @@ try {
die("Erreur: " . htmlspecialchars($e->getMessage()));
}
$pageTitle = "Éditer : " . htmlspecialchars($page['title']);
$extraJs = ['/assets/js/overtype.min.js'];
$pageTitle = "Éditer : " . htmlspecialchars($page["title"]);
$extraJs = ["/assets/js/overtype.min.js"];
$extraJsInline = <<<'JS'
var OT = window.OverType.default || window.OverType;
var hidden = document.getElementById('content');
@@ -40,22 +40,26 @@ var editor = new OT(document.getElementById('editor'), {
});
JS;
?>
<?php $isAdmin = true; $bodyClass = 'admin-body'; require_once APP_ROOT . '/templates/head.php'; ?>
<?php include APP_ROOT . '/templates/header.php'; ?>
<?php
$isAdmin = true;
$bodyClass = "admin-body";
require_once APP_ROOT . "/templates/head.php";
?>
<?php include APP_ROOT . "/templates/header.php"; ?>
<main id="main-content">
<h1>Éditer : <?= htmlspecialchars($page['title']) ?></h1>
<h1>É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="csrf_token" value="<?= htmlspecialchars(
$_SESSION["csrf_token"],
) ?>">
<input type="hidden" name="slug" value="<?= htmlspecialchars($slug) ?>">
<div>
<label for="editor">Contenu (Markdown) :</label>
<input type="hidden" id="content" name="content"
value="<?= htmlspecialchars($page['content'] ?? '') ?>">
value="<?= htmlspecialchars($page["content"] ?? "") ?>">
<div id="editor"></div>
</div>
<div class="admin-form-footer">
<button type="submit" class="admin-btn">Enregistrer</button>
@@ -63,4 +67,4 @@ JS;
</div>
</form>
</main>
<?php require_once APP_ROOT . '/templates/admin/footer.php'; ?>
<?php require_once APP_ROOT . "/templates/admin/footer.php"; ?>

View File

@@ -74,7 +74,9 @@
}
.admin-form
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]),
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(
[type="hidden"]
):not([type="submit"]),
.admin-form select,
.admin-form textarea,
.admin-inline-form input[type="text"],
@@ -94,7 +96,9 @@
}
.admin-form
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):focus,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(
[type="hidden"]
):not([type="submit"]):focus,
.admin-form select:focus,
.admin-form textarea:focus,
.admin-inline-form input:focus,
@@ -846,7 +850,9 @@
display: inline-flex;
align-items: center;
cursor: pointer;
transition: border-color 0.15s, color 0.15s;
transition:
border-color 0.15s,
color 0.15s;
}
.admin-btn-remove:hover {
@@ -880,10 +886,18 @@
}
/* Tags table column sizing */
.admin-body table:has(.admin-tags-count) th:nth-child(1) { width: 40%; }
.admin-body table:has(.admin-tags-count) th:nth-child(2) { width: 12%; }
.admin-body table:has(.admin-tags-count) th:nth-child(3) { width: 48%; }
.admin-tags-count { text-align: center; }
.admin-body table:has(.admin-tags-count) th:nth-child(1) {
width: 40%;
}
.admin-body table:has(.admin-tags-count) th:nth-child(2) {
width: 12%;
}
.admin-body table:has(.admin-tags-count) th:nth-child(3) {
width: 48%;
}
.admin-tags-count {
text-align: center;
}
/* ── Banner preview ─────────────────────────────────────────────────────── */
.admin-banner-preview img {
@@ -932,7 +946,9 @@
color: var(--text-primary);
font-size: 0.9rem;
text-decoration: none;
transition: border-color 0.15s, color 0.15s;
transition:
border-color 0.15s,
color 0.15s;
}
.admin-body .pagination-btn:hover:not(.disabled) {
@@ -951,3 +967,8 @@
color: var(--text-secondary);
padding: 0 0.5rem;
}
.admin-body #editor {
height: 50vh;
border: 1px solid var(--border-primary);
}