mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Refactor HTMX fragment architecture: DRY split into auth endpoints + shared templates
- 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
This commit is contained in:
12
TODO.md
12
TODO.md
@@ -21,6 +21,18 @@
|
|||||||
- [x] F. `ThesisEditController.php` — Remove separate video/audio/peertube_* handleFilePondQueueFiles calls; also legacy $_FILES path
|
- [x] F. `ThesisEditController.php` — Remove separate video/audio/peertube_* handleFilePondQueueFiles calls; also legacy $_FILES path
|
||||||
- [x] G. `ThesisCreateController.php` — Same as F
|
- [x] G. `ThesisCreateController.php` — Same as F
|
||||||
|
|
||||||
|
# HTMX Fragment Architecture Reorganization
|
||||||
|
|
||||||
|
- [x] Create shared templates `_licence.php` and `_format-website.php` in `templates/partials/form/`
|
||||||
|
- [x] Create `src/FragmentRenderer.php` helper
|
||||||
|
- [x] Create `public/admin/fragments/` and `public/partage/fragments/` subdirectories
|
||||||
|
- [x] Create thin fragment endpoint files (auth + data prep + render shared template)
|
||||||
|
- [x] Update all hx-post references in templates to point to new `fragments/` paths
|
||||||
|
- [x] Update `partage/index.php` routing for new fragments
|
||||||
|
- [x] Keep old fragment files as thin delegates to new `fragments/` for backward compat
|
||||||
|
- [x] Update nginx config for partage fragment PHP handling
|
||||||
|
- [ ] Deploy: `just deploy` + `just deploy-nginx`
|
||||||
|
|
||||||
## Previous items
|
## Previous items
|
||||||
|
|
||||||
- [x] Step 1 — Build 4 PHP endpoints (process.php, revert.php, load.php, remove.php)
|
- [x] Step 1 — Build 4 PHP endpoints (process.php, revert.php, load.php, remove.php)
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* fichiers-fragment.php (admin)
|
* Admin fragment: Format(s) + Fichiers block (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/fichiers.php instead.
|
||||||
* Admin-gated HTMX fragment: returns the combined Format(s) + Fichiers block
|
|
||||||
* for the admin add/edit forms. Wraps the shared logic in fichiers-fragment.php
|
|
||||||
* after enforcing authentication.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/fichiers.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
App::boot();
|
|
||||||
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
|
|
||||||
$_POST['admin_mode'] = '1';
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/templates/partials/form/fichiers-fragment.php';
|
|
||||||
|
|||||||
@@ -1,57 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* format-website-fragment.php (admin)
|
* Admin fragment: Site web format fieldset (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/format-website.php instead.
|
||||||
* Admin-gated HTMX fragment: returns the Site web URL fieldset for the
|
|
||||||
* admin edit form when "Site web" is among the selected format checkboxes.
|
|
||||||
* Uses id="edit-website-url-fieldset" to avoid collision with the partage form.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/format-website.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
App::boot();
|
|
||||||
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
|
|
||||||
$db = Database::getInstance()->getConnection();
|
|
||||||
|
|
||||||
$stmt = $db->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1');
|
|
||||||
$stmt->execute(['Site web']);
|
|
||||||
$websiteFormatId = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!$websiteFormatId) {
|
|
||||||
echo '<fieldset id="edit-website-url-fieldset" style="display:none"></fieldset>';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats'])
|
|
||||||
? array_map('intval', $_POST['formats'])
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (!in_array((int)$websiteFormatId, $selectedFormats, true)) {
|
|
||||||
echo '<fieldset id="edit-website-url-fieldset" style="display:none"></fieldset>';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$websiteUrl = htmlspecialchars($_POST['website_url'] ?? '');
|
|
||||||
$websiteLabel = htmlspecialchars($_POST['website_label'] ?? '');
|
|
||||||
?>
|
|
||||||
<fieldset id="edit-website-url-fieldset">
|
|
||||||
<legend>Site web</legend>
|
|
||||||
<div class="admin-form-group">
|
|
||||||
<label for="website_url">URL du site :</label>
|
|
||||||
<div class="admin-file-input">
|
|
||||||
<input type="url" id="website_url" name="website_url"
|
|
||||||
value="<?= $websiteUrl ?>"
|
|
||||||
placeholder="https://mon-tfe.erg.be">
|
|
||||||
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="admin-form-group">
|
|
||||||
<label for="website_label">Légende :</label>
|
|
||||||
<input type="text" id="website_label" name="website_label"
|
|
||||||
value="<?= $websiteLabel ?>"
|
|
||||||
placeholder="Description du site (optionnel)"
|
|
||||||
class="admin-file-label-input"
|
|
||||||
style="max-width:400px;">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|||||||
13
app/public/admin/fragments/fichiers.php
Normal file
13
app/public/admin/fragments/fichiers.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: Format(s) + Fichiers block (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
$_POST['admin_mode'] = '1';
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/templates/partials/form/fichiers-fragment.php';
|
||||||
29
app/public/admin/fragments/format-website.php
Normal file
29
app/public/admin/fragments/format-website.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: Site web format fieldset (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/FragmentRenderer.php';
|
||||||
|
|
||||||
|
$db = Database::getInstance()->getConnection();
|
||||||
|
|
||||||
|
$stmt = $db->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1');
|
||||||
|
$stmt->execute(['Site web']);
|
||||||
|
$websiteFormatId = $stmt->fetchColumn();
|
||||||
|
|
||||||
|
$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats'])
|
||||||
|
? array_map('intval', $_POST['formats'])
|
||||||
|
: [];
|
||||||
|
|
||||||
|
FragmentRenderer::render('form/_format-website', [
|
||||||
|
'fieldsetId' => 'edit-website-url-fieldset',
|
||||||
|
'selectedFormats' => $selectedFormats,
|
||||||
|
'websiteFormatId' => $websiteFormatId,
|
||||||
|
'websiteUrl' => $_POST['website_url'] ?? '',
|
||||||
|
'websiteLabel' => $_POST['website_label'] ?? '',
|
||||||
|
]);
|
||||||
9
app/public/admin/fragments/language-autre.php
Normal file
9
app/public/admin/fragments/language-autre.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: language-autre asterisk toggle (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/language-autre-fragment.php';
|
||||||
10
app/public/admin/fragments/language-search.php
Normal file
10
app/public/admin/fragments/language-search.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: language search (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/language-search-fragment.php';
|
||||||
23
app/public/admin/fragments/licence.php
Normal file
23
app/public/admin/fragments/licence.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: licence section (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/Database.php';
|
||||||
|
require_once APP_ROOT . '/src/FragmentRenderer.php';
|
||||||
|
|
||||||
|
$licenseTypes = Database::getInstance()->getAllLicenseTypes();
|
||||||
|
|
||||||
|
FragmentRenderer::render('form/_licence', [
|
||||||
|
'adminMode' => true,
|
||||||
|
'accessTypeId' => $_POST['access_type_id'] ?? '',
|
||||||
|
'licenseId' => $_POST['license_id'] ?? '',
|
||||||
|
'licenseCustom' => $_POST['license_custom'] ?? '',
|
||||||
|
'cc2r' => !empty($_POST['cc2r']),
|
||||||
|
'wantLicense' => !empty($_POST['want_license']),
|
||||||
|
'hxPost' => '/admin/fragments/licence.php',
|
||||||
|
'licenseTypes' => $licenseTypes,
|
||||||
|
]);
|
||||||
10
app/public/admin/fragments/tag-search.php
Normal file
10
app/public/admin/fragments/tag-search.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: tag search (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/tag-search-fragment.php';
|
||||||
9
app/public/admin/fragments/validate-file.php
Normal file
9
app/public/admin/fragments/validate-file.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Admin fragment: file validation (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||||
|
AdminAuth::requireLogin();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/Controllers/validate-file-fragment-shared.php';
|
||||||
@@ -1,17 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* language-autre-fragment.php (admin)
|
* Admin fragment: language-autre asterisk toggle (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/language-autre.php instead.
|
||||||
* HTMX fragment: returns the "Autre(s) langue(s)" input row.
|
|
||||||
* Called from the shared form partial when a language checkbox changes.
|
|
||||||
*
|
|
||||||
* Expected POST:
|
|
||||||
* languages[] — selected language IDs (may be absent)
|
|
||||||
* language_autre — current free-text value (for repopulation)
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/language-autre.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/public/partage/language-autre-fragment.php';
|
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* language-search-fragment.php (admin)
|
* Admin fragment: language search (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/language-search.php instead.
|
||||||
* HTMX fragment: returns matching language suggestions for the
|
|
||||||
* "Autre(s) langue(s)" interactive search input. Admin-auth gated wrapper.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/language-search.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
App::boot();
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/public/partage/language-search-fragment.php';
|
|
||||||
|
|||||||
@@ -1,109 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* HTMX fragment (admin): renders the licence section with conditional options.
|
* Admin fragment: licence section (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/licence.php instead.
|
||||||
* POST: access_type_id, license_id, license_custom, cc2r, want_license
|
|
||||||
*
|
|
||||||
* Libre (1): CC2r checkbox + licence select/custom (at least one required)
|
|
||||||
* Interne (2): opt-in "Je souhaite appliquer une licence" → CC2r + licence select/custom
|
|
||||||
* Interdit (3): no licence options
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/licence.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
|
|
||||||
$accessTypeId = $_POST['access_type_id'] ?? '';
|
|
||||||
$licenseId = $_POST['license_id'] ?? '';
|
|
||||||
$licenseCustom = $_POST['license_custom'] ?? '';
|
|
||||||
$cc2r = !empty($_POST['cc2r']);
|
|
||||||
$wantLicense = !empty($_POST['want_license']);
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Database.php';
|
|
||||||
$db = Database::getInstance();
|
|
||||||
$licenseTypes = $db->getAllLicenseTypes();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<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="/admin/licence-fragment.php"
|
|
||||||
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>
|
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* tag-search-fragment.php (admin)
|
* Admin fragment: tag search (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/tag-search.php instead.
|
||||||
* HTMX fragment: returns matching tag suggestions for the mot-clé
|
|
||||||
* interactive search input. Admin-auth gated wrapper.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/tag-search.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
App::boot();
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/public/partage/tag-search-fragment.php';
|
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* validate-file-fragment.php (admin)
|
* Admin fragment: file validation (HTMX partial).
|
||||||
*
|
* @deprecated Use /admin/fragments/validate-file.php instead.
|
||||||
* Admin-gated HTMX fragment: validates uploaded file MIME type and size.
|
|
||||||
* Wraps the shared validation logic.
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/validate-file.php';
|
||||||
require_once __DIR__ . '/../../src/AdminAuth.php';
|
|
||||||
AdminAuth::requireLogin();
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Controllers/validate-file-fragment-shared.php';
|
|
||||||
|
|||||||
@@ -1,66 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* format-website-fragment.php (partage)
|
* Partagé fragment: Site web format fieldset (HTMX partial).
|
||||||
*
|
* @deprecated Use /partage/fragments/format-website.php instead.
|
||||||
* HTMX fragment for the student share form: returns the website URL input fields
|
|
||||||
* if "Site web" is among the currently selected format checkboxes.
|
|
||||||
*
|
|
||||||
* Regular PHP include inside partage/index.php routing — no separate bootstrap.
|
|
||||||
* The parent partage/index.php already handles boot + session.
|
|
||||||
*
|
|
||||||
* Expected POST:
|
|
||||||
* - formats[]: array of selected format_type IDs
|
|
||||||
* - website_url: current website_url value (for repopulation)
|
|
||||||
* - website_label: current website_label value (for repopulation)
|
|
||||||
*/
|
*/
|
||||||
|
require_once __DIR__ . '/fragments/format-website.php';
|
||||||
// Find the "Site web" format ID
|
|
||||||
$stmt = Database::getInstance()->getConnection()->prepare(
|
|
||||||
'SELECT id FROM format_types WHERE name = ? LIMIT 1'
|
|
||||||
);
|
|
||||||
$stmt->execute(['Site web']);
|
|
||||||
$websiteFormatId = $stmt->fetchColumn();
|
|
||||||
|
|
||||||
if (!$websiteFormatId) {
|
|
||||||
echo '';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats'])
|
|
||||||
? array_map('intval', $_POST['formats'])
|
|
||||||
: [];
|
|
||||||
|
|
||||||
if (!in_array((int)$websiteFormatId, $selectedFormats, true)) {
|
|
||||||
echo '';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$websiteUrl = htmlspecialchars($_POST['website_url'] ?? '');
|
|
||||||
$websiteLabel = htmlspecialchars($_POST['website_label'] ?? '');
|
|
||||||
?>
|
|
||||||
<fieldset id="website-url-fieldset">
|
|
||||||
<legend>Site web</legend>
|
|
||||||
|
|
||||||
<div class="admin-form-group">
|
|
||||||
<label for="website_url">URL du site :</label>
|
|
||||||
<div class="admin-file-input">
|
|
||||||
<input type="url"
|
|
||||||
id="website_url"
|
|
||||||
name="website_url"
|
|
||||||
value="<?= $websiteUrl ?>"
|
|
||||||
placeholder="https://mon-tfe.erg.be">
|
|
||||||
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="admin-form-group">
|
|
||||||
<label for="website_label">Légende :</label>
|
|
||||||
<input type="text"
|
|
||||||
id="website_label"
|
|
||||||
name="website_label"
|
|
||||||
value="<?= $websiteLabel ?>"
|
|
||||||
placeholder="Description du site (optionnel)"
|
|
||||||
class="admin-file-label-input"
|
|
||||||
style="max-width:400px;">
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
|
||||||
|
|||||||
8
app/public/partage/fragments/fichiers.php
Normal file
8
app/public/partage/fragments/fichiers.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: Format(s) + Fichiers block (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/templates/partials/form/fichiers-fragment.php';
|
||||||
26
app/public/partage/fragments/format-website.php
Normal file
26
app/public/partage/fragments/format-website.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: Site web format fieldset (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/FragmentRenderer.php';
|
||||||
|
|
||||||
|
$db = Database::getInstance()->getConnection();
|
||||||
|
|
||||||
|
$stmt = $db->prepare('SELECT id FROM format_types WHERE name = ? LIMIT 1');
|
||||||
|
$stmt->execute(['Site web']);
|
||||||
|
$websiteFormatId = $stmt->fetchColumn();
|
||||||
|
|
||||||
|
$selectedFormats = isset($_POST['formats']) && is_array($_POST['formats'])
|
||||||
|
? array_map('intval', $_POST['formats'])
|
||||||
|
: [];
|
||||||
|
|
||||||
|
FragmentRenderer::render('form/_format-website', [
|
||||||
|
'fieldsetId' => 'website-url-fieldset',
|
||||||
|
'selectedFormats' => $selectedFormats,
|
||||||
|
'websiteFormatId' => $websiteFormatId,
|
||||||
|
'websiteUrl' => $_POST['website_url'] ?? '',
|
||||||
|
'websiteLabel' => $_POST['website_label'] ?? '',
|
||||||
|
]);
|
||||||
8
app/public/partage/fragments/language-autre.php
Normal file
8
app/public/partage/fragments/language-autre.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: language-autre asterisk toggle (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/language-autre-fragment.php';
|
||||||
8
app/public/partage/fragments/language-search.php
Normal file
8
app/public/partage/fragments/language-search.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: language search (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/language-search-fragment.php';
|
||||||
22
app/public/partage/fragments/licence.php
Normal file
22
app/public/partage/fragments/licence.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: licence section (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/Database.php';
|
||||||
|
require_once APP_ROOT . '/src/FragmentRenderer.php';
|
||||||
|
|
||||||
|
$licenseTypes = Database::getInstance()->getAllLicenseTypes();
|
||||||
|
|
||||||
|
FragmentRenderer::render('form/_licence', [
|
||||||
|
'adminMode' => false,
|
||||||
|
'accessTypeId' => $_POST['access_type_id'] ?? '',
|
||||||
|
'licenseId' => $_POST['license_id'] ?? '',
|
||||||
|
'licenseCustom' => $_POST['license_custom'] ?? '',
|
||||||
|
'cc2r' => !empty($_POST['cc2r']),
|
||||||
|
'wantLicense' => !empty($_POST['want_license']),
|
||||||
|
'hxPost' => '/partage/fragments/licence.php',
|
||||||
|
'licenseTypes' => $licenseTypes,
|
||||||
|
]);
|
||||||
8
app/public/partage/fragments/tag-search.php
Normal file
8
app/public/partage/fragments/tag-search.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: tag search (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/public/partage/tag-search-fragment.php';
|
||||||
8
app/public/partage/fragments/validate-file.php
Normal file
8
app/public/partage/fragments/validate-file.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Partagé fragment: file validation (HTMX partial).
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . '/../../../bootstrap.php';
|
||||||
|
App::boot();
|
||||||
|
|
||||||
|
require_once APP_ROOT . '/src/Controllers/validate-file-fragment-shared.php';
|
||||||
@@ -22,54 +22,59 @@ $parts = explode('/', $path);
|
|||||||
$slug = $parts[0] ?? '';
|
$slug = $parts[0] ?? '';
|
||||||
$action = $parts[1] ?? '';
|
$action = $parts[1] ?? '';
|
||||||
|
|
||||||
// Special route: /partage/language-autre-fragment (HTMX fragment, no auth needed)
|
// Special route: /partage/fragments/* (HTMX fragments under fragments/ subdirectory)
|
||||||
if ($slug === 'language-autre-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
if (str_starts_with($slug, 'fragments/') && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
App::boot();
|
App::boot();
|
||||||
require_once __DIR__ . '/language-autre-fragment.php';
|
$fragmentFile = __DIR__ . '/' . basename($slug);
|
||||||
|
if (file_exists($fragmentFile)) {
|
||||||
|
require_once $fragmentFile;
|
||||||
|
} else {
|
||||||
|
http_response_code(404);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special route: /partage/format-website-fragment (HTMX fragment, legacy — kept for safety)
|
// Legacy routes — kept for backward compatibility, delegate to fragments/
|
||||||
if ($slug === 'format-website-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
App::boot();
|
|
||||||
require_once __DIR__ . '/format-website-fragment.php';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special route: /partage/validate-file-fragment (HTMX fragment — file MIME/size validation)
|
|
||||||
if ($slug === 'validate-file-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
App::boot();
|
|
||||||
require_once __DIR__ . '/../../src/Controllers/validate-file-fragment-shared.php';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Special route: /partage/fichiers-fragment (HTMX fragment — format-aware fichiers block)
|
|
||||||
if ($slug === 'fichiers-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
App::boot();
|
|
||||||
require_once APP_ROOT . '/templates/partials/form/fichiers-fragment.php';
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special route: /partage/licence-fragment (HTMX fragment — licence section with conditional required)
|
|
||||||
if ($slug === 'licence-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($slug === 'licence-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
App::boot();
|
App::boot();
|
||||||
require_once __DIR__ . '/licence-fragment.php';
|
require_once __DIR__ . '/fragments/licence.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special route: /partage/tag-search-fragment (HTMX fragment — interactive tag search)
|
if ($slug === 'language-autre-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
if ($slug === 'tag-search-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
||||||
App::boot();
|
App::boot();
|
||||||
require_once __DIR__ . '/tag-search-fragment.php';
|
require_once __DIR__ . '/fragments/language-autre.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special route: /partage/language-search-fragment (HTMX fragment — interactive language search)
|
|
||||||
if ($slug === 'language-search-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($slug === 'language-search-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
App::boot();
|
App::boot();
|
||||||
require_once __DIR__ . '/language-search-fragment.php';
|
require_once __DIR__ . '/fragments/language-search.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($slug === 'tag-search-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
App::boot();
|
||||||
|
require_once __DIR__ . '/fragments/tag-search.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($slug === 'format-website-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
App::boot();
|
||||||
|
require_once __DIR__ . '/fragments/format-website.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($slug === 'fichiers-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
App::boot();
|
||||||
|
require_once __DIR__ . '/fragments/fichiers.php';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($slug === 'validate-file-fragment' && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
App::boot();
|
||||||
|
require_once __DIR__ . '/fragments/validate-file.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* language-autre-fragment.php
|
* Partagé fragment: language-autre asterisk toggle (HTMX partial).
|
||||||
*
|
* @deprecated Use /partage/fragments/language-autre.php instead.
|
||||||
* Shared HTMX fragment include: returns the requirement asterisk for the
|
|
||||||
* "Autre(s) langue(s)" label. When no standard language checkbox is checked,
|
|
||||||
* an asterisk is rendered to signal the field is required (server-side validated).
|
|
||||||
*
|
|
||||||
* Included by:
|
|
||||||
* - /admin/language-autre-fragment.php (AdminAuth gated)
|
|
||||||
* - partage/index.php special route (public, session already booted)
|
|
||||||
*
|
|
||||||
* Expected POST:
|
|
||||||
* languages[] — selected language IDs (may be absent)
|
|
||||||
*/
|
*/
|
||||||
|
require_once __DIR__ . '/fragments/language-autre.php';
|
||||||
$selectedIds = isset($_POST['languages']) && is_array($_POST['languages'])
|
|
||||||
? $_POST['languages']
|
|
||||||
: [];
|
|
||||||
$anyChecked = !empty($selectedIds);
|
|
||||||
|
|
||||||
// Also check if any "autre" language pills are present (posted as language_autre[])
|
|
||||||
$hasLangAutre = isset($_POST['language_autre']) && is_array($_POST['language_autre'])
|
|
||||||
&& count(array_filter($_POST['language_autre'], fn($l) => is_string($l) && trim($l) !== '')) > 0;
|
|
||||||
|
|
||||||
// The "Autre(s) langue(s)" label is required if no standard language is checked.
|
|
||||||
// The "Langue(s) du TFE" checkbox list is required if neither standard languages
|
|
||||||
// nor "autre" languages are set.
|
|
||||||
$langAutreRequired = !$anyChecked;
|
|
||||||
$checkboxesRequired = !$anyChecked && !$hasLangAutre;
|
|
||||||
?>
|
|
||||||
<span id="language-autre-required"><?= $langAutreRequired ? ' <span class="asterisk">*</span>' : '' ?></span>
|
|
||||||
<span id="languages-required-asterisk" hx-swap-oob="true"><?= $checkboxesRequired ? ' <span class="asterisk">*</span>' : '' ?></span>
|
|
||||||
|
|||||||
@@ -1,108 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* HTMX fragment (partage): renders the licence section with conditional options.
|
* Partagé fragment: licence section (HTMX partial).
|
||||||
*
|
* @deprecated Use /partage/fragments/licence.php instead.
|
||||||
* POST: access_type_id, license_id, license_custom, cc2r, want_license, admin_mode
|
|
||||||
*
|
|
||||||
* Libre (1): CC2r checkbox + licence select/custom (au moins une des deux)
|
|
||||||
* Interne (2): opt-in "Je souhaite appliquer une licence" → CC2r + licence
|
|
||||||
* Interdit (3): no licence options
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../bootstrap.php';
|
require_once __DIR__ . '/fragments/licence.php';
|
||||||
|
|
||||||
$accessTypeId = $_POST['access_type_id'] ?? '';
|
|
||||||
$licenseId = $_POST['license_id'] ?? '';
|
|
||||||
$licenseCustom = $_POST['license_custom'] ?? '';
|
|
||||||
$cc2r = !empty($_POST['cc2r']);
|
|
||||||
$wantLicense = !empty($_POST['want_license']);
|
|
||||||
$adminMode = ($_POST['admin_mode'] ?? '0') === '1';
|
|
||||||
|
|
||||||
require_once APP_ROOT . '/src/Database.php';
|
|
||||||
$db = Database::getInstance();
|
|
||||||
$licenseTypes = $db->getAllLicenseTypes();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<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="/partage/licence-fragment"
|
|
||||||
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>
|
|
||||||
|
|||||||
@@ -1,67 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* tag-search-fragment.php
|
* Partagé fragment: tag search (HTMX partial).
|
||||||
*
|
* @deprecated Use /partage/fragments/tag-search.php instead.
|
||||||
* Shared HTMX fragment: returns matching tag suggestions for the mot-clé
|
|
||||||
* interactive search input.
|
|
||||||
*
|
|
||||||
* Included by:
|
|
||||||
* - /admin/tag-search-fragment.php (AdminAuth gated)
|
|
||||||
* - partage/index.php special route (public, session already booted)
|
|
||||||
*
|
|
||||||
* Expected POST:
|
|
||||||
* q — search query string (partial tag name)
|
|
||||||
* tag[] — already selected tag names (sent via hx-include, to exclude from suggestions)
|
|
||||||
*/
|
*/
|
||||||
require_once __DIR__ . '/../../src/Database.php';
|
require_once __DIR__ . '/fragments/tag-search.php';
|
||||||
|
|
||||||
$query = trim(preg_replace('/\s+/', ' ', strtolower($_POST['tag_search_q'] ?? '')));
|
|
||||||
$currentTags = isset($_POST['tag']) && is_array($_POST['tag'])
|
|
||||||
? array_map(function($t) { return trim(preg_replace('/\s+/', ' ', strtolower($t))); }, $_POST['tag'])
|
|
||||||
: [];
|
|
||||||
|
|
||||||
$db = Database::getInstance();
|
|
||||||
$results = $db->searchTags($query);
|
|
||||||
|
|
||||||
// Deduplicate results by lowercase name
|
|
||||||
$seen = [];
|
|
||||||
$results = array_values(array_filter($results, function($tag) use (&$seen) {
|
|
||||||
$key = strtolower($tag['name']);
|
|
||||||
if (isset($seen[$key])) return false;
|
|
||||||
$seen[$key] = true;
|
|
||||||
return true;
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Filter out already-selected tags (case-insensitive)
|
|
||||||
$results = array_values(array_filter($results, function($tag) use ($currentTags) {
|
|
||||||
return !in_array(strtolower($tag['name']), $currentTags, true);
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Check if query exactly matches an existing tag (case-insensitive)
|
|
||||||
$exactExists = false;
|
|
||||||
foreach ($results as $tag) {
|
|
||||||
if (strcasecmp($tag['name'], $query) === 0) {
|
|
||||||
$exactExists = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If no exact match and query non-empty, suggest creation
|
|
||||||
$canCreate = ($query !== '' && !$exactExists && !in_array($query, $currentTags, true));
|
|
||||||
?>
|
|
||||||
<?php if (empty($results) && !$canCreate): ?>
|
|
||||||
<div class="tag-search-empty">Aucun mot-clé trouvé.</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php foreach ($results as $tag): ?>
|
|
||||||
<button type="button" class="tag-search-item" data-tag-id="<?= (int)$tag['id'] ?>" data-tag-name="<?= htmlspecialchars($tag['name']) ?>">
|
|
||||||
<span class="tag-search-item-name"><?= htmlspecialchars($tag['name']) ?></span>
|
|
||||||
<span class="tag-search-item-count">(<?= (int)$tag['thesis_count'] ?>)</span>
|
|
||||||
</button>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
|
|
||||||
<?php if ($canCreate): ?>
|
|
||||||
<button type="button" class="tag-search-item tag-search-item--create" data-tag-name="<?= htmlspecialchars($query) ?>">
|
|
||||||
<span class="tag-search-item-name">Créer « <?= htmlspecialchars($query) ?> »</span>
|
|
||||||
</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|||||||
45
app/src/FragmentRenderer.php
Normal file
45
app/src/FragmentRenderer.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lightweight HTMX fragment renderer.
|
||||||
|
*
|
||||||
|
* Renders a shared template partial without wrapping it in full-page layout
|
||||||
|
* (no <html>, <head>, <body>, header, or footer).
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
*
|
||||||
|
* // public/admin/fragments/licence.php
|
||||||
|
* AdminAuth::requireLogin();
|
||||||
|
* FragmentRenderer::render('form/_licence', [
|
||||||
|
* 'accessTypeId' => $_POST['access_type_id'] ?? '',
|
||||||
|
* 'licenseId' => $_POST['license_id'] ?? '',
|
||||||
|
* 'licenseTypes' => Database::getInstance()->getAllLicenseTypes(),
|
||||||
|
* 'cc2r' => !empty($_POST['cc2r']),
|
||||||
|
* 'wantLicense' => !empty($_POST['want_license']),
|
||||||
|
* 'adminMode' => true,
|
||||||
|
* 'hxPost' => '/admin/fragments/licence.php',
|
||||||
|
* ]);
|
||||||
|
*
|
||||||
|
* The template receives all keys in $data as variables via extract().
|
||||||
|
*/
|
||||||
|
class FragmentRenderer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Render a template partial for an HTMX fragment response.
|
||||||
|
*
|
||||||
|
* @param string $template Path relative to APP_ROOT/templates/partials/ (without .php extension)
|
||||||
|
* @param array $data Variables to extract into template scope
|
||||||
|
*/
|
||||||
|
public static function render(string $template, array $data = []): void
|
||||||
|
{
|
||||||
|
// Prevent output buffering from any wrapping layout
|
||||||
|
if (ob_get_level() === 0) {
|
||||||
|
ob_start();
|
||||||
|
}
|
||||||
|
|
||||||
|
extract($data, EXTR_SKIP);
|
||||||
|
require APP_ROOT . '/templates/partials/' . $template . '.php';
|
||||||
|
|
||||||
|
ob_end_flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1 @@
|
|||||||
[1778455046]
|
[1778590812]
|
||||||
@@ -1728,6 +1728,19 @@
|
|||||||
+%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
|
+%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
|
||||||
+\\\\\\\ to: sqvvzxku e3b36997 ".gitignore ignore rate_limit and theses and logs." (rebased revision)
|
+\\\\\\\ to: sqvvzxku e3b36997 ".gitignore ignore rate_limit and theses and logs." (rebased revision)
|
||||||
++ $linkName = $link['name'] ?? '';
|
++ $linkName = $link['name'] ?? '';
|
||||||
|
++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: sqvvzxku e3b36997 ".gitignore ignore rate_limit and theses and logs." (rebased revision)
|
||||||
|
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
|
||||||
|
- $linkName = $link['name'] ?? '';
|
||||||
|
- $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff from: somsyvxz 14a3cd10 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebase destination)
|
||||||
|
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ to: tkqwzqos dffabd97 "Refactor HTMX fragment architecture: DRY split into auth endpoints + shared templates" (rebased revision)
|
||||||
|
$linkName = $link['name'] ?? '';
|
||||||
|
$linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
||||||
|
$linkLockedYear = $link['locked_year'] ?? null;
|
||||||
|
+%%%%%%% diff from: somsyvxz 249f7943 "Bulk bar anti-shift, tags icons, AP no-wrap, credits reorder" (rebased revision)
|
||||||
|
+\\\\\\\ to: tkqwzqos e51fc3eb "Refactor HTMX fragment architecture: DRY split into auth endpoints + shared templates" (rebased revision)
|
||||||
|
++ $linkName = $link['name'] ?? '';
|
||||||
++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
++ $linkExpiresVal = $link['expires_at'] ? date('Y-m-d\TH:i', strtotime($link['expires_at'])) : '';
|
||||||
?>
|
?>
|
||||||
<tr class="admin-table-row" onclick="event.stopPropagation(); window.open('/partage/<?= urlencode($link['slug']) ?>', '_blank')" style="cursor:pointer">
|
<tr class="admin-table-row" onclick="event.stopPropagation(); window.open('/partage/<?= urlencode($link['slug']) ?>', '_blank')" style="cursor:pointer">
|
||||||
|
|||||||
48
app/templates/partials/form/_format-website.php
Normal file
48
app/templates/partials/form/_format-website.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* _format-website.php — Shared HTMX fragment template for the Site web fieldset.
|
||||||
|
*
|
||||||
|
* Returns the website URL + label inputs when "Site web" is among the selected
|
||||||
|
* format checkboxes. Pure presentation — receives all data via variables.
|
||||||
|
*
|
||||||
|
* Expected variables:
|
||||||
|
* string $fieldsetId — HTML id for the <fieldset> ('website-url-fieldset' or 'edit-website-url-fieldset')
|
||||||
|
* array $selectedFormats — selected format_type IDs
|
||||||
|
* int $websiteFormatId — ID of the "Site web" format_type
|
||||||
|
* string $websiteUrl — current value (for repopulation)
|
||||||
|
* string $websiteLabel — current value (for repopulation)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!$websiteFormatId) {
|
||||||
|
echo '<fieldset id="' . $fieldsetId . '" style="display:none"></fieldset>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!in_array((int)$websiteFormatId, array_map('intval', $selectedFormats), true)) {
|
||||||
|
echo '<fieldset id="' . $fieldsetId . '" style="display:none"></fieldset>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$escUrl = htmlspecialchars($websiteUrl);
|
||||||
|
$escLabel = htmlspecialchars($websiteLabel);
|
||||||
|
?>
|
||||||
|
<fieldset id="<?= $fieldsetId ?>">
|
||||||
|
<legend>Site web</legend>
|
||||||
|
<div class="admin-form-group">
|
||||||
|
<label for="website_url">URL du site :</label>
|
||||||
|
<div class="admin-file-input">
|
||||||
|
<input type="url" id="website_url" name="website_url"
|
||||||
|
value="<?= $escUrl ?>"
|
||||||
|
placeholder="https://mon-tfe.erg.be">
|
||||||
|
<small>Si le TFE est un site web, entrez son URL ici. Il sera affiché comme un site embarqué sur la page du TFE.</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="admin-form-group">
|
||||||
|
<label for="website_label">Légende :</label>
|
||||||
|
<input type="text" id="website_label" name="website_label"
|
||||||
|
value="<?= $escLabel ?>"
|
||||||
|
placeholder="Description du site (optionnel)"
|
||||||
|
class="admin-file-label-input"
|
||||||
|
style="max-width:400px;">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
102
app/templates/partials/form/_licence.php
Normal file
102
app/templates/partials/form/_licence.php
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?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>
|
||||||
@@ -42,7 +42,7 @@ $adminMode = $adminMode ?? false;
|
|||||||
<div class="licence-degree">
|
<div class="licence-degree">
|
||||||
<label class="admin-checkbox-label">
|
<label class="admin-checkbox-label">
|
||||||
<input type="radio" name="access_type_id" value=""
|
<input type="radio" name="access_type_id" value=""
|
||||||
hx-post="/admin/licence-fragment.php"
|
hx-post="/admin/fragments/licence.php"
|
||||||
hx-target=".licence-license-choice"
|
hx-target=".licence-license-choice"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-include="closest fieldset"
|
hx-include="closest fieldset"
|
||||||
@@ -56,7 +56,7 @@ $adminMode = $adminMode ?? false;
|
|||||||
<div class="licence-degree">
|
<div class="licence-degree">
|
||||||
<label class="admin-checkbox-label">
|
<label class="admin-checkbox-label">
|
||||||
<input type="radio" name="access_type_id" value="1"
|
<input type="radio" name="access_type_id" value="1"
|
||||||
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||||||
hx-target=".licence-license-choice"
|
hx-target=".licence-license-choice"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-include="closest fieldset"
|
hx-include="closest fieldset"
|
||||||
@@ -77,7 +77,7 @@ $adminMode = $adminMode ?? false;
|
|||||||
<div class="licence-degree">
|
<div class="licence-degree">
|
||||||
<label class="admin-checkbox-label">
|
<label class="admin-checkbox-label">
|
||||||
<input type="radio" name="access_type_id" value="2"
|
<input type="radio" name="access_type_id" value="2"
|
||||||
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||||||
hx-target=".licence-license-choice"
|
hx-target=".licence-license-choice"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-include="closest fieldset"
|
hx-include="closest fieldset"
|
||||||
@@ -99,7 +99,7 @@ $adminMode = $adminMode ?? false;
|
|||||||
<div class="licence-degree">
|
<div class="licence-degree">
|
||||||
<label class="admin-checkbox-label">
|
<label class="admin-checkbox-label">
|
||||||
<input type="radio" name="access_type_id" value="3"
|
<input type="radio" name="access_type_id" value="3"
|
||||||
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||||||
hx-target=".licence-license-choice"
|
hx-target=".licence-license-choice"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
hx-include="closest fieldset"
|
hx-include="closest fieldset"
|
||||||
@@ -121,7 +121,7 @@ $adminMode = $adminMode ?? false;
|
|||||||
|
|
||||||
<!-- Licence — swapped via htmx when radio changes -->
|
<!-- Licence — swapped via htmx when radio changes -->
|
||||||
<div class="licence-license-choice"
|
<div class="licence-license-choice"
|
||||||
hx-post="<?= $adminMode ? '/admin/licence-fragment.php' : '/partage/licence-fragment' ?>"
|
hx-post="<?= $adminMode ? '/admin/fragments/licence.php' : '/partage/fragments/licence.php' ?>"
|
||||||
hx-trigger="load"
|
hx-trigger="load"
|
||||||
hx-include="closest fieldset"
|
hx-include="closest fieldset"
|
||||||
hx-swap="outerHTML">
|
hx-swap="outerHTML">
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ $previewId = 'fp-' . htmlspecialchars($id);
|
|||||||
|
|
||||||
// Determine HTMX POST endpoint for inline file validation
|
// Determine HTMX POST endpoint for inline file validation
|
||||||
if (defined('ADMIN_MODE') && ADMIN_MODE) {
|
if (defined('ADMIN_MODE') && ADMIN_MODE) {
|
||||||
$validateUrl = '/admin/validate-file-fragment.php';
|
$validateUrl = '/admin/fragments/validate-file.php';
|
||||||
} else {
|
} else {
|
||||||
$validateUrl = '/partage/validate-file-fragment';
|
$validateUrl = '/partage/fragments/validate-file.php';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
|||||||
$checked = $formData["languages"] ?? [];
|
$checked = $formData["languages"] ?? [];
|
||||||
$_hasLangAutre = !empty($formData['language_autre']) && is_array($formData['language_autre']) && count(array_filter($formData['language_autre'], fn($l) => is_string($l) && trim($l) !== '')) > 0;
|
$_hasLangAutre = !empty($formData['language_autre']) && is_array($formData['language_autre']) && count(array_filter($formData['language_autre'], fn($l) => is_string($l) && trim($l) !== '')) > 0;
|
||||||
$required = !$adminMode && !$_hasLangAutre;
|
$required = !$adminMode && !$_hasLangAutre;
|
||||||
$hxPost = $mode === 'partage' ? "/partage/language-autre-fragment" : "/admin/language-autre-fragment.php";
|
$hxPost = $mode === 'partage' ? "/partage/fragments/language-autre.php" : "/admin/fragments/language-autre.php";
|
||||||
$hxTarget = "#languages-required-asterisk";
|
$hxTarget = "#languages-required-asterisk";
|
||||||
$hxSwap = "outerHTML";
|
$hxSwap = "outerHTML";
|
||||||
$labelHtml = htmlspecialchars($label) . '<span id="languages-required-asterisk">' . ($required ? ' <span class="asterisk">*</span>' : '') . '</span>';
|
$labelHtml = htmlspecialchars($label) . '<span id="languages-required-asterisk">' . ($required ? ' <span class="asterisk">*</span>' : '') . '</span>';
|
||||||
@@ -233,7 +233,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
|||||||
$hint = "Si votre TFE contient une langue absente de la liste, précisez-la ici.";
|
$hint = "Si votre TFE contient une langue absente de la liste, précisez-la ici.";
|
||||||
$selectedLanguages = $_selectedOtherLangs;
|
$selectedLanguages = $_selectedOtherLangs;
|
||||||
$required = $_langAutreRequired && !$adminMode;
|
$required = $_langAutreRequired && !$adminMode;
|
||||||
$hxPost = ($mode === 'partage') ? "/partage/language-search-fragment" : "/admin/language-search-fragment.php";
|
$hxPost = ($mode === 'partage') ? "/partage/fragments/language-search.php" : "/admin/fragments/language-search.php";
|
||||||
include APP_ROOT . "/templates/partials/form/language-search.php";
|
include APP_ROOT . "/templates/partials/form/language-search.php";
|
||||||
unset($_langAutreRequired, $_selectedOtherLangs, $_langRaw, $_l, $name, $label, $placeholder, $hint, $selectedLanguages, $required, $hxPost);
|
unset($_langAutreRequired, $_selectedOtherLangs, $_langRaw, $_l, $name, $label, $placeholder, $hint, $selectedLanguages, $required, $hxPost);
|
||||||
?>
|
?>
|
||||||
@@ -279,7 +279,7 @@ $checkedFormatsForSiteWeb = $checkedFormatsForSiteWeb ?? [];
|
|||||||
$selectedTags = $_selectedTags;
|
$selectedTags = $_selectedTags;
|
||||||
$required = !$adminMode;
|
$required = !$adminMode;
|
||||||
$minTags = ($mode === 'partage') ? 3 : 0;
|
$minTags = ($mode === 'partage') ? 3 : 0;
|
||||||
$hxPost = ($mode === 'partage') ? "/partage/tag-search-fragment" : "/admin/tag-search-fragment.php";
|
$hxPost = ($mode === 'partage') ? "/partage/fragments/tag-search.php" : "/admin/fragments/tag-search.php";
|
||||||
include APP_ROOT . "/templates/partials/form/tag-search.php";
|
include APP_ROOT . "/templates/partials/form/tag-search.php";
|
||||||
unset($_tagsRaw, $_selectedTags, $_t, $name, $label, $placeholder, $hint, $selectedTags, $hxPost, $minTags, $required);
|
unset($_tagsRaw, $_selectedTags, $_t, $name, $label, $placeholder, $hint, $selectedTags, $hxPost, $minTags, $required);
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ $name = $name ?? 'language_autre';
|
|||||||
$label = $label ?? 'Autre(s) langue(s)';
|
$label = $label ?? 'Autre(s) langue(s)';
|
||||||
$placeholder = $placeholder ?? 'Rechercher une langue…';
|
$placeholder = $placeholder ?? 'Rechercher une langue…';
|
||||||
$hint = $hint ?? null;
|
$hint = $hint ?? null;
|
||||||
$hxPost = $hxPost ?? '/admin/language-search-fragment.php';
|
$hxPost = $hxPost ?? '/admin/fragments/language-search.php';
|
||||||
$selectedLanguages = $selectedLanguages ?? [];
|
$selectedLanguages = $selectedLanguages ?? [];
|
||||||
$id = $id ?? $name;
|
$id = $id ?? $name;
|
||||||
$maxLanguages = $maxLanguages ?? 10;
|
$maxLanguages = $maxLanguages ?? 10;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ $name = $name ?? 'tag';
|
|||||||
$label = $label ?? 'Mots-clés';
|
$label = $label ?? 'Mots-clés';
|
||||||
$placeholder = $placeholder ?? 'Rechercher un mot-clé…';
|
$placeholder = $placeholder ?? 'Rechercher un mot-clé…';
|
||||||
$hint = $hint ?? null;
|
$hint = $hint ?? null;
|
||||||
$hxPost = $hxPost ?? '/admin/tag-search-fragment.php';
|
$hxPost = $hxPost ?? '/admin/fragments/tag-search.php';
|
||||||
$selectedTags = $selectedTags ?? [];
|
$selectedTags = $selectedTags ?? [];
|
||||||
$id = $id ?? $name;
|
$id = $id ?? $name;
|
||||||
$maxTags = $maxTags ?? 10;
|
$maxTags = $maxTags ?? 10;
|
||||||
|
|||||||
@@ -156,6 +156,14 @@ server {
|
|||||||
|
|
||||||
# Share-link (partage) — handled by front controller
|
# Share-link (partage) — handled by front controller
|
||||||
location /partage/ {
|
location /partage/ {
|
||||||
|
# Serve PHP fragments directly
|
||||||
|
location ~ \.php$ {
|
||||||
|
include snippets/fastcgi-php.conf;
|
||||||
|
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
|
||||||
|
fastcgi_param PHP_VALUE "upload_max_filesize=1024M \n post_max_size=1024M";
|
||||||
|
fastcgi_read_timeout 300;
|
||||||
|
fastcgi_send_timeout 300;
|
||||||
|
}
|
||||||
try_files $uri /index.php$is_args$args;
|
try_files $uri /index.php$is_args$args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user