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:
@@ -1,57 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* format-website-fragment.php (admin)
|
||||
*
|
||||
* 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.
|
||||
* Admin fragment: Site web format fieldset (HTMX partial).
|
||||
* @deprecated Use /admin/fragments/format-website.php instead.
|
||||
*/
|
||||
require_once __DIR__ . '/../../bootstrap.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>
|
||||
require_once __DIR__ . '/fragments/format-website.php';
|
||||
|
||||
Reference in New Issue
Block a user