mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add Charte static page (public + admin editing)
This commit is contained in:
42
app/src/Controllers/CharteController.php
Normal file
42
app/src/Controllers/CharteController.php
Normal 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',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user