Files
xamxam/app/templates/partials/form/fieldset-tfe-info.php
Pontoporeia 3016c199bd Fix edit form: is_published reset, contact decoupling, note label, author name case
- Fix #1: Add is_published to getThesisRawFields() SELECT so the publish
  checkbox stays checked when editing an already-published TFE.
- Fix #2: Rename 'Note contextuelle' → 'Note contextuelle relative à
  soutenance' in all templates and StudentEmail.
- Fix #3: Update findOrCreateAuthor to also UPDATE the author name when
  a record is found by name (fixes inability to capitalise names).
- Fix #4/#5: Decouple contact_interne (private author email) from
  contact_visible (public contact on TFE page). Add migration 037 to
  add contact_visible TEXT column to theses table and rebuild
  v_theses_full view. Update all controllers, templates, and DB methods
  to treat them independently.
- Fix #6: Investigated libre→interne restriction — no code barrier
  found; likely resolved by is_published fix.
2026-06-10 00:17:00 +02:00

79 lines
3.8 KiB
PHP

<?php
/**
* Shared partial — "Informations du TFE" fieldset.
*
* Variables consumed:
* callable|null $oldFn — callable($key, $default='') to retrieve old/current values;
* defaults to the global old() function when null.
* callable|null $withAutofocusFn — callable($field, $attrs=[]) to inject autofocus;
* defaults to identity when null.
* array $allowedObjet — list of allowed objet values; when count > 1 a radio group
* is shown; when count === 1 a hidden input is emitted instead.
* array $formData — raw form data array (used for checkbox states).
* string $synopsisExtra — optional HTML block injected after the synopsis label.
*/
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
$allowedObjet = $allowedObjet ?? [];
$formData = $formData ?? [];
$synopsisExtra = $synopsisExtra ?? '';
$adminMode = $adminMode ?? false;
?>
<fieldset>
<legend>Informations du TFE</legend>
<?php if (!empty($allowedObjet)): ?>
<?php if (count($allowedObjet) > 1): ?>
<div class="admin-form-group">
<label>Type de travail&nbsp;: <span class="asterisk">*</span></label>
<div class="form-radio-group">
<?php foreach ($allowedObjet as $objetVal): ?>
<label class="admin-checkbox-label">
<input type="radio" name="objet" value="<?= htmlspecialchars($objetVal) ?>"
<?= ($oldFn('objet') ?: $allowedObjet[0]) === $objetVal ? 'checked' : '' ?>
<?= $adminMode ? '' : 'required' ?>>
<?= htmlspecialchars(ucfirst($objetVal)) ?>
</label>
<?php endforeach; ?>
</div>
</div>
<?php else: ?>
<input type="hidden" name="objet" value="<?= htmlspecialchars($allowedObjet[0]) ?>">
<?php endif; ?>
<?php endif; ?>
<?php
$name = 'titre'; $label = 'Titre du TFE :'; $value = $oldFn('titre'); $required = !$adminMode;
$attrs = $withAutofocusFn('titre');
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php
$name = 'subtitle'; $label = 'Sous-titre (si applicable) :'; $value = $oldFn('subtitle'); $required = false;
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php
$name = 'auteurice'; $label = 'Auteur·ice(s) :'; $value = $oldFn('auteurice'); $required = !$adminMode;
$attrs = $withAutofocusFn('auteurice', ['autocomplete' => 'name']);
$hint = 'Séparez les auteur·ices par des virgules.';
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php if (!$adminMode): ?>
<?php
$name = 'mail'; $label = 'Contact visible (optionnel) [mail/site/insta/etc.] :'; $value = $oldFn('mail');
$attrs = ['autocomplete' => 'email'];
$hint = 'Un seul contact. Indiquez l\'URL complète pour un site (https://…), l\'adresse mail, le nom d\'utilisateur avec @ pour Instagram (@pseudo), ou l\'adresse complète pour Mastodon (@pseudo@instance). Ce contact sera visible publiquement sur la fiche du TFE.';
include APP_ROOT . '/templates/partials/form/text-field.php';
?>
<?php endif; ?>
<div>
<label for="synopsis">Synopsis :<?= $adminMode ? '' : ' <span class="asterisk">*</span>' ?></label>
<?= $synopsisExtra ?>
<textarea id="synopsis" name="synopsis" rows="7" <?= $adminMode ? '' : 'required' ?>
<?= ($withAutofocusFn('synopsis')['autofocus'] ?? false) ? 'autofocus' : '' ?>><?= $oldFn('synopsis') ?></textarea>
</div>
</fieldset>
<?php
unset($allowedObjet, $synopsisExtra);