mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
86 lines
4.0 KiB
PHP
86 lines
4.0 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 (returns $attrs) 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.
|
|
* Omit or pass [] to suppress the objet selector entirely.
|
|
* array $formData — raw form data array (used for contact_public checkbox state).
|
|
* string $synopsisExtra — optional HTML block injected after the synopsis label
|
|
* (use for student-facing explanations).
|
|
* bool $isAdminMode — when true the form uses admin-style helpers; default false.
|
|
*/
|
|
|
|
$oldFn = $oldFn ?? (function_exists('old') ? 'old' : fn($k, $d = '') => $d);
|
|
$withAutofocusFn = $withAutofocusFn ?? fn($field, $attrs = []) => $attrs;
|
|
$allowedObjet = $allowedObjet ?? [];
|
|
$formData = $formData ?? [];
|
|
$synopsisExtra = $synopsisExtra ?? '';
|
|
?>
|
|
<fieldset>
|
|
<legend>Informations du TFE</legend>
|
|
|
|
<?php if (!empty($allowedObjet)): ?>
|
|
<?php if (count($allowedObjet) > 1): ?>
|
|
<div class="admin-form-group">
|
|
<label>Type de travail : <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' : '' ?> 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 :'; $value = $oldFn('titre'); $required = true;
|
|
$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;
|
|
$attrs = [];
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
<?php
|
|
$name = 'auteurice'; $label = 'Auteur·ice(s) :'; $value = $oldFn('auteurice'); $required = true;
|
|
$attrs = $withAutofocusFn('auteurice', ['autocomplete' => 'name']);
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
<?php
|
|
$name = 'mail'; $label = 'Contact(s) (optionnel) [mail/site/insta/etc.] :'; $value = $oldFn('mail');
|
|
$attrs = ['autocomplete' => 'email'];
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
|
|
<div class="admin-form-group">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="contact_public" value="1"
|
|
<?= !empty($formData['contact_public']) ? 'checked' : '' ?>>
|
|
Je veux que mon contact soit accessible à toustes depuis la plateforme xamxam
|
|
</label>
|
|
<small>Si cette case est cochée, votre contact apparaîtra sur la page publique de votre TFE.</small>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="synopsis">Synopsis :</label>
|
|
<?= $synopsisExtra ?>
|
|
<textarea id="synopsis" name="synopsis" rows="7" required
|
|
<?= ($withAutofocusFn('synopsis')['autofocus'] ?? false) ? 'autofocus' : '' ?>><?= $oldFn('synopsis') ?></textarea>
|
|
</div>
|
|
</fieldset>
|
|
<?php
|
|
unset($oldFn, $withAutofocusFn, $allowedObjet, $synopsisExtra);
|