mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: extract MediaController, wire into Dispatcher, delete media.php
This commit is contained in:
21
app/templates/partials/flash-messages.php
Normal file
21
app/templates/partials/flash-messages.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Shared flash-message partial for the admin section.
|
||||
*
|
||||
* Consumes all flash variants via App::consumeFlash(), then renders toast markup.
|
||||
* Toast JS in the admin footer auto-removes them after 4 seconds.
|
||||
*
|
||||
* Usage: include once per request in the admin footer.
|
||||
*/
|
||||
$_flash = App::consumeFlash();
|
||||
?>
|
||||
<?php if ($_flash['error'] || $_flash['success']): ?>
|
||||
<div id="admin-toasts" style="display:none">
|
||||
<?php if ($_flash['error']): ?>
|
||||
<div class="toast" role="alert" data-type="error">⚠ <?= htmlspecialchars($_flash['error']) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($_flash['success']): ?>
|
||||
<div class="toast" role="status" data-type="success">✓ <?= htmlspecialchars($_flash['success']) ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
39
app/templates/partials/form/checkbox-list.php
Normal file
39
app/templates/partials/form/checkbox-list.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Checkbox list partial — renders a group of checkboxes (e.g. languages, formats).
|
||||
*
|
||||
* The group label uses a visible <span> as the first column (matching other form
|
||||
* rows), while a <fieldset>/<legend> in the second column provides the accessible
|
||||
* grouping required by WCAG 1.3.1. The <legend> is visually hidden (sr-only) to
|
||||
* avoid duplicating the visible label text.
|
||||
*
|
||||
* Variables consumed:
|
||||
* string $name — input name attribute (will be posted as array: name[])
|
||||
* string $label — group label text
|
||||
* array $options — each element must have 'id' and 'name' keys
|
||||
* array $checked — array of 'id' values that are currently checked
|
||||
*/
|
||||
|
||||
$checked = $checked ?? [];
|
||||
?>
|
||||
<div>
|
||||
<span class="admin-row-label"><?= htmlspecialchars($label) ?></span>
|
||||
<fieldset class="admin-checkbox-group">
|
||||
<legend class="sr-only"><?= htmlspecialchars($label) ?></legend>
|
||||
<ul>
|
||||
<?php foreach ($options as $opt): ?>
|
||||
<li>
|
||||
<label class="admin-checkbox-label">
|
||||
<input type="checkbox"
|
||||
name="<?= htmlspecialchars($name) ?>[]"
|
||||
value="<?= htmlspecialchars((string)$opt['id']) ?>"
|
||||
<?= in_array((string)$opt['id'], array_map('strval', $checked)) ? 'checked' : '' ?>>
|
||||
<?= htmlspecialchars($opt['name']) ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</fieldset>
|
||||
</div>
|
||||
<?php
|
||||
unset($checked);
|
||||
33
app/templates/partials/form/file-field.php
Normal file
33
app/templates/partials/form/file-field.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* File input partial.
|
||||
*
|
||||
* Variables consumed:
|
||||
* string $name — input name attribute (used for id too unless $id set)
|
||||
* string $label — visible label text
|
||||
* string $accept — MIME types / extensions for the accept attribute (e.g. 'image/jpeg,image/png')
|
||||
* string|null $hint — optional hint shown in <small> below the input
|
||||
* bool $multiple — whether to allow multiple file selection; default false
|
||||
* string|null $id — override the id attribute (defaults to $name)
|
||||
*/
|
||||
|
||||
$accept = $accept ?? '';
|
||||
$hint = $hint ?? null;
|
||||
$multiple = $multiple ?? false;
|
||||
$id = $id ?? $name;
|
||||
?>
|
||||
<div>
|
||||
<label for="<?= htmlspecialchars($id) ?>"><?= htmlspecialchars($label) ?></label>
|
||||
<div class="admin-file-input">
|
||||
<input type="file"
|
||||
id="<?= htmlspecialchars($id) ?>"
|
||||
name="<?= htmlspecialchars($name) ?><?= $multiple ? '[]' : '' ?>"
|
||||
<?= $accept ? 'accept="' . htmlspecialchars($accept) . '"' : '' ?>
|
||||
<?= $multiple ? 'multiple' : '' ?>>
|
||||
<?php if ($hint): ?>
|
||||
<small><?= htmlspecialchars($hint) ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
unset($accept, $hint, $multiple, $id);
|
||||
115
app/templates/partials/form/jury-fieldset.php
Normal file
115
app/templates/partials/form/jury-fieldset.php
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Jury composition fieldset partial.
|
||||
*
|
||||
* Variables consumed (all optional — defaults to empty/add-mode):
|
||||
* $juryPresident string|null President name
|
||||
* $juryPromoteur string|null Promoteur name
|
||||
* $juryPromoteurExt int 1 if promoteur is external, 0 otherwise
|
||||
* $juryLecteurs array Each element: ['name' => string, 'is_external' => int]
|
||||
*
|
||||
* In "add" mode (no existing jury data), callers should pass nulls/empty arrays and
|
||||
* may rely on the $formData repopulation helpers (old/wasSelected) defined in add.php.
|
||||
* When those helpers exist and no explicit values are set, the partial uses them.
|
||||
*/
|
||||
|
||||
$juryPresident = $juryPresident ?? null;
|
||||
$juryPromoteur = $juryPromoteur ?? null;
|
||||
$juryPromoteurExt = $juryPromoteurExt ?? 0;
|
||||
$juryLecteurs = $juryLecteurs ?? [];
|
||||
|
||||
// In add-mode, repopulate from flash form data when helpers are available.
|
||||
$addMode = ($juryPresident === null && $juryPromoteur === null && empty($juryLecteurs));
|
||||
if ($addMode && function_exists('old')) {
|
||||
$juryPresident = old('jury_president') ?: null;
|
||||
$juryPromoteur = old('jury_promoteur') ?: null;
|
||||
$juryPromoteurExt = function_exists('wasSelected') && wasSelected('jury_promoteur_ext', '1') ? 1 : 0;
|
||||
}
|
||||
|
||||
$juryIdx = max(count($juryLecteurs), 1);
|
||||
?>
|
||||
<!-- Composition du jury -->
|
||||
<fieldset>
|
||||
<legend>Composition du jury</legend>
|
||||
|
||||
<!-- Président·e -->
|
||||
<div>
|
||||
<label for="jury_president">Président·e :</label>
|
||||
<input type="text" id="jury_president" name="jury_president"
|
||||
value="<?= htmlspecialchars($juryPresident ?? '') ?>"
|
||||
placeholder="Nom du/de la président·e (interne)">
|
||||
</div>
|
||||
|
||||
<!-- Promoteur·ice -->
|
||||
<div>
|
||||
<label for="jury_promoteur">Promoteur·ice :</label>
|
||||
<div class="admin-jury-row">
|
||||
<input type="text" id="jury_promoteur" name="jury_promoteur"
|
||||
value="<?= htmlspecialchars($juryPromoteur ?? '') ?>" placeholder="Nom">
|
||||
<label class="admin-checkbox-label admin-jury-ext">
|
||||
<input type="checkbox" name="jury_promoteur_ext" value="1"
|
||||
<?= $juryPromoteurExt ? 'checked' : '' ?>
|
||||
aria-label="Promoteur·ice — externe"> Externe
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Lecteur·ices (dynamic list) -->
|
||||
<fieldset class="admin-jury-lecteurs">
|
||||
<legend>Lecteur·ices</legend>
|
||||
<div id="jury-lecteurs-list" class="admin-jury-list">
|
||||
<?php if (empty($juryLecteurs)): ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_lecteurs[]" placeholder="Nom"
|
||||
id="jury_lecteur_0" aria-label="Lecteur·ice 1 — nom">
|
||||
<label class="admin-checkbox-label admin-jury-ext">
|
||||
<input type="checkbox" name="jury_lecteurs_ext[0]" value="1"
|
||||
aria-label="Lecteur·ice 1 — externe"> Externe
|
||||
</label>
|
||||
<button type="button" class="admin-btn-remove" onclick="removeJuryRow(this)"
|
||||
aria-label="Supprimer le lecteur·ice 1"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php foreach ($juryLecteurs as $li => $lm): ?>
|
||||
<?php $lNum = $li + 1; ?>
|
||||
<div class="admin-jury-entry">
|
||||
<input type="text" name="jury_lecteurs[]"
|
||||
value="<?= htmlspecialchars($lm['name']) ?>" placeholder="Nom"
|
||||
id="jury_lecteur_<?= $li ?>" aria-label="Lecteur·ice <?= $lNum ?> — nom">
|
||||
<label class="admin-checkbox-label admin-jury-ext">
|
||||
<input type="checkbox" name="jury_lecteurs_ext[<?= $li ?>]" value="1"
|
||||
<?= $lm['is_external'] ? 'checked' : '' ?>
|
||||
aria-label="Lecteur·ice <?= $lNum ?> — externe"> Externe
|
||||
</label>
|
||||
<button type="button" class="admin-btn-remove" onclick="removeJuryRow(this)"
|
||||
aria-label="Supprimer le lecteur·ice <?= $lNum ?>"><span aria-hidden="true">✕</span></button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<button type="button" class="admin-btn-secondary admin-add-jury-btn"
|
||||
onclick="addJuryRow()">+ Ajouter un·e lecteur·ice</button>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<script>
|
||||
var juryIdx = <?= $juryIdx ?>;
|
||||
function addJuryRow() {
|
||||
var list = document.getElementById('jury-lecteurs-list');
|
||||
var n = list.querySelectorAll('.admin-jury-entry').length + 1;
|
||||
var div = document.createElement('div');
|
||||
div.className = 'admin-jury-entry';
|
||||
div.innerHTML = '<input type="text" name="jury_lecteurs[]" placeholder="Nom"'
|
||||
+ ' aria-label="Lecteur\u00b7ice ' + n + ' \u2014 nom">'
|
||||
+ '<label class="admin-checkbox-label admin-jury-ext">'
|
||||
+ '<input type="checkbox" name="jury_lecteurs_ext[' + juryIdx + ']" value="1"'
|
||||
+ ' aria-label="Lecteur\u00b7ice ' + n + ' \u2014 externe"> Externe'
|
||||
+ '</label>'
|
||||
+ '<button type="button" class="admin-btn-remove" onclick="removeJuryRow(this)"'
|
||||
+ ' aria-label="Supprimer le lecteur\u00b7ice ' + n + '"><span aria-hidden="true">\u2715</span></button>';
|
||||
list.appendChild(div);
|
||||
juryIdx++;
|
||||
}
|
||||
function removeJuryRow(btn) {
|
||||
btn.closest('.admin-jury-entry').remove();
|
||||
}
|
||||
</script>
|
||||
61
app/templates/partials/form/select-field.php
Normal file
61
app/templates/partials/form/select-field.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Select field partial.
|
||||
*
|
||||
* Variables consumed:
|
||||
* string $name — select name attribute (also used for id)
|
||||
* string $label — visible label text
|
||||
* array $options — each element must have 'id' and 'name' keys;
|
||||
* may optionally have 'code' for display suffix
|
||||
* mixed $selected — currently selected value (compared to option 'id');
|
||||
* pass null or '' for no selection
|
||||
* bool $required — whether the field is required; default false
|
||||
* string $placeholder — text for the leading empty <option>; default ''
|
||||
* set to null to suppress the empty option entirely
|
||||
* string|null $id — override the id attribute (defaults to $name)
|
||||
* string|null $hint — optional hint shown in <small> below the select
|
||||
*/
|
||||
|
||||
$required = $required ?? false;
|
||||
$placeholder = array_key_exists('placeholder', get_defined_vars()) ? $placeholder : '';
|
||||
$id = $id ?? $name;
|
||||
$hint = $hint ?? null;
|
||||
$attrs = $attrs ?? [];
|
||||
?>
|
||||
<div>
|
||||
<label for="<?= htmlspecialchars($id) ?>"><?= htmlspecialchars($label) ?></label>
|
||||
<?php
|
||||
$selectAttrStr = '';
|
||||
foreach ($attrs as $k => $v) {
|
||||
if ($v === true) {
|
||||
$selectAttrStr .= ' ' . htmlspecialchars($k);
|
||||
} else {
|
||||
$selectAttrStr .= ' ' . htmlspecialchars($k) . '="' . htmlspecialchars((string)$v) . '"';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<select id="<?= htmlspecialchars($id) ?>"
|
||||
name="<?= htmlspecialchars($name) ?>"
|
||||
<?= $required ? 'required' : '' ?>
|
||||
<?= $selectAttrStr ?>>
|
||||
<?php if ($placeholder !== null): ?>
|
||||
<option value=""><?= htmlspecialchars($placeholder) ?></option>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($options as $opt): ?>
|
||||
<?php
|
||||
// Match by id (numeric FK) or by name string (when the view returns the name).
|
||||
$isSelected = ((string)$selected === (string)$opt['id'])
|
||||
|| ($selected !== null && $selected !== '' && isset($opt['name']) && (string)$selected === (string)$opt['name']);
|
||||
?>
|
||||
<option value="<?= htmlspecialchars((string)$opt['id']) ?>"
|
||||
<?= $isSelected ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($opt['name']) ?><?php if (!empty($opt['code'])): ?> (<?= htmlspecialchars($opt['code']) ?>)<?php endif; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if ($hint): ?>
|
||||
<small><?= htmlspecialchars($hint) ?></small>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
unset($required, $placeholder, $id, $hint, $attrs, $selectAttrStr, $k, $v);
|
||||
60
app/templates/partials/form/text-field.php
Normal file
60
app/templates/partials/form/text-field.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Text field partial — single-line text / number / url / email input.
|
||||
*
|
||||
* Variables consumed:
|
||||
* string $name — input name attribute (also used for id)
|
||||
* string $label — visible label text
|
||||
* string $value — current value (already htmlspecialchars'd by caller, or raw)
|
||||
* string $type — input type; default 'text'
|
||||
* bool $required — whether the field is required; default false
|
||||
* string $placeholder — placeholder text; default ''
|
||||
* string|null $hint — optional hint shown in <small> below the input
|
||||
* string|null $id — override the id attribute (defaults to $name)
|
||||
* array $attrs — extra HTML attributes as key=>value pairs (e.g. min/max for number)
|
||||
*
|
||||
* The partial does NOT call htmlspecialchars on $value — the caller is responsible.
|
||||
*/
|
||||
|
||||
$type = $type ?? 'text';
|
||||
$required = $required ?? false;
|
||||
$placeholder = $placeholder ?? '';
|
||||
$hint = $hint ?? null;
|
||||
$id = $id ?? $name;
|
||||
$attrs = $attrs ?? [];
|
||||
|
||||
$attrStr = '';
|
||||
foreach ($attrs as $k => $v) {
|
||||
if ($v === true) {
|
||||
$attrStr .= ' ' . htmlspecialchars($k);
|
||||
} else {
|
||||
$attrStr .= ' ' . htmlspecialchars($k) . '="' . htmlspecialchars((string)$v) . '"';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div>
|
||||
<label for="<?= htmlspecialchars($id) ?>"><?= htmlspecialchars($label) ?></label>
|
||||
<?php if ($hint): ?>
|
||||
<div>
|
||||
<input type="<?= htmlspecialchars($type) ?>"
|
||||
id="<?= htmlspecialchars($id) ?>"
|
||||
name="<?= htmlspecialchars($name) ?>"
|
||||
value="<?= $value ?>"
|
||||
<?= $required ? 'required' : '' ?>
|
||||
<?= $placeholder ? 'placeholder="' . htmlspecialchars($placeholder) . '"' : '' ?>
|
||||
<?= $attrStr ?>>
|
||||
<small><?= htmlspecialchars($hint) ?></small>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<input type="<?= htmlspecialchars($type) ?>"
|
||||
id="<?= htmlspecialchars($id) ?>"
|
||||
name="<?= htmlspecialchars($name) ?>"
|
||||
value="<?= $value ?>"
|
||||
<?= $required ? 'required' : '' ?>
|
||||
<?= $placeholder ? 'placeholder="' . htmlspecialchars($placeholder) . '"' : '' ?>
|
||||
<?= $attrStr ?>>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
// Reset consumed variables so includes in a loop don't bleed state.
|
||||
unset($type, $required, $placeholder, $hint, $id, $attrs, $attrStr, $k, $v);
|
||||
61
app/templates/partials/pagination.php
Normal file
61
app/templates/partials/pagination.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* Pagination partial
|
||||
*
|
||||
* Required variables (set before include):
|
||||
* int $page — current page (1-based)
|
||||
* int $totalPages — total number of pages
|
||||
* array $baseParams — query-string params preserved across page links
|
||||
* (e.g. ['year' => 2024, 'query' => 'design'])
|
||||
* The 'page' key is injected automatically; do not include it.
|
||||
*
|
||||
* Usage:
|
||||
* <?php $baseParams = array_filter(['year' => $year]); ?>
|
||||
* <?php include APP_ROOT . '/templates/partials/pagination.php'; ?>
|
||||
*/
|
||||
|
||||
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;
|
||||
?>
|
||||
<nav class="pagination-wrap" aria-label="Pagination">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="<?= $paginationUrl(1) ?>"
|
||||
class="pagination-btn<?= $atFirst ? ' disabled' : '' ?>"
|
||||
<?= $atFirst ? 'aria-disabled="true" tabindex="-1"' : '' ?>
|
||||
aria-label="Première page">«</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $paginationUrl(max(1, $page - 1)) ?>"
|
||||
class="pagination-btn<?= $atFirst ? ' disabled' : '' ?>"
|
||||
<?= $atFirst ? 'aria-disabled="true" tabindex="-1"' : '' ?>
|
||||
aria-label="Page précédente">‹</a>
|
||||
</li>
|
||||
<li class="pagination-info" aria-current="page">
|
||||
<span class="page-current"><?= $page ?></span> / <?= $totalPages ?>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $paginationUrl(min($totalPages, $page + 1)) ?>"
|
||||
class="pagination-btn<?= $atLast ? ' disabled' : '' ?>"
|
||||
<?= $atLast ? 'aria-disabled="true" tabindex="-1"' : '' ?>
|
||||
aria-label="Page suivante">›</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= $paginationUrl($totalPages) ?>"
|
||||
class="pagination-btn<?= $atLast ? ' disabled' : '' ?>"
|
||||
<?= $atLast ? 'aria-disabled="true" tabindex="-1"' : '' ?>
|
||||
aria-label="Dernière page">»</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
199
app/templates/partials/repertoire-index.php
Normal file
199
app/templates/partials/repertoire-index.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/**
|
||||
* Partial: répertoire index columns.
|
||||
* Rendered both on full page load and as HTMX partial swap.
|
||||
*
|
||||
* Expected variables:
|
||||
* $repData array output of Database::getRepertoireFilterData()
|
||||
* $activeFilters array{years:int[], ap:string[], or:string[], fi:string[], kw:string[]}
|
||||
*/
|
||||
|
||||
$activeSets = [
|
||||
'years' => array_map('strval', $activeFilters['years'] ?? []),
|
||||
'ap' => $activeFilters['ap'] ?? [],
|
||||
'or' => $activeFilters['or'] ?? [],
|
||||
'fi' => $activeFilters['fi'] ?? [],
|
||||
'kw' => $activeFilters['kw'] ?? [],
|
||||
];
|
||||
|
||||
// Build the student map from matched students only
|
||||
$studentMap = []; // name => id
|
||||
foreach ($repData['students'] as $s) {
|
||||
if (empty($s['authors'])) continue;
|
||||
foreach (explode(',', $s['authors']) as $name) {
|
||||
$name = trim($name);
|
||||
if ($name !== '' && !isset($studentMap[$name])) {
|
||||
$studentMap[$name] = (int)$s['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($studentMap);
|
||||
|
||||
/**
|
||||
* Build the toggle URL for a filter button.
|
||||
* Toggles $value in $dim; keeps all other active filters intact.
|
||||
*/
|
||||
function repToggleUrl(array $sets, string $dim, string $value): string {
|
||||
if (in_array($value, $sets[$dim], true)) {
|
||||
$sets[$dim] = array_values(array_filter($sets[$dim], fn($v) => $v !== $value));
|
||||
} else {
|
||||
$sets[$dim][] = $value;
|
||||
}
|
||||
$params = [];
|
||||
foreach ($sets['years'] as $v) $params[] = 'fy[]=' . urlencode((string)$v);
|
||||
foreach ($sets['ap'] as $v) $params[] = 'ap[]=' . urlencode($v);
|
||||
foreach ($sets['or'] as $v) $params[] = 'or[]=' . urlencode($v);
|
||||
foreach ($sets['fi'] as $v) $params[] = 'fi[]=' . urlencode($v);
|
||||
foreach ($sets['kw'] as $v) $params[] = 'kw[]=' . urlencode($v);
|
||||
$qs = implode('&', $params);
|
||||
return '/repertoire.php' . ($qs ? '?' . $qs : '');
|
||||
}
|
||||
|
||||
$anyActive = !empty($activeSets['years']) || !empty($activeSets['ap'])
|
||||
|| !empty($activeSets['or']) || !empty($activeSets['fi'])
|
||||
|| !empty($activeSets['kw']);
|
||||
|
||||
// Common HTMX attributes for all active filter buttons
|
||||
$hx = 'hx-target="#repertoire-index" hx-swap="outerHTML" hx-push-url="true" hx-indicator="#rep-indicator"';
|
||||
?>
|
||||
<div id="repertoire-index" class="repertoire-index">
|
||||
|
||||
<!-- ANNÉES -->
|
||||
<section class="repertoire-col" data-col="years">
|
||||
<h2>Années</h2>
|
||||
<ul>
|
||||
<?php foreach ($repData['years'] as $item):
|
||||
$val = (string)$item['value'];
|
||||
$isActive = in_array($val, $activeSets['years'], true);
|
||||
$isFaded = $anyActive && !$item['matched'] && !$isActive;
|
||||
$cls = 'rep-entry'
|
||||
. ($isActive ? ' rep-entry--selected' : '')
|
||||
. ($isFaded ? ' rep-entry--faded' : '');
|
||||
$url = repToggleUrl($activeSets, 'years', $val);
|
||||
?>
|
||||
<li>
|
||||
<button type="button" class="<?= $cls ?>"
|
||||
aria-pressed="<?= $isActive ? 'true' : 'false' ?>"
|
||||
<?= $isFaded ? 'disabled' : "hx-get=\"" . htmlspecialchars($url) . "\" $hx" ?>>
|
||||
<?= htmlspecialchars($val) ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- ATELIERS PLURIDISCIPLINAIRES -->
|
||||
<section class="repertoire-col" data-col="ap">
|
||||
<h2>Ateliers Pluridisciplinaires</h2>
|
||||
<ul>
|
||||
<?php foreach ($repData['ap_programs'] as $item):
|
||||
$val = $item['value'];
|
||||
$isActive = in_array($val, $activeSets['ap'], true);
|
||||
$isFaded = $anyActive && !$item['matched'] && !$isActive;
|
||||
$cls = 'rep-entry'
|
||||
. ($isActive ? ' rep-entry--selected' : '')
|
||||
. ($isFaded ? ' rep-entry--faded' : '');
|
||||
$url = repToggleUrl($activeSets, 'ap', $val);
|
||||
?>
|
||||
<li>
|
||||
<button type="button" class="<?= $cls ?>"
|
||||
aria-pressed="<?= $isActive ? 'true' : 'false' ?>"
|
||||
<?= $isFaded ? 'disabled' : "hx-get=\"" . htmlspecialchars($url) . "\" $hx" ?>>
|
||||
<?= htmlspecialchars($val) ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- ORIENTATIONS -->
|
||||
<section class="repertoire-col" data-col="or">
|
||||
<h2>Orientations</h2>
|
||||
<ul>
|
||||
<?php foreach ($repData['orientations'] as $item):
|
||||
$val = $item['value'];
|
||||
$isActive = in_array($val, $activeSets['or'], true);
|
||||
$isFaded = $anyActive && !$item['matched'] && !$isActive;
|
||||
$cls = 'rep-entry'
|
||||
. ($isActive ? ' rep-entry--selected' : '')
|
||||
. ($isFaded ? ' rep-entry--faded' : '');
|
||||
$url = repToggleUrl($activeSets, 'or', $val);
|
||||
?>
|
||||
<li>
|
||||
<button type="button" class="<?= $cls ?>"
|
||||
aria-pressed="<?= $isActive ? 'true' : 'false' ?>"
|
||||
<?= $isFaded ? 'disabled' : "hx-get=\"" . htmlspecialchars($url) . "\" $hx" ?>>
|
||||
<?= htmlspecialchars($val) ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- FINALITÉ DU MASTER -->
|
||||
<section class="repertoire-col" data-col="fi">
|
||||
<h2>Finalité du Master</h2>
|
||||
<ul>
|
||||
<?php foreach ($repData['finality_types'] as $item):
|
||||
$val = $item['value'];
|
||||
$isActive = in_array($val, $activeSets['fi'], true);
|
||||
$isFaded = $anyActive && !$item['matched'] && !$isActive;
|
||||
$cls = 'rep-entry'
|
||||
. ($isActive ? ' rep-entry--selected' : '')
|
||||
. ($isFaded ? ' rep-entry--faded' : '');
|
||||
$url = repToggleUrl($activeSets, 'fi', $val);
|
||||
?>
|
||||
<li>
|
||||
<button type="button" class="<?= $cls ?>"
|
||||
aria-pressed="<?= $isActive ? 'true' : 'false' ?>"
|
||||
<?= $isFaded ? 'disabled' : "hx-get=\"" . htmlspecialchars($url) . "\" $hx" ?>>
|
||||
<?= htmlspecialchars($val) ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- ÉTUDIANTES -->
|
||||
<section class="repertoire-col" data-col="students">
|
||||
<h2>Étudiantes</h2>
|
||||
<ul>
|
||||
<?php if (empty($studentMap)): ?>
|
||||
<li class="rep-empty">—</li>
|
||||
<?php else: ?>
|
||||
<?php foreach ($studentMap as $name => $id): ?>
|
||||
<li>
|
||||
<a href="tfe.php?id=<?= (int)$id ?>" class="rep-entry rep-entry--link">
|
||||
<?= htmlspecialchars($name) ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<!-- MOTS-CLÉS -->
|
||||
<section class="repertoire-col" data-col="kw">
|
||||
<h2>Mots-clés</h2>
|
||||
<ul>
|
||||
<?php foreach ($repData['keywords'] as $item):
|
||||
$val = $item['value'];
|
||||
$isActive = in_array($val, $activeSets['kw'], true);
|
||||
$isFaded = $anyActive && !$item['matched'] && !$isActive;
|
||||
$cls = 'rep-entry'
|
||||
. ($isActive ? ' rep-entry--selected' : '')
|
||||
. ($isFaded ? ' rep-entry--faded' : '');
|
||||
$url = repToggleUrl($activeSets, 'kw', $val);
|
||||
?>
|
||||
<li>
|
||||
<button type="button" class="<?= $cls ?>"
|
||||
aria-pressed="<?= $isActive ? 'true' : 'false' ?>"
|
||||
<?= $isFaded ? 'disabled' : "hx-get=\"" . htmlspecialchars($url) . "\" $hx" ?>>
|
||||
<?= htmlspecialchars($val) ?>
|
||||
</button>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
67
app/templates/partials/status-badge.php
Normal file
67
app/templates/partials/status-badge.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Status badge partial.
|
||||
*
|
||||
* Renders a single <span class="status-badge …"> 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:
|
||||
* <?php $badgeType = 'publish'; $badgeValue = $thesis['is_published']; include PARTIALS . '/status-badge.php'; ?>
|
||||
*
|
||||
* Example — access badge:
|
||||
* <?php $badgeType = 'access'; $badgeValue = $thesis['access_type']; include PARTIALS . '/status-badge.php'; ?>
|
||||
*
|
||||
* Example — generic ok badge:
|
||||
* <?php $badgeType = 'ok'; $badgeValue = $hasPassword; $badgeOkLabel = 'Active'; $badgeWarnLabel = 'Non configurée'; $badgeContext = ''; include PARTIALS . '/status-badge.php'; ?>
|
||||
*/
|
||||
|
||||
$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;
|
||||
}
|
||||
?>
|
||||
<span class="status-badge <?= $cssClass ?>" aria-label="<?= htmlspecialchars($ariaLabel) ?>"><span aria-hidden="true"><?= $symbol ?> </span><?= htmlspecialchars($visibleLabel) ?></span>
|
||||
<?php
|
||||
// Clean up variables so they don't bleed into the including scope.
|
||||
unset($badgeType, $badgeValue, $badgeOkLabel, $badgeWarnLabel, $badgeContext,
|
||||
$isOk, $accessName, $accessSlug, $symbols, $symbol, $cssClass, $visibleLabel, $ariaLabel);
|
||||
Reference in New Issue
Block a user