This commit is contained in:
Esteban
2026-07-02 15:13:54 +02:00
parent a019dcb00d
commit 07bae3eff3
38 changed files with 2039 additions and 226 deletions
+21 -3
View File
@@ -10,7 +10,9 @@ function listeEcoles() {
global $dbh;
try {
$stmt = $dbh->prepare('SELECT id, title, status, tags, description, duration, image_url FROM schools ORDER BY id DESC');
// SELECT * : les colonnes markdown / link_url sont optionnelles (la page fonctionne
// même si la migration SQL n'a pas encore été exécutée)
$stmt = $dbh->prepare('SELECT * FROM schools ORDER BY id DESC');
$stmt->execute();
return $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
@@ -23,7 +25,7 @@ function recupererEcoleParId($id) {
global $dbh;
try {
$stmt = $dbh->prepare('SELECT id, title, status, tags, description, duration, image_url FROM schools WHERE id = :id');
$stmt = $dbh->prepare('SELECT * FROM schools WHERE id = :id');
$stmt->bindValue(':id', $id, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch(PDO::FETCH_ASSOC);
@@ -40,6 +42,9 @@ function afficherEcoleCard($ecole, $admin = false) {
$duration = htmlspecialchars($ecole['duration']);
$image = htmlspecialchars($ecole['image_url']);
$status = htmlspecialchars($ecole['status'] ?? '');
$markdown = trim($ecole['markdown'] ?? '');
$lien = trim($ecole['link_url'] ?? '');
$pdf = trim($ecole['pdf_filename'] ?? '');
$tags = [];
// S'il y a des tags alors on les sépares grâce à la virgule (tags1,tags2,etc...)
@@ -76,10 +81,23 @@ function afficherEcoleCard($ecole, $admin = false) {
echo '<p>' . $description . '</p>';
// Indicateur de page détaillée (uniquement sur la page publique) : markdown > PDF > lien externe > rien
if (!$admin) {
if ($markdown !== '') {
echo '<a class="card-link" href="./details.php?type=ecole&id=' . $id . '"><i class="fa-solid fa-file-lines"></i> Voir la page détaillée</a>';
} elseif ($pdf !== '') {
echo '<a class="card-link" href="./details.php?type=ecole&id=' . $id . '"><i class="fa-solid fa-file-pdf"></i> Voir le PDF</a>';
} elseif ($lien !== '') {
echo '<a class="card-link" href="' . $lien . '" target="_blank" rel="noopener noreferrer"><i class="fa-solid fa-arrow-up-right-from-square"></i> Voir le lien externe</a>';
} else {
echo '<span class="card-link card-link-none"><i class="fa-solid fa-eye-slash"></i> Pas de page détaillée</span>';
}
}
// Boutons de modification / suppression pour le panel admin
if ($admin) {
echo '<div class="admin-actions">';
echo '<a class="btn-submit btn-edit" href="./admin.php?edit_school=' . $id . '">Modifier</a>';
echo '<a class="btn-submit btn-edit" href="./admin.php?edit_school=' . $id . '#admin-ecoles">Modifier</a>';
echo '<a class="btn-submit btn-delete" href="../scripts/removeSchool.php?id=' . $id . '" onclick="return confirm(\'Voulez-vous vraiment supprimer cette école ?\');">Supprimer</a>';
echo '</div>';
}