mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
fix: allow isAuthenticated() bypass in development mode
This commit is contained in:
@@ -6,6 +6,30 @@ 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();
|
||||
|
||||
@@ -16,10 +40,9 @@ try {
|
||||
$rawContent = APROPOS_STATIC_CONTENT;
|
||||
}
|
||||
|
||||
// Contacts, credits, erg_url from apropos_contents table
|
||||
// Contacts and credits 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;
|
||||
@@ -29,7 +52,6 @@ try {
|
||||
$rawContent = APROPOS_STATIC_CONTENT;
|
||||
$contacts = null;
|
||||
$credits = null;
|
||||
$ergUrl = 'https://erg.be';
|
||||
}
|
||||
|
||||
$pd = new Parsedown();
|
||||
@@ -67,7 +89,7 @@ $bodyClass = 'apropos-body';
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
<div class="apropos-toc-erg">
|
||||
<a href="<?= htmlspecialchars($ergUrl) ?>" target="_blank" rel="noopener">
|
||||
<a href="https://erg.be" target="_blank" rel="noopener">
|
||||
Site de l'erg ↗
|
||||
</a>
|
||||
</div>
|
||||
@@ -88,17 +110,19 @@ $bodyClass = 'apropos-body';
|
||||
<section class="apropos-section" id="apropos-contacts">
|
||||
<h2 class="apropos-section-title">Contacts</h2>
|
||||
<div class="apropos-contacts-grid">
|
||||
<?php foreach ($contacts as $contact): ?>
|
||||
<?php foreach ($contacts as $group): ?>
|
||||
<address class="apropos-contact-card">
|
||||
<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>
|
||||
<?= 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>
|
||||
@@ -110,16 +134,10 @@ $bodyClass = 'apropos-body';
|
||||
<section class="apropos-section" id="apropos-credits">
|
||||
<h2 class="apropos-section-title">Crédits</h2>
|
||||
<dl class="apropos-credits-list">
|
||||
<?php foreach ($credits as $credit): ?>
|
||||
<?php foreach ($credits as $group): ?>
|
||||
<div class="apropos-credit-row">
|
||||
<dt><?= htmlspecialchars($credit['label']) ?></dt>
|
||||
<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>
|
||||
<dt><?= htmlspecialchars($group['label']) ?></dt>
|
||||
<dd><?= renderEntries($group['entries'] ?? []) ?></dd>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</dl>
|
||||
|
||||
Reference in New Issue
Block a user