mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
- Live file preview on all file inputs (file-field partial, edit template): thumbnails for images, emoji icons for PDF/video/zip/vtt, filename + size - New file-preview.js wired via $extraJs in add.php / edit.php and direct <script> in partage/index.php; $extraJs support added to head.php - admin/recapitulatif.php: replace plain table with rich file list — image thumbnails linked to media.php, type badges, human-readable size, date - partage/recapitulatif.php: full rewrite — shows thesis metadata + files list with same rich display (no media links for student privacy) - form.css: new sections for .file-preview-list (live preview) and .recap-file-list / .recap-dl / .partage-recap (recap pages)
54 lines
1.5 KiB
PHP
54 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';
|
|
$extraCss = ['/assets/css/form.css'];
|
|
$extraJs = ['/assets/js/file-preview.js'];
|
|
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';
|