mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
feat: add file display to forms and recap pages
- Live file preview on all file inputs (file-field partial, edit template): thumbnails for images, emoji icons for PDF/video/zip/vtt, filename + size - New file-preview.js wired via $extraJs in add.php / edit.php and direct <script> in partage/index.php; $extraJs support added to head.php - admin/recapitulatif.php: replace plain table with rich file list — image thumbnails linked to media.php, type badges, human-readable size, date - partage/recapitulatif.php: full rewrite — shows thesis metadata + files list with same rich display (no media links for student privacy) - form.css: new sections for .file-preview-list (live preview) and .recap-file-list / .recap-dl / .partage-recap (recap pages)
This commit is contained in:
@@ -84,19 +84,41 @@
|
||||
<?php if (!empty($files)): ?>
|
||||
<section>
|
||||
<h2>Fichiers</h2>
|
||||
<table>
|
||||
<thead><tr><th scope="col">Type</th><th scope="col">Fichier</th><th scope="col">Taille</th><th scope="col">Date</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($files as $f): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($f['file_type']) ?></td>
|
||||
<td><?= htmlspecialchars($f['file_name']) ?></td>
|
||||
<td><?= formatFileSize($f['file_size']) ?></td>
|
||||
<td><?= date('d/m/Y H:i', strtotime($f['uploaded_at'])) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul class="recap-file-list">
|
||||
<?php foreach ($files as $f): ?>
|
||||
<?php
|
||||
$mime = $f['mime_type'] ?? '';
|
||||
$isImage = str_starts_with($mime, 'image/');
|
||||
$mediaUrl = '/media.php?path=' . urlencode($f['file_path']);
|
||||
$fileName = htmlspecialchars($f['file_name'] ?? basename($f['file_path']));
|
||||
$fileType = htmlspecialchars($f['file_type']);
|
||||
?>
|
||||
<li class="recap-file-item">
|
||||
<?php if ($isImage): ?>
|
||||
<a href="<?= $mediaUrl ?>" target="_blank" rel="noopener" class="recap-file-thumb-link">
|
||||
<img src="<?= $mediaUrl ?>" alt="<?= $fileName ?>" class="recap-file-thumb" loading="lazy">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span class="recap-file-icon">
|
||||
<?php
|
||||
if ($mime === 'application/pdf') echo '📄';
|
||||
elseif (str_starts_with($mime, 'video/')) echo '🎬';
|
||||
elseif (str_starts_with($mime, 'audio/')) echo '🎵';
|
||||
elseif (in_array($mime, ['application/zip','application/x-zip-compressed'])) echo '🗜️';
|
||||
elseif (str_ends_with($f['file_name'] ?? '', '.vtt')) echo '💬';
|
||||
else echo '📎';
|
||||
?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<div class="recap-file-meta">
|
||||
<a href="<?= $mediaUrl ?>" target="_blank" rel="noopener" class="recap-file-name"><?= $fileName ?></a>
|
||||
<span class="recap-file-type-badge"><?= $fileType ?></span>
|
||||
<span class="recap-file-size"><?= formatFileSize($f['file_size']) ?></span>
|
||||
<span class="recap-file-date"><?= date('d/m/Y H:i', strtotime($f['uploaded_at'])) ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user