diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index 90662fd54b..ab53769201 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, + ]); } /** * 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'])) { @@ -148,104 +116,52 @@ 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'] : '', + ]); } /** * 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, + ]); } /** * 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/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 %} + + 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 @@ + 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' %} + +

+ + +
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:' %}

+ + + + +
+
+ +
+