From 47ff2312377b05c8c10be78b344ac92b602e3f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 7 Jan 2018 16:34:24 -0200 Subject: [PATCH 1/4] Use template for getHtmlForExportSelectOptions 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 | 59 +++++++------------- templates/display/export/select_options.twig | 19 +++++++ 2 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 templates/display/export/select_options.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 90662fd54b..c02dab0f5c 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -46,28 +46,12 @@ class Export /** * Prints Html For Export Selection Options * - * @param String $tmp_select Tmp selected method of export + * @param string $tmpSelect Tmp selected method of export * * @return string */ - public static function getHtmlForExportSelectOptions($tmp_select = '') + public static function getHtmlForExportSelectOptions($tmpSelect = '') { - $multi_values = '
'; - $multi_values .= ''; - $multi_values .= __('Select all'); - $multi_values .= ''; - $multi_values .= ' / '; - $multi_values .= ''; - $multi_values .= __('Unselect all') . '
'; - - $multi_values .= '
'; + $databases[] = [ + 'name' => $currentDb, + 'is_selected' => $isSelected, + ]; + } - return $multi_values; + return Template::get('display/export/select_options')->render([ + 'databases' => $databases, + ]); } /** diff --git a/templates/display/export/select_options.twig b/templates/display/export/select_options.twig new file mode 100644 index 0000000000..7b153a3d4e --- /dev/null +++ b/templates/display/export/select_options.twig @@ -0,0 +1,19 @@ +
+

+ + {% trans 'Select all' %} + + / + + {% trans 'Unselect all' %} + +

+ + +
From 0fa3dd73665c5de27c33a261a3ebd21d9e22bd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 7 Jan 2018 17:11:11 -0200 Subject: [PATCH 2/4] Use template for getHtmlForHiddenInput 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 | 62 +++++++-------------- templates/display/export/hidden_inputs.twig | 23 ++++++++ 2 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 templates/display/export/hidden_inputs.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index c02dab0f5c..5a5e44bf2d 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -93,37 +93,22 @@ class Export /** * Prints Html For Export Hidden Input * - * @param String $export_type Selected Export Type - * @param String $db Selected DB - * @param String $table Selected Table - * @param String $single_table Single Table - * @param String $sql_query Sql Query + * @param string $exportType Selected Export Type + * @param string $db Selected DB + * @param string $table Selected Table + * @param string $singleTable Single Table + * @param string $sqlQuery SQL Query * * @return string */ public static function getHtmlForHiddenInput( - $export_type, $db, $table, $single_table, $sql_query + $exportType, + $db, + $table, + $singleTable, + $sqlQuery ) { global $cfg; - $html = ""; - if ($export_type == 'server') { - $html .= Url::getHiddenInputs('', '', 1); - } elseif ($export_type == 'database') { - $html .= Url::getHiddenInputs($db, '', 1); - } else { - $html .= Url::getHiddenInputs($db, $table, 1); - } - - // just to keep this value for possible next display of this form after saving - // on server - if (!empty($single_table)) { - $html .= '' - . "\n"; - } - - $html .= ''; - $html .= "\n"; // If the export method was not set, the default is quick if (isset($_GET['export_method'])) { @@ -131,25 +116,20 @@ class Export } elseif (! isset($cfg['Export']['method'])) { $cfg['Export']['method'] = 'quick'; } - // The export method (quick, custom or custom-no-form) - $html .= ''; - if (! empty($sql_query)) { - $html .= '' . "\n"; - } elseif (isset($_GET['sql_query'])) { - $html .= '' . "\n"; + if (empty($sqlQuery) && isset($_GET['sql_query'])) { + $sqlQuery = $_GET['sql_query']; } - $html .= ''; - - return $html; + return Template::get('display/export/hidden_inputs')->render([ + 'db' => $db, + 'table' => $table, + 'export_type' => $exportType, + 'export_method' => $cfg['Export']['method'], + 'single_table' => $singleTable, + 'sql_query' => $sqlQuery, + 'template_id' => isset($_GET['template_id']) ? $_GET['template_id'] : '', + ]); } /** diff --git a/templates/display/export/hidden_inputs.twig b/templates/display/export/hidden_inputs.twig new file mode 100644 index 0000000000..fa01a18759 --- /dev/null +++ b/templates/display/export/hidden_inputs.twig @@ -0,0 +1,23 @@ +{% if export_type == 'server' %} + {{ Url_getHiddenInputs('', '', 1) }} +{% elseif export_type == 'database' %} + {{ Url_getHiddenInputs(db, '', 1) }} +{% else %} + {{ Url_getHiddenInputs(db, table, 1) }} +{% endif %} + +{# Just to keep this value for possible next display of this form after saving on server #} +{% if single_table is not empty %} + +{% endif %} + + + +{# The export method (quick, custom or custom-no-form) #} + + +{% if sql_query is not empty %} + +{% endif %} + + From 0cefaca34159b6201376d97e814f610911900ab5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 7 Jan 2018 17:22:44 -0200 Subject: [PATCH 3/4] Use template for getHtmlForExportOptionHeader 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 | 35 ++++++--------------- templates/display/export/option_header.twig | 12 +++++++ 2 files changed, 22 insertions(+), 25 deletions(-) create mode 100644 templates/display/export/option_header.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 5a5e44bf2d..d799899491 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -135,34 +135,19 @@ class Export /** * Prints Html For Export Options Header * - * @param String $export_type Selected Export Type - * @param String $db Selected DB - * @param String $table Selected Table + * @param string $exportType Selected Export Type + * @param string $db Selected DB + * @param string $table Selected Table * - * @return string + * @return string HTML */ - public static function getHtmlForExportOptionHeader($export_type, $db, $table) + public static function getHtmlForExportOptionHeader($exportType, $db, $table) { - $html = ''; - - return $html; + return Template::get('display/export/option_header')->render([ + 'export_type' => $exportType, + 'db' => $db, + 'table' => $table, + ]); } /** diff --git a/templates/display/export/option_header.twig b/templates/display/export/option_header.twig new file mode 100644 index 0000000000..074586a7ba --- /dev/null +++ b/templates/display/export/option_header.twig @@ -0,0 +1,12 @@ + From d87245e8d462424dd3d1dccebff384faea057bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Sun, 7 Jan 2018 18:01:46 -0200 Subject: [PATCH 4/4] Use template for getHtmlForExportTemplateLoading 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 +++---------------- .../display/export/template_loading.twig | 27 ++++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-) create mode 100644 templates/display/export/template_loading.twig diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index d799899491..ab53769201 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -153,47 +153,15 @@ class Export /** * Returns HTML for export template operations * - * @param string $export_type export type - server, database, or table + * @param string $exportType export type - server, database, or table * * @return string HTML for export template operations */ - public static function getHtmlForExportTemplateLoading($export_type) + public static function getHtmlForExportTemplateLoading($exportType) { - $html = '
'; - $html .= '

' . __('Export templates:') . '

'; - - $html .= '
'; - $html .= '
'; - $html .= '

' . __('New template:') . '

'; - $html .= ''; - $html .= ''; - $html .= '
'; - $html .= '
'; - - $html .= '
'; - $html .= '
'; - $html .= '

' . __('Existing templates:') . '

'; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= '
'; - $html .= '
'; - - $html .= '
'; - - $html .= '
'; - - return $html; + return Template::get('display/export/template_loading')->render([ + 'options' => self::getOptionsForExportTemplates($exportType), + ]); } /** diff --git a/templates/display/export/template_loading.twig b/templates/display/export/template_loading.twig new file mode 100644 index 0000000000..e1f57d83e2 --- /dev/null +++ b/templates/display/export/template_loading.twig @@ -0,0 +1,27 @@ +
+

{% trans 'Export templates:' %}

+ +
+
+

{% trans 'New template:' %}

+ + +
+
+ +
+
+

{% trans 'Existing templates:' %}

+ + + + +
+
+ +
+