mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
Add Charte static page (public + admin editing)
This commit is contained in:
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user