From c0ea9039d4fdfe14ced3db8700ecafbaec6186f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Tue, 9 Jan 2018 22:04:58 -0200 Subject: [PATCH 01/15] Use template for getOptionsForExportTemplates method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 33 +++++++++---------- .../display/export/template_options.twig | 7 ++++ 2 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 templates/display/export/template_options.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index ab53769201..0e96872b00 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -34,7 +34,7 @@ class Export * * @return string */ - public static function exportCheckboxCheck($str) + private static function exportCheckboxCheck($str) { if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) { return ' checked="checked"'; @@ -165,16 +165,14 @@ class Export } /** - * Returns HTML for the options in teplate dropdown + * Returns HTML for the options in template dropdown * - * @param string $export_type export type - server, database, or table + * @param string $exportType export type - server, database, or table * * @return string HTML for the options in teplate dropdown */ - public static function getOptionsForExportTemplates($export_type) + private static function getOptionsForExportTemplates($exportType) { - $ret = ''; - // Get the relation settings $cfgRelation = Relation::getRelationsParam(); @@ -183,24 +181,25 @@ class Export . Util::backquote($cfgRelation['export_templates']) . " WHERE `username` = " . "'" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) - . "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($export_type) . "'" + . "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($exportType) . "'" . " ORDER BY `template_name`;"; $result = Relation::queryAsControlUser($query); - if (!$result) { - return $ret; - } - while ($row = $GLOBALS['dbi']->fetchAssoc($result, DatabaseInterface::CONNECT_CONTROL)) { - $ret .= ''; } - return $ret; + return Template::get('display/export/template_options')->render([ + 'templates' => $templates, + 'selected_template' => !empty($_GET['template_id']) ? $_GET['template_id'] : null, + ]); } /** diff --git a/templates/display/export/template_options.twig b/templates/display/export/template_options.twig new file mode 100644 index 0000000000..ddcd4f5b55 --- /dev/null +++ b/templates/display/export/template_options.twig @@ -0,0 +1,7 @@ + + +{% for template in templates %} + +{% endfor %} From 0da1a53cf46ec0ca453034fdd27598ad3d4d0d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 00:33:09 -0200 Subject: [PATCH 02/15] Use template for getHtmlForExportOptionsMethod method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 42 ++++------------------------ templates/display/export/method.twig | 22 +++++++++++++++ 2 files changed, 27 insertions(+), 37 deletions(-) create mode 100644 templates/display/export/method.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 0e96872b00..d7d7b51cd8 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -211,46 +211,14 @@ class Export { global $cfg; if (isset($_GET['quick_or_custom'])) { - $export_method = $_GET['quick_or_custom']; + $exportMethod = $_GET['quick_or_custom']; } else { - $export_method = $cfg['Export']['method']; + $exportMethod = $cfg['Export']['method']; } - if ($export_method == 'custom-no-form') { - return ''; - } - - $html = '
'; - $html .= '

' . __('Export method:') . '

'; - $html .= '
    '; - $html .= '
  • '; - $html .= 'render([ + 'export_method' => $exportMethod, + ]); } /** diff --git a/templates/display/export/method.twig b/templates/display/export/method.twig new file mode 100644 index 0000000000..5521f5748d --- /dev/null +++ b/templates/display/export/method.twig @@ -0,0 +1,22 @@ +{% if export_method != 'custom-no-form' %} +
    +

    {% trans 'Export method:' %}

    +
      +
    • + + +
    • + +
    • + + +
    • +
    +
    +{% endif %} From b093d7caddf37c2c5b72cbb0485a356f89bc6909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 01:11:30 -0200 Subject: [PATCH 03/15] Use template for getHtmlForExportOptionsSelection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 22 +++++++--------------- templates/display/export/selection.twig | 10 ++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 templates/display/export/selection.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index d7d7b51cd8..2664f560b0 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -224,25 +224,17 @@ class Export /** * Prints Html For Export Options Selection * - * @param String $export_type Selected Export Type - * @param String $multi_values Export Options + * @param string $exportType Selected Export Type + * @param string $multiValues Export Options * * @return string */ - public static function getHtmlForExportOptionsSelection($export_type, $multi_values) + public static function getHtmlForExportOptionsSelection($exportType, $multiValues) { - $html = '
    '; - if ($export_type == 'server') { - $html .= '

    ' . __('Databases:') . '

    '; - } elseif ($export_type == 'database') { - $html .= '

    ' . __('Tables:') . '

    '; - } - if (! empty($multi_values)) { - $html .= $multi_values; - } - $html .= '
    '; - - return $html; + return Template::get('display/export/selection')->render([ + 'export_type' => $exportType, + 'multi_values' => $multiValues, + ]); } /** diff --git a/templates/display/export/selection.twig b/templates/display/export/selection.twig new file mode 100644 index 0000000000..6f691f5a36 --- /dev/null +++ b/templates/display/export/selection.twig @@ -0,0 +1,10 @@ +
    + {% if export_type == 'server' %} +

    {% trans 'Databases:' %}

    + {% elseif export_type == 'database' %} +

    {% trans 'Tables:' %}

    + {% endif %} + {% if multi_values is not empty %} + {{ multi_values|raw }} + {% endif %} +
    From b45deaeb4accc50567d7879f602e05163711b5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 10:45:27 -0200 Subject: [PATCH 04/15] Use template for getHtmlForExportOptionsFormatDropdown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 13 ++++++------- templates/display/export/format_dropdown.twig | 4 ++++ 2 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 templates/display/export/format_dropdown.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 2664f560b0..d7045b64a5 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -240,17 +240,16 @@ class Export /** * Prints Html For Export Options Format dropdown * - * @param ExportPlugin[] $export_list Export List + * @param ExportPlugin[] $exportList Export List * * @return string */ - public static function getHtmlForExportOptionsFormatDropdown($export_list) + public static function getHtmlForExportOptionsFormatDropdown($exportList) { - $html = '
    '; - $html .= '

    ' . __('Format:') . '

    '; - $html .= Plugins::getChoice('Export', 'what', $export_list, 'format'); - $html .= '
    '; - return $html; + $dropdown = Plugins::getChoice('Export', 'what', $exportList, 'format'); + return Template::get('display/export/format_dropdown')->render([ + 'dropdown' => $dropdown, + ]); } /** diff --git a/templates/display/export/format_dropdown.twig b/templates/display/export/format_dropdown.twig new file mode 100644 index 0000000000..adda19bac9 --- /dev/null +++ b/templates/display/export/format_dropdown.twig @@ -0,0 +1,4 @@ +
    +

    {% trans 'Format:' %}

    + {{ dropdown|raw }} +
    From 8ee32ab972aa5058d6e9b467858f0918a670a9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 14:12:55 -0200 Subject: [PATCH 05/15] Use template for getHtmlForExportOptionsFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 45 ++++---------------- templates/display/export/options_format.twig | 24 +++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 templates/display/export/options_format.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index d7045b64a5..3ac4e17048 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -255,49 +255,20 @@ class Export /** * Prints Html For Export Options Format-specific options * - * @param ExportPlugin[] $export_list Export List + * @param ExportPlugin[] $exportList Export List * * @return string */ - public static function getHtmlForExportOptionsFormat($export_list) + public static function getHtmlForExportOptionsFormat($exportList) { - $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 .= Plugins::getOptions('Export', $export_list); - $html .= '
    '; - - if (Encoding::canConvertKanji()) { - // Japanese encoding setting - $html .= '
    '; - $html .= '

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

    '; - $html .= Encoding::kanjiEncodingForm(); - $html .= '
    '; - } - - $html .= '
    '; - - $html .= Util::getExternalBug( - __('SQL compatibility mode'), 'mysql', '50027', '14515' - ); global $cfg; - if ($cfg['ExecTimeLimit'] > 0) { - $html .= ''; - } else { - // if the time limit set is zero, then time out won't occur - // So no need to check for time out. - $html .= ''; - } - $html .= '
    '; + $options = Plugins::getOptions('Export', $exportList); - return $html; + return Template::get('display/export/options_format')->render([ + 'options' => $options, + 'can_convert_kanji' => Encoding::canConvertKanji(), + 'exec_time_limit' => $cfg['ExecTimeLimit'], + ]); } /** diff --git a/templates/display/export/options_format.twig b/templates/display/export/options_format.twig new file mode 100644 index 0000000000..7cfbe13b3e --- /dev/null +++ b/templates/display/export/options_format.twig @@ -0,0 +1,24 @@ +
    +

    {% trans 'Format-specific options:' %}

    +

    + {% trans 'Scroll down to fill in the options for the selected format and ignore the options for other formats.' %} +

    + {{ options|raw }} +
    + +{% if can_convert_kanji %} + {# Japanese encoding setting #} +
    +

    {% trans 'Encoding Conversion:' %}

    + {% include 'encoding/kanji_encoding_form.twig' %} +
    +{% endif %} + +
    + 0 %} + onclick="check_time_out({{ exec_time_limit }})" + {%- endif %}> +
    From 083ae21f51295f1620ae194b2d8865922e0b0484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 15:09:48 -0200 Subject: [PATCH 06/15] Use template for getHtmlForExportOptionsRows method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 65 +++++----------------- templates/display/export/options_rows.twig | 35 ++++++++++++ 2 files changed, 49 insertions(+), 51 deletions(-) create mode 100644 templates/display/export/options_rows.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 3ac4e17048..b7b7889e1d 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -274,61 +274,24 @@ class Export /** * Prints Html For Export Options Rows * - * @param String $db Selected DB - * @param String $table Selected Table - * @param String $unlim_num_rows Num of Rows + * @param string $db Selected DB + * @param string $table Selected Table + * @param string $unlimNumRows Num of Rows * * @return string */ - public static function getHtmlForExportOptionsRows($db, $table, $unlim_num_rows) + public static function getHtmlForExportOptionsRows($db, $table, $unlimNumRows) { - $html = '
    '; - $html .= '

    ' . __('Rows:') . '

    '; - $html .= '
      '; - $html .= '
    • '; - $html .= ''; - $html .= '
        '; - $html .= '
      • '; - $html .= ''; - $html .= ''; - $html .= '
      • '; - $html .= '
      • '; - $html .= ''; - $html .= ''; - $html .= '
      • '; - $html .= '
      '; - $html .= '
    • '; - $html .= '
    • '; - $html .= ''; - $html .= '
    • '; - $html .= '
    '; - $html .= '
    '; - return $html; + $tableObject = new Table($table, $db); + $numberOfRows = $tableObject->countRecords(); + + return Template::get('display/export/options_rows')->render([ + 'allrows' => isset($_GET['allrows']) ? $_GET['allrows'] : null, + 'limit_to' => isset($_GET['limit_to']) ? $_GET['limit_to'] : null, + 'limit_from' => isset($_GET['limit_from']) ? $_GET['limit_from'] : null, + 'unlim_num_rows' => $unlimNumRows, + 'number_of_rows' => $numberOfRows, + ]); } /** diff --git a/templates/display/export/options_rows.twig b/templates/display/export/options_rows.twig new file mode 100644 index 0000000000..5a7e39ed4b --- /dev/null +++ b/templates/display/export/options_rows.twig @@ -0,0 +1,35 @@ +
    +

    {% trans 'Rows:' %}

    +
      +
    • + + +
        +
      • + + +
      • +
      • + + +
      • +
      +
    • +
    • + + +
    • +
    +
    From 0183003195598283f76c3bc9d92a76939f335ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 15:52:19 -0200 Subject: [PATCH 07/15] Use template for getHtmlForExportOptionsQuickExport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 37 ++++++------------- .../display/export/options_quick_export.twig | 20 ++++++++++ 2 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 templates/display/export/options_quick_export.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index b7b7889e1d..83b116e41d 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -302,34 +302,19 @@ class Export public static function getHtmlForExportOptionsQuickExport() { global $cfg; - $html = '
    '; - $html .= '

    ' . __('Output:') . '

    '; - $html .= '
      '; - $html .= '
    • '; - $html .= '%s'), - htmlspecialchars(Util::userDir($cfg['SaveDir'])) + $saveDir = Util::userDir($cfg['SaveDir']); + $exportIsChecked = (bool) self::exportCheckboxCheck( + 'quick_export_onserver' + ); + $exportOverwriteIsChecked = (bool) self::exportCheckboxCheck( + 'quick_export_onserver_overwrite' ); - $html .= ''; - $html .= '
    • '; - $html .= '
    • '; - $html .= 'render([ + 'save_dir' => $saveDir, + 'export_is_checked' => $exportIsChecked, + 'export_overwrite_is_checked' => $exportOverwriteIsChecked, + ]); } /** diff --git a/templates/display/export/options_quick_export.twig b/templates/display/export/options_quick_export.twig new file mode 100644 index 0000000000..b3bd159f35 --- /dev/null +++ b/templates/display/export/options_quick_export.twig @@ -0,0 +1,20 @@ +
      +

      {% trans 'Output:' %}

      +
        +
      • + + +
      • +
      • + + +
      • +
      +
      From 11c43ef9807c13dbc8176ebeccbf0532e4f149e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 17:30:00 -0200 Subject: [PATCH 08/15] Use template for getHtmlForExportOptionsOutputSaveDir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 32 +++++++------------ .../export/options_output_save_dir.twig | 15 +++++++++ test/classes/Display/ExportTest.php | 4 +-- 3 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 templates/display/export/options_output_save_dir.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 83b116e41d..6c7958edd5 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -325,29 +325,19 @@ class Export public static function getHtmlForExportOptionsOutputSaveDir() { global $cfg; - $html = '
    • '; - $html .= '%s'), - htmlspecialchars(Util::userDir($cfg['SaveDir'])) + $saveDir = Util::userDir($cfg['SaveDir']); + $exportIsChecked = (bool) self::exportCheckboxCheck( + 'onserver' + ); + $exportOverwriteIsChecked = (bool) self::exportCheckboxCheck( + 'onserver_overwrite' ); - $html .= ''; - $html .= '
    • '; - $html .= '
    • '; - $html .= 'render([ + 'save_dir' => $saveDir, + 'export_is_checked' => $exportIsChecked, + 'export_overwrite_is_checked' => $exportOverwriteIsChecked, + ]); } diff --git a/templates/display/export/options_output_save_dir.twig b/templates/display/export/options_output_save_dir.twig new file mode 100644 index 0000000000..b4526aa4bb --- /dev/null +++ b/templates/display/export/options_output_save_dir.twig @@ -0,0 +1,15 @@ +
    • + + +
    • +
    • + + +
    • diff --git a/test/classes/Display/ExportTest.php b/test/classes/Display/ExportTest.php index e98684dd04..012e1b3d2a 100644 --- a/test/classes/Display/ExportTest.php +++ b/test/classes/Display/ExportTest.php @@ -203,12 +203,12 @@ class ExportTest extends TestCase //validate 4: Export::getHtmlForExportOptionsQuickExport $this->assertContains( - 'assertContains( - 'Save on server in the directory ' . $dir . '', + 'Save on server in the directory ' . $dir . '', $html ); From bcb67cb15fd99ebab9ea7ebf88b0f04934d60478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 10 Jan 2018 20:47:53 -0200 Subject: [PATCH 09/15] Use template for getHtmlForExportOptionsOutputFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 66 +++++++------------ .../display/export/options_output_format.twig | 13 ++++ 2 files changed, 37 insertions(+), 42 deletions(-) create mode 100644 templates/display/export/options_output_format.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 6c7958edd5..7b4e1ce938 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -344,20 +344,17 @@ class Export /** * Prints Html For Export Options * - * @param String $export_type Selected Export Type + * @param string $exportType Selected Export Type * * @return string */ - public static function getHtmlForExportOptionsOutputFormat($export_type) + public static function getHtmlForExportOptionsOutputFormat($exportType) { - $html = '
    • '; - $html .= ''; - $html .= 'getUserValue( - 'pma_db_filename_template', - $GLOBALS['cfg']['Export']['file_template_database'] - ) + if ($exportType == 'database') { + $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue( + 'pma_db_filename_template', + $GLOBALS['cfg']['Export']['file_template_database'] ); - } elseif ($export_type == 'table') { - $html .= htmlspecialchars( - $GLOBALS['PMA_Config']->getUserValue( - 'pma_table_filename_template', - $GLOBALS['cfg']['Export']['file_template_table'] - ) + } elseif ($exportType == 'table') { + $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue( + 'pma_table_filename_template', + $GLOBALS['cfg']['Export']['file_template_table'] ); } else { - $html .= htmlspecialchars( - $GLOBALS['PMA_Config']->getUserValue( - 'pma_server_filename_template', - $GLOBALS['cfg']['Export']['file_template_server'] - ) + $filenameTemplate = $GLOBALS['PMA_Config']->getUserValue( + 'pma_server_filename_template', + $GLOBALS['cfg']['Export']['file_template_server'] ); } } - $html .= '"'; - $html .= '/>'; - $html .= 'render([ + 'message' => $msg->getMessage(), + 'filename_template' => $filenameTemplate, + 'is_checked' => (bool) self::exportCheckboxCheck('remember_file_template'), + ]); } /** diff --git a/templates/display/export/options_output_format.twig b/templates/display/export/options_output_format.twig new file mode 100644 index 0000000000..0039d87cd6 --- /dev/null +++ b/templates/display/export/options_output_format.twig @@ -0,0 +1,13 @@ +
    • + + + + +
    • From 16459bf343b5e4b985b61c69063bedfe41605fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 11 Jan 2018 15:08:46 -0200 Subject: [PATCH 10/15] Use template for getHtmlForExportOptionsOutputCharset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 22 ++++--------------- .../export/options_output_charset.twig | 16 ++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 templates/display/export/options_output_charset.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 7b4e1ce938..f0166fb7f1 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -415,25 +415,11 @@ class Export public static function getHtmlForExportOptionsOutputCharset() { global $cfg; - $html = '
    • ' . "\n"; - $html .= '
    • '; - return $html; + return Template::get('display/export/options_output_charset')->render([ + 'encodings' => Encoding::listEncodings(), + 'export_charset' => $cfg['Export']['charset'], + ]); } /** diff --git a/templates/display/export/options_output_charset.twig b/templates/display/export/options_output_charset.twig new file mode 100644 index 0000000000..bd316bf916 --- /dev/null +++ b/templates/display/export/options_output_charset.twig @@ -0,0 +1,16 @@ +
    • + + +
    • From 5b6bd8214511ce75aba4c65da8a8b7fe7c84c45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 11 Jan 2018 18:41:57 -0200 Subject: [PATCH 11/15] Use template for getHtmlForExportOptionsOutputCompression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 45 +++++-------------- .../export/options_output_compression.twig | 24 ++++++++++ 2 files changed, 35 insertions(+), 34 deletions(-) create mode 100644 templates/display/export/options_output_compression.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index f0166fb7f1..8d9e3cec2a 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -431,52 +431,29 @@ class Export { global $cfg; if (isset($_GET['compression'])) { - $selected_compression = $_GET['compression']; + $selectedCompression = $_GET['compression']; } elseif (isset($cfg['Export']['compression'])) { - $selected_compression = $cfg['Export']['compression']; + $selectedCompression = $cfg['Export']['compression']; } else { - $selected_compression = "none"; + $selectedCompression = 'none'; } // Since separate files export works with ZIP only if (isset($cfg['Export']['as_separate_files']) && $cfg['Export']['as_separate_files'] ) { - $selected_compression = "zip"; + $selectedCompression = 'zip'; } - $html = ""; // zip and gzip encode features - $is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress')); - $is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode')); - if ($is_zip || $is_gzip) { - $html .= '
    • '; - $html .= ''; - $html .= ''; - $html .= '
    • '; - } else { - $html .= ''; - } + $isZip = ($cfg['ZipDump'] && @function_exists('gzcompress')); + $isGzip = ($cfg['GZipDump'] && @function_exists('gzencode')); - return $html; + return Template::get('display/export/options_output_compression')->render([ + 'is_zip' => $isZip, + 'is_gzip' => $isGzip, + 'selected_compression' => $selectedCompression, + ]); } /** diff --git a/templates/display/export/options_output_compression.twig b/templates/display/export/options_output_compression.twig new file mode 100644 index 0000000000..19059811ca --- /dev/null +++ b/templates/display/export/options_output_compression.twig @@ -0,0 +1,24 @@ +{% if is_zip or is_gzip %} +
    • + + +
    • +{% else %} + +{% endif %} From ebb22f8600540f7120bca9f7db7259ebc0c583f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 12 Jan 2018 16:44:46 -0200 Subject: [PATCH 12/15] Use template for getHtmlForExportOptionsOutputRadio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 14 ++++---------- templates/display/export/options_output_radio.twig | 7 +++++++ 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 templates/display/export/options_output_radio.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 8d9e3cec2a..603fb1cd9e 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -463,16 +463,10 @@ class Export */ public static function getHtmlForExportOptionsOutputRadio() { - $html = '
    • '; - $html .= '
    • '; - return $html; + return Template::get('display/export/options_output_radio')->render([ + 'has_repopulate' => isset($_GET['repopulate']), + 'export_asfile' => $GLOBALS['cfg']['Export']['asfile'], + ]); } /** diff --git a/templates/display/export/options_output_radio.twig b/templates/display/export/options_output_radio.twig new file mode 100644 index 0000000000..7adf21eef2 --- /dev/null +++ b/templates/display/export/options_output_radio.twig @@ -0,0 +1,7 @@ +
    • + + +
    • From 31b7b9cc1454b43941a4b5bfa67784112ef5bb8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 12 Jan 2018 17:17:09 -0200 Subject: [PATCH 13/15] Use template for getHtmlForExportOptionsOutputSeparateFiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 23 ++++++------------- .../export/options_output_separate_files.twig | 12 ++++++++++ 2 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 templates/display/export/options_output_separate_files.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 603fb1cd9e..50b7db1cc1 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -472,27 +472,18 @@ class Export /** * Prints Html For Export Options Checkbox - Separate files * - * @param String $export_type Selected Export Type + * @param string $exportType Selected Export Type * * @return string */ - public static function getHtmlForExportOptionsOutputSeparateFiles($export_type) + public static function getHtmlForExportOptionsOutputSeparateFiles($exportType) { - $html = '
    • '; - $html .= ''; - $html .= '
    • '; - - return $html; + return Template::get('display/export/options_output_separate_files')->render([ + 'is_checked' => $isChecked, + 'export_type' => $exportType, + ]); } /** diff --git a/templates/display/export/options_output_separate_files.twig b/templates/display/export/options_output_separate_files.twig new file mode 100644 index 0000000000..fec85c4de5 --- /dev/null +++ b/templates/display/export/options_output_separate_files.twig @@ -0,0 +1,12 @@ +
    • + + +
    • From 81864e549eb359cfea3a28ed2e244ef4b8ba59a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Fri, 12 Jan 2018 20:13:08 -0200 Subject: [PATCH 14/15] Use template for getHtmlForExportOptionsOutput MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 106 +++++++------------ templates/display/export/options_output.twig | 54 ++++++++++ 2 files changed, 90 insertions(+), 70 deletions(-) create mode 100644 templates/display/export/options_output.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 50b7db1cc1..b1f2293f03 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -489,89 +489,55 @@ class Export /** * Prints Html For Export Options * - * @param String $export_type Selected Export Type + * @param string $exportType Selected Export Type * * @return string */ - public static function getHtmlForExportOptionsOutput($export_type) + public static function getHtmlForExportOptionsOutput($exportType) { global $cfg; - $html = '
      '; - $html .= '

      ' . __('Output:') . '

      '; - $html .= '
        '; - $html .= '
      • '; - } elseif (isset($_GET['lock_tables'])) { - $html .= ' checked="checked"'; - } - $html .= '
      • '; - } + $isCheckedLockTables = (bool) self::exportCheckboxCheck('lock_tables'); + $isCheckedAsfile = (bool) self::exportCheckboxCheck('asfile'); - $html .= '
      • '; - $html .= ''; - $html .= '
          '; + $optionsOutputSaveDir = ''; if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) { - $html .= self::getHtmlForExportOptionsOutputSaveDir(); + $optionsOutputSaveDir = self::getHtmlForExportOptionsOutputSaveDir(); } - - $html .= self::getHtmlForExportOptionsOutputFormat($export_type); - - // charset of file + $optionsOutputFormat = self::getHtmlForExportOptionsOutputFormat($exportType); + $optionsOutputCharset = ''; if (Encoding::isSupported()) { - $html .= self::getHtmlForExportOptionsOutputCharset(); - } // end if - - $html .= self::getHtmlForExportOptionsOutputCompression(); - - if ($export_type == 'server' - || $export_type == 'database' - ) { - $html .= self::getHtmlForExportOptionsOutputSeparateFiles($export_type); + $optionsOutputCharset = self::getHtmlForExportOptionsOutputCharset(); } + $optionsOutputCompression = self::getHtmlForExportOptionsOutputCompression(); + $optionsOutputSeparateFiles = ''; + if ($exportType == 'server' || $exportType == 'database') { + $optionsOutputSeparateFiles = self::getHtmlForExportOptionsOutputSeparateFiles( + $exportType + ); + } + $optionsOutputRadio = self::getHtmlForExportOptionsOutputRadio(); - $html .= '
        '; - $html .= '
      • '; - - $html .= self::getHtmlForExportOptionsOutputRadio(); - - $html .= '
      '; - - /* - * @todo use sprintf() for better translatability, while keeping the - * principle (for screen readers) - */ - $html .= ''; - $html .= '' . __('MiB'); - - $html .= '
      '; - - return $html; + return Template::get('display/export/options_output')->render([ + 'has_aliases' => $hasAliases, + 'export_type' => $exportType, + 'is_checked_lock_tables' => $isCheckedLockTables, + 'is_checked_asfile' => $isCheckedAsfile, + 'repopulate' => isset($_GET['repopulate']), + 'lock_tables' => isset($_GET['lock_tables']), + 'save_dir' => isset($cfg['SaveDir']) ? $cfg['SaveDir'] : null, + 'is_encoding_supported' => Encoding::isSupported(), + 'options_output_save_dir' => $optionsOutputSaveDir, + 'options_output_format' => $optionsOutputFormat, + 'options_output_charset' => $optionsOutputCharset, + 'options_output_compression' => $optionsOutputCompression, + 'options_output_separate_files' => $optionsOutputSeparateFiles, + 'options_output_radio' => $optionsOutputRadio, + ]); } /** diff --git a/templates/display/export/options_output.twig b/templates/display/export/options_output.twig new file mode 100644 index 0000000000..60d721ca02 --- /dev/null +++ b/templates/display/export/options_output.twig @@ -0,0 +1,54 @@ +
      +

      {% trans 'Output:' %}

      +
        +
      • + + +
      • + + {% if export_type != 'server' %} +
      • + + +
      • + {% endif %} + +
      • + + +
          + {% if save_dir is not empty %} + {{ options_output_save_dir|raw }} + {% endif %} + + {{ options_output_format|raw }} + + {% if is_encoding_supported %} + {{ options_output_charset|raw }} + {% endif %} + + {{ options_output_compression|raw }} + + {% if export_type == 'server' or export_type == 'database' %} + {{ options_output_separate_files|raw }} + {% endif %} +
        +
      • + + {{ options_output_radio|raw }} +
      + + ' + )|raw }} +
      From 0a933ca060dfff07213cdef1b0f2c68d3ed06df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sat, 13 Jan 2018 00:19:42 -0200 Subject: [PATCH 15/15] Refactor exportCheckboxCheck method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurício Meneghini Fauth --- libraries/classes/Display/Export.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index b1f2293f03..ecd6420e5c 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -32,15 +32,12 @@ class Export * * @param string $str option name * - * @return string + * @return boolean */ - private static function exportCheckboxCheck($str) + private static function checkboxCheck($str) { - if (isset($GLOBALS['cfg']['Export'][$str]) && $GLOBALS['cfg']['Export'][$str]) { - return ' checked="checked"'; - } - - return null; + return isset($GLOBALS['cfg']['Export'][$str]) + && $GLOBALS['cfg']['Export'][$str]; } /** @@ -303,10 +300,10 @@ class Export { global $cfg; $saveDir = Util::userDir($cfg['SaveDir']); - $exportIsChecked = (bool) self::exportCheckboxCheck( + $exportIsChecked = self::checkboxCheck( 'quick_export_onserver' ); - $exportOverwriteIsChecked = (bool) self::exportCheckboxCheck( + $exportOverwriteIsChecked = self::checkboxCheck( 'quick_export_onserver_overwrite' ); @@ -326,10 +323,10 @@ class Export { global $cfg; $saveDir = Util::userDir($cfg['SaveDir']); - $exportIsChecked = (bool) self::exportCheckboxCheck( + $exportIsChecked = self::checkboxCheck( 'onserver' ); - $exportOverwriteIsChecked = (bool) self::exportCheckboxCheck( + $exportOverwriteIsChecked = self::checkboxCheck( 'onserver_overwrite' ); @@ -403,7 +400,7 @@ class Export return Template::get('display/export/options_output_format')->render([ 'message' => $msg->getMessage(), 'filename_template' => $filenameTemplate, - 'is_checked' => (bool) self::exportCheckboxCheck('remember_file_template'), + 'is_checked' => self::checkboxCheck('remember_file_template'), ]); } @@ -478,7 +475,7 @@ class Export */ public static function getHtmlForExportOptionsOutputSeparateFiles($exportType) { - $isChecked = (bool) self::exportCheckboxCheck('as_separate_files'); + $isChecked = self::checkboxCheck('as_separate_files'); return Template::get('display/export/options_output_separate_files')->render([ 'is_checked' => $isChecked, @@ -501,8 +498,8 @@ class Export && !Core::emptyRecursive($_SESSION['tmpval']['aliases']); unset($_SESSION['tmpval']['aliases']); - $isCheckedLockTables = (bool) self::exportCheckboxCheck('lock_tables'); - $isCheckedAsfile = (bool) self::exportCheckboxCheck('asfile'); + $isCheckedLockTables = self::checkboxCheck('lock_tables'); + $isCheckedAsfile = self::checkboxCheck('asfile'); $optionsOutputSaveDir = ''; if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {