From c82669ba57501e15e26cb6bed3fe4e2f4c38ef02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Mon, 13 Nov 2017 15:57:13 -0200 Subject: [PATCH] Use template for getColumnsHTML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .../classes/Database/MultiTableQuery.php | 45 +++---------------- .../database/multi_table_query/columns.twig | 34 ++++++++++++++ 2 files changed, 40 insertions(+), 39 deletions(-) create mode 100644 templates/database/multi_table_query/columns.twig diff --git a/libraries/classes/Database/MultiTableQuery.php b/libraries/classes/Database/MultiTableQuery.php index f52c3af33b..9259116207 100644 --- a/libraries/classes/Database/MultiTableQuery.php +++ b/libraries/classes/Database/MultiTableQuery.php @@ -42,45 +42,12 @@ class MultiTableQuery private function getColumnsHTML() { $tables = $GLOBALS['dbi']->getTables($this->_db); - $html_output = '
'; - for ($i = 0; $i < count($tables); $i++) - { - $html_output .= ''; - } - - $html_output .= ''; - - for ($i = 1; $i <= $this->_default_no_of_columns; $i++) - { - $html_output .= Template::get('database/multi_table_query/new_column')->render(array( - 'id' => $i, - 'tables' => $tables - )); - } - $html_output .= '
'; - $html_output .= ''; - $html_output .= '
 '; - $html_output .= '
'; - - $html_output .= '
'; - $html_output .= ''; - $html_output .= '
'; - - $html_output .= '
'; - - return $html_output; + return Template::get('database/multi_table_query/columns')->render([ + 'tables' => $tables, + 'dbi' => $GLOBALS['dbi'], + 'db' => $this->_db, + 'default_no_of_columns' => $this->_default_no_of_columns, + ]); } public function getFormHTML() diff --git a/templates/database/multi_table_query/columns.twig b/templates/database/multi_table_query/columns.twig new file mode 100644 index 0000000000..c17c4114ea --- /dev/null +++ b/templates/database/multi_table_query/columns.twig @@ -0,0 +1,34 @@ +
+ {% set tables_count = tables|length - 1 %} + {% for i in 0..tables_count %} + + {% endfor %} + + + + {% for i in 1..default_no_of_columns %} + {% include 'database/multi_table_query/new_column.twig' with { + 'id': i, + 'tables': tables + } only %} + {% endfor %} +
+ +
  +
+ +
+ +
+