Add Charte static page (public + admin editing)

This commit is contained in:
Pontoporeia
2026-06-09 19:43:09 +02:00
parent 317547ac93
commit 4a2b000fca
10 changed files with 405 additions and 30 deletions

View File

@@ -0,0 +1,42 @@
<?php
require_once APP_ROOT . '/src/Database.php';
require_once APP_ROOT . '/src/ErrorHandler.php';
require_once APP_ROOT . '/src/EmailObfuscator.php';
use League\CommonMark\CommonMarkConverter;
class CharteController
{
public static function create(): self
{
return new self();
}
public function handle(): array
{
try {
$db = Database::getInstance();
$dbPage = $db->getPage('charte');
$content = $dbPage ? $dbPage['content'] : '';
$pageTitle = $dbPage ? $dbPage['title'] : 'Charte';
} catch (Exception $e) {
ErrorHandler::log('charte_page', $e);
$content = '';
$pageTitle = 'Charte';
}
$converter = new CommonMarkConverter(['html_input' => 'strip']);
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
return [
'content' => $content,
'html' => $html,
'pageTitle' => $pageTitle . ' XAMXAM',
'metaDescription' => "Charte d'utilisation de XAMXAM, le répertoire des TFE de l'erg.",
'currentNav' => 'charte',
'extraCss' => ['/assets/css/apropos.css'],
'bodyClass' => 'apropos-body',
];
}
}

View File

@@ -13,6 +13,7 @@
* /tfe/<id> → TfeController → tfe view
* /apropos → AboutController → about view
* /licence → LicenceController → licence view
* /charte → CharteController → charte view
* /media.php → MediaController (direct output)
* /live-reload → LiveReloadController (direct output)
* /partage/<slug> → share-link flow
@@ -34,6 +35,8 @@ class Dispatcher
'/apropos.php' => ['controller' => 'AboutController', 'action' => 'handle', 'view' => 'public/about'],
'/licence' => ['controller' => 'LicenceController', 'action' => 'handle', 'view' => 'public/licence'],
'/licence.php' => ['controller' => 'LicenceController', 'action' => 'handle', 'view' => 'public/licence'],
'/charte' => ['controller' => 'CharteController', 'action' => 'handle', 'view' => 'public/charte'],
'/charte.php' => ['controller' => 'CharteController', 'action' => 'handle', 'view' => 'public/charte'],
];
private string $path;