mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
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:
@@ -5,23 +5,43 @@ require_once APP_ROOT . '/src/Database.php';
|
||||
|
||||
$pageTitle = "Liste des TFE";
|
||||
$page = isset($_GET["page"]) ? intval($_GET["page"]) : 1;
|
||||
$year = isset($_GET["year"]) ? intval($_GET["year"]) : null;
|
||||
$itemsPerPage = 10;
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$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);
|
||||
} catch (Exception $e) {
|
||||
error_log("Error loading theses: " . $e->getMessage());
|
||||
$itemsToLoad = [];
|
||||
$totalPages = 0;
|
||||
$availableYears = [];
|
||||
}
|
||||
|
||||
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>
|
||||
<?php foreach ($itemsToLoad as $item): ?>
|
||||
<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): ?>
|
||||
<nav class="pagination">
|
||||
<?php
|
||||
$yearParam = $year ? '&year=' . (int)$year : '';
|
||||
?>
|
||||
<?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 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; ?>
|
||||
|
||||
<span class="pagination-info">Page <?= (int)$page ?> sur <?= (int)$totalPages ?></span>
|
||||
|
||||
Reference in New Issue
Block a user