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:
@@ -218,6 +218,7 @@ function renderShareLinkForm(string $slug, array $link): void
|
||||
<title><?= htmlspecialchars($pageTitle) ?></title>
|
||||
<link rel="stylesheet" href="<?= App::assetV('/assets/css/common.css') ?>">
|
||||
<link rel="stylesheet" href="<?= App::assetV('/assets/css/form.css') ?>">
|
||||
<script src="<?= App::assetV('/assets/js/file-preview.js') ?>" defer></script>
|
||||
</head>
|
||||
<body class="student-body">
|
||||
<main id="main-content">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Thanks page for share-link submissions.
|
||||
* Displays a centered confirmation with a link to create another thesis via the same link.
|
||||
* Confirmation / recap page for share-link submissions.
|
||||
* Displays the submitted thesis details and uploaded files.
|
||||
*/
|
||||
if (!defined('APP_ROOT')) {
|
||||
require_once __DIR__ . '/../../bootstrap.php';
|
||||
@@ -15,21 +15,31 @@ if ($thesisId <= 0) {
|
||||
die('ID de TFE invalide.');
|
||||
}
|
||||
|
||||
// Verify the thesis exists
|
||||
$db = Database::getInstance();
|
||||
$db = Database::getInstance();
|
||||
$thesis = $db->getThesis($thesisId);
|
||||
if (!$thesis) {
|
||||
http_response_code(404);
|
||||
die('TFE introuvable.');
|
||||
}
|
||||
|
||||
$files = $db->getThesisFiles($thesisId);
|
||||
|
||||
// Was the confirmation e-mail sent?
|
||||
$emailSent = !empty($_SESSION['share_email_sent']);
|
||||
unset($_SESSION['share_email_sent']);
|
||||
|
||||
// Get the share link slug from the referer path
|
||||
$pathParts = explode('/', trim($_SERVER['REQUEST_URI'] ?? '', '/'));
|
||||
$slug = count($pathParts) >= 2 ? $pathParts[0] : null;
|
||||
// Derive share-link slug from the URI so we can build the "submit another" link.
|
||||
$pathParts = explode('/', trim(parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH), '/'));
|
||||
// URI is /partage/recapitulatif?id=N → parts[0]=partage, parts[1]=recapitulatif
|
||||
// We have no slug here, so just link back to /partage/ root.
|
||||
$slug = null;
|
||||
|
||||
function partageFormatFileSize(int $bytes): string {
|
||||
if ($bytes >= 1073741824) return number_format($bytes / 1073741824, 2) . ' GB';
|
||||
if ($bytes >= 1048576) return number_format($bytes / 1048576, 2) . ' MB';
|
||||
if ($bytes >= 1024) return number_format($bytes / 1024, 2) . ' KB';
|
||||
return $bytes . ' B';
|
||||
}
|
||||
|
||||
$pageTitle = 'Merci — TFE enregistré';
|
||||
?>
|
||||
@@ -43,20 +53,99 @@ $pageTitle = 'Merci — TFE enregistré';
|
||||
<link rel="stylesheet" href="<?= App::assetV('/assets/css/form.css') ?>">
|
||||
</head>
|
||||
<body class="student-body">
|
||||
<main id="main-content" class="thanks-student-page">
|
||||
<main id="main-content" class="partage-recap">
|
||||
|
||||
<div class="thanks-success">
|
||||
<h1>✅ Merci !</h1>
|
||||
<p class="thanks-message">Votre TFE a bien été enregistré sur la plateforme.</p>
|
||||
<?php if ($emailSent): ?>
|
||||
<p class="flash-success">📧 Un e-mail de confirmation a été envoyé avec un récapitulatif de votre soumission.</p>
|
||||
<?php endif; ?>
|
||||
<?php if ($thesis): ?>
|
||||
<p><strong><?= htmlspecialchars($thesis['title']) ?></strong><?php if (!empty($thesis['authors'])): ?> — <?= htmlspecialchars($thesis['authors']) ?><?php endif; ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($slug): ?>
|
||||
<a href="/partage/<?= urlencode($slug) ?>" class="btn-new-form">+ Soumettre un autre TFE</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<section class="recap-section">
|
||||
<h2>Récapitulatif de votre soumission</h2>
|
||||
<dl class="recap-dl">
|
||||
<dt>Titre</dt>
|
||||
<dd><?= htmlspecialchars($thesis['title']) ?></dd>
|
||||
|
||||
<?php if (!empty($thesis['subtitle'])): ?>
|
||||
<dt>Sous-titre</dt>
|
||||
<dd><?= htmlspecialchars($thesis['subtitle']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['authors'])): ?>
|
||||
<dt>Auteur·ice(s)</dt>
|
||||
<dd><?= htmlspecialchars($thesis['authors']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['year'])): ?>
|
||||
<dt>Année</dt>
|
||||
<dd><?= htmlspecialchars((string)$thesis['year']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['orientation'])): ?>
|
||||
<dt>Orientation</dt>
|
||||
<dd><?= htmlspecialchars($thesis['orientation']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['ap_program'])): ?>
|
||||
<dt>Atelier pluridisciplinaire</dt>
|
||||
<dd><?= htmlspecialchars($thesis['ap_program']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['finality_type'])): ?>
|
||||
<dt>Finalité</dt>
|
||||
<dd><?= htmlspecialchars($thesis['finality_type']) ?></dd>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($thesis['keywords'])): ?>
|
||||
<dt>Mots-clés</dt>
|
||||
<dd><?= htmlspecialchars($thesis['keywords']) ?></dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<?php if (!empty($files)): ?>
|
||||
<section class="recap-section">
|
||||
<h2>Fichiers soumis</h2>
|
||||
<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">
|
||||
<span class="recap-file-name"><?= $fileName ?></span>
|
||||
<span class="recap-file-type-badge"><?= $fileType ?></span>
|
||||
<span class="recap-file-size"><?= partageFormatFileSize((int)$f['file_size']) ?></span>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user