From d81ebdb847755459157939c2b73bf251b8b6b5dc Mon Sep 17 00:00:00 2001 From: xmujay Date: Sun, 14 Apr 2013 23:05:18 +0800 Subject: [PATCH] refactor display_export.lib.php --- libraries/display_export.lib.php | 409 ++++++++++++++++--------------- 1 file changed, 209 insertions(+), 200 deletions(-) diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index ae236dbe15..84e210665c 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -29,7 +29,7 @@ require_once './libraries/plugin_interface.lib.php'; function PMA_exportCheckboxCheck($str) { if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) { - echo ' checked="checked"'; + return ' checked="checked"'; } } @@ -51,24 +51,28 @@ if (empty($export_list)) { exit; } -echo '
'; +$html = ""; +$html .= ''; if ($export_type == 'server') { - echo PMA_generate_common_hidden_inputs('', '', 1); + $html .= PMA_generate_common_hidden_inputs('', '', 1); } elseif ($export_type == 'database') { - echo PMA_generate_common_hidden_inputs($db, '', 1); + $html .= PMA_generate_common_hidden_inputs($db, '', 1); } else { - echo PMA_generate_common_hidden_inputs($db, $table, 1); + $html .= PMA_generate_common_hidden_inputs($db, $table, 1); } // just to keep this value for possible next display of this form after saving // on server if (isset($single_table)) { - echo '' . "\n"; + $html .= '' + . "\n"; } -echo ''; -echo "\n"; +$html .= ''; +$html .= "\n"; // If the export method was not set, the default is quick if (isset($_GET['export_method'])) { @@ -77,30 +81,30 @@ if (isset($_GET['export_method'])) { $cfg['Export']['method'] = 'quick'; } // The export method (quick, custom or custom-no-form) -echo ''; if (isset($_GET['sql_query'])) { - echo '' . "\n"; } elseif (! empty($sql_query)) { - echo '' . "\n"; } -echo ''; if (isset($_GET['quick_or_custom'])) { $export_method = $_GET['quick_or_custom']; @@ -108,162 +112,163 @@ if (isset($_GET['quick_or_custom'])) { $export_method = $cfg['Export']['method']; } -echo '
'; -echo '

' . __('Export Method:') . '

'; -echo '
    '; -echo '
  • '; -echo ''; +$html .= '
      '; +$html .= '
    • '; +$html .= ''; -echo ''; -echo '
    • '; +$html .= ' />'; +$html .= ''; +$html .= ''; -echo '
    • '; -echo ''; -echo ''; -echo '
    • '; +$html .= ' />'; +$html .= ''; +$html .= ''; -echo '
    '; -echo '
'; +$html .= ''; +$html .= ''; -echo '
'; +$html .= '
'; if ($export_type == 'server') { - echo '

' . __('Database(s):') . '

'; + $html .= '

' . __('Database(s):') . '

'; } else if ($export_type == 'database') { - echo '

' . __('Table(s):') . '

'; + $html .= '

' . __('Table(s):') . '

'; } if (! empty($multi_values)) { - echo $multi_values; + $html .= $multi_values; } -echo '
'; +$html .= '
'; if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table)) { - echo '
'; - echo '

' . __('Rows:') . '

'; - echo '
    '; - echo '
  • '; - echo ''; + $html .= '
      '; + $html .= '
    • '; + $html .= ''; - echo ''; - echo '
        '; - echo '
      • '; - echo ''; - echo '' . __('Dump some row(s)') . ''; + $html .= '
          '; + $html .= '
        • '; + $html .= ''; + $html .= ''; - echo '
        • '; - echo '
        • '; - echo ''; - echo ''; + $html .= '
        • '; + $html .= '
        • '; + $html .= ''; + $html .= ''; - echo '
        • '; - echo '
        '; - echo '
      • '; - echo '
      • '; - echo ''; - echo ' '; - echo '
      • '; - echo '
      '; - echo '
'; + $html .= '/>'; + $html .= ' '; + $html .= ''; + $html .= ''; + $html .= ''; } if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { - echo '
'; - echo '

' . __('Output:') . '

'; - echo '
    '; - echo '
  • '; - echo ''; - echo ''; + $html .= '
  • '; + $html .= '
  • '; + $html .= ''; -echo '

    ' . __('Output:') . '

    '; -echo '
      '; -echo '
    • '; -echo ''; +$html .= '
        '; +$html .= '
      • '; +$html .= ''; -echo ''; -echo '
          '; +$html .= '/>'; +$html .= ''; +$html .= '
            '; if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { - echo '
          • '; - echo ''; - echo '
          • '; + $html .= '%s'), htmlspecialchars(PMA_Util::userDir($cfg['SaveDir'])) ); - echo ''; - echo '
          • '; - echo '
          • '; - echo ''; - echo ''; - echo '
          • '; + $html .= ''; + $html .= ''; + $html .= '
          • '; + $html .= ''; -echo '
          • '; +$html .= ''; -echo 'getUserValue( 'pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database'] ) ); } elseif ($export_type == 'table') { - echo htmlspecialchars( + $html .= htmlspecialchars( $GLOBALS['PMA_Config']->getUserValue( 'pma_table_filename_template', $GLOBALS['cfg']['Export']['file_template_table'] ) ); } else { - echo htmlspecialchars( + $html .= htmlspecialchars( $GLOBALS['PMA_Config']->getUserValue( 'pma_server_filename_template', $GLOBALS['cfg']['Export']['file_template_server'] @@ -320,36 +325,36 @@ if (isset($_GET['filename_template'])) { ); } } -echo '"'; -echo '/>'; -echo ''; -echo ''; -echo '
          • '; +$html .= '"'; +$html .= '/>'; +$html .= '
          '; -echo ''; -echo '
        • '; -echo ''; -echo '
        • '; -echo '
        '; -echo '
'; +$html .= ''; +$html .= ''; -echo '
'; -echo '

' . __('Format:') . '

'; -echo PMA_pluginGetChoice('Export', 'what', $export_list, 'format'); -echo '
'; +$html .= '
'; +$html .= '

' . __('Format:') . '

'; +$html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format'); +$html .= '
'; -echo '
'; -echo '

' . __('Format-specific options:') . '

'; -echo '

'; -echo __('Scroll down to fill in the options for the selected format and ignore the options for other formats.'); -echo '

'; -echo PMA_pluginGetOptions('Export', $export_list); -echo '
'; +$html .= '
'; +$html .= '

' . __('Format-specific options:') . '

'; +$html .= '

'; +$html .= __('Scroll down to fill in the options for the selected format and ignore the options for other formats.'); +$html .= '

'; +$html .= PMA_pluginGetOptions('Export', $export_list); +$html .= '
'; if (function_exists('PMA_set_enc_form')) { // Encoding setting form appended by Y.Kawada // Japanese encoding setting - echo '
'; - echo '

' . __('Encoding Conversion:') . '

'; - echo PMA_set_enc_form(' '); - echo '
'; + $html .= '
'; + $html .= '

' . __('Encoding Conversion:') . '

'; + $html .= PMA_set_enc_form(' '); + $html .= '
'; } -echo '
'; +$html .= '
'; -echo PMA_Util::getExternalBug( +$html .= PMA_Util::getExternalBug( __('SQL compatibility mode'), 'mysql', '50027', '14515' ); -echo ''; -echo '
'; -echo ''; +$html .= ''; +$html .= '
'; +$html .= ''; + +$response = PMA_Response::getInstance(); +$response->addHTML($html);