merge head/nav templates into unified head.php + header.php; semantic CSS for nav

This commit is contained in:
Pontoporeia
2026-03-31 22:22:56 +02:00
parent 4ff959a72d
commit 780b1b2a13
24 changed files with 162 additions and 137 deletions

View File

@@ -1,11 +0,0 @@
<?php
// Admin head: builds on the shared public head.
// Sets admin defaults then delegates to public/head.php for the full <head> block.
$pageTitle = isset($pageTitle) ? $pageTitle . ' Admin' : 'Admin';
$extraCss = array_merge(['/assets/css/admin.css'], $extraCss ?? []);
$_adminHead = true; // flag so public/head.php knows to skip OG/meta
?>
<?php include APP_ROOT . '/templates/public/head.php'; ?>
<body class="admin-body">
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
<?php include APP_ROOT . '/templates/admin/nav.php'; ?>

View File

@@ -1,26 +0,0 @@
<?php
// admin/nav.php — admin navigation bar
// Reads $pageTitle (set by each page) and $_GET['id'] for context-sensitive edit link.
$_adminCurrentPage = basename($_SERVER['PHP_SELF']);
$_adminThesisId = $_GET['id'] ?? null;
?>
<nav class="admin-nav" aria-label="Navigation admin">
<a href="/" class="admin-nav__logo" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 256 256" style="vertical-align:middle;margin-right:0.4em"><path d="M208,72H128V32a8,8,0,0,0-13.66-5.66l-96,96a8,8,0,0,0,0,11.32l96,96A8,8,0,0,0,128,224V184h80a16,16,0,0,0,16-16V88A16,16,0,0,0,208,72Zm0,96H120a8,8,0,0,0-8,8v28.69L35.31,128,112,51.31V80a8,8,0,0,0,8,8h88Z"></path></svg>Posterg<span class="sr-only"> (site public, nouvel onglet)</span>
</a>
<ul class="admin-nav__list">
<li><a href="/admin/" <?= $_adminCurrentPage === 'index.php' ? 'aria-current="page"' : '' ?>>Liste des TFE</a></li>
<li><a href="/admin/add.php" <?= $_adminCurrentPage === 'add.php' ? 'aria-current="page"' : '' ?>>Ajouter un TFE</a></li>
<li><a href="/admin/import.php" <?= $_adminCurrentPage === 'import.php' ? 'aria-current="page"' : '' ?>>Importer une liste de TFE</a></li>
<li><a href="/admin/pages.php" <?= in_array($_adminCurrentPage, ['pages.php', 'pages-edit.php']) ? 'aria-current="page"' : '' ?>>Pages statiques</a></li>
<li><a href="/admin/tags.php" <?= $_adminCurrentPage === 'tags.php' ? 'aria-current="page"' : '' ?>>Mots-clés</a></li>
<li><a href="/admin/system.php" <?= in_array($_adminCurrentPage, ['system.php', 'status.php', 'logs.php']) ? 'aria-current="page"' : '' ?>>Système</a></li>
<li><a href="/admin/account.php" <?= $_adminCurrentPage === 'account.php' ? 'aria-current="page"' : '' ?>>Compte</a></li>
<?php if ($_adminThesisId && in_array($_adminCurrentPage, ['edit.php', 'thanks.php'])): ?>
<li><a href="/admin/edit.php?id=<?= intval($_adminThesisId) ?>" <?= $_adminCurrentPage === 'edit.php' ? 'aria-current="page"' : '' ?>>Modifier</a></li>
<?php endif; ?>
<?php if (defined('ADMIN_PASSWORD_HASH')): ?>
<li class="admin-nav__logout"><a href="/admin/logout.php">Déconnexion</a></li>
<?php endif; ?>
</ul>
</nav>

View File

@@ -3,8 +3,15 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?php
// Admin: append suffix to title and prepend admin.css
if (!empty($isAdmin)) {
$pageTitle = isset($pageTitle) ? $pageTitle . ' Admin' : 'Admin';
$extraCss = array_merge(['/assets/css/admin.css'], $extraCss ?? []);
}
?>
<title><?= htmlspecialchars($pageTitle ?? 'Posterg') ?></title>
<?php if (!empty($_adminHead)) { $ogTags = []; $metaDescription = ''; } ?>
<?php if (empty($isAdmin)): ?>
<?php if (!empty($metaDescription)): ?>
<meta name="description" content="<?= htmlspecialchars($metaDescription) ?>">
<?php endif; ?>
@@ -49,6 +56,7 @@
<meta name="twitter:image:alt" content="<?= htmlspecialchars($ogImageAlt) ?>">
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<link rel="icon" type="image/svg+xml" href="/assets/admin_favicon.svg">
<link rel="stylesheet" href="/assets/css/modern-normalize.min.css">
<link rel="stylesheet" href="/assets/css/common.css">
@@ -65,3 +73,4 @@
</script>
<?php endif; ?>
</head>
<body class="<?= htmlspecialchars($bodyClass ?? '') ?>">

