From 7834d88873df202629f6c722a5f9baccc969b15d Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 2 Apr 2026 12:20:31 +0200 Subject: [PATCH] Extract pagination into templates/partials/pagination.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pagination nav was duplicated between public/index.php and public/search.php with structural differences: index.php used string concatenation for query params and had first/last-page buttons (« »); search.php used http_build_query but had only prev/next (‹ ›) and a flat rather than a - 1): ?> - - + '']); + include APP_ROOT . '/templates/partials/pagination.php'; + ?>

Aucun résultat pour cette recherche.

diff --git a/templates/partials/pagination.php b/templates/partials/pagination.php new file mode 100644 index 0000000..586bf4a --- /dev/null +++ b/templates/partials/pagination.php @@ -0,0 +1,61 @@ + 2024, 'query' => 'design']) + * The 'page' key is injected automatically; do not include it. + * + * Usage: + * $year]); ?> + * + */ + +if (!isset($page, $totalPages) || $totalPages <= 1) { + return; // nothing to render +} + +$baseParams = isset($baseParams) && is_array($baseParams) ? $baseParams : []; + +/** Build a URL for a given target page, preserving all base params. */ +$paginationUrl = static function(int $targetPage) use ($baseParams): string { + return '?' . http_build_query(array_merge($baseParams, ['page' => $targetPage])); +}; + +$atFirst = $page <= 1; +$atLast = $page >= $totalPages; +?> +