mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
migrate apropos data from config/apropos.php to SQLite
- Create apropos_contents table via migration 010 - Add Database methods: getAproposContent(), saveAproposContent(), getAllAproposContents() - Replace admin/pages.php with admin/contenus.php (renamed header from 'Pages statiques' to 'Contenus') - Replace admin/pages-edit.php with admin/contenus-edit.php (support editing pages + apropos contents) - Create admin/actions/apropos.php for saving apropos data (contacts, credits, erg_url) - Update public/apropos.php to read contacts/credits/erg_url from DB - Delete config/apropos.php
This commit is contained in:
@@ -3,29 +3,39 @@ require_once __DIR__ . '/../config/bootstrap.php';
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
|
||||
$apropos = require APP_ROOT . '/config/apropos.php';
|
||||
|
||||
$currentNav = 'apropos';
|
||||
|
||||
// Fallback static content used when DB content is the placeholder
|
||||
define('APROPOS_STATIC_CONTENT', "Ce site POSTERG a été créé pour répertorier et valoriser les mémoires de l'erg – École de Recherches Graphique de Bruxelles.\n\nL'objectif est à la fois d'offrir une vitrine aux projets des anciens étudiantes et de mettre en lumière la diversité des disciplines et des parcours qui façonnent l'histoire de l'école à travers les âges, depuis près de 100 ans.");
|
||||
define('APROPOS_STATIC_CONTENT', "Ce site POSTERG a été créé pour répertorier et valoriser les mémoires de l'erg – École de Recherches Graphique de Bruxelles.\n\nL'objectif est à la fois d'offrir une vitrine aux projets des anciennes étudiantes et de mettre en lumière la diversité des disciplines et des parcours qui façonnent l'histoire de l'école à travers les âges, depuis près de 100 ans.");
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
|
||||
// Intro text from pages table
|
||||
$aboutPage = $db->getPage('about');
|
||||
$rawContent = $aboutPage ? $aboutPage['content'] : '';
|
||||
// Use static fallback if content is placeholder
|
||||
if (empty(trim($rawContent)) || trim($rawContent) === 'Contenu à venir') {
|
||||
$rawContent = APROPOS_STATIC_CONTENT;
|
||||
}
|
||||
|
||||
// Contacts, credits, erg_url from apropos_contents table
|
||||
$contacts = $db->getAproposContent('contacts');
|
||||
$credits = $db->getAproposContent('credits');
|
||||
$ergUrl = $db->getAproposContent('erg_url') ?: 'https://erg.be';
|
||||
|
||||
// Apply defaults if DB returns empty
|
||||
$contacts = is_array($contacts) && !empty($contacts) ? $contacts : null;
|
||||
$credits = is_array($credits) && !empty($credits) ? $credits : null;
|
||||
} catch (Exception $e) {
|
||||
error_log("Error loading about page: " . $e->getMessage());
|
||||
$rawContent = APROPOS_STATIC_CONTENT;
|
||||
$contacts = null;
|
||||
$credits = null;
|
||||
$ergUrl = 'https://erg.be';
|
||||
}
|
||||
|
||||
$pd = new Parsedown();
|
||||
$pd->setSafeMode(true);
|
||||
$aboutHtml = $pd->text($rawContent);
|
||||
|
||||
$pageTitle = 'À Propos – Posterg';
|
||||
$metaDescription = 'À propos de Posterg, le répertoire des mémoires de fin d\'études de l\'erg – École de Recherches Graphiques de Bruxelles.';
|
||||
$ogTags = [
|
||||
@@ -49,15 +59,15 @@ $bodyClass = 'apropos-body';
|
||||
<p class="apropos-toc-label">Parties</p>
|
||||
<ul>
|
||||
<li><a href="#apropos-intro">À propos</a></li>
|
||||
<?php if (!empty($apropos['contacts'])): ?>
|
||||
<?php if (!empty($contacts)): ?>
|
||||
<li><a href="#apropos-contacts">Contacts</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($apropos['credits'])): ?>
|
||||
<?php if (!empty($credits)): ?>
|
||||
<li><a href="#apropos-credits">Crédits</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<div class="apropos-toc-erg">
|
||||
<a href="<?= htmlspecialchars($apropos['erg_url']) ?>" target="_blank" rel="noopener">
|
||||
<a href="<?= htmlspecialchars($ergUrl) ?>" target="_blank" rel="noopener">
|
||||
Site de l'erg ↗
|
||||
</a>
|
||||
</div>
|
||||
@@ -73,14 +83,20 @@ $bodyClass = 'apropos-body';
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if (!empty($apropos['contacts'])): ?>
|
||||
<?php if (!empty($contacts)): ?>
|
||||
<!-- Contacts section -->
|
||||
<section class="apropos-section" id="apropos-contacts">
|
||||
<h2 class="apropos-section-title">Contacts</h2>
|
||||
<div class="apropos-contacts-grid">
|
||||
<?php foreach ($apropos['contacts'] as $contact): ?>
|
||||
<?php foreach ($contacts as $contact): ?>
|
||||
<address class="apropos-contact-card">
|
||||
<strong><?= htmlspecialchars($contact['name']) ?></strong>
|
||||
<strong>
|
||||
<?php if (!empty($contact['url'])): ?>
|
||||
<a href="<?= htmlspecialchars($contact['url']) ?>" target="_blank" rel="noopener"><?= htmlspecialchars($contact['name']) ?></a>
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars($contact['name']) ?>
|
||||
<?php endif; ?>
|
||||
</strong>
|
||||
<span><?= htmlspecialchars($contact['role']) ?></span>
|
||||
<a href="mailto:<?= htmlspecialchars($contact['email']) ?>"><?= htmlspecialchars($contact['email']) ?></a>
|
||||
</address>
|
||||
@@ -89,15 +105,21 @@ $bodyClass = 'apropos-body';
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($apropos['credits'])): ?>
|
||||
<?php if (!empty($credits)): ?>
|
||||
<!-- Credits section -->
|
||||
<section class="apropos-section" id="apropos-credits">
|
||||
<h2 class="apropos-section-title">Crédits</h2>
|
||||
<dl class="apropos-credits-list">
|
||||
<?php foreach ($apropos['credits'] as $credit): ?>
|
||||
<?php foreach ($credits as $credit): ?>
|
||||
<div class="apropos-credit-row">
|
||||
<dt><?= htmlspecialchars($credit['label']) ?></dt>
|
||||
<dd><?= htmlspecialchars($credit['value']) ?></dd>
|
||||
<dd>
|
||||
<?php if (!empty($credit['url'])): ?>
|
||||
<a href="<?= htmlspecialchars($credit['url']) ?>" target="_blank" rel="noopener"><?= htmlspecialchars($credit['value']) ?></a>
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars($credit['value']) ?>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user