Files
xamxam/app/templates/partials/form/file-field.php
Pontoporeia 32a7509598 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)
2026-04-27 20:52:27 +02:00

37 lines
1.4 KiB
PHP

<?php
/**
* File input partial.
*
* Variables consumed:
* string $name — input name attribute (used for id too unless $id set)
* string $label — visible label text
* string $accept — MIME types / extensions for the accept attribute (e.g. 'image/jpeg,image/png')
* string|null $hint — optional hint shown in <small> below the input
* bool $multiple — whether to allow multiple file selection; default false
* string|null $id — override the id attribute (defaults to $name)
*/
$accept = $accept ?? '';
$hint = $hint ?? null;
$multiple = $multiple ?? false;
$id = $id ?? $name;
$previewId = 'fp-' . htmlspecialchars($id);
?>
<div>
<label for="<?= htmlspecialchars($id) ?>"><?= htmlspecialchars($label) ?></label>
<div class="admin-file-input">
<input type="file"
id="<?= htmlspecialchars($id) ?>"
name="<?= htmlspecialchars($name) ?><?= $multiple ? '[]' : '' ?>"
<?= $accept ? 'accept="' . htmlspecialchars($accept) . '"' : '' ?>
<?= $multiple ? 'multiple' : '' ?>
data-preview="<?= $previewId ?>">
<div id="<?= $previewId ?>" class="file-preview-list" aria-live="polite"></div>
<?php if ($hint): ?>
<small><?= htmlspecialchars($hint) ?></small>
<?php endif; ?>
</div>
</div>
<?php
unset($accept, $hint, $multiple, $id, $previewId);