mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
1. maxFileSize bug: FileValidateSize plugin overrides core's maxFileSize
setter. Core uses toBytes('1GB') = 1073741824, but plugin registers
maxFileSize as [null, Type.INT] which calls toInt('1GB') = 1.
Fix: all maxFileSize and perExtensionMaxSize values as raw bytes.
Also fix option name: fileValidateSizeFilterItem → fileValidateSizeFilter.
2. Temp file persistence: files uploaded via FilePond went to
tmp/filepond/ and vanished from the UI on page reload because
data-existing-files only included DB-persisted files.
Fix: session-track temp file_ids in handleProcess, inject via
getSessionTempFiles() into data-existing-files, teach handleLoad
to stream temp files from disk, and route JS remove → revert for hex IDs.
68 lines
2.7 KiB
PHP
68 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* Admin fragment: Format(s) + Fichiers block (HTMX partial).
|
|
*
|
|
* GET /admin/fragments/fichiers.php?_thesis_id=123
|
|
*
|
|
* When _thesis_id is provided, loads existing files from DB and renders
|
|
* the fragment in edit mode with pre-populated FilePond pools. Used by
|
|
* the relink flow to refresh pools after a file is linked server-side.
|
|
*/
|
|
require_once __DIR__ . '/../../../bootstrap.php';
|
|
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
|
require_once APP_ROOT . '/src/Database.php';
|
|
App::boot();
|
|
|
|
AdminAuth::requireLogin();
|
|
|
|
$_POST['admin_mode'] = '1';
|
|
|
|
$thesisId = filter_var($_GET['_thesis_id'] ?? '', FILTER_VALIDATE_INT);
|
|
if ($thesisId) {
|
|
$db = Database::getInstance();
|
|
$currentFiles = $db->getThesisFiles($thesisId);
|
|
|
|
// Build per-queue-type existing-files JSON for FilePond edit mode
|
|
$buildQueueFilesJson = function (array $files, string $queueType): array {
|
|
$result = [];
|
|
foreach ($files as $f) {
|
|
$ft = $f['file_type'] ?? '';
|
|
$fp = $f['file_path'] ?? '';
|
|
if (str_starts_with($fp, 'http://') || str_starts_with($fp, 'https://')) continue;
|
|
if ($queueType === 'cover' && $ft !== 'cover') continue;
|
|
if ($queueType === 'note_intention' && $ft !== 'note_intention') continue;
|
|
if ($queueType === 'tfe' && ($ft === 'cover' || $ft === 'note_intention' || $ft === 'annex')) continue;
|
|
if ($queueType === 'annexe' && $ft !== 'annex') continue;
|
|
$result[] = [
|
|
'source' => (string)((int)$f['id']),
|
|
'options' => [
|
|
'type' => 'local',
|
|
'file' => [
|
|
'name' => $f['file_name'] ?? basename($f['file_path'] ?? ''),
|
|
'size' => (int)($f['file_size'] ?? 0),
|
|
'type' => $f['mime_type'] ?? 'application/octet-stream',
|
|
],
|
|
],
|
|
];
|
|
}
|
|
|
|
// Include session temp files so uploads survive page reload
|
|
require_once APP_ROOT . '/src/FilepondHandler.php';
|
|
$tempFiles = FilepondHandler::getSessionTempFiles($queueType);
|
|
foreach ($tempFiles as $tf) {
|
|
$result[] = $tf;
|
|
}
|
|
|
|
return $result;
|
|
};
|
|
|
|
$existingFilesJsonForCover = $buildQueueFilesJson($currentFiles, 'cover');
|
|
$existingFilesJsonForNoteIntention = $buildQueueFilesJson($currentFiles, 'note_intention');
|
|
$existingFilesJsonForTfe = $buildQueueFilesJson($currentFiles, 'tfe');
|
|
$existingFilesJsonForAnnexe = $buildQueueFilesJson($currentFiles, 'annexe');
|
|
|
|
$_POST['edit_mode'] = '1';
|
|
}
|
|
|
|
require_once APP_ROOT . '/templates/partials/form/fichiers-fragment.php';
|