cleanup: remplacer <details> par <fieldset>/<legend> (comme contenus.php)

This commit is contained in:
Pontoporeia
2026-07-03 17:12:15 +02:00
parent a1f32acaa1
commit 786eef6df5
4 changed files with 127 additions and 132 deletions
@@ -4,7 +4,7 @@
*
* GET /admin/actions/cleanup-stats-fragment.php
*
* Returns an HTML fragment ready for HTMX swap into #tmp-cleanup-stats-wrapper.
* Returns an HTML fragment ready for HTMX innerHTML swap into #tmp-cleanup-stats-wrapper.
*/
require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../src/AdminAuth.php';
@@ -24,13 +24,6 @@ $trActive = $d['trash_active_count'] ?? 0;
$totalStale = $fpStale + $trStale;
$totalFiles = $fpStale + $fpActive + $trStale + $trActive;
// Build summary meta: total stale count + total size
$staleParts = [];
if ($fpStale > 0) $staleParts[] = $fpStale . ' téléversement';
if ($trStale > 0) $staleParts[] = $trStale . ' corbeille';
$staleMeta = implode(' + ', $staleParts);
// Approximate total stale size
$staleSize = ($d['filepond_stale_size'] ?? 0) + ($d['trash_stale_size'] ?? 0);
$staleHuman = '';
if ($staleSize >= 1073741824) { $staleHuman = number_format($staleSize / 1073741824, 1) . ' GB'; }
@@ -38,50 +31,52 @@ elseif ($staleSize >= 1048576) { $staleHuman = number_format($staleSize / 104857
elseif ($staleSize >= 1024) { $staleHuman = number_format($staleSize / 1024, 0) . ' KB'; }
elseif ($staleSize > 0) { $staleHuman = $staleSize . ' B'; }
$summaryMeta = $staleMeta;
if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
$fpMeta = $fpStale . ' dossier' . ($fpStale > 1 ? 's' : '');
if ($fpStale > 0) {
$fpMeta .= ' · ' . ($d['filepond_stale_human'] ?? '');
}
$trMeta = $trStale . ' fichier' . ($trStale > 1 ? 's' : '');
if ($trStale > 0) {
$trMeta .= ' · ' . ($d['trash_stale_human'] ?? '');
}
?>
<?php if ($totalStale === 0 && $totalFiles === 0): ?>
<div id="tmp-cleanup-stats-wrapper">
<details class="n-section" open>
<summary>
<fieldset>
<legend>
<?= icon('paint-brush-household') ?>
Fichiers temporaires
</summary>
</legend>
<p style="margin:0;color:var(--accent-green)">✓ Aucun fichier temporaire.</p>
</details>
</div>
</fieldset>
<?php return; endif; ?>
<div id="tmp-cleanup-stats-wrapper">
<!-- Bulk actions bar -->
<div id="cleanup-bulk-actions" class="admin-bulk-actions" style="display:none">
<strong><span id="cleanup-selected-count">0</span> fichier(s) sélectionné(s)</strong>
<div class="admin-bulk-btns">
<button type="button" class="btn btn--sm btn--red" onclick="cleanupBulkDelete()">
<?= icon('trash') ?> Supprimer la sélection
</button>
</div>
<!-- Bulk actions bar -->
<div id="cleanup-bulk-actions" class="admin-bulk-actions" style="display:none">
<strong><span id="cleanup-selected-count">0</span> fichier(s) sélectionné(s)</strong>
<div class="admin-bulk-btns">
<button type="button" class="btn btn--sm btn--red" onclick="cleanupBulkDelete()">
<?= icon('trash') ?> Supprimer la sélection
</button>
</div>
</div>
<!-- Hidden bulk form (HTMX-powered) -->
<form id="cleanup-bulk-form" method="post" action="/admin/actions/cleanup-tmp.php"
hx-post="/admin/actions/cleanup-tmp.php"
hx-target="#tmp-cleanup-stats-wrapper"
hx-swap="outerHTML"
hx-indicator="#tmp-cleanup-stats-wrapper"
style="display:none">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<div id="cleanup-bulk-checkboxes"></div>
</form>
<details class="n-section" open>
<summary>
<?= icon('paint-brush-household') ?>
Fichiers temporaires <span class="n-meta"><?= htmlspecialchars($summaryMeta) ?></span>
</summary>
<!-- Hidden bulk form (HTMX-powered) -->
<form id="cleanup-bulk-form" method="post" action="/admin/actions/cleanup-tmp.php"
hx-post="/admin/actions/cleanup-tmp.php"
hx-target="#tmp-cleanup-stats-wrapper"
hx-swap="innerHTML"
hx-indicator="#tmp-cleanup-stats-wrapper"
style="display:none">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
<div id="cleanup-bulk-checkboxes"></div>
</form>
<?php if ($fpStale > 0): ?>
<fieldset>
<legend>
<?= icon('paint-brush-household') ?>
Téléversements abandonnés <span class="n-meta"><?= htmlspecialchars($fpMeta) ?></span>
</legend>
<table class="n-table">
<thead><tr><th width="1%"><input type="checkbox" onchange="cleanupToggleAll(this, 'filepond')" title="Tout sélectionner"></th><th>Nom</th><th>Taille</th><th>Âge</th><th width="1%"></th></tr></thead>
<tbody>
@@ -97,7 +92,7 @@ if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
hx-confirm="Supprimer définitivement ce téléversement abandonné ?"
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","filepond_dir":"<?= htmlspecialchars($f['name']) ?>"}'
hx-target="#tmp-cleanup-stats-wrapper"
hx-swap="outerHTML"
hx-swap="innerHTML"
hx-indicator="#tmp-cleanup-stats-wrapper">
<?= icon('trash') ?>
Supprimer
@@ -107,13 +102,15 @@ if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
<?php endforeach; ?>
</tbody>
</table>
</fieldset>
<?php endif; ?>
<?php if ($trStale > 0): ?>
<p class="n-heading">
<fieldset>
<legend>
<?= icon('trash') ?>
Corbeille
</p>
Corbeille <span class="n-meta"><?= htmlspecialchars($trMeta) ?></span>
</legend>
<table class="n-table">
<thead><tr><th width="1%"><input type="checkbox" onchange="cleanupToggleAll(this, 'trash')" title="Tout sélectionner"></th><th>Nom</th><th>Taille</th><th>Âge</th><th width="1%"></th></tr></thead>
<tbody>
@@ -129,7 +126,7 @@ if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
hx-confirm="Supprimer définitivement ce fichier de la corbeille ?"
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","trash_file":"<?= htmlspecialchars($f['name']) ?>"}'
hx-target="#tmp-cleanup-stats-wrapper"
hx-swap="outerHTML"
hx-swap="innerHTML"
hx-indicator="#tmp-cleanup-stats-wrapper">
<?= icon('trash') ?>
Supprimer
@@ -139,6 +136,7 @@ if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
<?php endforeach; ?>
</tbody>
</table>
</fieldset>
<?php endif; ?>
<?php if ($fpActive > 0 || $trActive > 0): ?>
@@ -147,5 +145,3 @@ if ($staleHuman) $summaryMeta .= ' · ' . $staleHuman;
<?php if ($trActive) echo $trActive . ' fichier(s) récent(s) (' . htmlspecialchars($d['trash_active_human']) . ')'; ?>
</p>
<?php endif; ?>
</details>
</div>