mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
All admin pages refactored to thin controllers + pure view templates, mirroring the public-page pattern: Controllers (public/admin/*.php): auth, data loading, include template Views (templates/admin/*.php): pure HTML/PHP output Fragment partials (templates/admin/partials/): toast, system-log-panel, system-nginx-config-panel Pages migrated: login, tags, contenus, contenus-edit, account, acces-etudiante, thanks, add, edit, parametres, system, index Fragment endpoints refactored: system-fragment.php, toast-fragment.php Skipped (pure redirects): logout, logs, status, import
52 lines
1.5 KiB
PHP
52 lines
1.5 KiB
PHP
<?php
|
|
require_once __DIR__ . "/../../bootstrap.php";
|
|
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
AdminAuth::requireLogin();
|
|
|
|
if (empty($_SESSION["csrf_token"])) {
|
|
$_SESSION["csrf_token"] = bin2hex(random_bytes(32));
|
|
}
|
|
|
|
$pageTitle = "Ajouter un TFE";
|
|
|
|
require_once __DIR__ . '/../../src/Controllers/ThesisCreateController.php';
|
|
|
|
try {
|
|
$ctrl = ThesisCreateController::make();
|
|
extract($ctrl->loadFormData());
|
|
} catch (Exception $e) {
|
|
error_log('Failed to load form data: ' . $e->getMessage());
|
|
die('Erreur lors du chargement du formulaire.');
|
|
}
|
|
|
|
$formData = $_SESSION['form_data'] ?? [];
|
|
unset($_SESSION['form_data']);
|
|
$autofocusField = App::consumeAutofocus();
|
|
|
|
function withAutofocus(string $fieldName, array $attrs = []): array {
|
|
global $autofocusField;
|
|
if ($autofocusField === $fieldName) {
|
|
$attrs['autofocus'] = true;
|
|
}
|
|
return $attrs;
|
|
}
|
|
|
|
function old($key, $default = "") {
|
|
global $formData;
|
|
return isset($formData[$key]) ? htmlspecialchars($formData[$key]) : $default;
|
|
}
|
|
|
|
function wasSelected($key, $value) {
|
|
global $formData;
|
|
if (!isset($formData[$key])) return false;
|
|
if (is_array($formData[$key])) return in_array($value, $formData[$key]);
|
|
return $formData[$key] == $value;
|
|
}
|
|
|
|
$isAdmin = true;
|
|
$bodyClass = 'admin-body';
|
|
require_once APP_ROOT . '/templates/head.php';
|
|
include APP_ROOT . '/templates/header.php';
|
|
include APP_ROOT . '/templates/admin/add.php';
|
|
require_once APP_ROOT . '/templates/admin/footer.php';
|