-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathExportController.php
More file actions
83 lines (67 loc) · 2.4 KB
/
ExportController.php
File metadata and controls
83 lines (67 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Controllers\Server;
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\Controllers\InvocableController;
use PhpMyAdmin\Current;
use PhpMyAdmin\Dbal\DatabaseInterface;
use PhpMyAdmin\Export\Export;
use PhpMyAdmin\Export\Options;
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Message;
use PhpMyAdmin\Plugins;
use PhpMyAdmin\Plugins\ExportType;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Routing\Route;
use function __;
use function array_merge;
#[Route('/server/export', ['GET', 'POST'])]
final readonly class ExportController implements InvocableController
{
public function __construct(
private ResponseRenderer $response,
private Options $export,
private DatabaseInterface $dbi,
private PageSettings $pageSettings,
) {
}
public function __invoke(ServerRequest $request): Response
{
if ($this->dbi->isSuperUser()) {
$this->dbi->selectDb('mysql');
}
$this->pageSettings->init('Export');
$pageSettingsErrorHtml = $this->pageSettings->getErrorHTML();
$pageSettingsHtml = $this->pageSettings->getHTML();
$this->response->addScriptFiles(['export.js']);
$databases = $this->export->getDatabasesForSelectOptions();
if ($request->has('single_table')) {
Export::$singleTable = (bool) $request->getParam('single_table');
}
$exportList = Plugins::getExport(ExportType::Server, Export::$singleTable);
if ($exportList === []) {
$this->response->addHTML(Message::error(
__('Could not load export plugins, please check your installation!'),
)->getDisplay());
return $this->response->response();
}
$options = $this->export->getOptions(
ExportType::Server,
Current::$database,
Current::$table,
Current::$sqlQuery,
Current::$numTables,
0,
$exportList,
$request->getParam('format'),
$request->getParam('what'),
);
$this->response->render('server/export/index', array_merge($options, [
'page_settings_error_html' => $pageSettingsErrorHtml,
'page_settings_html' => $pageSettingsHtml,
'databases' => $databases,
]));
return $this->response->response();
}
}