mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
admin edit.php: add cover image + thesis file management fields
- Database: add deleteThesisFile() and handleCoverUpload() methods - ThesisEditController::load(): expose currentFiles + currentCover to view - ThesisEditController::save(): handle couverture upload/removal, per-file deletion (delete_files[]), and new thesis file uploads - edit.php template: new Fichiers fieldset with cover preview+remove, existing files list with delete checkboxes, new file upload input (mirrors add.php / partage.php)
This commit is contained in:
@@ -95,6 +95,60 @@
|
||||
|
||||
<?php $name = 'lien'; $label = 'Lien externe :'; $value = htmlspecialchars($thesis['baiu_link'] ?? ''); $type = 'url'; include APP_ROOT . '/templates/partials/form/text-field.php'; ?>
|
||||
|
||||
<!-- Fichiers -->
|
||||
<fieldset>
|
||||
<legend>Fichiers</legend>
|
||||
|
||||
<!-- Cover image -->
|
||||
<div>
|
||||
<label>Image de couverture :</label>
|
||||
<div>
|
||||
<?php if (!empty($currentCover)): ?>
|
||||
<div class="admin-banner-preview">
|
||||
<img src="/media.php?path=<?= urlencode($currentCover['file_path']) ?>"
|
||||
alt="Couverture actuelle" style="max-height:180px;">
|
||||
<label class="admin-checkbox-label">
|
||||
<input type="checkbox" name="remove_cover" value="1"> Supprimer la couverture
|
||||
</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'; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Existing thesis files -->
|
||||
<?php
|
||||
$thesisFilesList = array_filter($currentFiles, fn($f) => $f['file_type'] !== 'cover');
|
||||
?>
|
||||
<?php if (!empty($thesisFilesList)): ?>
|
||||
<div class="admin-form-group">
|
||||
<label>Fichiers existants :</label>
|
||||
<ul class="admin-file-list">
|
||||
<?php foreach ($thesisFilesList as $f): ?>
|
||||
<li class="admin-file-list-item">
|
||||
<span class="admin-file-info">
|
||||
<span class="admin-file-type">[<?= htmlspecialchars($f['file_type']) ?>]</span>
|
||||
<a href="/media.php?path=<?= urlencode($f['file_path']) ?>" target="_blank" rel="noopener">
|
||||
<?= htmlspecialchars($f['file_name'] ?? basename($f['file_path'])) ?>
|
||||
</a>
|
||||
<?php if (!empty($f['file_size'])): ?>
|
||||
<small>(<?= number_format($f['file_size'] / 1024 / 1024, 2) ?> MB)</small>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<label class="admin-checkbox-label admin-file-delete">
|
||||
<input type="checkbox" name="delete_files[]" value="<?= (int)$f['id'] ?>">
|
||||
Supprimer
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?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>
|
||||
|
||||
<!-- Image bannière (custom: includes current banner preview + remove checkbox) -->
|
||||
<div>
|
||||
<label>Image bannière (accueil) :</label>
|
||||
|
||||
Reference in New Issue
Block a user