feat : RSS content, feed catégorie, cookie commentaires, flux erreurs, email preview (v1.6.17)

- RSS : content:encoded (HTML complet) + fix description via plain (#42)
- RSS : flux filtré par ?category=nom (#43)
- Commentaires : cookie nom/email pour pré-remplir le formulaire (#51)
- flux/ : bandeau admin des feeds en erreur (#45)
- admin/emails : bouton « Voir ↗ » vers /admin/email-preview/{id} en nouvel onglet (#37)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-16 10:00:37 +02:00
parent dc4701d667
commit 51055b7321
8 changed files with 131 additions and 32 deletions
+34 -4
View File
@@ -1402,9 +1402,10 @@ switch ($action) {
case 'flux':
require_once BASE_PATH . '/src/FeedFetcher.php';
$fetcher = new FeedFetcher(DATA_PATH . '/_cache/feeds');
$fluxItems = [];
$pdo = dbPdo();
$fetcher = new FeedFetcher(DATA_PATH . '/_cache/feeds');
$fluxItems = [];
$fluxErrors = [];
$pdo = dbPdo();
if ($pdo) {
try {
$st = $pdo->query(
@@ -1417,6 +1418,11 @@ switch ($action) {
foreach ($st->fetchAll(PDO::FETCH_ASSOC) as $_row) {
$data = $fetcher->get($_row['feed_url']);
if (!$data) {
$fluxErrors[] = [
'feed_url' => $_row['feed_url'],
'label' => $_row['label'],
'user_email' => $_row['user_email'],
];
continue;
}
$feedTitle = $_row['label'] !== '' ? $_row['label'] : $data['feed_title'];
@@ -2541,7 +2547,7 @@ switch ($action) {
'queued' => (int)($row['queued'] ?? 0),
];
$adminData['emails'] = $pdo->query(
"SELECT id, created_at, to_email, subject, status, error_message, content_text, sent_at
"SELECT id, created_at, to_email, subject, status, error_message, content_text, content_html, sent_at
FROM journal_smtp $whereEml
ORDER BY created_at DESC
LIMIT $emlLimit OFFSET $emlOffset"
@@ -2757,6 +2763,30 @@ switch ($action) {
header('Location: /admin/smtp');
exit;
case 'admin_email_preview':
requireAuth();
if (!isAdmin()) {
http_response_code(403);
exit;
}
$previewId = (int)($_GET['id'] ?? 0);
$pdo = dbPdo();
$emailRow = null;
if ($pdo && $previewId > 0) {
$st = $pdo->prepare('SELECT subject, content_html, content_text FROM journal_smtp WHERE id = :id');
$st->execute([':id' => $previewId]);
$emailRow = $st->fetch(PDO::FETCH_ASSOC) ?: null;
}
if (!$emailRow) {
http_response_code(404);
echo 'Email introuvable.';
exit;
}
header('Content-Type: text/html; charset=UTF-8');
$previewHtml = !empty($emailRow['content_html']) ? $emailRow['content_html'] : nl2br(htmlspecialchars((string)$emailRow['content_text']));
echo '<!doctype html><html lang="fr"><head><meta charset="utf-8"><title>' . htmlspecialchars((string)$emailRow['subject']) . '</title></head><body>' . $previewHtml . '</body></html>';
exit;
case 'admin_toggle_featured':
requireAuth();
if (!isAdmin() || $_SERVER['REQUEST_METHOD'] !== 'POST') {