Refactor schema_export function to a static method
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
b68b570773
commit
ca27f9303b
@ -7,8 +7,10 @@
|
||||
*/
|
||||
namespace PhpMyAdmin;
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Encoding;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\ExportPlugin;
|
||||
use PhpMyAdmin\Sanitize;
|
||||
use PhpMyAdmin\Table;
|
||||
@ -1046,4 +1048,41 @@ class Export
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get all the export options and verify
|
||||
* call and include the appropriate Schema Class depending on $export_type
|
||||
*
|
||||
* @param string $export_type format of the export
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function processExportSchema($export_type)
|
||||
{
|
||||
/**
|
||||
* default is PDF, otherwise validate it's only letters a-z
|
||||
*/
|
||||
if (! isset($export_type) || ! preg_match('/^[a-zA-Z]+$/', $export_type)) {
|
||||
$export_type = 'pdf';
|
||||
}
|
||||
|
||||
// sanitize this parameter which will be used below in a file inclusion
|
||||
$export_type = Core::securePath($export_type);
|
||||
|
||||
// get the specific plugin
|
||||
/* @var $export_plugin SchemaPlugin */
|
||||
$export_plugin = Plugins::getPlugin(
|
||||
"schema",
|
||||
$export_type,
|
||||
'libraries/classes/Plugins/Schema/'
|
||||
);
|
||||
|
||||
// Check schema export type
|
||||
if (! isset($export_plugin)) {
|
||||
Core::fatalError(__('Bad type!'));
|
||||
}
|
||||
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$export_plugin->exportSchema($GLOBALS['db']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,10 +6,9 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
use PhpMyAdmin\Core;
|
||||
use PhpMyAdmin\Plugins;
|
||||
use PhpMyAdmin\Plugins\SchemaPlugin;
|
||||
use PhpMyAdmin\Export;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
/**
|
||||
* Gets some core libraries
|
||||
@ -23,48 +22,11 @@ require_once 'libraries/common.inc.php';
|
||||
$cfgRelation = Relation::getRelationsParam();
|
||||
|
||||
if (! isset($_REQUEST['export_type'])) {
|
||||
PhpMyAdmin\Util::checkParameters(array('export_type'));
|
||||
Util::checkParameters(array('export_type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the appropriate Schema Class depending on $export_type
|
||||
* default is PDF
|
||||
*/
|
||||
PMA_processExportSchema($_REQUEST['export_type']);
|
||||
|
||||
/**
|
||||
* get all the export options and verify
|
||||
* call and include the appropriate Schema Class depending on $export_type
|
||||
*
|
||||
* @param string $export_type format of the export
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_processExportSchema($export_type)
|
||||
{
|
||||
/**
|
||||
* default is PDF, otherwise validate it's only letters a-z
|
||||
*/
|
||||
if (! isset($export_type) || ! preg_match('/^[a-zA-Z]+$/', $export_type)) {
|
||||
$export_type = 'pdf';
|
||||
}
|
||||
|
||||
// sanitize this parameter which will be used below in a file inclusion
|
||||
$export_type = Core::securePath($export_type);
|
||||
|
||||
// get the specific plugin
|
||||
/* @var $export_plugin SchemaPlugin */
|
||||
$export_plugin = Plugins::getPlugin(
|
||||
"schema",
|
||||
$export_type,
|
||||
'libraries/classes/Plugins/Schema/'
|
||||
);
|
||||
|
||||
// Check schema export type
|
||||
if (! isset($export_plugin)) {
|
||||
Core::fatalError(__('Bad type!'));
|
||||
}
|
||||
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$export_plugin->exportSchema($GLOBALS['db']);
|
||||
}
|
||||
Export::processExportSchema($_REQUEST['export_type']);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user