mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
- DB migration 007: add sort_order + display_label to thesis_files - Database: getThesisFiles ordered by sort_order; insertThesisFile accepts label/order; new reorderThesisFiles() and updateThesisFileLabel() methods - ThesisCreateController + ThesisEditController: expand allowed MIME/exts to include audio (mp3/ogg/wav/flac/aac/m4a), video (webm/mov/ogv), image (gif/webp), archives (tar/gz), any-ext via octet-stream; max size raised to 500 MB; accept file_labels[] and file_orders[] POST fields; detectFileType() helper - MediaController: expanded MIME allowlist; HTTP Range support for audio/video; force-download for unknown types; inline for known displayable types - fieldset-files.php: sortable queue UI with SortableJS, per-file labels, 500 MB hint - templates/admin/edit.php: existing files as sortable list with drag handles, type icons, label inputs, delete checkboxes, hidden sort-order fields - file-upload-queue.js: new JS replacing file-preview.js — sortable new-file queue, per-file labels, hidden order fields on submit, backward-compat legacy preview - tfe.php: renders audio (<audio>), all video formats, images, PDF, and download-only 'other' files; reads display_label; sorted by sort_order - tfe.css + form.css: styles for audio player, download files, sortable queue, drag handles, file type badges, label inputs - .htaccess + .user.ini: upload_max_filesize=512M / post_max_size=520M
54 lines
1.6 KiB
PHP
54 lines
1.6 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/sortable.min.js', '/assets/js/file-upload-queue.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';
|