mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Replace HTMX+PHP file upload queues with client-side JS
Drops the session-backed HTMX incremental upload system in favour of a single JS module that manages `File` objects client-side and injects them into `FormData` on submit. Key changes: * `file-upload-queue.js`: client-side queues with validation, reorder (SortableJS), removal, dirty-state tracking, and fetch-based submit with manual redirect handling * `fichiers-fragment.php`: empty queue containers for JS-managed queues; HTMX format switching still works with queue rehydration after swap; annexe uploads now support multiple files * Form UI cleanup: moved existing files and cover preview into the `Fichiers` fieldset (edit mode); removed redundant queue labels while keeping labels for single-file inputs (`couverture`, `note d'intention`); added delete buttons for existing files * `ThesisFileHandler.php`: added `handleTfeQueueFiles()`/`handleAnnexeQueueFiles()` reading from `$_FILES['queue_file']`; introduced `extractFilesSubArray()` for nested upload arrays; removed session-based queue handling * `ThesisCreateController.php` & `ThesisEditController.php`: switched to extracted `['queue_file']` uploads * `beforeunload-guard.js`: now also watches `window.__xamxamDirty` * Deleted obsolete PHP upload/remove/reorder queue endpoints for `partage` and `admin` * Cleaned up route dispatch in `partage/index.php` * Misc form and styling updates in templates/CSS * Added `docs/cms-migration-plan.html`
This commit is contained in:
@@ -197,14 +197,17 @@ class ThesisCreateController
|
||||
$this->handleCoverUpload($thesisId, $files['couverture'] ?? null, $folderPath, $filePrefix);
|
||||
$this->handleNoteIntentionUpload($thesisId, $files['note_intention'] ?? null, $folderPath, $filePrefix);
|
||||
|
||||
// TFE files come from session temp (incremental upload via HTMX)
|
||||
$sessionUploads = $_SESSION['tfe_uploads'] ?? [];
|
||||
$nextNum = $this->handleTfeFilesFromSession($thesisId, $sessionUploads, $folderPath, $filePrefix, 1);
|
||||
// Clear session uploads after successful commit
|
||||
$this->cleanupSessionUploads();
|
||||
// TFE files from client-side JS queue (FormData)
|
||||
$queueFiles = $files['queue_file'] ?? [];
|
||||
$qTfe = $this->extractFilesSubArray($queueFiles, 'tfe');
|
||||
$qVideo = $this->extractFilesSubArray($queueFiles, 'video');
|
||||
$qAudio = $this->extractFilesSubArray($queueFiles, 'audio');
|
||||
$qAnnexe = $this->extractFilesSubArray($queueFiles, 'annexe');
|
||||
|
||||
$this->handleAnnexeFiles($thesisId, $files['annexes'] ?? null, $folderPath, $filePrefix, $post);
|
||||
// PeerTube file rows don't go on disk, but the uploads themselves are processed separately
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qTfe, $folderPath, $filePrefix, 1);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qVideo, $folderPath, $filePrefix, $nextNum);
|
||||
$nextNum = $this->handleTfeQueueFiles($thesisId, $qAudio, $folderPath, $filePrefix, $nextNum);
|
||||
$this->handleAnnexeQueueFiles($thesisId, $qAnnexe, $folderPath, $filePrefix);
|
||||
|
||||
// ── 5b. PeerTube video / audio uploads ────────────────────────────────
|
||||
$this->handlePeerTubeUpload($thesisId, $data['titre'], $files, 'peertube_video');
|
||||
@@ -518,10 +521,14 @@ class ThesisCreateController
|
||||
$exemplaireErg = !empty($post['exemplaire_erg']);
|
||||
$cc2r = !empty($post['cc2r']);
|
||||
|
||||
// Annexes validation: if has_annexes is checked, at least one annexe file must be provided
|
||||
// Annexes validation: if has_annexes is checked, queue_file[annexe] must have at least one file
|
||||
$hasAnnexes = !empty($post['has_annexes']);
|
||||
if (!$adminMode && $hasAnnexes && empty($_FILES['annexes']['name'][0])) {
|
||||
throw new Exception('Veuillez fournir au moins un fichier d\'annexe.');
|
||||
if (!$adminMode && $hasAnnexes) {
|
||||
$queueAnnexes = $this->extractFilesSubArray($files['queue_file'] ?? [], 'annexe');
|
||||
$hasAnnexeFiles = is_array($queueAnnexes['name'] ?? null) && count(array_filter($queueAnnexes['name'])) > 0;
|
||||
if (!$hasAnnexeFiles) {
|
||||
throw new Exception('Veuillez fournir au moins un fichier d\'annexe.');
|
||||
}
|
||||
}
|
||||
|
||||
return compact(
|
||||
|
||||
Reference in New Issue
Block a user