mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 08:09:18 +02:00
- Created templates/partials/form/_licence.php (shared HTML, no auth logic)
- Created templates/partials/form/_format-website.php (shared HTML, no auth logic)
- Created src/FragmentRenderer.php helper for clean fragment rendering
- Created public/{admin,partage}/fragments/ subdirectories
- Created thin fragment endpoint files: auth guard + data fetch + render template
- Updated all hx-post references in templates to new fragments/ paths
- Updated partage/index.php routing for new fragments subdirectory
- Kept old fragment files as thin delegates for backward compat
- Updated nginx config: added PHP handler in /partage/ location block
103 lines
4.6 KiB
PHP
103 lines
4.6 KiB
PHP
<?php
|
|
/**
|
|
* _licence.php — Shared HTMX fragment template for the licence section.
|
|
*
|
|
* Renders conditional licence options based on access_type_id.
|
|
* Pure presentation — receives all data via variables.
|
|
*
|
|
* Expected variables:
|
|
* string $accessTypeId — '1' (Libre), '2' (Interne), '3' (Interdit)
|
|
* string $licenseId — selected license_id (for repopulation)
|
|
* string $licenseCustom — custom licence text (for repopulation)
|
|
* bool $cc2r — CC2r checkbox state
|
|
* bool $wantLicense — want_license checkbox state (Interne only)
|
|
* array $licenseTypes — [{id, name}] from getAllLicenseTypes()
|
|
* bool $adminMode — false for partage, true for admin
|
|
* string $hxPost — HTMX endpoint for the want_license checkbox re-fetch
|
|
*/
|
|
?>
|
|
<div class="licence-license-choice">
|
|
<?php if ($accessTypeId === '1'): ?>
|
|
<fieldset class="licence-options-fieldset">
|
|
<legend>Options de licence</legend>
|
|
<p class="licence-note">J'autorise que mon TFE soit disponible en libre accès. Je suis conscient·e des responsabilités légales.</p>
|
|
|
|
<div class="admin-form-group">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="cc2r" value="1"
|
|
<?= $cc2r ? 'checked' : '' ?>>
|
|
J'accepte les conditions collectives de réutilisation (CC2r)
|
|
</label>
|
|
<small><a href="https://cc2r.net/" target="_blank" rel="noopener">En savoir plus sur la CC2r ↗</a></small>
|
|
</div>
|
|
|
|
<div class="licence-or-separator"><span>et / ou</span></div>
|
|
|
|
<?php
|
|
$name = 'license_id'; $label = 'Licence :'; $options = $licenseTypes;
|
|
$selected = $licenseId; $placeholder = '— Sélectionner —'; $required = false;
|
|
include APP_ROOT . '/templates/partials/form/select-field.php';
|
|
?>
|
|
|
|
<?php
|
|
$name = 'license_custom'; $label = 'Ou précisez une autre licence :';
|
|
$value = htmlspecialchars($licenseCustom);
|
|
$hint = 'Ex: CC BY-NC 4.0, Tous droits réservés…';
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
</fieldset>
|
|
|
|
<?php elseif ($accessTypeId === '2'): ?>
|
|
<fieldset class="licence-options-fieldset">
|
|
<legend>Options de licence</legend>
|
|
<p class="licence-note">Mon TFE est accessible sur place et sur la plateforme xamxam par la communauté erg. J'autorise une (ré-)utilisation dans un contexte académique au sein de l'erg.</p>
|
|
|
|
<div class="admin-form-group">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="want_license" value="1"
|
|
hx-post="<?= $hxPost ?>"
|
|
hx-target=".licence-license-choice"
|
|
hx-swap="outerHTML"
|
|
hx-include="closest fieldset"
|
|
<?= $wantLicense ? 'checked' : '' ?>>
|
|
<strong>Je souhaite appliquer une licence sur mon TFE</strong>
|
|
</label>
|
|
<small>Par défaut, aucune licence spécifique n'est appliquée. Cochez pour en choisir une.</small>
|
|
</div>
|
|
|
|
<?php if ($wantLicense): ?>
|
|
<div class="admin-form-group">
|
|
<label class="admin-checkbox-label">
|
|
<input type="checkbox" name="cc2r" value="1"
|
|
<?= $cc2r ? 'checked' : '' ?>>
|
|
J'accepte les conditions collectives de réutilisation (CC2r)
|
|
</label>
|
|
<small><a href="https://cc2r.net/" target="_blank" rel="noopener">En savoir plus sur la CC2r ↗</a></small>
|
|
</div>
|
|
|
|
<?php
|
|
$name = 'license_id'; $label = 'Licence :'; $options = $licenseTypes;
|
|
$selected = $licenseId; $placeholder = '— Sélectionner —'; $required = false;
|
|
include APP_ROOT . '/templates/partials/form/select-field.php';
|
|
?>
|
|
|
|
<?php
|
|
$name = 'license_custom'; $label = 'Ou précisez une autre licence :';
|
|
$value = htmlspecialchars($licenseCustom);
|
|
$hint = 'Ex: CC BY-NC 4.0, Tous droits réservés…';
|
|
include APP_ROOT . '/templates/partials/form/text-field.php';
|
|
?>
|
|
|
|
<p class="licence-note"><em>Je suis conscient·e des obligations légales venant avec la licence choisie et acquiesce avoir lu la documentation prévue à cet effet par l'erg, ainsi qu'avoir discuté des enjeux des licences avec l'équipe pédagogique.</em></p>
|
|
<?php endif; ?>
|
|
</fieldset>
|
|
|
|
<?php elseif ($accessTypeId === '3'): ?>
|
|
<fieldset class="licence-options-fieldset">
|
|
<legend>Options de licence</legend>
|
|
<p class="licence-note">Mon TFE n'est pas disponible en physique ni sur le site. Une note descriptive est visible publiquement.</p>
|
|
<p class="licence-note"><em>Aucune licence n'est applicable.</em></p>
|
|
</fieldset>
|
|
<?php endif; ?>
|
|
</div>
|