mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: extract MediaController, wire into Dispatcher, delete media.php
This commit is contained in:
152
app/public/apropos.php
Normal file
152
app/public/apropos.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../bootstrap.php';
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
|
||||
$currentNav = 'apropos';
|
||||
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.");
|
||||
|
||||
/**
|
||||
* Render a comma-separated list of entries with links.
|
||||
* Entries joined with comma, last two joined with " & ".
|
||||
*/
|
||||
function renderEntries(array $entries): string {
|
||||
if (empty($entries)) return '';
|
||||
$parts = [];
|
||||
foreach ($entries as $e) {
|
||||
$text = htmlspecialchars($e['text'] ?? '');
|
||||
$url = $e['url'] ?? '';
|
||||
if (!empty($url)) {
|
||||
$parts[] = '<span class="apropos-entry"><a href="' . htmlspecialchars($url) . '" target="_blank" rel="noopener">' . $text . '</a></span>';
|
||||
} else {
|
||||
$parts[] = '<span class="apropos-entry">' . $text . '</span>';
|
||||
}
|
||||
}
|
||||
$count = count($parts);
|
||||
if ($count === 1) return $parts[0];
|
||||
// Join all but last two with ", ", join last two with " & "
|
||||
$prefix = implode(', ', array_slice($parts, 0, $count - 2));
|
||||
$suffix = implode(' & ', array_slice($parts, -2));
|
||||
return $prefix !== '' ? $prefix . ', ' . $suffix : $suffix;
|
||||
}
|
||||
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
|
||||
// Intro text from pages table
|
||||
$aboutPage = $db->getPage('about');
|
||||
$rawContent = $aboutPage ? $aboutPage['content'] : '';
|
||||
if (empty(trim($rawContent)) || trim($rawContent) === 'Contenu à venir') {
|
||||
$rawContent = APROPOS_STATIC_CONTENT;
|
||||
}
|
||||
|
||||
// Contacts and credits from apropos_contents table
|
||||
$contacts = $db->getAproposContent('contacts');
|
||||
$credits = $db->getAproposContent('credits');
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
$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 = [
|
||||
'type' => 'website',
|
||||
'title' => $pageTitle,
|
||||
'description' => $metaDescription,
|
||||
'url' => 'https://posterg.erg.be/apropos.php',
|
||||
'site_name' => 'Posterg – ERG',
|
||||
];
|
||||
$extraCss = ['/assets/css/apropos.css'];
|
||||
$bodyClass = 'apropos-body';
|
||||
?>
|
||||
<?php include APP_ROOT . '/templates/head.php'; ?>
|
||||
<?php include APP_ROOT . '/templates/header.php'; ?>
|
||||
|
||||
<main class="apropos-main" id="main-content">
|
||||
<div class="apropos-layout">
|
||||
|
||||
<!-- LEFT: sticky table of contents -->
|
||||
<nav class="apropos-toc" aria-label="Sections de la page">
|
||||
<p class="apropos-toc-label">Parties</p>
|
||||
<ul>
|
||||
<li><a href="#apropos-intro">À propos</a></li>
|
||||
<?php if (!empty($contacts)): ?>
|
||||
<li><a href="#apropos-contacts">Contacts</a></li>
|
||||
<?php endif; ?>
|
||||
<?php if (!empty($credits)): ?>
|
||||
<li><a href="#apropos-credits">Crédits</a></li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<div class="apropos-toc-erg">
|
||||
<a href="https://erg.be" target="_blank" rel="noopener">
|
||||
Site de l'erg ↗
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- MIDDLE: main prose + sections -->
|
||||
<div class="apropos-content">
|
||||
|
||||
<!-- Intro text from DB -->
|
||||
<section class="apropos-section" id="apropos-intro">
|
||||
<div class="prose">
|
||||
<?= $aboutHtml ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?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 ($contacts as $group): ?>
|
||||
<address class="apropos-contact-card">
|
||||
<?= renderEntries($group['entries'] ?? []) ?>
|
||||
<?php if (!empty($group['role'])): ?>
|
||||
<span><?= htmlspecialchars($group['role']) ?></span>
|
||||
<?php endif; ?>
|
||||
<?php
|
||||
// Show the email from the first entry (or any that has one on separate line)
|
||||
$emails = array_filter(array_column($group['entries'] ?? [], 'email'), fn($e) => !empty($e));
|
||||
foreach ($emails as $email):
|
||||
?>
|
||||
<a href="mailto:<?= htmlspecialchars($email) ?>"><?= htmlspecialchars($email) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</address>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?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 ($credits as $group): ?>
|
||||
<div class="apropos-credit-row">
|
||||
<dt><?= htmlspecialchars($group['label']) ?></dt>
|
||||
<dd><?= renderEntries($group['entries'] ?? []) ?></dd>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<?php include APP_ROOT . '/templates/footer.php'; ?>
|
||||
Reference in New Issue
Block a user