with a decorative symbol, * an aria-label, and the visible label text. * * Variables (set before include): * * $badgeType (string) One of: * 'publish' — publish/pending state (uses $badgeValue as bool) * 'access' — access-type label (uses $badgeValue as string name) * 'ok' — generic green/yellow ok-or-warn (uses $badgeValue as bool) * * $badgeValue (mixed) Meaning depends on $badgeType (see above). * * $badgeOkLabel (string, optional) Label when ok/published/true. Default: 'Oui' * $badgeWarnLabel (string, optional) Label when warn/pending/false. Default: 'Non' * $badgeContext (string, optional) Prefix for aria-label, e.g. 'Statut'. * When empty the visible label is used directly. * * Example — publish badge: * * * Example — access badge: * * * Example — generic ok badge: * */ $badgeType = $badgeType ?? 'ok'; $badgeValue = $badgeValue ?? false; $badgeOkLabel = $badgeOkLabel ?? 'Oui'; $badgeWarnLabel = $badgeWarnLabel ?? 'Non'; $badgeContext = $badgeContext ?? null; // null = use visible label as aria-label if ($badgeType === 'publish') { $isOk = (bool) $badgeValue; $symbol = $isOk ? '●' : '◌'; $cssClass = $isOk ? 'status-published' : 'status-pending'; $visibleLabel = $isOk ? 'Publié' : 'En attente'; $ariaLabel = 'Statut : ' . $visibleLabel; } elseif ($badgeType === 'access') { $accessName = (string) $badgeValue; $accessSlug = strtolower(preg_replace('/[^a-z]/i', '', $accessName)); $symbols = ['libre' => '○', 'interne' => '◑', 'interdit' => '●']; $symbol = $symbols[$accessSlug] ?? '●'; $cssClass = 'status-access status-access--' . $accessSlug; $visibleLabel = $accessName; $ariaLabel = 'Accès : ' . $visibleLabel; } else { // 'ok' — generic boolean badge $isOk = (bool) $badgeValue; $symbol = $isOk ? '●' : '◌'; $cssClass = $isOk ? 'status-published' : 'status-pending'; $visibleLabel = $isOk ? $badgeOkLabel : $badgeWarnLabel; $ariaLabel = $badgeContext !== null ? ($badgeContext !== '' ? $badgeContext . ' : ' . $visibleLabel : $visibleLabel) : $visibleLabel; } ?>