mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
Extract status-badge.php partial; replace inline badge markup in index.php and account.php
Add templates/partials/status-badge.php — a single reusable partial that
renders the <span class="status-badge …"> 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)
This commit is contained in:
@@ -33,20 +33,12 @@ if (empty($_SESSION['csrf_token'])) {
|
||||
<div class="admin-account-status">
|
||||
<div class="admin-account-status__row">
|
||||
<span class="admin-account-status__label">Authentification PHP</span>
|
||||
<?php if ($hasPassword): ?>
|
||||
<span class="status-badge status-published">Active</span>
|
||||
<?php else: ?>
|
||||
<span class="status-badge status-pending">Non configurée</span>
|
||||
<?php endif; ?>
|
||||
<?php $badgeType = 'ok'; $badgeValue = $hasPassword; $badgeOkLabel = 'Active'; $badgeWarnLabel = 'Non configurée'; include APP_ROOT . '/templates/partials/status-badge.php'; ?>
|
||||
</div>
|
||||
<div class="admin-account-status__row">
|
||||
<span class="admin-account-status__label">Fichier de configuration</span>
|
||||
<code class="admin-account-status__code">config/admin_credentials.php</code>
|
||||
<?php if (file_exists($credentialsFile)): ?>
|
||||
<span class="status-badge status-published">Présent</span>
|
||||
<?php else: ?>
|
||||
<span class="status-badge status-pending">Absent</span>
|
||||
<?php endif; ?>
|
||||
<?php $badgeType = 'ok'; $badgeValue = file_exists($credentialsFile); $badgeOkLabel = 'Présent'; $badgeWarnLabel = 'Absent'; include APP_ROOT . '/templates/partials/status-badge.php'; ?>
|
||||
</div>
|
||||
<?php if (!$hasPassword): ?>
|
||||
<p class="admin-account-status__note">
|
||||
|
||||
Reference in New Issue
Block a user