mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add website-type TFE support: URLs stored as thesis_files rows, HTMX-toggle on Site web format
This commit is contained in:
@@ -36,12 +36,6 @@
|
||||
<?php $name = 'language_autre'; $label = 'Autre(s) langue(s) :'; $value = old('language_autre'); $hint = 'Si votre TFE contient une langue absente de la liste, précisez-la ici.'; include APP_ROOT . '/templates/partials/form/text-field.php'; ?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Format(s) ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Format(s)</legend>
|
||||
<?php $name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $formData['formats'] ?? []; $required = true; include APP_ROOT . '/templates/partials/form/checkbox-list.php'; ?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Mots-clés ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Mots-clés</legend>
|
||||
@@ -74,9 +68,59 @@
|
||||
require APP_ROOT . '/templates/partials/form/jury-fieldset.php';
|
||||
?>
|
||||
|
||||
<!-- ═══════════════════ Format(s) ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Format(s)</legend>
|
||||
<?php
|
||||
$name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $formData['formats'] ?? []; $required = true;
|
||||
$hxPost = '/partage/format-website-fragment';
|
||||
$hxTarget = '#website-url-fieldset';
|
||||
// Capture before include unsets it
|
||||
$_checkedFormatsForSiteWeb = $checked;
|
||||
include APP_ROOT . '/templates/partials/form/checkbox-list.php';
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Fichiers ═══════════════════ -->
|
||||
<?php include APP_ROOT . '/templates/partials/form/fieldset-files.php'; ?>
|
||||
|
||||
<!-- Website URL fieldset — shown/hidden via HTMX when "Site web" checked -->
|
||||
<fieldset id="website-url-fieldset" style="display:none">
|
||||
<legend>Site web</legend>
|
||||
|
||||
<div class="admin-form-group">
|
||||
<label for="website_url">URL du site :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="url"
|
||||
id="website_url"
|
||||
name="website_url"
|
||||
value="<?= htmlspecialchars($formData['website_url'] ?? '') ?>"
|
||||
placeholder="https://mon-tfe.erg.be">
|
||||
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-form-group">
|
||||
<label for="website_label">Légende :</label>
|
||||
<input type="text"
|
||||
id="website_label"
|
||||
name="website_label"
|
||||
value="<?= htmlspecialchars($formData['website_label'] ?? '') ?>"
|
||||
placeholder="Description du site (optionnel)"
|
||||
class="admin-file-label-input"
|
||||
style="max-width:400px;">
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
// Server-side: show if Site web already checked (e.g. on error redirect)
|
||||
$_stmt = Database::getInstance()->getConnection()->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1');
|
||||
$_stmt->execute(['Site web']);
|
||||
$_siteWebId = $_stmt->fetchColumn();
|
||||
if ($_siteWebId && in_array((string)$_siteWebId, array_map('strval', $_checkedFormatsForSiteWeb), true)) {
|
||||
echo '<script>document.getElementById("website-url-fieldset").style.display=""</script>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- ═══════════════════ Métadonnées complémentaires ═══════════════════ -->
|
||||
<?php
|
||||
$oldFn = 'old';
|
||||
|
||||
@@ -60,16 +60,6 @@
|
||||
<?php $name = 'language_autre'; $label = 'Autre(s) langue(s) :'; $value = old('language_autre'); include APP_ROOT . '/templates/partials/form/text-field.php'; ?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Format(s) ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Format(s)</legend>
|
||||
<?php
|
||||
$checkedFormats = $formData['formats'] ?? $currentFormats;
|
||||
$name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $checkedFormats; $required = true;
|
||||
include APP_ROOT . '/templates/partials/form/checkbox-list.php';
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Mots-clés ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Mots-clés</legend>
|
||||
@@ -132,6 +122,20 @@
|
||||
require APP_ROOT . '/templates/partials/form/jury-fieldset.php';
|
||||
?>
|
||||
|
||||
<!-- ═══════════════════ Format(s) ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Format(s)</legend>
|
||||
<?php
|
||||
$checkedFormats = $formData['formats'] ?? $currentFormats ?? [];
|
||||
$name = 'formats'; $label = 'Format(s) du TFE :'; $options = $formatTypes; $checked = $checkedFormats; $required = true;
|
||||
$hxPost = '/partage/format-website-fragment';
|
||||
$hxTarget = '#website-url-fieldset';
|
||||
// Capture before include unsets it
|
||||
$_checkedFormatsForSiteWeb = $checked;
|
||||
include APP_ROOT . '/templates/partials/form/checkbox-list.php';
|
||||
?>
|
||||
</fieldset>
|
||||
|
||||
<!-- ═══════════════════ Fichiers ═══════════════════ -->
|
||||
<fieldset>
|
||||
<legend>Fichiers</legend>
|
||||
@@ -173,20 +177,25 @@
|
||||
$fType === 'video' || in_array($fExt, ['mp4','webm','mov','ogv']) => '🎬',
|
||||
$fType === 'audio' || in_array($fExt, ['mp3','ogg','wav','flac','aac','m4a']) => '🔊',
|
||||
$fType === 'caption' || $fExt === 'vtt' => '💬',
|
||||
$fType === 'website' => '🌐',
|
||||
default => '📎',
|
||||
};
|
||||
$isExternalUrl = str_starts_with($f['file_path'] ?? '', 'http://') || str_starts_with($f['file_path'] ?? '', 'https://');
|
||||
$fLinkHref = $isExternalUrl
|
||||
? htmlspecialchars($f['file_path'])
|
||||
: ('/media.php?path=' . urlencode($f['file_path']));
|
||||
?>
|
||||
<li class="admin-file-list-item" data-file-id="<?= (int)$f['id'] ?>">
|
||||
<input type="hidden" name="file_sort_order[]" value="<?= (int)$f['id'] ?>">
|
||||
<span class="admin-file-drag-handle" title="Réordonner">⠿</span>
|
||||
<span class="admin-file-icon-col"><?= $fIcon ?></span>
|
||||
<span class="admin-file-info">
|
||||
<a href="/media.php?path=<?= urlencode($f['file_path']) ?>" target="_blank" rel="noopener" class="admin-file-name">
|
||||
<a href="<?= $fLinkHref ?>" target="_blank" rel="noopener" class="admin-file-name">
|
||||
<?= htmlspecialchars($f['file_name'] ?? basename($f['file_path'])) ?>
|
||||
</a>
|
||||
<span class="admin-file-meta-row">
|
||||
<span class="admin-file-type-badge"><?= htmlspecialchars($fType) ?></span>
|
||||
<?php if (!empty($f['file_size'])): ?>
|
||||
<?php if (!empty($f['file_size']) && $f['file_size'] > 0): ?>
|
||||
<span class="admin-file-size"><?= number_format($f['file_size'] / 1024 / 1024, 2) ?> MB</span>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
@@ -239,6 +248,55 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- Website URL fieldset — shown/hidden via HTMX when "Site web" checked -->
|
||||
<?php
|
||||
// Extract existing website URL/label from thesis_files for initial render
|
||||
$existingWebsite = null;
|
||||
$existingWebsiteLabel = '';
|
||||
foreach ($currentFiles as $f) {
|
||||
if ($f['file_type'] === 'website') {
|
||||
$existingWebsite = $f['file_path'] ?? '';
|
||||
$existingWebsiteLabel = $f['display_label'] ?? '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<fieldset id="website-url-fieldset" style="display:none">
|
||||
<legend>Site web</legend>
|
||||
|
||||
<div class="admin-form-group">
|
||||
<label for="website_url">URL du site :</label>
|
||||
<div class="admin-file-input">
|
||||
<input type="url"
|
||||
id="website_url"
|
||||
name="website_url"
|
||||
value="<?= htmlspecialchars($existingWebsite ?? '') ?>"
|
||||
placeholder="https://mon-tfe.erg.be">
|
||||
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="admin-form-group">
|
||||
<label for="website_label">Légende :</label>
|
||||
<input type="text"
|
||||
id="website_label"
|
||||
name="website_label"
|
||||
value="<?= htmlspecialchars($existingWebsiteLabel) ?>"
|
||||
placeholder="Description du site (optionnel)"
|
||||
class="admin-file-label-input"
|
||||
style="max-width:400px;">
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
// Server-side: show if Site web already checked
|
||||
$_stmt = Database::getInstance()->getConnection()->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1');
|
||||
$_stmt->execute(['Site web']);
|
||||
$_siteWebId = $_stmt->fetchColumn();
|
||||
if ($_siteWebId && in_array((string)$_siteWebId, array_map('strval', $_checkedFormatsForSiteWeb), true)) {
|
||||
echo '<script>document.getElementById("website-url-fieldset").style.display=""</script>';
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- ═══════════════════ Métadonnées complémentaires ═══════════════════ -->
|
||||
<?php
|
||||
$editMetaFormData = [
|
||||
|
||||
Reference in New Issue
Block a user