getPage($pageSlug); if (!$page) { die("Page introuvable."); } $editTitle = $page["title"]; if ($pageSlug === 'about') { $editType = 'about_page'; $aboutContacts = $db->getAproposContent('contacts'); $aboutContacts = is_array($aboutContacts) ? $aboutContacts : []; $sidebarLinks = $db->getAproposContent('sidebar_links'); $sidebarLinks = is_array($sidebarLinks) ? $sidebarLinks : []; // Fallback: migrate legacy individual sidebar link keys if (empty($sidebarLinks)) { $ergSiteUrl = $db->getAproposContent('erg_site_url'); $sourceCodeUrl = $db->getAproposContent('source_code_url'); if ($ergSiteUrl) { $sidebarLinks[] = ['label' => 'Site de l\'erg', 'url' => $ergSiteUrl]; } if ($sourceCodeUrl) { $sidebarLinks[] = ['label' => 'Code source', 'url' => $sourceCodeUrl]; } } } else { $editType = "page"; } } elseif ($formHelpKey) { $editType = "form_help"; $formHelpContent = $db->getFormHelpBlock($formHelpKey); $editTitle = $formHelpKey; } else { $editType = "apropos"; $value = $db->getAproposContent($aproposKey); $editTitle = match($aproposKey) { 'contacts' => 'Contacts', }; } } catch (Exception $e) { die("Erreur: " . htmlspecialchars($e->getMessage())); } $pageTitle = "Éditer : " . $editTitle; $initialContent = ''; $extraJs = []; $extraJsInline = ''; if ($editType === 'page' || $editType === 'about_page') { $initialContent = $page["content"] ?? ""; $extraJs = ["/assets/js/vendor/overtype.min.js", "/assets/js/app/autosave.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, toolbar: true, onChange: function(value) { hidden.value = value; } }); JS; } elseif ($editType === 'form_help') { $initialContent = $formHelpContent; $extraJs = ["/assets/js/vendor/overtype.min.js", "/assets/js/app/autosave.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, toolbar: true, onChange: function(value) { hidden.value = value; } }); JS; } elseif ($editType === 'apropos') { $extraJs = ["/assets/js/app/autosave.js"]; } $isAdmin = true; $bodyClass = "admin-body"; require_once APP_ROOT . "/templates/head.php"; include APP_ROOT . "/templates/header.php"; include APP_ROOT . '/templates/admin/contenus-edit.php'; require_once APP_ROOT . "/templates/admin/footer.php";