feat: filtres et suppression massive dans admin/articles, profil auteur amélioré
- Admin articles : filtres auteur/catégorie/statut par GET, compteur de résultats
- Admin articles : suppression massive avec checkboxes, confirmation JS, contrôle d'ownership
- Profil auteur : bio tronquée à 3 lignes avec bouton 'plus', limite à 6 articles affichés
- Profil auteur : bouton CTA pill 'Mes liens' vers /liens/{slug}
- Page liens : boutons pill colorés (palette auto par index), fond gris clair, grand avatar
This commit is contained in:
@@ -105,12 +105,74 @@ function adminStatusBadge(array $a, int $now): string
|
||||
<!-- ─────────────────────────── ARTICLES ─────────────────────────── -->
|
||||
<?php elseif ($tab === 'articles'): ?>
|
||||
|
||||
<!-- Filtres -->
|
||||
<form class="row g-2 align-items-center mb-3" method="get" action="/admin/articles">
|
||||
<?php if (isAdmin() && !empty($adminData['filter_authors'])): ?>
|
||||
<div class="col-auto">
|
||||
<select name="filter_author" class="form-select form-select-sm">
|
||||
<option value="">Tous les auteurs</option>
|
||||
<?php foreach ($adminData['filter_authors'] as $_fa): ?>
|
||||
<option value="<?= htmlspecialchars($_fa) ?>"
|
||||
<?= ($adminData['filter_author'] ?? '') === $_fa ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($_fa) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($adminData['filter_categories'])): ?>
|
||||
<div class="col-auto">
|
||||
<select name="filter_category" class="form-select form-select-sm">
|
||||
<option value="">Toutes les catégories</option>
|
||||
<?php foreach ($adminData['filter_categories'] as $_fc): ?>
|
||||
<option value="<?= htmlspecialchars($_fc) ?>"
|
||||
<?= ($adminData['filter_category'] ?? '') === $_fc ? 'selected' : '' ?>>
|
||||
<?= htmlspecialchars($_fc) ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-auto">
|
||||
<select name="filter_status" class="form-select form-select-sm">
|
||||
<option value="">Tous les statuts</option>
|
||||
<option value="published" <?= ($adminData['filter_status'] ?? '') === 'published' ? 'selected' : '' ?>>Publié</option>
|
||||
<option value="draft" <?= ($adminData['filter_status'] ?? '') === 'draft' ? 'selected' : '' ?>>Brouillon</option>
|
||||
<option value="preview" <?= ($adminData['filter_status'] ?? '') === 'preview' ? 'selected' : '' ?>>Avant-première</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto d-flex gap-2">
|
||||
<button type="submit" class="btn btn-secondary btn-sm">Filtrer</button>
|
||||
<?php $hasFilter = ($adminData['filter_author'] ?? '') !== '' || ($adminData['filter_category'] ?? '') !== '' || ($adminData['filter_status'] ?? '') !== ''; ?>
|
||||
<?php if ($hasFilter): ?>
|
||||
<a href="/admin/articles" class="btn btn-link btn-sm p-0">Réinitialiser</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($hasFilter): ?>
|
||||
<div class="col-auto">
|
||||
<span class="text-muted small"><?= count($adminData['articles']) ?> résultat(s)</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
|
||||
<?php if (empty($adminData['articles'])): ?>
|
||||
<p class="text-muted">Aucun article.</p>
|
||||
<?php else: ?>
|
||||
<form method="post" action="/?action=admin_bulk_delete" id="bulk-form">
|
||||
<div class="d-flex justify-content-between align-items-center mb-2">
|
||||
<div class="form-check mb-0">
|
||||
<input class="form-check-input" type="checkbox" id="check-all">
|
||||
<label class="form-check-label small text-muted" for="check-all">Tout sélectionner</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger btn-sm"
|
||||
onclick="return document.querySelectorAll('.bulk-check:checked').length > 0 && confirm('Supprimer les articles sélectionnés ? Cette action est irréversible.')">
|
||||
Supprimer la sélection
|
||||
</button>
|
||||
</div>
|
||||
<table class="table table-sm table-hover align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:2rem"></th>
|
||||
<th>Titre</th>
|
||||
<?php if (isAdmin()): ?><th>Auteur</th><?php endif; ?>
|
||||
<th>Catégorie</th>
|
||||
@@ -122,6 +184,10 @@ function adminStatusBadge(array $a, int $now): string
|
||||
<tbody>
|
||||
<?php foreach ($adminData['articles'] as $a): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<input class="form-check-input bulk-check" type="checkbox"
|
||||
name="uuids[]" value="<?= htmlspecialchars($a['uuid']) ?>">
|
||||
</td>
|
||||
<td>
|
||||
<a href="/post/<?= htmlspecialchars($a['slug'] ?? '') ?>">
|
||||
<?= htmlspecialchars($a['title']) ?>
|
||||
@@ -143,6 +209,12 @@ function adminStatusBadge(array $a, int $now): string
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
document.getElementById('check-all').addEventListener('change', function() {
|
||||
document.querySelectorAll('.bulk-check').forEach(function(cb) { cb.checked = this.checked; }, this);
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ─────────────────────────── UTILISATEURS ─────────────────────────── -->
|
||||
|
||||
Reference in New Issue
Block a user