mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-09-25 09:53:08 +02:00
feat: allow exporting an empty CSV template for imports
This commit is contained in:
@@ -20,6 +20,7 @@ require_once APP_ROOT . '/src/ErrorHandler.php';
|
||||
$doCsv = !empty($_GET['csv']);
|
||||
$doFiles = !empty($_GET['files']);
|
||||
$doDb = !empty($_GET['db']);
|
||||
$doTemplate = !empty($_GET['template']);
|
||||
|
||||
// Optional: filter by selected thesis IDs (bulk selection export)
|
||||
$idsRaw = $_GET['ids'] ?? '';
|
||||
@@ -33,12 +34,30 @@ if ($idsRaw !== '') {
|
||||
}
|
||||
}
|
||||
|
||||
if (!$doCsv && !$doFiles && !$doDb) {
|
||||
if (!$doCsv && !$doFiles && !$doDb && !$doTemplate) {
|
||||
$doCsv = true;
|
||||
}
|
||||
|
||||
$controller = ExportController::create();
|
||||
|
||||
// Empty CSV template: stream only the header row (no data).
|
||||
if ($doTemplate) {
|
||||
AdminLogger::make()->logCsvExport();
|
||||
|
||||
$filename = 'xamxam-template.csv';
|
||||
|
||||
header('Content-Type: text/csv; charset=UTF-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
|
||||
echo "\xEF\xBB\xBF";
|
||||
|
||||
$out = fopen('php://output', 'w');
|
||||
fputcsv($out, ExportController::CSV_HEADERS, ',', '"', '');
|
||||
fclose($out);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($doCsv) {
|
||||
AdminLogger::make()->logCsvExport();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user