Files
xamxam/app/templates/admin/edit.php
Pontoporeia cc0ae32df0 fix: resolve partage form submission issues
- Replace mb_strlen/mb_substr/mb_strtolower with strlen/substr/strtolower
  (mbstring extension missing on server, causing fatal error)
- Scope annexes checkbox HTMX swap to #annexes-input-block with hx-select
  (prevents duplicating entire page inside Fichiers fieldset)
- Split format+fichiers response: #format-fichiers-block (stable) and
  #format-extras-block (swappable, inside Fichiers fieldset). Format
  checkboxes use hx-select to extract only the extras, preserving file queue.
- Keep format extras inline in Fichiers fieldset (no sub-fieldsets). Remove
  website legend input (URL only).
- When PeerTube upload disabled, show direct file upload inputs for
  video/audio (name=files[]).
- Add "Glissez-déposez" sort hint below TFE file queue.
- Fix .fq-name overflow with width:0;min-width:100% chain.
- Remove legend placeholder from .fq-item.
- Merge "Récits et expérimentation" AP into "Narration Spéculative".
  Rename PACS to "Pratique de lart - outils critiques, arts et contexte
  simultanés".
- Remove président·e field from jury fieldset, form templates, and
  controller validation. Keep DB column and display logic for existing data.
2026-05-19 00:08:05 +02:00

120 lines
4.8 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 = [];
foreach ($jury as $jm) {
if ($jm['role'] === 'president') {
continue;
}
if ($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'];
}
$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>