47 lines
1.7 KiB
PHP
47 lines
1.7 KiB
PHP
<?php
|
|
require_once BASE_PATH . '/src/Parsedown.php';
|
|
$Parsedown = new Parsedown();
|
|
|
|
ob_start();
|
|
?>
|
|
|
|
<h1 class="mb-4 text-center">📝 Tous les posts</h1>
|
|
|
|
<div class="row row-cols-1 row-cols-md-2 g-4">
|
|
<?php foreach ($posts as $post): ?>
|
|
<div class="col">
|
|
<div class="card shadow-sm h-100 border-<?php echo $post['is_published'] ? 'primary' : 'warning'; ?>">
|
|
<div class="card-body d-flex flex-column">
|
|
<h5 class="card-title text-primary">
|
|
<?= htmlspecialchars($post['title']) ?>
|
|
<?php if (!$post['is_published']): ?>
|
|
<span class="badge bg-warning text-dark ms-2">⏳ Brouillon</span>
|
|
<?php endif; ?>
|
|
</h5>
|
|
|
|
<div class="card-text text-body">
|
|
<?php
|
|
$html = $Parsedown->text($post['content']);
|
|
$preview = mb_strimwidth(strip_tags($html), 0, 300, '…');
|
|
echo '<p>' . $preview . '</p>';
|
|
?>
|
|
</div>
|
|
|
|
<p class="text-muted small mt-auto mb-2">📅 Publié le <?= date('d/m/Y', strtotime($post['created_at'])) ?></p>
|
|
|
|
<div class="d-flex justify-content-end gap-2">
|
|
<a href="route.php?action=view&id=<?= $post['id'] ?>" class="btn btn-sm btn-outline-primary">🔍 Voir</a>
|
|
<a href="route.php?action=edit&id=<?= $post['id'] ?>" class="btn btn-sm btn-outline-secondary">✏️ Modifier</a>
|
|
</div>
|
|
<a href="route.php?action=view&id=<?= $post['id'] ?>" class="stretched-link"></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php
|
|
$content = ob_get_clean();
|
|
$title = 'Liste des posts';
|
|
include __DIR__ . '/layout.php';
|