Improve readability of XML export code

This commit is contained in:
Piotr Przybylski
2011-07-13 23:40:58 +02:00
parent ed88c4a7b6
commit 6d0f28b425

View File

@@ -82,13 +82,12 @@ function PMA_exportFooter() {
function PMA_exportHeader() { function PMA_exportHeader() {
global $crlf; global $crlf;
global $cfg; global $cfg;
global $what;
global $db; global $db;
global $table; global $table;
global $tables; global $tables;
$export_struct = isset($GLOBALS[$what . '_export_struc']) ? true : false; $export_struct = isset($GLOBALS['xml_export_struc']) ? true : false;
$export_data = isset($GLOBALS[$what . '_export_contents']) ? true : false; $export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
if ($GLOBALS['output_charset_conversion']) { if ($GLOBALS['output_charset_conversion']) {
$charset = $GLOBALS['charset_of_file']; $charset = $GLOBALS['charset_of_file'];
@@ -142,11 +141,11 @@ function PMA_exportHeader() {
$type = 'table'; $type = 'table';
} }
if ($is_view && ! isset($GLOBALS[$what . '_export_views'])) { if ($is_view && ! isset($GLOBALS['xml_export_views'])) {
continue; continue;
} }
if (! $is_view && ! isset($GLOBALS[$what . '_export_tables'])) { if (! $is_view && ! isset($GLOBALS['xml_export_tables'])) {
continue; continue;
} }
@@ -158,7 +157,7 @@ function PMA_exportHeader() {
$head .= $tbl . ';' . $crlf; $head .= $tbl . ';' . $crlf;
$head .= ' </pma:' . $type . '>' . $crlf; $head .= ' </pma:' . $type . '>' . $crlf;
if (isset($GLOBALS[$what . '_export_triggers']) && $GLOBALS[$what . '_export_triggers']) { if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
// Export triggers // Export triggers
$triggers = PMA_DBI_get_triggers($db, $table); $triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) { if ($triggers) {
@@ -181,7 +180,7 @@ function PMA_exportHeader() {
} }
} }
if (isset($GLOBALS[$what . '_export_functions']) && $GLOBALS[$what . '_export_functions']) { if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
// Export functions // Export functions
$functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); $functions = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($functions) { if ($functions) {
@@ -204,7 +203,7 @@ function PMA_exportHeader() {
} }
} }
if (isset($GLOBALS[$what . '_export_procedures']) && $GLOBALS[$what . '_export_procedures']) { if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
// Export procedures // Export procedures
$procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE'); $procedures = PMA_DBI_get_procedures_or_functions($db, 'PROCEDURE');
if ($procedures) { if ($procedures) {
@@ -251,9 +250,8 @@ function PMA_exportHeader() {
*/ */
function PMA_exportDBHeader($db) { function PMA_exportDBHeader($db) {
global $crlf; global $crlf;
global $what;
if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) { if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$head = ' <!--' . $crlf $head = ' <!--' . $crlf
. ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf . ' - ' . __('Database') . ': ' . (isset($GLOBALS['use_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. ' -->' . $crlf . ' -->' . $crlf
@@ -278,9 +276,8 @@ function PMA_exportDBHeader($db) {
*/ */
function PMA_exportDBFooter($db) { function PMA_exportDBFooter($db) {
global $crlf; global $crlf;
global $what;
if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) { if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
return PMA_exportOutputHandler(' </database>' . $crlf); return PMA_exportOutputHandler(' </database>' . $crlf);
} }
else else
@@ -317,9 +314,8 @@ function PMA_exportDBCreate($db) {
* @access public * @access public
*/ */
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $what;
if (isset($GLOBALS[$what . '_export_contents']) && $GLOBALS[$what . '_export_contents']) { if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result); $columns_cnt = PMA_DBI_num_fields($result);