From 77bfd2f8e3436c10c1e865595fe5d3d445ad76d5 Mon Sep 17 00:00:00 2001 From: Pontoporeia Date: Thu, 2 Apr 2026 12:50:46 +0200 Subject: [PATCH] Extract status-badge.php partial; replace inline badge markup in index.php and account.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add templates/partials/status-badge.php — a single reusable partial that renders the element for three badge types: 'publish' — Publié / En attente derived from a boolean is_published value 'access' — access-type label (Libre / Interne / Interdit) with slug-based CSS modifier class and appropriate symbol (○ ◑ ●) 'ok' — generic green/yellow boolean badge with caller-supplied labels (used for 'Active'/'Non configurée' and 'Présent'/'Absent' in account.php) All three variants emit aria-label with a context prefix and wrap the decorative symbol in aria-hidden="true" — behaviour identical to the inline code they replace. Callers set $badgeType + $badgeValue (+ optional $badgeOkLabel / $badgeWarnLabel / $badgeContext) before the include; the partial unsets all working variables after rendering so they do not bleed into the including scope. Files changed: templates/partials/status-badge.php — new partial public/admin/index.php — table status column now uses partial (removes 15 lines of inline if/else/php) public/admin/account.php — two credential status rows now use partial (removes 8 lines of inline if/else) --- TODO.md | 2 +- public/admin/account.php | 12 +----- public/admin/index.php | 15 +------ templates/partials/status-badge.php | 67 +++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 templates/partials/status-badge.php diff --git a/TODO.md b/TODO.md index 432b505..14371b8 100644 --- a/TODO.md +++ b/TODO.md @@ -44,7 +44,7 @@ PHP has no component system, but `include`/`require` with variable scoping works ### Shared UI partials — `templates/partials/` - [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 +- [x] **`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()` ## System Page Caching — Database-Backed Status Cache diff --git a/public/admin/account.php b/public/admin/account.php index 1f4e758..783a225 100644 --- a/public/admin/account.php +++ b/public/admin/account.php @@ -33,20 +33,12 @@ if (empty($_SESSION['csrf_token'])) {