Files
xamxam/app/public/admin/contenus-langues-fragment.php
Pontoporeia dfde88eaa5 Migrate all <img>-based icons to inline SVG via PHP helper
Replace every <img src="/assets/icons/..."> with <?= icon('name') ?>
across 26 template files. The PHP helper inlines the SVG markup into the
DOM so CSS color cascades naturally through fill="currentColor".

- Add src/icon.php helper: reads SVG file, sets width/height to 1em,
  injects aria-hidden, supports optional CSS class
- Fix 12 icon SVGs that had hardcoded fill="#000000" or missing fill attr
- Replace search.svg with Phosphor fill-based magnifying glass
- Add explicit SVG sizes for admin header nav icons (16px/20px)
- Scope public search icon CSS to form[role=search]:not(.header-search-form)
  to avoid breaking admin header layout; change stroke to fill
- Remove <img> filter: brightness(0) invert(1) hacks from admin.css
2026-06-21 17:52:27 +02:00

100 lines
4.5 KiB
PHP

<?php
/**
* contenus-langues-fragment.php
*
* HTMX fragment: returns the langues table for the contenus page,
* optionally filtered by a search query.
*/
require_once __DIR__ . '/../../bootstrap.php';
require_once __DIR__ . '/../../src/AdminAuth.php';
AdminAuth::requireLogin();
if (empty($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
require_once __DIR__ . '/../../src/Database.php';
$searchQuery = trim($_GET['q'] ?? '');
try {
$db = new Database();
$languages = ($searchQuery !== '') ? $db->searchLanguages($searchQuery) : $db->getAllLanguagesWithCount();
} catch (Exception $e) {
die('<div class="flash-error">Erreur : ' . htmlspecialchars($e->getMessage()) . '</div>');
}
?>
<div id="langues-bulk-actions" class="admin-bulk-actions" style="display:none;position:sticky;top:0;z-index:10">
<strong><span id="langues-selected-count">0</span> langue(s) sélectionnée(s)</strong>
<div class="admin-bulk-btns">
<button type="button" class="btn btn--sm btn--secondary" onclick="languesCancelSelection()" title="Annuler la sélection">
<?= icon('x-close') ?>
Annuler
</button>
<button type="button" class="btn btn--sm btn--red admin-btn-delete"
onclick="languesConfirmBulkDelete()"
title="Supprimer les langues sélectionnées">
<?= icon('trash') ?>
Supprimer
</button>
<button type="button" class="btn btn--sm btn--warning admin-btn-merge"
onclick="languesConfirmBulkMerge()"
title="Fusionner les langues sélectionnées">
<?= icon('link-chain') ?>
Fusionner
</button>
</div>
</div>
<form id="langues-bulk-form" method="post" action="actions/language.php">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="merge_bulk">
<input type="hidden" name="return" value="/admin/contenus.php">
<input type="hidden" name="target_id" id="langues-bulk-target" value="">
<div id="langues-bulk-checkboxes"></div>
</form>
<table class="admin-table--sticky">
<thead>
<tr>
<th scope="col" style="width:1%"><input type="checkbox" onchange="languesToggleAll(this)"></th>
<th scope="col">Nom</th>
<th scope="col" style="width:1%;white-space:nowrap">TFE Associé</th>
<th scope="col" style="width:1%">Actions</th>
</tr>
</thead>
<tbody>
<?php if (empty($languages)): ?>
<tr><td colspan="4" class="admin-empty">Aucune langue trouvée.</td></tr>
<?php else: ?>
<?php foreach ($languages as $lang): ?>
<tr>
<td style="width:1%"><input type="checkbox" name="selected_langs[]" value="<?= (int)$lang['id'] ?>" onchange="languesUpdateBulk()"></td>
<td id="lang-name-<?= (int)$lang['id'] ?>" data-name="<?= htmlspecialchars($lang['name']) ?>">
<span class="tag-name-cell"><?= htmlspecialchars($lang['name']) ?></span>
<button type="button" class="admin-icon-btn admin-icon-btn--edit" title="Renommer"
onclick="languesStartRename(<?= (int)$lang['id'] ?>)">
<?= icon('pencil-note') ?>
</button>
</td>
<td class="admin-tags-count" style="width:1%;white-space:nowrap"><?= (int)$lang['thesis_count'] ?></td>
<td class="admin-actions-col" style="width:1%">
<div class="admin-actions">
<form method="post" action="actions/language.php" class="admin-inline-form">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="return" value="/admin/contenus.php">
<input type="hidden" name="language_id" value="<?= (int)$lang['id'] ?>">
<button type="button" class="admin-icon-btn admin-icon-btn--delete" title="Supprimer"
onclick="languesConfirmDelete(this, <?= htmlspecialchars(json_encode($lang['name']), ENT_QUOTES) ?>)">
<?= icon('trash') ?>
</button>
</form>
</div>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>