From 99506813b62354b77a2bfd3f1e217b3dfd92ebb8 Mon Sep 17 00:00:00 2001 From: Leonardo Strozzi Date: Mon, 18 Jun 2018 21:55:18 -0300 Subject: [PATCH] Refactor db search templates Signed-off-by: Leonardo Strozzi --- db_search.php | 8 +------- libraries/classes/Database/Search.php | 14 ++------------ .../search/{selection_form.twig => main.twig} | 16 ++++++++++++++++ templates/database/search/result_divs.twig | 13 ------------- templates/database/search/results.twig | 8 ++++---- 5 files changed, 23 insertions(+), 36 deletions(-) rename templates/database/search/{selection_form.twig => main.twig} (79%) delete mode 100644 templates/database/search/result_divs.twig diff --git a/db_search.php b/db_search.php index ed5c4e18d4..56777e7a6b 100644 --- a/db_search.php +++ b/db_search.php @@ -68,10 +68,4 @@ if ($response->isAjax() && empty($_REQUEST['ajax_page_request'])) { } // Display the search form -$response->addHTML($db_search->getSelectionForm()); -$response->addHTML('
'); -$response->addHTML( - '
' -); -$response->addHTML('
'); -$response->addHTML($db_search->getResultDivs()); +$response->addHTML($db_search->getMainHtml()); diff --git a/libraries/classes/Database/Search.php b/libraries/classes/Database/Search.php index 6cba4788a6..e6dfd32a44 100644 --- a/libraries/classes/Database/Search.php +++ b/libraries/classes/Database/Search.php @@ -317,7 +317,7 @@ class Search * * @return string HTML for selection form */ - public function getSelectionForm() + public function getMainHtml() { $choices = [ '1' => $this->searchTypes[1] . ' ' @@ -332,7 +332,7 @@ class Search '4' => $this->searchTypes[4], '5' => $this->searchTypes[5] . ' ' . Util::showMySQLDocu('Regexp') ]; - return $this->template->render('database/search/selection_form', [ + return $this->template->render('database/search/main', [ 'db' => $this->db, 'choices' => $choices, 'criteria_search_string' => $this->criteriaSearchString, @@ -343,14 +343,4 @@ class Search ? $this->criteriaColumnName : null, ]); } - - /** - * Provides div tags for browsing search results and sql query form. - * - * @return string div tags - */ - public function getResultDivs() - { - return $this->template->render('database/search/result_divs'); - } } diff --git a/templates/database/search/selection_form.twig b/templates/database/search/main.twig similarity index 79% rename from templates/database/search/selection_form.twig rename to templates/database/search/main.twig index 2a7ed8b4af..11b5c061b6 100644 --- a/templates/database/search/selection_form.twig +++ b/templates/database/search/main.twig @@ -61,3 +61,19 @@
+
+
+
+{# These two table-image and table-link elements display the table name in browse search results #} +
+ +
+{# Div for browsing results #} +
+ {# This browse-results div is used to load the browse and delete results in the db search #} +
+
+ {# This sqlqueryform div is used to load the delete form in the db search #} +
+{# Toggle query box link #} + diff --git a/templates/database/search/result_divs.twig b/templates/database/search/result_divs.twig deleted file mode 100644 index 9f5f19ffdd..0000000000 --- a/templates/database/search/result_divs.twig +++ /dev/null @@ -1,13 +0,0 @@ -{# These two table-image and table-link elements display the table name in browse search results #} -
- -
-{# Div for browsing results #} -
- {# This browse-results div is used to load the browse and delete results in the db search #} -
-
- {# This sqlqueryform div is used to load the delete form in the db search #} -
-{# Toggle query box link #} - diff --git a/templates/database/search/results.twig b/templates/database/search/results.twig index efe5529615..07bdaebc53 100644 --- a/templates/database/search/results.twig +++ b/templates/database/search/results.twig @@ -1,9 +1,9 @@ {% for row in rows %} @@ -15,7 +15,7 @@ %1$s matches in %2$s {% endtrans %} {% endset %} - {{ result_message|format(row.result_count, row.table)|raw }} + {{ result_message | format(row.result_count, row.table) | raw }} {% if row.result_count > 0 %} {% set url_params = { @@ -51,7 +51,7 @@ {% endfor %}
- {{ 'Search results for "%s" %s:'|format( + {{ 'Search results for "%s" %s:' | format( criteria_search_string, search_type_description - )|raw }} + ) | raw }}
-{% if criteria_tables|length > 1 %} +{% if criteria_tables | length > 1 %}

{% trans %} Total: {{ count }} match