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:
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';
|
||||
Reference in New Issue
Block a user