mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Add autosave draft system for partage form with HTMX-based session persistence
- New fragment endpoint POST/GET /partage/fragments/draft.php: saves all form fields to PHP session, excludes file/csrf/slug fields GET returns JSON for JS hydration on page load rotates both global CSRF and share CSRF tokens in sync - form.php accepts optional $formExtraAttrs and $showAutosaveStatus: allows injecting HTMX attributes and 'Brouillon enregistré' indicator - renderShareLinkForm adds hx-post with change/input debounce trigger, loads autosave-handler.js, hydrate fields from draft on page load - Draft cleared on successful form submission in handleShareLinkSubmission - autosave-handler.js now also updates share_link_token hidden input when rotating CSRF token (partage form uses both csrf_token and share_link_token) - Added .autosave-status CSS to form.css (was admin.css-only) - Updated fragment routing to accept GET requests (needed for draft hydration)
This commit is contained in:
@@ -8,15 +8,8 @@
|
||||
*/
|
||||
class AppLogger
|
||||
{
|
||||
private string $logDir;
|
||||
private string $logFile;
|
||||
|
||||
public function __construct(?string $logDir = null)
|
||||
public function __construct()
|
||||
{
|
||||
$this->logDir = $logDir ?? (defined('STORAGE_ROOT') ? STORAGE_ROOT . '/logs' : __DIR__ . '/../storage/logs');
|
||||
|
||||
// Keep for backward compat — actual file I/O is now handled by Monolog via Logger::get('app')
|
||||
$this->logFile = $this->logDir . '/form-submissions.log';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -175,7 +175,7 @@ class ExportController
|
||||
$ptInstanceUrl = $this->getPeerTubeInstanceUrl();
|
||||
}
|
||||
$tid = (int) $f['thesis_id'];
|
||||
$peertubeLinks[$tid] = $peertubeLinks[$tid] ?? ['dirname' => '', 'links' => []];
|
||||
$peertubeLinks[$tid] ??= ['dirname' => '', 'links' => []];
|
||||
$peertubeLinks[$tid]['links'][] = [
|
||||
'uuid' => $uuid,
|
||||
'url' => $ptInstanceUrl !== '' ? rtrim($ptInstanceUrl, '/') . '/videos/watch/' . $uuid : '',
|
||||
|
||||
@@ -107,10 +107,14 @@ class TfeController
|
||||
. ' – XAMXAM';
|
||||
|
||||
// Editable messages
|
||||
$restrictedMessage = $this->db->getSetting('tfe_restricted_message',
|
||||
'Les fichiers attachés à ce TFE sont réservés aux utilisateur·ices autorisé·es.');
|
||||
$forbiddenMessage = $this->db->getSetting('tfe_forbidden_message',
|
||||
"Ce TFE n'est pas disponible en ligne.");
|
||||
$restrictedMessage = $this->db->getSetting(
|
||||
'tfe_restricted_message',
|
||||
'Les fichiers attachés à ce TFE sont réservés aux utilisateur·ices autorisé·es.'
|
||||
);
|
||||
$forbiddenMessage = $this->db->getSetting(
|
||||
'tfe_forbidden_message',
|
||||
"Ce TFE n'est pas disponible en ligne."
|
||||
);
|
||||
|
||||
return [
|
||||
// Core data
|
||||
|
||||
@@ -104,7 +104,7 @@ class ThesisEditController
|
||||
$licenseTypes = $this->db->getAllLicenseTypes();
|
||||
$enabledAccessTypes = $this->db->getEnabledFormAccessTypes();
|
||||
|
||||
$rawRow = $this->db->getThesisRawFields($thesisId);
|
||||
$rawRow = $this->db->getThesisRawFields($thesisId) ?? [];
|
||||
$currentLicenseId = $rawRow['license_id'] ?? null;
|
||||
$currentAccessTypeId = $rawRow['access_type_id'] ?? null;
|
||||
$currentContextNote = $rawRow['context_note'] ?? '';
|
||||
|
||||
@@ -2016,7 +2016,7 @@ class Database
|
||||
* Return the raw FK fields not exposed through v_theses_full string columns.
|
||||
* Returns ['license_id', 'access_type_id', 'context_note'] or null if not found.
|
||||
*
|
||||
* @return array{license_id:int|null,access_type_id:int|null,context_note:string}|null
|
||||
* @return array{license_id:int|null,access_type_id:int|null,context_note:string,contact_visible:int|null}|null
|
||||
*/
|
||||
public function getThesisRawFields(int $thesisId): ?array
|
||||
{
|
||||
|
||||
@@ -146,7 +146,7 @@ class FilepondHandler
|
||||
|
||||
// Track temp file in session so it survives page reloads
|
||||
if (session_status() === PHP_SESSION_ACTIVE) {
|
||||
$_SESSION['filepond_tmp'][$queueType] = $_SESSION['filepond_tmp'][$queueType] ?? [];
|
||||
$_SESSION['filepond_tmp'][$queueType] ??= [];
|
||||
$_SESSION['filepond_tmp'][$queueType][] = $fileId;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\RotatingFileHandler;
|
||||
use Monolog\Level;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user