mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
212 lines
11 KiB
PHP
212 lines
11 KiB
PHP
<main id="main-content">
|
|
<h1>Modifier un TFE</h1>
|
|
|
|
<form method="post" action="/admin/actions/edit.php" class="admin-form" enctype="multipart/form-data">
|
|
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($_SESSION['csrf_token']) ?>">
|
|
<input type="hidden" name="thesis_id" value="<?= $thesisId ?>">
|
|
|
|
<!-- ═══════════════════ Informations du TFE ═══════════════════ -->
|
|
<?php
|
|
// Build a merged $formData that includes contact_public for the fieldset partial.
|
|
$formData = array_merge($formData ?? [], ['contact_public' => $currentAuthorShowContact ?? false]);
|
|
// Build old()-compatible callable from the already-loaded $thesis data.
|
|
$editOldFn = function (string $key, string $default = '') use ($thesis, $formData, $currentAuthorEmail) {
|
|
if (!empty($formData[$key])) return htmlspecialchars($formData[$key]);
|
|
$map = [
|
|
'titre' => htmlspecialchars($thesis['title']),
|
|
'subtitle' => htmlspecialchars($thesis['subtitle'] ?? ''),
|
|
'auteurice'=> htmlspecialchars($thesis['authors'] ?? ''),
|
|
'mail' => htmlspecialchars($currentAuthorEmail ?? ''),
|
|
'synopsis' => htmlspecialchars($thesis['synopsis'] ?? ''),
|
|
];
|
|
return $map[$key] ?? $default;
|
|
};
|
|
$editWithAutofocusFn = function (string $field, array $attrs = []) use ($autofocusField) {
|
|
if ($autofocusField === $field) $attrs['autofocus'] = true;
|
|
return $attrs;
|
|
};
|
|
$allowedObjet = [];
|
|
$synopsisExtra = '';
|
|
$oldFn = $editOldFn;
|
|
$withAutofocusFn = $editWithAutofocusFn;
|
|
include APP_ROOT . '/templates/partials/form/fieldset-tfe-info.php';
|
|
// Restore $formData to original for downstream partials.
|
|
$formData = $_SESSION['form_data'] ?? [];
|
|
?>
|
|
|
|
<!-- ═══════════════════ Composition du jury ═══════════════════ -->
|
|
<?php
|
|
$juryPresident = null;
|
|
$juryPromoteur = null;
|
|
$juryPromoteurExt = 0;
|
|
$juryLecteurs = [];
|
|
foreach ($jury as $jm) {
|
|
if ($jm['role'] === 'president') {
|
|
$juryPresident = $jm['name'];
|
|
} elseif ($jm['role'] === 'promoteur') {
|
|
$juryPromoteur = $jm['name'];
|
|
$juryPromoteurExt = (int)$jm['is_external'];
|
|
} elseif ($jm['role'] === 'lecteur') {
|
|
$juryLecteurs[] = $jm;
|
|
}
|
|
}
|
|
require APP_ROOT . '/templates/partials/form/jury-fieldset.php';
|
|
?>
|
|
|
|
<!-- ═══════════════════ Cadre académique ═══════════════════ -->
|
|
<?php
|
|
$editFormData = [
|
|
'année' => $thesis['year'],
|
|
'orientation' => $thesis['orientation'],
|
|
'ap' => $thesis['ap_program'],
|
|
'finality' => $thesis['finality_type'],
|
|
'languages' => $currentLanguages,
|
|
'formats' => $currentFormats,
|
|
'tag' => $thesis['keywords'] ?? '',
|
|
];
|
|
$editAcademicOldFn = function (string $key, string $default = '') use ($editFormData) {
|
|
return isset($editFormData[$key]) && !is_array($editFormData[$key])
|
|
? htmlspecialchars((string)$editFormData[$key])
|
|
: $default;
|
|
};
|
|
$oldFn = $editAcademicOldFn;
|
|
$withAutofocusFn = $editWithAutofocusFn;
|
|
$formData = $editFormData;
|
|
include APP_ROOT . '/templates/partials/form/fieldset-academic.php';
|
|
?>
|
|
|
|
<!-- ═══════════════════ Fichiers ═══════════════════ -->
|
|
<fieldset>
|
|
<legend>Fichiers</legend>
|
|
|
|
<!-- Cover image -->
|
|
<div class="admin-form-group">
|
|
<label>Image de couverture :</label>
|
|
<div class="admin-file-input">
|
|
<?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; ?>
|
|
<input type="file" id="couverture" name="couverture" accept="image/jpeg,image/png" data-preview="fp-couverture">
|
|
<div id="fp-couverture" class="file-preview-list" aria-live="polite"></div>
|
|
<small><?= empty($currentCover) ? 'JPG, PNG. Max 10 MB.' : 'Laisser vide pour conserver la couverture actuelle. JPG, PNG. Max 10 MB.' ?></small>
|
|
</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 du TFE 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 -->
|
|
<div class="admin-form-group">
|
|
<label for="files">Ajouter des fichiers du TFE :</label>
|
|
<div class="admin-file-input">
|
|
<input type="file" id="files" name="files[]" multiple
|
|
accept=".pdf,.jpg,.jpeg,.png,.mp4,.zip,.vtt"
|
|
data-preview="fp-files">
|
|
<div id="fp-files" class="file-preview-list" aria-live="polite"></div>
|
|
<small>PDF, JPG, PNG, MP4, ZIP. Max 50 MB par fichier. Pour les vidéos, un fichier .vtt de sous-titres peut être joint.</small>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Banner image -->
|
|
<div class="admin-form-group">
|
|
<label>Image bannière (accueil) :</label>
|
|
<div class="admin-file-input">
|
|
<?php if (!empty($thesis['banner_path'])): ?>
|
|
<div class="admin-banner-preview">
|
|
<img src="/media.php?path=<?= urlencode($thesis['banner_path']) ?>"
|
|
alt="Bannière actuelle">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="remove_banner" value="1"> Supprimer la bannière
|
|
</label>
|
|
</div>
|
|
<?php endif; ?>
|
|
<input type="file" name="banner" id="banner" accept="image/jpeg,image/png,image/webp" data-preview="fp-banner">
|
|
<div id="fp-banner" class="file-preview-list" aria-live="polite"></div>
|
|
<small><?= empty($thesis['banner_path']) ? 'JPG, PNG ou WEBP. Format paysage recommandé (4:1). Max 5 MB.' : 'Laisser vide pour conserver la bannière actuelle. JPG, PNG ou WEBP. Format paysage recommandé (4:1). Max 5 MB.' ?></small>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<!-- ═══════════════════ Métadonnées complémentaires ═══════════════════ -->
|
|
<?php
|
|
$editMetaFormData = [
|
|
'license_id' => $currentLicenseId,
|
|
'duration_info' => $thesis['file_size_info'] ?? '',
|
|
'lien' => $thesis['baiu_link'] ?? '',
|
|
'access_type_id' => $currentAccessTypeId,
|
|
];
|
|
$editMetaOldFn = function (string $key, string $default = '') use ($editMetaFormData) {
|
|
return isset($editMetaFormData[$key])
|
|
? htmlspecialchars((string)$editMetaFormData[$key])
|
|
: $default;
|
|
};
|
|
$oldFn = $editMetaOldFn;
|
|
$withAutofocusFn = $editWithAutofocusFn;
|
|
$formData = $editMetaFormData;
|
|
$defaultAccessTypeId = $currentAccessTypeId;
|
|
$showDescription = true;
|
|
include APP_ROOT . '/templates/partials/form/fieldset-metadata.php';
|
|
?>
|
|
|
|
<!-- ═══════════════════ Note contextuelle ═══════════════════ -->
|
|
<fieldset>
|
|
<legend>Note contextuelle</legend>
|
|
<div>
|
|
<label for="context_note">Note contextuelle :</label>
|
|
<div>
|
|
<textarea id="context_note" name="context_note"
|
|
rows="4" maxlength="1500"><?= htmlspecialchars($currentContextNote ?? '') ?></textarea>
|
|
<small>Visible publiquement pour les TFE Interne ou Interdit. Max 1 500 caractères.</small>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<!-- ═══════════════════ Publication ════════════════════════ -->
|
|
<fieldset>
|
|
<legend>Publication</legend>
|
|
<div>
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="is_published" value="1"
|
|
<?= $thesis['is_published'] ? 'checked' : '' ?>>
|
|
Publier ce TFE sur le site public
|
|
</label>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<div class="admin-form-footer">
|
|
<button type="submit" class="admin-btn">Enregistrer</button>
|
|
<a href="/admin/thanks.php?id=<?= $thesisId ?>" class="admin-btn-secondary admin-cancel-link">Annuler</a>
|
|
</div>
|
|
</form>
|
|
</main>
|