Changes Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to implements the new Identifier\Identifier interface. Moves Dbal\DatabaseName, Dbal\TableName and Triggers\TriggerName to the Identifiers namespace. Renames the tryFromValue() and fromValue() methods to just tryFrom() and from() respectively. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpMyAdmin\Controllers;
|
|
|
|
use PhpMyAdmin\Core;
|
|
use PhpMyAdmin\Exceptions\ExportException;
|
|
use PhpMyAdmin\Export;
|
|
use PhpMyAdmin\Html\MySQLDocumentation;
|
|
use PhpMyAdmin\Http\ServerRequest;
|
|
use PhpMyAdmin\Identifiers\DatabaseName;
|
|
use PhpMyAdmin\Message;
|
|
use PhpMyAdmin\ResponseRenderer;
|
|
|
|
use function __;
|
|
use function is_string;
|
|
use function mb_strlen;
|
|
|
|
/**
|
|
* Schema export handler
|
|
*/
|
|
class SchemaExportController
|
|
{
|
|
public function __construct(private Export $export, private ResponseRenderer $response)
|
|
{
|
|
}
|
|
|
|
public function __invoke(ServerRequest $request): void
|
|
{
|
|
$db = DatabaseName::tryFrom($request->getParsedBodyParam('db'));
|
|
/** @var mixed $exportType */
|
|
$exportType = $request->getParsedBodyParam('export_type');
|
|
if ($db === null || ! is_string($exportType) || $exportType === '') {
|
|
$errorMessage = __('Missing parameter:') . ($db === null ? ' db' : ' export_type')
|
|
. MySQLDocumentation::showDocumentation('faq', 'faqmissingparameters', true)
|
|
. '[br]';
|
|
$this->response->setRequestStatus(false);
|
|
$this->response->addHTML(Message::error($errorMessage)->getDisplay());
|
|
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Include the appropriate Schema Class depending on $exportType, default is PDF.
|
|
*/
|
|
try {
|
|
$exportInfo = $this->export->getExportSchemaInfo($db, $exportType);
|
|
} catch (ExportException $exception) {
|
|
$this->response->setRequestStatus(false);
|
|
$this->response->addHTML(Message::error($exception->getMessage())->getDisplay());
|
|
|
|
return;
|
|
}
|
|
|
|
$this->response->disable();
|
|
Core::downloadHeader(
|
|
$exportInfo['fileName'],
|
|
$exportInfo['mediaType'],
|
|
mb_strlen($exportInfo['fileData'], '8bit'),
|
|
);
|
|
echo $exportInfo['fileData'];
|
|
}
|
|
}
|