80
templates/header.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
// header.php — unified site header for public and admin sections.
// Reads: $isAdmin (bool), $currentNav (string, public only)
$_isAdmin = !empty($isAdmin);
$_navCurrent = $currentNav ?? '';
$_currentPage = basename($_SERVER['PHP_SELF']);
$_thesisId = $_GET['id'] ?? null;
?>
<header>
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
<?php if ($_isAdmin): ?>
<nav aria-label="Navigation admin">
<a href="/" target="_blank" rel="noopener noreferrer">
<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 256 256" style="vertical-align:middle;margin-right:0.4em"><path d="M208,72H128V32a8,8,0,0,0-13.66-5.66l-96,96a8,8,0,0,0,0,11.32l96,96A8,8,0,0,0,128,224V184h80a16,16,0,0,0,16-16V88A16,16,0,0,0,208,72Zm0,96H120a8,8,0,0,0-8,8v28.69L35.31,128,112,51.31V80a8,8,0,0,0,8,8h88Z"></path></svg>Posterg<span class="sr-only"> (site public, nouvel onglet)</span>
</a>
<ul>
<li><a href="/admin/" <?= $_currentPage === 'index.php' ? 'aria-current="page"' : '' ?>>Liste des TFE</a></li>
<li><a href="/admin/add.php" <?= $_currentPage === 'add.php' ? 'aria-current="page"' : '' ?>>Ajouter un TFE</a></li>
<li><a href="/admin/import.php" <?= $_currentPage === 'import.php' ? 'aria-current="page"' : '' ?>>Importer une liste de TFE</a></li>
<li><a href="/admin/pages.php" <?= in_array($_currentPage, ['pages.php', 'pages-edit.php']) ? 'aria-current="page"' : '' ?>>Pages statiques</a></li>
<li><a href="/admin/tags.php" <?= $_currentPage === 'tags.php' ? 'aria-current="page"' : '' ?>>Mots-clés</a></li>
<li><a href="/admin/system.php" <?= in_array($_currentPage, ['system.php', 'status.php', 'logs.php']) ? 'aria-current="page"' : '' ?>>Système</a></li>
<li><a href="/admin/account.php" <?= $_currentPage === 'account.php' ? 'aria-current="page"' : '' ?>>Compte</a></li>
<?php if ($_thesisId && in_array($_currentPage, ['edit.php', 'thanks.php'])): ?>
<li><a href="/admin/edit.php?id=<?= intval($_thesisId) ?>" <?= $_currentPage === 'edit.php' ? 'aria-current="page"' : '' ?>>Modifier</a></li>
<?php endif; ?>
<?php if (defined('ADMIN_PASSWORD_HASH')): ?>
<li data-nav-logout><a href="/admin/logout.php">Déconnexion</a></li>
<?php endif; ?>
</ul>
</nav>
<?php else: ?>
<nav aria-label="Navigation principale">
<a href="/index.php">Posterg</a>
<ul>
<li>
<a href="/search.php"
<?= ($_navCurrent === 'repertoire') ? 'aria-current="page"' : '' ?>>Répertoire</a>
</li>
<li>
<a href="/licence.php"
<?= ($_navCurrent === 'licence') ? 'aria-current="page"' : '' ?>>Licence</a>
</li>
<li>
<a href="/apropos.php"
<?= ($_navCurrent === 'apropos') ? 'aria-current="page"' : '' ?>>À Propos</a>
</li>
</ul>
</nav>
<?php
// Search bar — public section only
$searchBarValue = $searchBarValue ?? $_GET['query'] ?? '';
?>
<form class="site-search" method="GET" action="/search.php"
role="search" aria-label="Recherche">
<label for="site-search-input" class="sr-only">Recherche</label>
<svg class="site-search__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
aria-hidden="true" focusable="false">
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
</svg>
<input
id="site-search-input"
class="site-search__input"
type="text"
name="query"
placeholder="Recherche..."
value="<?= htmlspecialchars($searchBarValue) ?>"
autocomplete="off"
>
</form>
<?php endif; ?>
</header>

View File

@@ -1,23 +0,0 @@
<?php
// nav.php — shared public navigation bar
// Usage: include this partial from any public page
// Provide $currentNav variable to mark active links (optional)
$_navCurrent = $currentNav ?? '';
?>
<nav class="site-nav" aria-label="Navigation principale">
<a class="site-nav__logo" href="/index.php">Posterg</a>
<ul role="list">
<li>
<a href="/search.php"
<?= ($_navCurrent === 'repertoire') ? 'aria-current="page"' : '' ?>>Répertoire</a>
</li>
<li>
<a href="/licence.php"
<?= ($_navCurrent === 'licence') ? 'aria-current="page"' : '' ?>>Licence</a>
</li>
<li>
<a href="/apropos.php"
<?= ($_navCurrent === 'apropos') ? 'aria-current="page"' : '' ?>>À Propos</a>
</li>
</ul>
</nav>