feat: add year filter to main index

- Footer now displays all available years horizontally with scroll
- Click on year filters thesis list to that year
- Active year highlighted in footer
- 'Tous' link to reset filter
- Filter info banner shows when year selected with reset button
- Pagination preserves year filter
- Styled with horizontal scroll, smooth scrollbar
- Tests passing 
This commit is contained in:
Théophile Gervreau-Mercier
2026-02-12 12:26:32 +01:00
parent 942a93a3ad
commit 9511bb93b5
5 changed files with 121 additions and 14 deletions

View File

@@ -22,7 +22,6 @@
/* } */ /* } */
body { body {
background-color: yellow;
margin: 0; margin: 0;
} }
@@ -82,7 +81,7 @@ label[type="button"] {
margin-top: 2rem; margin-top: 2rem;
font-size: 16px; font-size: 16px;
border-radius: 10px; border-radius: 10px;
padding: 2ch; padding: 1rem;
margin: 1rem; margin: 1rem;
a { a {
color: black; color: black;

View File

@@ -13,7 +13,8 @@ main {
height: 60vh; height: 60vh;
} }
footer { footer {
height: 20vh; height: 10vh;
font-size: 0.8em;
} }
body { body {
@@ -51,6 +52,33 @@ header .title, header section, header nav {
text-decoration: none; text-decoration: none;
line-height: 2.5rem; line-height: 2.5rem;
} }
/* Filter info banner */
.filter-info {
background: rgba(149, 87, 181, 0.9);
color: white;
padding: 0.5rem 1rem;
text-align: center;
font-size: 0.9rem;
display: flex;
align-items: center;
justify-content: center;
gap: 1rem;
}
.clear-filter {
color: white;
text-decoration: none;
padding: 0.25rem 0.75rem;
background: rgba(0, 0, 0, 0.2);
border-radius: 15px;
font-size: 0.85rem;
transition: background 0.2s;
}
.clear-filter:hover {
background: rgba(0, 0, 0, 0.4);
}
main { main {
height: 60vh; height: 60vh;
@@ -80,6 +108,57 @@ main {
footer { footer {
background: #222222ff; background: #222222ff;
overflow: hidden;
}
/* Years navigation in footer */
.years-nav {
height: 100%;
display: flex;
align-items: center;
}
.years-scroll {
display: flex;
gap: 1rem;
overflow-x: auto;
overflow-y: hidden;
scroll-behavior: smooth;
padding: 0.5rem 0;
width: 100%;
}
/* Hide scrollbar but keep functionality */
.years-scroll::-webkit-scrollbar {
height: 4px;
}
.years-scroll::-webkit-scrollbar-track {
background: transparent;
}
.years-scroll::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.3);
border-radius: 2px;
}
.year-link {
color: white;
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 20px;
white-space: nowrap;
transition: background 0.2s;
font-size: 1rem;
}
.year-link:hover {
background: rgba(255, 255, 255, 0.1);
}
.year-link.active {
background: #9557b5ff;
font-weight: bold;
} }
/* .card { */ /* .card { */

View File

@@ -5,23 +5,43 @@ require_once APP_ROOT . '/src/Database.php';
$pageTitle = "Liste des TFE"; $pageTitle = "Liste des TFE";
$page = isset($_GET["page"]) ? intval($_GET["page"]) : 1; $page = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
$year = isset($_GET["year"]) ? intval($_GET["year"]) : null;
$itemsPerPage = 10; $itemsPerPage = 10;
try { try {
$db = Database::getInstance(); $db = Database::getInstance();
$offset = ($page - 1) * $itemsPerPage; $offset = ($page - 1) * $itemsPerPage;
$itemsToLoad = $db->getPublishedTheses($itemsPerPage, $offset);
$totalItems = $db->countPublishedTheses(); // Get available years for footer
$availableYears = $db->getAvailableYears();
// Filter by year if specified
if ($year) {
$itemsToLoad = $db->searchTheses(['year' => $year], $itemsPerPage, $offset);
$totalItems = $db->countSearchResults(['year' => $year]);
} else {
$itemsToLoad = $db->getPublishedTheses($itemsPerPage, $offset);
$totalItems = $db->countPublishedTheses();
}
$totalPages = ceil($totalItems / $itemsPerPage); $totalPages = ceil($totalItems / $itemsPerPage);
} catch (Exception $e) { } catch (Exception $e) {
error_log("Error loading theses: " . $e->getMessage()); error_log("Error loading theses: " . $e->getMessage());
$itemsToLoad = []; $itemsToLoad = [];
$totalPages = 0; $totalPages = 0;
$availableYears = [];
} }
include APP_ROOT . '/templates/header.php'; include APP_ROOT . '/templates/header.php';
?> ?>
<?php if ($year): ?>
<div class="filter-info">
Année : <?= htmlspecialchars($year) ?>
<a href="index.php" class="clear-filter">✕ Réinitialiser</a>
</div>
<?php endif; ?>
<main> <main>
<?php foreach ($itemsToLoad as $item): ?> <?php foreach ($itemsToLoad as $item): ?>
<a href="memoire.php?id=<?= (int)$item["id"] ?>" class="card-link"> <a href="memoire.php?id=<?= (int)$item["id"] ?>" class="card-link">
@@ -42,12 +62,15 @@ include APP_ROOT . '/templates/header.php';
<?php if ($totalPages > 1): ?> <?php if ($totalPages > 1): ?>
<nav class="pagination"> <nav class="pagination">
<?php
$yearParam = $year ? '&year=' . (int)$year : '';
?>
<?php if ($page > 1): ?> <?php if ($page > 1): ?>
<a href="?page=<?= (int)($page - 1) ?>" class="pagination-previous">Précédent</a> <a href="?page=<?= (int)($page - 1) . $yearParam ?>" class="pagination-previous">Précédent</a>
<?php endif; ?> <?php endif; ?>
<?php if ($page < $totalPages): ?> <?php if ($page < $totalPages): ?>
<a href="?page=<?= (int)($page + 1) ?>" class="pagination-next">Suivant</a> <a href="?page=<?= (int)($page + 1) . $yearParam ?>" class="pagination-next">Suivant</a>
<?php endif; ?> <?php endif; ?>
<span class="pagination-info">Page <?= (int)$page ?> sur <?= (int)$totalPages ?></span> <span class="pagination-info">Page <?= (int)$page ?> sur <?= (int)$totalPages ?></span>

View File

@@ -1 +1 @@
[1770894924] [1770895586]

View File

@@ -1,11 +1,17 @@
<!-- footer.php --> <!-- footer.php -->
<footer> <footer>
<div> <nav class="years-nav">
<button>Année</button> <div class="years-scroll">
</div> <?php if (!empty($availableYears)): ?>
<div> <a href="index.php" class="year-link <?= !isset($year) ? 'active' : '' ?>">Tous</a>
<button>Cursus</button> <?php foreach ($availableYears as $y): ?>
</div> <a href="index.php?year=<?= (int)$y ?>" class="year-link <?= isset($year) && $year == $y ? 'active' : '' ?>">
<?= htmlspecialchars($y) ?>
</a>
<?php endforeach; ?>
<?php endif; ?>
</div>
</nav>
</footer> </footer>
</body> </body>