Merge pull request #13651 from mauriciofauth/export

Refactor export functions to static methods
This commit is contained in:
Maurício Meneghini Fauth 2017-09-05 15:18:49 -03:00 committed by GitHub
commit 08c357ec7c
34 changed files with 1188 additions and 1192 deletions

View File

@ -6,8 +6,11 @@
* @package PhpMyAdmin
*/
use PhpMyAdmin\Config\PageSettings;
use PhpMyAdmin\Display\Export;
use PhpMyAdmin\Display\Export as DisplayExport;
use PhpMyAdmin\Export;
use PhpMyAdmin\Message;
use PhpMyAdmin\Response;
use PhpMyAdmin\Util;
/**
* Gets some core libraries
@ -15,7 +18,6 @@ use PhpMyAdmin\Response;
require_once 'libraries/common.inc.php';
require_once 'libraries/config/user_preferences.forms.php';
require_once 'libraries/config/page_settings.forms.php';
require_once 'libraries/export.lib.php';
PageSettings::showGroup('Export');
@ -24,7 +26,7 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export.js');
// $sub_part is used in PhpMyAdmin\Util::getDbInfo() to see if we are coming from
// $sub_part is used in Util::getDbInfo() to see if we are coming from
// db_export.php, in which case we don't obey $cfg['MaxTableList']
$sub_part = '_export';
require_once 'libraries/db_common.inc.php';
@ -40,7 +42,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PhpMyAdmin\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
/**
* Displays the form
@ -50,7 +52,7 @@ $export_page_title = __('View dump (schema) of database');
// exit if no tables in db found
if ($num_tables < 1) {
$response->addHTML(
PhpMyAdmin\Message::error(__('No tables found in database.'))->getDisplay()
Message::error(__('No tables found in database.'))->getDisplay()
);
exit;
} // end if
@ -95,25 +97,25 @@ foreach (array('table_select', 'table_structure', 'table_data') as $one_key) {
foreach ($tables as $each_table) {
if (isset($_GET['table_select']) && is_array($_GET['table_select'])) {
$is_checked = PMA_getCheckedClause(
$is_checked = Export::getCheckedClause(
$each_table['Name'], $_GET['table_select']
);
} elseif (isset($table_select)) {
$is_checked = PMA_getCheckedClause(
$is_checked = Export::getCheckedClause(
$each_table['Name'], $table_select
);
} else {
$is_checked = ' checked="checked"';
}
if (isset($_GET['table_structure']) && is_array($_GET['table_structure'])) {
$structure_checked = PMA_getCheckedClause(
$structure_checked = Export::getCheckedClause(
$each_table['Name'], $_GET['table_structure']
);
} else {
$structure_checked = $is_checked;
}
if (isset($_GET['table_data']) && is_array($_GET['table_data'])) {
$data_checked = PMA_getCheckedClause(
$data_checked = Export::getCheckedClause(
$each_table['Name'], $_GET['table_data']
);
} else {
@ -151,7 +153,7 @@ if (! isset($multi_values)) {
}
$response = Response::getInstance();
$response->addHTML(
Export::getExportDisplay(
DisplayExport::getExportDisplay(
'database', $db, $table, $sql_query, $num_tables,
$unlim_num_rows, $multi_values
)

View File

@ -8,6 +8,7 @@
use PhpMyAdmin\Core;
use PhpMyAdmin\Encoding;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Sanitize;
@ -26,7 +27,6 @@ if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit') {
}
include_once 'libraries/common.inc.php';
include_once 'libraries/plugin_interface.lib.php';
include_once 'libraries/export.lib.php';
//check if it's the GET request to check export time out
if (isset($_GET['check_time_out'])) {
@ -290,7 +290,7 @@ if ((!empty($parser->statements[0]))
$aliases = \PhpMyAdmin\SqlParser\Utils\Misc::getAliases($parser->statements[0], $db);
}
if (!empty($_REQUEST['aliases'])) {
$aliases = PMA_mergeAliases($aliases, $_REQUEST['aliases']);
$aliases = Export::mergeAliases($aliases, $_REQUEST['aliases']);
$_SESSION['tmpval']['aliases'] = $_REQUEST['aliases'];
}
@ -301,7 +301,7 @@ Util::setTimeLimit();
if (! empty($cfg['MemoryLimit'])) {
@ini_set('memory_limit', $cfg['MemoryLimit']);
}
register_shutdown_function('PMA_shutdownDuringExport');
register_shutdown_function('PhpMyAdmin\Export::shutdown');
// Start with empty buffer
$dump_buffer = '';
$dump_buffer_len = 0;
@ -331,7 +331,7 @@ $output_charset_conversion = $asfile
$GLOBALS['onfly_compression'] = $GLOBALS['cfg']['CompressOnFly']
&& $compression == 'gzip';
if ($GLOBALS['onfly_compression']) {
$GLOBALS['memory_limit'] = PMA_getMemoryLimitForExport();
$GLOBALS['memory_limit'] = Export::getMemoryLimit();
}
// Generate filename and mime type if needed
@ -339,7 +339,7 @@ if ($asfile) {
if (empty($remember_template)) {
$remember_template = '';
}
list($filename, $mime_type) = PMA_getExportFilenameAndMimetype(
list($filename, $mime_type) = Export::getFilenameAndMimetype(
$export_type, $remember_template, $export_plugin, $compression,
$filename_template
);
@ -349,13 +349,13 @@ if ($asfile) {
// Open file on server if needed
if ($save_on_server) {
list($save_filename, $message, $file_handle) = PMA_openExportFile(
list($save_filename, $message, $file_handle) = Export::openFile(
$filename, $quick_export
);
// problem opening export file on server?
if (! empty($message)) {
PMA_showExportPage($db, $table, $export_type);
Export::showPage($db, $table, $export_type);
}
} else {
/**
@ -383,7 +383,7 @@ if ($save_on_server) {
exit();
}
}
list($html, $back_button) = PMA_getHtmlForDisplayedExportHeader(
list($html, $back_button) = Export::getHtmlForDisplayedExportHeader(
$export_type, $db, $table
);
echo $html;
@ -424,7 +424,7 @@ do {
if (! isset($db_select)) {
$db_select = '';
}
PMA_exportServer(
Export::exportServer(
$db_select, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$aliases, $separate_files
@ -441,19 +441,19 @@ do {
$table_data = $tables;
}
if (isset($lock_tables)) {
PMA_lockTables($db, $tables, "READ");
Export::lockTables($db, $tables, "READ");
try {
PMA_exportDatabase(
Export::exportDatabase(
$db, $tables, $whatStrucOrData, $table_structure,
$table_data, $export_plugin, $crlf, $err_url, $export_type,
$do_relation, $do_comments, $do_mime, $do_dates, $aliases,
$separate_files
);
} finally {
PMA_unlockTables();
Export::unlockTables();
}
} else {
PMA_exportDatabase(
Export::exportDatabase(
$db, $tables, $whatStrucOrData, $table_structure, $table_data,
$export_plugin, $crlf, $err_url, $export_type, $do_relation,
$do_comments, $do_mime, $do_dates, $aliases, $separate_files
@ -473,18 +473,18 @@ do {
}
if (isset($lock_tables)) {
try {
PMA_lockTables($db, array($table), "READ");
PMA_exportTable(
Export::lockTables($db, array($table), "READ");
Export::exportTable(
$db, $table, $whatStrucOrData, $export_plugin, $crlf,
$err_url, $export_type, $do_relation, $do_comments,
$do_mime, $do_dates, $allrows, $limit_to, $limit_from,
$sql_query, $aliases
);
} finally {
PMA_unlockTables();
Export::unlockTables();
}
} else {
PMA_exportTable(
Export::exportTable(
$db, $table, $whatStrucOrData, $export_plugin, $crlf, $err_url,
$export_type, $do_relation, $do_comments, $do_mime, $do_dates,
$allrows, $limit_to, $limit_from, $sql_query, $aliases
@ -499,14 +499,14 @@ do {
// End of fake loop
if ($save_on_server && ! empty($message)) {
PMA_showExportPage($db, $table, $export_type);
Export::showPage($db, $table, $export_type);
}
/**
* Send the dump as a file...
*/
if (empty($asfile)) {
echo PMA_getHtmlForDisplayedExportFooter($back_button);
echo Export::getHtmlForDisplayedExportFooter($back_button);
return;
} // end if
@ -522,21 +522,21 @@ if ($output_charset_conversion) {
// Compression needed?
if ($compression) {
if (! empty($separate_files)) {
$dump_buffer = PMA_compressExport(
$dump_buffer = Export::compress(
$dump_buffer_objects, $compression, $filename
);
} else {
$dump_buffer = PMA_compressExport($dump_buffer, $compression, $filename);
$dump_buffer = Export::compress($dump_buffer, $compression, $filename);
}
}
/* If we saved on server, we have to close file now */
if ($save_on_server) {
$message = PMA_closeExportFile(
$message = Export::closeFile(
$file_handle, $dump_buffer, $save_filename
);
PMA_showExportPage($db, $table, $export_type);
Export::showPage($db, $table, $export_type);
} else {
echo $dump_buffer;
}

1049
libraries/classes/Export.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
*/
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\Export\Helpers\TableProperty;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
@ -195,12 +196,12 @@ class ExportCodegen extends ExportPlugin
if (isset($CG_FORMATS[$format])) {
$method = $CG_HANDLERS[$format];
return PMA_exportOutputHandler(
return Export::outputHandler(
$this->$method($db, $table, $crlf, $aliases)
);
}
return PMA_exportOutputHandler(sprintf("%s is not supported.", $format));
return Export::outputHandler(sprintf("%s is not supported.", $format));
}
/**

View File

@ -10,6 +10,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -255,7 +256,7 @@ class ExportCsv extends ExportPlugin
$schema_insert .= $csv_separator;
} // end for
$schema_insert = trim(mb_substr($schema_insert, 0, -1));
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
if (!Export::outputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end if
@ -320,7 +321,7 @@ class ExportCsv extends ExportPlugin
}
} // end for
if (!PMA_exportOutputHandler($schema_insert . $csv_terminated)) {
if (!Export::outputHandler($schema_insert . $csv_terminated)) {
return false;
}
} // end while

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -107,7 +108,7 @@ class ExportHtmlword extends ExportPlugin
{
global $charset;
return PMA_exportOutputHandler(
return Export::outputHandler(
'<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
@ -130,7 +131,7 @@ class ExportHtmlword extends ExportPlugin
*/
public function exportFooter()
{
return PMA_exportOutputHandler('</body></html>');
return Export::outputHandler('</body></html>');
}
/**
@ -147,7 +148,7 @@ class ExportHtmlword extends ExportPlugin
$db_alias = $db;
}
return PMA_exportOutputHandler(
return Export::outputHandler(
'<h1>' . __('Database') . ' ' . htmlspecialchars($db_alias) . '</h1>'
);
}
@ -204,7 +205,7 @@ class ExportHtmlword extends ExportPlugin
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'<h2>'
. __('Dumping data for table') . ' ' . htmlspecialchars($table_alias)
. '</h2>'
@ -212,7 +213,7 @@ class ExportHtmlword extends ExportPlugin
) {
return false;
}
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'<table class="width100" cellspacing="1">'
)
) {
@ -241,7 +242,7 @@ class ExportHtmlword extends ExportPlugin
. '</strong></td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
if (!Export::outputHandler($schema_insert)) {
return false;
}
} // end if
@ -262,12 +263,12 @@ class ExportHtmlword extends ExportPlugin
. '</td>';
} // end for
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
if (!Export::outputHandler($schema_insert)) {
return false;
}
} // end while
$GLOBALS['dbi']->freeResult($result);
if (!PMA_exportOutputHandler('</table>')) {
if (!Export::outputHandler('</table>')) {
return false;
}
@ -605,7 +606,7 @@ class ExportHtmlword extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
} // end switch
return PMA_exportOutputHandler($dump);
return Export::outputHandler($dump);
}
/**

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -118,7 +119,7 @@ class ExportJson extends ExportPlugin
'comment' => 'Export to JSON plugin for PHPMyAdmin',
);
return PMA_exportOutputHandler(
return Export::outputHandler(
'[' . $crlf . $this->encode($meta) . ',' . $crlf
);
}
@ -132,7 +133,7 @@ class ExportJson extends ExportPlugin
{
global $crlf;
return PMA_exportOutputHandler(']' . $crlf);
return Export::outputHandler(']' . $crlf);
}
/**
@ -156,7 +157,7 @@ class ExportJson extends ExportPlugin
'name' => $db_alias
);
return PMA_exportOutputHandler(
return Export::outputHandler(
$this->encode($meta) . ',' . $crlf
);
}
@ -212,7 +213,7 @@ class ExportJson extends ExportPlugin
$this->initAlias($aliases, $db_alias, $table_alias);
if (! $this->first) {
if (!PMA_exportOutputHandler(',')) {
if (!Export::outputHandler(',')) {
return false;
}
} else {
@ -229,7 +230,7 @@ class ExportJson extends ExportPlugin
);
list($header, $footer) = explode('"@@DATA@@"', $buffer);
if (!PMA_exportOutputHandler($header . $crlf . '[' . $crlf)) {
if (!Export::outputHandler($header . $crlf . '[' . $crlf)) {
return false;
}
@ -256,7 +257,7 @@ class ExportJson extends ExportPlugin
// Output table name as comment if this is the first record of the table
if ($record_cnt > 1) {
if (!PMA_exportOutputHandler(',' . $crlf)) {
if (!Export::outputHandler(',' . $crlf)) {
return false;
}
}
@ -267,12 +268,12 @@ class ExportJson extends ExportPlugin
$data[$columns[$i]] = $record[$i];
}
if (!PMA_exportOutputHandler($this->encode($data))) {
if (!Export::outputHandler($this->encode($data))) {
return false;
}
}
if (!PMA_exportOutputHandler($crlf . ']' . $crlf . $footer . $crlf)) {
if (!Export::outputHandler($crlf . ']' . $crlf . $footer . $crlf)) {
return false;
}

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -222,7 +223,7 @@ class ExportLatex extends ExportPlugin
. '% ' . __('Server version:') . ' ' . $GLOBALS['dbi']->getVersionString() . $crlf
. '% ' . __('PHP Version:') . ' ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
}
/**
@ -253,7 +254,7 @@ class ExportLatex extends ExportPlugin
. '% ' . __('Database:') . ' ' . '\'' . $db_alias . '\'' . $crlf
. '% ' . $crlf;
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
}
/**
@ -350,7 +351,7 @@ class ExportLatex extends ExportPlugin
)
. '} \\\\';
}
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
@ -363,11 +364,11 @@ class ExportLatex extends ExportPlugin
}
$buffer = mb_substr($buffer, 0, -2) . '\\\\ \\hline \hline ';
if (!PMA_exportOutputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
if (!Export::outputHandler($buffer . ' \\endfirsthead ' . $crlf)) {
return false;
}
if (isset($GLOBALS['latex_caption'])) {
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'\\caption{'
. Util::expandUserString(
$GLOBALS['latex_data_continued_caption'],
@ -383,11 +384,11 @@ class ExportLatex extends ExportPlugin
return false;
}
}
if (!PMA_exportOutputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
if (!Export::outputHandler($buffer . '\\endhead \\endfoot' . $crlf)) {
return false;
}
} else {
if (!PMA_exportOutputHandler('\\\\ \hline')) {
if (!Export::outputHandler('\\\\ \hline')) {
return false;
}
}
@ -416,13 +417,13 @@ class ExportLatex extends ExportPlugin
}
}
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
}
$buffer = ' \\end{longtable}' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
@ -505,7 +506,7 @@ class ExportLatex extends ExportPlugin
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure:') . ' '
. $table_alias . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
@ -574,7 +575,7 @@ class ExportLatex extends ExportPlugin
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
@ -647,14 +648,14 @@ class ExportLatex extends ExportPlugin
$buffer = str_replace("\000", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
} // end while
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);
return Export::outputHandler($buffer);
} // end of the 'exportStructure' method
/**

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -261,7 +262,7 @@ class ExportMediawiki extends ExportPlugin
break;
} // end switch
return PMA_exportOutputHandler($output);
return Export::outputHandler($output);
}
/**
@ -346,7 +347,7 @@ class ExportMediawiki extends ExportPlugin
// End table construction
$output .= "|}" . str_repeat($this->_exportCRLF(), 2);
return PMA_exportOutputHandler($output);
return Export::outputHandler($output);
}
/**

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
@ -147,7 +148,7 @@ class ExportOds extends ExportPlugin
$GLOBALS['ods_buffer'] .= '</office:spreadsheet>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
OpenDocument::create(
'application/vnd.oasis.opendocument.spreadsheet',
$GLOBALS['ods_buffer']

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\OpenDocument;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
@ -166,7 +167,7 @@ class ExportOdt extends ExportPlugin
$GLOBALS['odt_buffer'] .= '</office:text>'
. '</office:body>'
. '</office:document-content>';
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
OpenDocument::create(
'application/vnd.oasis.opendocument.text',
$GLOBALS['odt_buffer']

View File

@ -8,6 +8,7 @@
*/
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
@ -150,7 +151,7 @@ class ExportPdf extends ExportPlugin
$pdf = $this->_getPdf();
// instead of $pdf->Output():
if (!PMA_exportOutputHandler($pdf->getPDFData())) {
if (!Export::outputHandler($pdf->getPDFData())) {
return false;
}

View File

@ -10,6 +10,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Items\HiddenPropertyItem;
@ -86,7 +87,7 @@ class ExportPhparray extends ExportPlugin
*/
public function exportHeader()
{
PMA_exportOutputHandler(
Export::outputHandler(
'<?php' . $GLOBALS['crlf']
. '/**' . $GLOBALS['crlf']
. ' * Export to PHP Array plugin for PHPMyAdmin' . $GLOBALS['crlf']
@ -120,7 +121,7 @@ class ExportPhparray extends ExportPlugin
if (empty($db_alias)) {
$db_alias = $db;
}
PMA_exportOutputHandler(
Export::outputHandler(
'/**' . $GLOBALS['crlf']
. ' * Database ' . $this->commentString(Util::backquote($db_alias))
. $GLOBALS['crlf'] . ' */' . $GLOBALS['crlf']
@ -245,7 +246,7 @@ class ExportPhparray extends ExportPlugin
}
$buffer .= $crlf . ');' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\Charsets;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -579,7 +580,7 @@ class ExportSql extends ExportPlugin
}
if (!empty($text)) {
return PMA_exportOutputHandler($text);
return Export::outputHandler($text);
} else {
return false;
}
@ -665,7 +666,7 @@ class ExportSql extends ExportPlugin
$GLOBALS['dbi']->query('SET time_zone = "' . $GLOBALS['old_tz'] . '"');
}
return PMA_exportOutputHandler($foot);
return Export::outputHandler($foot);
}
/**
@ -772,7 +773,7 @@ class ExportSql extends ExportPlugin
$this->_sent_charset = true;
}
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
}
/**
@ -797,7 +798,7 @@ class ExportSql extends ExportPlugin
$compat = 'NONE';
}
if (isset($GLOBALS['sql_drop_database'])) {
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'DROP DATABASE IF EXISTS '
. Util::backquoteCompat(
$db_alias,
@ -833,7 +834,7 @@ class ExportSql extends ExportPlugin
$create_query .= ' DEFAULT CHARACTER SET ' . $collation;
}
$create_query .= ';' . $crlf;
if (!PMA_exportOutputHandler($create_query)) {
if (!Export::outputHandler($create_query)) {
return false;
}
@ -855,7 +856,7 @@ class ExportSql extends ExportPlugin
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'NONE'
) {
$result = PMA_exportOutputHandler(
$result = Export::outputHandler(
'USE '
. Util::backquoteCompat(
$db,
@ -865,7 +866,7 @@ class ExportSql extends ExportPlugin
. ';' . $crlf
);
} else {
$result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
$result = Export::outputHandler('USE ' . $db . ';' . $crlf);
}
return $result;
@ -900,7 +901,7 @@ class ExportSql extends ExportPlugin
)
. $this->_exportComment();
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
}
/**
@ -918,17 +919,17 @@ class ExportSql extends ExportPlugin
//add indexes to the sql dump file
if (isset($GLOBALS['sql_indexes'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_indexes']);
$result = Export::outputHandler($GLOBALS['sql_indexes']);
unset($GLOBALS['sql_indexes']);
}
//add auto increments to the sql dump file
if (isset($GLOBALS['sql_auto_increments'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_auto_increments']);
$result = Export::outputHandler($GLOBALS['sql_auto_increments']);
unset($GLOBALS['sql_auto_increments']);
}
//add constraints to the sql dump file
if (isset($GLOBALS['sql_constraints'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
$result = Export::outputHandler($GLOBALS['sql_constraints']);
unset($GLOBALS['sql_constraints']);
}
@ -977,7 +978,7 @@ class ExportSql extends ExportPlugin
}
if (!empty($text)) {
return PMA_exportOutputHandler($text);
return Export::outputHandler($text);
} else {
return false;
}
@ -1007,7 +1008,7 @@ class ExportSql extends ExportPlugin
. $this->_exportComment()
. $this->_exportComment(__('Metadata'))
. $this->_exportComment();
if (!PMA_exportOutputHandler($comment)) {
if (!Export::outputHandler($comment)) {
return false;
}
@ -1090,7 +1091,7 @@ class ExportSql extends ExportPlugin
$comment .= $this->_exportComment();
if (!PMA_exportOutputHandler($comment)) {
if (!Export::outputHandler($comment)) {
return false;
}
@ -1140,7 +1141,7 @@ class ExportSql extends ExportPlugin
$lastPage = $GLOBALS['crlf']
. "SET @LAST_PAGE = LAST_INSERT_ID();"
. $GLOBALS['crlf'];
if (!PMA_exportOutputHandler($lastPage)) {
if (!Export::outputHandler($lastPage)) {
return false;
}
@ -2130,7 +2131,7 @@ class ExportSql extends ExportPlugin
// but not in the case of export
unset($GLOBALS['sql_constraints_query']);
return PMA_exportOutputHandler($dump);
return Export::outputHandler($dump);
}
/**
@ -2188,7 +2189,7 @@ class ExportSql extends ExportPlugin
. $this->_exportComment()
. $this->_possibleCRLF();
if (!PMA_exportOutputHandler($head)) {
if (!Export::outputHandler($head)) {
return false;
}
@ -2208,7 +2209,7 @@ class ExportSql extends ExportPlugin
if (! defined('TESTSUITE')) {
trigger_error($message, E_USER_ERROR);
}
return PMA_exportOutputHandler(
return Export::outputHandler(
$this->_exportComment($message)
);
}
@ -2298,8 +2299,8 @@ class ExportSql extends ExportPlugin
)
. $this->_exportComment()
. $crlf;
PMA_exportOutputHandler($truncatehead);
PMA_exportOutputHandler($truncate);
Export::outputHandler($truncatehead);
Export::outputHandler($truncate);
}
// scheme for inserting fields
@ -2350,7 +2351,7 @@ class ExportSql extends ExportPlugin
)
. $this->_exportComment()
. $crlf;
if (!PMA_exportOutputHandler($head)) {
if (!Export::outputHandler($head)) {
return false;
}
}
@ -2359,7 +2360,7 @@ class ExportSql extends ExportPlugin
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row == 0
) {
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'SET IDENTITY_INSERT '
. Util::backquoteCompat(
$table_alias,
@ -2470,7 +2471,7 @@ class ExportSql extends ExportPlugin
&& $sql_max_size > 0
&& $query_size + $insertLineSize > $sql_max_size
) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
if (!Export::outputHandler(';' . $crlf)) {
return false;
}
$query_size = 0;
@ -2487,7 +2488,7 @@ class ExportSql extends ExportPlugin
}
unset($values);
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
($current_row == 1 ? '' : $separator . $crlf)
. $insert_line
)
@ -2497,7 +2498,7 @@ class ExportSql extends ExportPlugin
} // end while
if ($current_row > 0) {
if (!PMA_exportOutputHandler(';' . $crlf)) {
if (!Export::outputHandler(';' . $crlf)) {
return false;
}
}
@ -2507,7 +2508,7 @@ class ExportSql extends ExportPlugin
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row > 0
) {
$outputSucceeded = PMA_exportOutputHandler(
$outputSucceeded = Export::outputHandler(
$crlf . 'SET IDENTITY_INSERT '
. Util::backquoteCompat(
$table_alias,

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -131,7 +132,7 @@ class ExportTexytext extends ExportPlugin
$db_alias = $db;
}
return PMA_exportOutputHandler(
return Export::outputHandler(
'===' . __('Database') . ' ' . $db_alias . "\n\n"
);
}
@ -188,7 +189,7 @@ class ExportTexytext extends ExportPlugin
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
if (!PMA_exportOutputHandler(
if (!Export::outputHandler(
'== ' . __('Dumping data for table') . ' ' . $table_alias . "\n\n"
)
) {
@ -215,7 +216,7 @@ class ExportTexytext extends ExportPlugin
. htmlspecialchars(stripslashes($col_as));
} // end for
$text_output .= "\n|------\n";
if (!PMA_exportOutputHandler($text_output)) {
if (!Export::outputHandler($text_output)) {
return false;
}
} // end if
@ -239,7 +240,7 @@ class ExportTexytext extends ExportPlugin
);
} // end for
$text_output .= "\n";
if (!PMA_exportOutputHandler($text_output)) {
if (!Export::outputHandler($text_output)) {
return false;
}
} // end while
@ -559,7 +560,7 @@ class ExportTexytext extends ExportPlugin
$dump .= $this->getTableDefStandIn($db, $table, $crlf, $aliases);
} // end switch
return PMA_exportOutputHandler($dump);
return Export::outputHandler($dump);
}
/**

View File

@ -9,6 +9,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -367,7 +368,7 @@ class ExportXml extends ExportPlugin
}
}
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
}
/**
@ -379,7 +380,7 @@ class ExportXml extends ExportPlugin
{
$foot = '</pma_xml_export>';
return PMA_exportOutputHandler($foot);
return Export::outputHandler($foot);
}
/**
@ -406,7 +407,7 @@ class ExportXml extends ExportPlugin
. ' -->' . $crlf . ' <database name="'
. htmlspecialchars($db_alias) . '">' . $crlf;
return PMA_exportOutputHandler($head);
return Export::outputHandler($head);
} else {
return true;
}
@ -426,7 +427,7 @@ class ExportXml extends ExportPlugin
if (isset($GLOBALS['xml_export_contents'])
&& $GLOBALS['xml_export_contents']
) {
return PMA_exportOutputHandler(' </database>' . $crlf);
return Export::outputHandler(' </database>' . $crlf);
} else {
return true;
}
@ -492,7 +493,7 @@ class ExportXml extends ExportPlugin
$buffer = ' <!-- ' . __('Table') . ' '
. htmlspecialchars($table_alias) . ' -->' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
@ -518,7 +519,7 @@ class ExportXml extends ExportPlugin
}
$buffer .= ' </table>' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
}

View File

@ -10,6 +10,7 @@
namespace PhpMyAdmin\Plugins\Export;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Export;
use PhpMyAdmin\Plugins\ExportPlugin;
use PhpMyAdmin\Properties\Plugins\ExportPluginProperties;
use PhpMyAdmin\Properties\Options\Groups\OptionsPropertyMainGroup;
@ -73,7 +74,7 @@ class ExportYaml extends ExportPlugin
*/
public function exportHeader()
{
PMA_exportOutputHandler(
Export::outputHandler(
'%YAML 1.1' . $GLOBALS['crlf'] . '---' . $GLOBALS['crlf']
);
@ -87,7 +88,7 @@ class ExportYaml extends ExportPlugin
*/
public function exportFooter()
{
PMA_exportOutputHandler('...' . $GLOBALS['crlf']);
Export::outputHandler('...' . $GLOBALS['crlf']);
return true;
}
@ -206,7 +207,7 @@ class ExportYaml extends ExportPlugin
$buffer .= ' ' . $columns[$i] . ': "' . $record[$i] . '"' . $crlf;
}
if (!PMA_exportOutputHandler($buffer)) {
if (!Export::outputHandler($buffer)) {
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,26 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for export.lib.php
* tests for PhpMyAdmin\Export
*
* @package PhpMyAdmin-test
*/
namespace PhpMyAdmin\Tests;
/*
* Include to test.
*/
require_once 'libraries/export.lib.php';
use PhpMyAdmin\Export;
/**
* class PMA_Export_Test
* PhpMyAdmin\ExportTest class
*
* this class is for testing export.lib.php functions
* this class is for testing PhpMyAdmin\Export methods
*
* @package PhpMyAdmin-test
* @group large
*/
class PMA_Export_Test extends PHPUnit_Framework_TestCase
class ExportTest extends \PHPUnit_Framework_TestCase
{
/**
* Test for setUp
*
* @return void
*/
public function setUp()
{
}
/**
* Test for PMA_mergeAliases
* Test for Export::mergeAliases
*
* @return void
*/
@ -104,7 +90,7 @@ class PMA_Export_Test extends PHPUnit_Framework_TestCase
)
)
);
$actual = PMA_mergeAliases($aliases1, $aliases2);
$actual = Export::mergeAliases($aliases1, $aliases2);
$this->assertEquals($expected, $actual);
}
}

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportCodegen;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportCsv;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportExcel;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportHtmlword;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportJson;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportLatex;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportMediawiki;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportOds;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportOdt;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -8,7 +8,6 @@
use PhpMyAdmin\Plugins\Export\ExportPdf;
use PhpMyAdmin\Plugins\Export\Helpers\Pdf;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportPhparray;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -8,7 +8,6 @@
use PhpMyAdmin\Plugins\Export\ExportSql;
use PhpMyAdmin\Table;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportTexytext;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -10,7 +10,6 @@ use PhpMyAdmin\Table;
$GLOBALS['db'] = 'db';
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'test/PMATestCase.php';

View File

@ -7,7 +7,6 @@
*/
use PhpMyAdmin\Plugins\Export\ExportYaml;
require_once 'libraries/export.lib.php';
require_once 'libraries/config.default.php';
require_once 'libraries/database_interface.inc.php';
require_once 'test/PMATestCase.php';