mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Phase 1: Replace Parsedown with league/commonmark (4 call sites)
This commit is contained in:
@@ -12,6 +12,8 @@ require_once __DIR__ . '/../../src/AdminAuth.php';
|
||||
AdminAuth::requireLogin();
|
||||
require_once __DIR__ . '/../../src/Database.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
@@ -91,10 +93,8 @@ function renderCollapsed(Database $db, string $key): void
|
||||
|
||||
$mdHtml = '';
|
||||
if ($hasContent) {
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
$pd = new Parsedown();
|
||||
$pd->setSafeMode(true);
|
||||
$mdHtml = $pd->text($content);
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
$mdHtml = $converter->convert($content)->getContent();
|
||||
}
|
||||
?>
|
||||
<div class="fhb-inline <?= $enabled ? '' : 'fhb-inline--disabled' ?>" data-key="<?= htmlspecialchars($key) ?>">
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class AboutController
|
||||
{
|
||||
private string $defaultContent = "Ce site XAMXAM a été créé pour répertorier et valoriser les mémoires de l'erg – École de Recherches Graphiques 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.";
|
||||
@@ -31,12 +32,11 @@ class AboutController
|
||||
$contacts = null;
|
||||
}
|
||||
|
||||
$pd = new Parsedown();
|
||||
$pd->setSafeMode(true);
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
|
||||
return [
|
||||
'currentNav' => 'apropos',
|
||||
'aboutHtml' => EmailObfuscator::obfuscateHtml($pd->text($rawContent)),
|
||||
'aboutHtml' => EmailObfuscator::obfuscateHtml($converter->convert($rawContent)->getContent()),
|
||||
'contacts' => $contacts,
|
||||
'pageTitle' => 'À Propos – XAMXAM',
|
||||
'metaDescription' => "À propos de XAMXAM, le répertoire des mémoires de fin d'études de l'erg – École de Recherches Graphiques de Bruxelles.",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
class LicenceController
|
||||
{
|
||||
public static function create(): self
|
||||
@@ -25,9 +26,8 @@ class LicenceController
|
||||
$pageTitle = 'Licences';
|
||||
}
|
||||
|
||||
$pd = new Parsedown();
|
||||
$pd->setSafeMode(true);
|
||||
$html = EmailObfuscator::obfuscateHtml($pd->text($content));
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"2":1779229816,"3":1779229853}
|
||||
[1779231711]
|
||||
@@ -7,7 +7,6 @@
|
||||
* string $helpKey — block key, used as element id.
|
||||
*
|
||||
* Outputs nothing when $helpContent is empty or whitespace-only.
|
||||
* Parsedown must already be autoloaded (it is, via bootstrap → APP_ROOT/src/).
|
||||
*/
|
||||
|
||||
$helpContent = trim($helpContent ?? '');
|
||||
@@ -15,13 +14,11 @@ if ($helpContent === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once APP_ROOT . '/src/Parsedown.php';
|
||||
$pd = new Parsedown();
|
||||
$pd->setSafeMode(true);
|
||||
$html = $pd->text($helpContent);
|
||||
$converter = new League\CommonMark\CommonMarkConverter(['html_input' => 'strip']);
|
||||
$html = $converter->convert($helpContent)->getContent();
|
||||
?>
|
||||
<div class="student-help-block" id="help-<?= htmlspecialchars($helpKey ?? 'unknown') ?>">
|
||||
<?= $html ?>
|
||||
</div>
|
||||
<?php
|
||||
unset($helpContent, $pd, $html);
|
||||
unset($helpContent, $converter, $html);
|
||||
|
||||
Reference in New Issue
Block a user