diff --git a/TODO.md b/TODO.md index a5751a6..1388498 100644 --- a/TODO.md +++ b/TODO.md @@ -43,7 +43,7 @@ PHP has no component system, but `include`/`require` with variable scoping works - [ ] **`jury-fieldset.php`** — the entire jury composition fieldset + JS is duplicated verbatim between `add.php` and `edit.php`; extract into one partial accepting `$juryPresident`, `$juryPromoteur`, `$juryPromoteurExt`, `$juryLecteurs[]` ### Shared UI partials — `templates/partials/` -- [ ] **`pagination.php`** — pagination nav is duplicated between `index.php` and `search.php` with minor variations; unify into one partial accepting `$page`, `$totalPages`, `$baseParams[]` +- [x] **`pagination.php`** — pagination nav is duplicated between `index.php` and `search.php` with minor variations; unify into one partial accepting `$page`, `$totalPages`, `$baseParams[]` - [ ] **`status-badge.php`** — the published/pending badge + access badge pattern is repeated in `index.php` admin table rows; extract into a partial - [ ] **`admin-alert.php`** — rename/merge `flash-messages.php` to also handle the 3 different legacy flash key patterns (`$_SESSION['error']`, `$_SESSION['admin_error']`, `$_SESSION['edit_error']`, etc.) that pages still consume manually instead of via `App::consumeFlash()` @@ -79,7 +79,7 @@ The admin system page (`/admin/system.php`) runs expensive operations on every l - [ ] Extract `ThesisEditController` — merges edit.php + actions/edit.php, deduplicate jury fieldset (§2 step 5) - [ ] Extract remaining controllers one by one (§2 step 6) - [ ] Consolidate action handlers into controller methods (§4) -- [ ] Introduce pagination partial `templates/partials/pagination.php` (§6) +- [x] Introduce pagination partial `templates/partials/pagination.php` (§6) - [ ] Introduce admin form partials: select-field, checkbox-list, jury-fieldset (§6) - [ ] Unify flash message keys project-wide to `_flash_error` / `_flash_success` (§7) - [ ] Move OG tag construction into controller logic (§8) diff --git a/public/index.php b/public/index.php index 37dcf28..09c4bbf 100644 --- a/public/index.php +++ b/public/index.php @@ -126,40 +126,10 @@ $bodyClass = 'home-body'; - 1): ?> - - + $year]); + include APP_ROOT . '/templates/partials/pagination.php'; + ?> diff --git a/public/search.php b/public/search.php index e1f4e98..60e0bed 100644 --- a/public/search.php +++ b/public/search.php @@ -179,19 +179,11 @@ $bodyClass = 'search-body'; - 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; +?> +