edit.php: rework Fichiers fieldset layout

- Drop file-field.php partial for cover/banner (it added a second label)
- Inline all three file inputs with admin-file-input wrapper
- Move banner inside the Fichiers fieldset
- Each entry: one label, one input, one small hint — no duplicate labels
- Context-aware hints: 'Laisser vide pour conserver...' when file already exists
This commit is contained in:
Pontoporeia
2026-04-27 20:38:45 +02:00
parent 8e864fc624
commit 4d88bd8cc5
2 changed files with 33 additions and 25 deletions

View File

@@ -7,6 +7,7 @@
- [x] Add `deleteThesisFile()` and `handleCoverUpload()` to Database.php
- [x] Update `ThesisEditController::save()` to handle cover, file deletion, new uploads
- [x] Update `ThesisEditController::load()` to expose `currentFiles` + `currentCover`
- [x] Rework Fichiers fieldset layout: inline file inputs (no partial double-label), banner moved inside fieldset, one label per field
## Overview

View File

@@ -100,9 +100,9 @@
<legend>Fichiers</legend>
<!-- Cover image -->
<div>
<div class="admin-form-group">
<label>Image de couverture :</label>
<div>
<div class="admin-file-input">
<?php if (!empty($currentCover)): ?>
<div class="admin-banner-preview">
<img src="/media.php?path=<?= urlencode($currentCover['file_path']) ?>"
@@ -112,17 +112,16 @@
</label>
</div>
<?php endif; ?>
<?php $name = 'couverture'; $label = empty($currentCover) ? 'Image de couverture :' : 'Remplacer la couverture :'; $accept = 'image/jpeg,image/png'; $hint = 'JPG, PNG. Max 10 MB.'; include APP_ROOT . '/templates/partials/form/file-field.php'; ?>
<input type="file" id="couverture" name="couverture" accept="image/jpeg,image/png">
<small><?= empty($currentCover) ? 'JPG, PNG. Max 10 MB.' : 'Laisser vide pour conserver la couverture actuelle. JPG, PNG. Max 10 MB.' ?></small>
</div>
</div>
<!-- Existing thesis files -->
<?php
$thesisFilesList = array_filter($currentFiles, fn($f) => $f['file_type'] !== 'cover');
?>
<?php $thesisFilesList = array_filter($currentFiles, fn($f) => $f['file_type'] !== 'cover'); ?>
<?php if (!empty($thesisFilesList)): ?>
<div class="admin-form-group">
<label>Fichiers existants :</label>
<label>Fichiers du TFE existants :</label>
<ul class="admin-file-list">
<?php foreach ($thesisFilesList as $f): ?>
<li class="admin-file-list-item">
@@ -146,13 +145,19 @@
<?php endif; ?>
<!-- New thesis files -->
<?php $name = 'files'; $label = 'Ajouter des fichiers :'; $accept = '.pdf,.jpg,.jpeg,.png,.mp4,.zip,.vtt'; $hint = 'PDF, JPG, PNG, MP4, ZIP. Max 50 MB par fichier. Pour les vidéos, un fichier .vtt peut être joint.'; $multiple = true; include APP_ROOT . '/templates/partials/form/file-field.php'; ?>
</fieldset>
<div class="admin-form-group">
<label for="files">Ajouter des fichiers du TFE :</label>
<div class="admin-file-input">
<input type="file" id="files" name="files[]" multiple
accept=".pdf,.jpg,.jpeg,.png,.mp4,.zip,.vtt">
<small>PDF, JPG, PNG, MP4, ZIP. Max 50 MB par fichier. Pour les vidéos, un fichier .vtt de sous-titres peut être joint.</small>
</div>
</div>
<!-- Image bannière (custom: includes current banner preview + remove checkbox) -->
<div>
<!-- Banner image -->
<div class="admin-form-group">
<label>Image bannière (accueil) :</label>
<div>
<div class="admin-file-input">
<?php if (!empty($thesis['banner_path'])): ?>
<div class="admin-banner-preview">
<img src="/media.php?path=<?= urlencode($thesis['banner_path']) ?>"
@@ -163,10 +168,12 @@
</div>
<?php endif; ?>
<input type="file" name="banner" accept="image/jpeg,image/png,image/webp">
<small>JPG, PNG ou WEBP. Format paysage recommandé (4:1). Max 5 MB.</small>
<small><?= empty($thesis['banner_path']) ? 'JPG, PNG ou WEBP. Format paysage recommandé (4:1). Max 5 MB.' : 'Laisser vide pour conserver la bannière actuelle. JPG, PNG ou WEBP. Format paysage recommandé (4:1). Max 5 MB.' ?></small>
</div>
</div>
</fieldset>
<!-- Publication toggle -->
<div>
<label>Publication :</label>