Files
xamxam/app/public/admin/actions/peertube-orphans-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

115 lines
4.9 KiB
PHP

<?php
/**
* PeerTube orphan check as HTML fragment (admin).
*
* GET /admin/actions/peertube-orphans-fragment.php
*
* Returns an HTML fragment ready for HTMX swap into #peertube-orphans-wrapper.
*/
require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../src/AdminAuth.php';
AdminAuth::requireLogin();
// Re-use the existing JSON endpoint internally
ob_start();
require __DIR__ . '/peertube-orphans.php';
$json = ob_get_clean();
$d = json_decode($json, true);
if (!($d['configured'] ?? false)): ?>
<div id="peertube-orphans-wrapper">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<?= 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>
<?php return; endif; ?>
<?php if (!empty($d['error'])): ?>
<div id="peertube-orphans-wrapper">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<?= 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>
<?php return; endif; ?>
<div id="peertube-orphans-wrapper">
<details id="peertube-orphans-col" class="n-section" open>
<summary>
<?= 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">
<?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-vals='{"csrf_token":"<?= htmlspecialchars($_SESSION['csrf_token']) ?>","uuid":"<?= htmlspecialchars($v['uuid']) ?>"}'
hx-target="#peertube-orphans-wrapper"
hx-swap="outerHTML"
hx-trigger="click"
hx-indicator="#peertube-orphans-wrapper">
<?= 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>
<?php endif; ?>
</div>
</details>
<?php if (($d['stale_count'] ?? 0) > 0): ?>
<details id="peertube-stale-section" class="n-section" open>
<summary>
<?= icon('warning-diamond') ?>
Références DB obsolètes <span class="n-meta"><?= $d['stale_count'] ?></span>
</summary>
<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>
<tbody>
<?php foreach ($d['stale_entries'] as $s): ?>
<tr>
<td style="word-break:break-all;color:var(--text-secondary)"><?= htmlspecialchars($s['uuid']) ?></td>
<td>
<?php if (!empty($s['theses'])): ?>
<?= implode(', ', array_map(function($t) {
$label = $t['identifier'] ?: '#' . $t['thesis_id'];
return '<a href="/admin/contenus-edit.php?id=' . (int)$t['thesis_id'] . '" target="_blank">' . htmlspecialchars($label) . '</a>';
}, $s['theses'])) ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</details>
<?php endif; ?>
</div>