mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-08-10 23:31:21 +02:00
Reintroduce TFE duration metadata: DB columns, form fields, controllers, views, and migration
Add 'unsafe-eval' to CSP script-src directives (htmx requires Function())
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||
require_once APP_ROOT . '/src/MarkdownHelper.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
@@ -29,9 +30,12 @@ class CharteController
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
|
||||
|
||||
$tocItems = MarkdownHelper::extractToc($content);
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
'html' => $html,
|
||||
'tocItems' => $tocItems,
|
||||
'pageTitle' => $pageTitle . ' – XAMXAM',
|
||||
'metaDescription' => "Charte d'utilisation de XAMXAM, le répertoire des TFE de l'erg.",
|
||||
'currentNav' => 'charte',
|
||||
@@ -39,4 +43,5 @@ class CharteController
|
||||
'bodyClass' => 'apropos-body',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
require_once APP_ROOT . '/src/Database.php';
|
||||
require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
require_once APP_ROOT . '/src/EmailObfuscator.php';
|
||||
require_once APP_ROOT . '/src/MarkdownHelper.php';
|
||||
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
@@ -29,9 +30,12 @@ class LicenceController
|
||||
$converter = new CommonMarkConverter(['html_input' => 'strip']);
|
||||
$html = EmailObfuscator::obfuscateHtml($converter->convert($content)->getContent());
|
||||
|
||||
$tocItems = MarkdownHelper::extractToc($content);
|
||||
|
||||
return [
|
||||
'content' => $content,
|
||||
'html' => $html,
|
||||
'tocItems' => $tocItems,
|
||||
'pageTitle' => $pageTitle . ' – XAMXAM',
|
||||
'metaDescription' => "Informations sur les licences d'utilisation des mémoires publiés sur XAMXAM, le répertoire des TFE de l'erg.",
|
||||
'currentNav' => 'licence',
|
||||
@@ -39,4 +43,5 @@ class LicenceController
|
||||
'bodyClass' => 'apropos-body',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -162,6 +162,8 @@ class ThesisCreateController
|
||||
'exemplaire_baiu' => $data['exemplaireBaiu'],
|
||||
'exemplaire_erg' => $data['exemplaireErg'],
|
||||
'cc2r' => $data['cc2r'],
|
||||
'duration_value' => $data['durationValue'],
|
||||
'duration_unit' => $data['durationUnit'],
|
||||
]);
|
||||
|
||||
$identifier = $this->db->getThesisIdentifier($thesisId);
|
||||
@@ -548,6 +550,22 @@ class ThesisCreateController
|
||||
$exemplaireErg = !empty($post['exemplaire_erg']);
|
||||
$cc2r = !empty($post['cc2r']);
|
||||
|
||||
// Duration: numeric value + unit (optional, admin-validated)
|
||||
$validDurationUnits = ['pages', 'minutes', 'sec', 'heures', 'mo'];
|
||||
$durationValue = $post['duration_value'] ?? null;
|
||||
$durationUnit = $post['duration_unit'] ?? 'pages';
|
||||
if ($durationValue !== null && $durationValue !== '') {
|
||||
$durationValue = filter_var($durationValue, FILTER_VALIDATE_FLOAT);
|
||||
if ($durationValue === false || $durationValue <= 0) {
|
||||
$durationValue = null; // ignore invalid
|
||||
}
|
||||
} else {
|
||||
$durationValue = null;
|
||||
}
|
||||
if (!in_array($durationUnit, $validDurationUnits, true)) {
|
||||
$durationUnit = 'pages';
|
||||
}
|
||||
|
||||
// Annexes are optional — no validation required
|
||||
$hasAnnexes = !empty($post['has_annexes']);
|
||||
|
||||
@@ -577,7 +595,9 @@ class ThesisCreateController
|
||||
'juryPoints',
|
||||
'exemplaireBaiu',
|
||||
'exemplaireErg',
|
||||
'cc2r'
|
||||
'cc2r',
|
||||
'durationValue',
|
||||
'durationUnit'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,8 @@ class ThesisEditController
|
||||
$currentAccessTypeId = $rawRow['access_type_id'] ?? null;
|
||||
$currentContextNote = $rawRow['context_note'] ?? '';
|
||||
$currentContactVisible = $rawRow['contact_visible'] ?? '';
|
||||
$currentDurationValue = $rawRow['duration_value'] ?? null;
|
||||
$currentDurationUnit = $rawRow['duration_unit'] ?? 'pages';
|
||||
|
||||
// Author contact info (from view)
|
||||
$contactInterne = $thesis['contact_interne'] ?? '';
|
||||
@@ -132,6 +134,8 @@ class ThesisEditController
|
||||
'currentAccessTypeId' => $currentAccessTypeId,
|
||||
'currentContextNote' => $currentContextNote,
|
||||
'currentContactVisible' => $currentContactVisible,
|
||||
'currentDurationValue' => $currentDurationValue,
|
||||
'currentDurationUnit' => $currentDurationUnit,
|
||||
'contactInterne' => $contactInterne,
|
||||
'contactPublic' => $contactPublic,
|
||||
'currentRaw' => $rawRow,
|
||||
@@ -219,6 +223,8 @@ class ThesisEditController
|
||||
'exemplaire_erg' => !empty($post['exemplaire_erg']),
|
||||
'cc2r' => !empty($post['cc2r']),
|
||||
'license_custom' => trim($post['license_custom'] ?? ''),
|
||||
'duration_value' => isset($post['duration_value']) && $post['duration_value'] !== '' ? (float)$post['duration_value'] : null,
|
||||
'duration_unit' => !empty($post['duration_unit']) ? $post['duration_unit'] : 'pages',
|
||||
];
|
||||
// Regenerate identifier if year changed or if identifier prefix doesn't match year
|
||||
$oldThesis = $this->db->getThesis($thesisId);
|
||||
|
||||
Reference in New Issue
Block a user