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/peertube-orphans-fragment.php
*
* Returns an HTML fragment ready for HTMX swap into #peertube-orphans-fragment.
* Returns an HTML fragment ready for HTMX innerHTML swap into #peertube-orphans-fragment.
*/
require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../src/AdminAuth.php';
@@ -17,80 +17,69 @@ $json = ob_get_clean();
$d = json_decode($json, true);
if (!($d['configured'] ?? false)): ?>
<div id="peertube-orphans-fragment" style="display:contents">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<fieldset>
<legend>
<?= icon('video') ?>
Vidéos PeerTube orphelines
</summary>
<div id="peertube-orphans-stats">
<p style="margin:0;color:var(--color-warning)">⚠️ PeerTube non configuré.</p>
</div>
</details>
</div>
</legend>
<p style="margin:0;color:var(--color-warning)">⚠️ PeerTube non configuré.</p>
</fieldset>
<?php return; endif; ?>
<?php if (!empty($d['error'])): ?>
<div id="peertube-orphans-fragment" style="display:contents">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<fieldset>
<legend>
<?= icon('video') ?>
Vidéos PeerTube orphelines
</summary>
<div id="peertube-orphans-stats">
<p style="margin:0;color:var(--color-error)">✗ <?= htmlspecialchars($d['error']) ?></p>
</div>
</details>
</div>
</legend>
<p style="margin:0;color:var(--color-error)">✗ <?= htmlspecialchars($d['error']) ?></p>
</fieldset>
<?php return; endif; ?>
<div id="peertube-orphans-fragment" style="display:contents">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<fieldset>
<legend>
<?= icon('video') ?>
Vidéos PeerTube orphelines <span class="n-meta"><?= (int)($d['orphan_count'] ?? 0) ?> vidéos orphelines</span>
</summary>
<div id="peertube-orphans-stats">
</legend>
<?php if (($d['orphan_count'] ?? 0) > 0): ?>
<table class="n-table">
<thead><tr><th>Nom</th><th>Date</th><th width="1%"></th></tr></thead>
<tbody>
<?php foreach ($d['orphans'] as $v): ?>
<tr>
<td>
<strong><?= htmlspecialchars($v['name']) ?></strong>
<span class="n-table__info" style="display:block"><?= htmlspecialchars($v['uuid']) ?></span>
</td>
<td style="white-space:nowrap"><?= htmlspecialchars(substr($v['createdAt'] ?? '', 0, 10)) ?></td>
<td style="white-space:nowrap">
<button type="button" class="btn btn--sm btn--danger" style="font-size:0.85em;padding:2px var(--space-xs)"
hx-post="/admin/actions/peertube-delete.php"
hx-confirm="Supprimer définitivement cette vidéo de PeerTube ?"
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","uuid":"<?= htmlspecialchars($v['uuid']) ?>"}'
hx-target="#peertube-orphans-fragment"
hx-swap="outerHTML"
hx-trigger="click"
hx-indicator="#peertube-orphans-fragment">
<?= icon('trash') ?>
Supprimer
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<table class="n-table">
<thead><tr><th>Nom</th><th>Date</th><th width="1%"></th></tr></thead>
<tbody>
<?php foreach ($d['orphans'] as $v): ?>
<tr>
<td>
<strong><?= htmlspecialchars($v['name']) ?></strong>
<span class="n-table__info" style="display:block"><?= htmlspecialchars($v['uuid']) ?></span>
</td>
<td style="white-space:nowrap"><?= htmlspecialchars(substr($v['createdAt'] ?? '', 0, 10)) ?></td>
<td style="white-space:nowrap">
<button type="button" class="btn btn--sm btn--danger" style="font-size:0.85em;padding:2px var(--space-xs)"
hx-post="/admin/actions/peertube-delete.php"
hx-confirm="Supprimer définitivement cette vidéo de PeerTube ?"
hx-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","uuid":"<?= htmlspecialchars($v['uuid']) ?>"}'
hx-target="#peertube-orphans-fragment"
hx-swap="innerHTML"
hx-trigger="click"
hx-indicator="#peertube-orphans-fragment">
<?= icon('trash') ?>
Supprimer
</button>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<p style="margin:0;color:var(--accent-green)">✓ Aucune vidéo orpheline.</p>
<p style="margin:0;color:var(--accent-green)">✓ Aucune vidéo orpheline.</p>
<?php endif; ?>
</div>
</details>
</fieldset>
<?php if (($d['stale_count'] ?? 0) > 0): ?>
<details id="peertube-stale-section" class="n-section" open>
<summary>
<fieldset>
<legend>
<?= icon('warning-diamond') ?>
Références DB obsolètes <span class="n-meta"><?= $d['stale_count'] ?></span>
</summary>
</legend>
<p style="margin:0 0 var(--space-sm) 0;font-size:0.85em;color:var(--text-secondary)">Ces UUID sont référencés en base de données mais n'existent plus sur la chaîne PeerTube. Les TFE liés affichent des liens morts.</p>
<table class="n-table">
<thead><tr><th>UUID</th><th>TFE(s)</th></tr></thead>
@@ -110,6 +99,5 @@ if (!($d['configured'] ?? false)): ?>
<?php endforeach; ?>
</tbody>
</table>
</details>
</fieldset>
<?php endif; ?>
</div>