mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
1. fix: form improvements — multiple promoteurices, asterisks, contact dedup, bentopdf - Multiple promoteurice (interne + ULB): both fieldsets now support dynamic add/remove rows (same pattern as lecteurs). field names changed to arrays (jury_promoteur[], jury_promoteur_ulb_name[]). Controllers accept both scalar and array forms for backwards compat. - ULB promoteurice: when finality=Approfondi, asterisk appears on legend and first ULB input is marked required (JS toggle). Non-Approfondi hides the fieldset and clears values. - Contact visibility duplication: removed redundant contact_public checkbox from admin add/edit forms (showContact=false). The 'mail' field in fieldset-tfe-info already serves this purpose. - Asterisk fixes: website URL field now has asterisk+required when Site web format selected. Video/audio already had correct required handling. - bentopdf link: clearer full URL 'https://bentopdf.com/' in both fichiers-fragment.php and form.php (edit mode) 2. refactor: merge Note contextuelle into Backoffice, add Lien BAIU, reorder fields Backoffice fieldset now contains in order: 1. Note contextuelle (was standalone fieldset) 2. Points du jury 3. Remarques 4. Lien BAIU (moved from Métadonnées complémentaires) 5. Exemplaire physique BAIU 6. Exemplaire physique ERG 7. Contact interne Métadonnées complémentaires now only has: pages, minutes, annexes checkbox. Removed dead showContextNote variable from form.php, add.php, edit.php. Controller baiu_link still mapped to input name "lien" (no migration needed). 3. refactor: move annexes checkbox from Métadonnées into Fichiers fieldset - Removed 'Ce TFE comporte des annexes' checkbox from fieldset-metadata.php. - Added annexes checkbox + conditional file input to fichiers-fragment.php. When checked, an HTMX swap reveals the 'annexes' file input (multiple, PDF or ZIP/TAR, max 500 MB). - form.php seeds ['has_annexes'] for initial fragment render. - Métadonnées complémentaires now only contains pages + minutes.
121 lines
4.9 KiB
PHP
121 lines
4.9 KiB
PHP
<main id="main-content">
|
|
<h1>Modifier un TFE</h1>
|
|
|
|
<?php
|
|
// ── Build a unified old() callable for the entire edit form ────────────────
|
|
$editFormData = array_merge($formData ?? [], [
|
|
'titre' => $thesis['title'],
|
|
'subtitle' => $thesis['subtitle'] ?? '',
|
|
'auteurice' => $thesis['authors'] ?? '',
|
|
'mail' => $currentAuthorEmail ?? '',
|
|
'synopsis' => $thesis['synopsis'] ?? '',
|
|
'tag' => $thesis['keywords'] ?? '',
|
|
'année' => $thesis['year'],
|
|
'orientation' => $thesis['orientation'],
|
|
'ap' => $thesis['ap_program'],
|
|
'finality' => $thesis['finality_type'],
|
|
'duration_pages' => $currentRaw['duration_pages'] ?? '',
|
|
'duration_minutes' => $currentRaw['duration_minutes'] ?? '',
|
|
'lien' => $thesis['baiu_link'] ?? '',
|
|
'contact_public' => $currentAuthorShowContact ?? false,
|
|
]);
|
|
$oldFn = fn(string $key, string $default = '') =>
|
|
isset($editFormData[$key]) && !is_array($editFormData[$key])
|
|
? htmlspecialchars((string)$editFormData[$key]) : $default;
|
|
|
|
$withAutofocusFn = function (string $field, array $attrs = []) use ($autofocusField) {
|
|
if ($autofocusField === $field) $attrs['autofocus'] = true;
|
|
return $attrs;
|
|
};
|
|
|
|
// ── Shared form variables ──────────────────────────────────────────────────
|
|
$mode = 'edit';
|
|
$formAction = '/admin/actions/edit.php';
|
|
$hiddenFields = '<input type="hidden" name="csrf_token" value="' . htmlspecialchars($_SESSION['csrf_token']) . '">'
|
|
. '<input type="hidden" name="thesis_id" value="' . $thesisId . '">';
|
|
|
|
$synopsisExtra = '';
|
|
$formData = $editFormData;
|
|
|
|
// Jury data
|
|
$juryPromoteur = null;
|
|
$juryPromoteurs = [];
|
|
$juryPromoteurUlb = null;
|
|
$juryPromoteursUlb = [];
|
|
$lecteursInternes = [];
|
|
$lecteursExternes = [];
|
|
$juryPresident = null;
|
|
foreach ($jury as $jm) {
|
|
if ($jm['role'] === 'president') {
|
|
$juryPresident = $jm['name'];
|
|
} elseif ($jm['role'] === 'promoteur') {
|
|
if (($jm['is_ulb'] ?? 0) == 1) {
|
|
$juryPromoteursUlb[] = $jm;
|
|
} else {
|
|
$juryPromoteurs[] = $jm;
|
|
}
|
|
} elseif ($jm['role'] === 'lecteur') {
|
|
if (($jm['is_external'] ?? 0) == 1) {
|
|
$lecteursExternes[] = $jm;
|
|
} else {
|
|
$lecteursInternes[] = $jm;
|
|
}
|
|
}
|
|
}
|
|
// Backwards compat: if only one, also set the scalar for simple templates
|
|
if (!empty($juryPromoteurs) && $juryPromoteur === null) {
|
|
$juryPromoteur = $juryPromoteurs[0]['name'];
|
|
}
|
|
if (!empty($juryPromoteursUlb) && $juryPromoteurUlb === null) {
|
|
$juryPromoteurUlb = $juryPromoteursUlb[0]['name'];
|
|
}
|
|
$showPresident = true;
|
|
$showPromoteurUlb = true;
|
|
$promoteurUlbConditional = false;
|
|
|
|
// Licence / access — always all enabled for admin
|
|
$libreEnabled = true;
|
|
$interneEnabled = true;
|
|
$interditEnabled = true;
|
|
$generalitiesHtml = $helpFn('fieldset_generalites');
|
|
$defaultAccessTypeId = $currentAccessTypeId ?? 2;
|
|
$formData['access_type_id'] = $currentAccessTypeId;
|
|
$formData['license_id'] = $currentLicenseId;
|
|
$formData['license_custom'] = $currentRaw['license_custom'] ?? '';
|
|
$formData['cc2r'] = $currentRaw['cc4r'] ?? false;
|
|
|
|
// Optional sections
|
|
$showContact = false; // Admin: contact visibility controlled by filling 'mail' field in fieldset-tfe-info
|
|
$showBackoffice = true;
|
|
$showPublish = true;
|
|
|
|
// Files: edit mode
|
|
$filesMode = 'edit';
|
|
$currentCover = $currentCover ?? null;
|
|
$currentFiles = $currentFiles ?? [];
|
|
$currentContextNote = $currentContextNote ?? null;
|
|
|
|
// Website URL from existing files
|
|
$existingWebsiteUrl = '';
|
|
$existingWebsiteLabel = '';
|
|
foreach ($currentFiles as $f) {
|
|
if ($f['file_type'] === 'website') {
|
|
$existingWebsiteUrl = $f['file_path'] ?? '';
|
|
$existingWebsiteLabel = $f['display_label'] ?? '';
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Languages — either from flash repopulation or current thesis data
|
|
$formData['languages'] = $formData['languages'] ?? $currentLanguages ?? [];
|
|
|
|
// Formats — either from flash repopulation or current thesis data
|
|
$checkedFormats = $formData['formats'] ?? $currentFormats ?? [];
|
|
// Populate formData.formats for checkbox-list partial
|
|
$formData['formats'] = $checkedFormats;
|
|
$checkedFormatsForSiteWeb = $checkedFormats;
|
|
|
|
include APP_ROOT . '/templates/partials/form/form.php';
|
|
?>
|
|
</main>
|