mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
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`
66 lines
2.4 KiB
PHP
66 lines
2.4 KiB
PHP
<?php
|
|
/**
|
|
* Shared partial — "Fichiers" fieldset (add / student submission mode).
|
|
*
|
|
* Order per spec:
|
|
* 1. Image de couverture (optionnel)
|
|
* 2. Note d'intention (obligatoire)
|
|
* 3. TFE (obligatoire)
|
|
* 4. Annexes éventuelles (optionnel)
|
|
*
|
|
* Variables consumed:
|
|
* bool $adminMode — when true, no field is required (admin add/edit mode).
|
|
*/
|
|
$adminMode = $adminMode ?? false;
|
|
?>
|
|
<fieldset>
|
|
<legend>Fichiers</legend>
|
|
|
|
<?php
|
|
$name = 'couverture';
|
|
$label = 'Image de couverture (optionnel) :';
|
|
$accept = 'image/jpeg,image/png,image/webp';
|
|
$hint = 'JPG, PNG ou WEBP. Format 4:3 recommandé. Max 20 MB.';
|
|
include APP_ROOT . '/templates/partials/form/file-field.php';
|
|
?>
|
|
|
|
<?php
|
|
$name = 'note_intention';
|
|
$label = 'Note d\'intention :';
|
|
$accept ='.pdf';
|
|
$hint = 'Format PDF uniquement.';
|
|
$required = !$adminMode;
|
|
include APP_ROOT . '/templates/partials/form/file-field.php';
|
|
?>
|
|
|
|
<!-- TFE files — multi-file, with per-file labels -->
|
|
<div class="admin-form-group admin-files-fieldgroup">
|
|
<label>TFE (obligatoire) :</label>
|
|
<div class="admin-file-input">
|
|
<input type="file" id="tfe-files-input"
|
|
name="files[]" multiple
|
|
accept=".pdf,.jpg,.jpeg,.png,.gif,.webp,.mp4,.webm,.mov,.ogv,.mp3,.ogg,.oga,.wav,.flac,.aac,.m4a,.vtt"
|
|
class="tfe-file-picker">
|
|
<small class="admin-file-hint">
|
|
Types acceptés : PDF · JPG/PNG/GIF/WEBP · MP4/WebM/MOV (vidéo) · MP3/OGG/WAV/FLAC (audio) · ZIP/TAR (archives). Max 500 MB par fichier.
|
|
Les fichiers <code>.vtt</code> sont des sous-titres et seront associés automatiquement à la vidéo précédente.
|
|
</small>
|
|
|
|
<!-- File queue — populated by JS -->
|
|
<ul id="tfe-file-queue" class="tfe-file-queue" aria-label="Fichiers sélectionnés">
|
|
<!-- File queue rendered client-side by file-upload-queue.js -->
|
|
</ul>
|
|
<p id="tfe-file-queue-empty" class="tfe-queue-empty">Aucun fichier sélectionné.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$name = 'annexes';
|
|
$label = 'Annexes éventuelles (optionnel) :';
|
|
$accept = '.pdf,.zip,.tar,.gz';
|
|
$hint = 'PDF ou archives ZIP/TAR.';
|
|
$multiple = true;
|
|
include APP_ROOT . '/templates/partials/form/file-field.php';
|
|
?>
|
|
</fieldset>
|