mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
feat: extract MediaController, wire into Dispatcher, delete media.php
This commit is contained in:
36
app/public/admin/actions/export-csv.php
Normal file
36
app/public/admin/actions/export-csv.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Export TFE listings as CSV.
|
||||
*
|
||||
* Thin dispatcher — delegates all data assembly to ExportController,
|
||||
* then streams the response.
|
||||
*/
|
||||
require_once __DIR__ . "/../../../bootstrap.php";
|
||||
require_once __DIR__ . '/../../../src/AdminAuth.php';
|
||||
AdminAuth::requireLogin();
|
||||
|
||||
require_once APP_ROOT . '/src/Controllers/ExportController.php';
|
||||
$controller = ExportController::create();
|
||||
|
||||
$filename = 'posterg-export-' . date('Y-m-d') . '.csv';
|
||||
|
||||
header('Content-Type: text/csv; charset=UTF-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
header('Cache-Control: no-cache, must-revalidate');
|
||||
|
||||
// UTF-8 BOM for Excel compatibility
|
||||
echo "\xEF\xBB\xBF";
|
||||
|
||||
$out = fopen('php://output', 'w');
|
||||
|
||||
// Column headers
|
||||
fputcsv($out, ExportController::CSV_HEADERS, ',', '"', '');
|
||||
|
||||
// Data rows
|
||||
$rows = $controller->exportAllTheses();
|
||||
foreach ($rows as $csvLine) {
|
||||
fputcsv($out, $csvLine, ',', '"', '');
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
exit;
|
||||
Reference in New Issue
Block a user