First pass search for searchSources tabs, a=chris

Chris Pollett [2019-11-28 04:Nov:th]
First pass search for searchSources tabs, a=chris
Filename
src/configs/PublicHelpPages.php
src/controllers/AdminController.php
src/controllers/Controller.php
src/controllers/components/CrawlComponent.php
src/data/public_default.db
src/locale/ar/configure.ini
src/locale/bn/configure.ini
src/locale/de/configure.ini
src/locale/en_US/configure.ini
src/locale/es/configure.ini
src/locale/fa/configure.ini
src/locale/fr_FR/configure.ini
src/locale/he/configure.ini
src/locale/hi/configure.ini
src/locale/in_ID/configure.ini
src/locale/it/configure.ini
src/locale/ja/configure.ini
src/locale/kn/configure.ini
src/locale/ko/configure.ini
src/locale/nl/configure.ini
src/locale/pl/configure.ini
src/locale/pt/configure.ini
src/locale/ru/configure.ini
src/locale/te/configure.ini
src/locale/th/configure.ini
src/locale/tr/configure.ini
src/locale/vi_VN/configure.ini
src/locale/zh_CN/configure.ini
src/models/Model.php
src/views/elements/SearchsourcesElement.php
src/views/helpers/PagingtableHelper.php
src/views/helpers/SearchformHelper.php
diff --git a/src/configs/PublicHelpPages.php b/src/configs/PublicHelpPages.php
index 244db13ed..6a59614c6 100644
--- a/src/configs/PublicHelpPages.php
+++ b/src/configs/PublicHelpPages.php
@@ -1719,7 +1719,25 @@ page_footer=

 sort=aname

-END_HEAD_VARSThis pane is used to edit how a url is displayed in search results. To edit a url give the full url (including  http:// or  https://) in the Url field and click the Load button. This will take you to a screen where you can see and change how that url is currently edited, or if the URL has never been edited, it will allow you to edit it. On this page, you will see an Action drop down with two choice: '''Filter Host''' and '''Edit Search Results'''. The former will remove any url with the same hostname as the input url from the search results. For example, if one loaded the url: http://a.com/b/c, then filtering it would add an entry for the host http://a.com/ into the results to be filtered. Anytime, when a url with this host would have appeared in search results, it will be removed. Selecting '''Edit Search Results''' option will reveal Title and Description fields in which a user can enter the title text and snippet descriptions they would like to have when the URL is displayed in search results. This does not usually filter results from search, but instead just changes them. However, if one wants to filter a single URL rather than a host name one can select the '''Edit Search Results''' option and leave both fields blank and click Save.
+END_HEAD_VARSThis pane is used to edit how a url is displayed in search results.
+
+<br><br>
+
+To edit a url give the full url (including  http:// or  https://) in the Url field and click the Load button. This will take you to a screen where you can see and change how that url is currently edited, or if the URL has never been edited, it will allow you to edit it.
+
+<br>
+
+On this page, you will see an Action drop down with two choices:
+* '''Filter Host'''
+* '''Edit Search Results'''
+
+<br>
+
+'''Filter Host''' will remove any url with the same hostname as the input url from the search results. For example, if one loaded the url: http://a.com/b/c, then filtering it would add an entry for the host http://a.com/ into the results to be filtered. Anytime, when a url with this host would have appeared in search results, it will be removed.
+
+<br>
+
+'''Edit Search Results''' option will reveal Title and Description fields in which a user can enter the title text and snippet descriptions they would like to have when the URL is displayed in search results. This does not usually filter results from search, but instead just changes them. However, if one wants to filter a single URL rather than a host name one can select the '''Edit Search Results''' option and leave both fields blank and click Save.
 EOD;
 $help_pages["en-US"]["Editing_Locales"] = <<< EOD
 page_type=standard
diff --git a/src/controllers/AdminController.php b/src/controllers/AdminController.php
index faa0147af..3fc14228c 100755
--- a/src/controllers/AdminController.php
+++ b/src/controllers/AdminController.php
@@ -645,7 +645,7 @@ class AdminController extends Controller implements CrawlConstants
         $between_fields = array_merge($between_comparison_fields,
             $timestamp_comparison_fields);
         foreach ($comparisons_all as $comparison_start) {
-            $comparison = $comparison_start . "_comparison";
+            $comparison = $comparison_start . $field_postfix . "_comparison";
             $comparison_types = (in_array($comparison_start,
                  $equal_comparison_fields)) ? 'EQUAL_COMPARISON_TYPES' :
                  ((in_array($comparison_start, $inequality_comparison_fields)) ?
@@ -664,7 +664,7 @@ class AdminController extends Controller implements CrawlConstants
                 urlencode($data[$comparison]);
         }
         foreach ($comparisons_all as $sort_start) {
-            $sort = $sort_start . "_sort";
+            $sort = $sort_start . $field_postfix . "_sort";
             $data[$sort] = (isset($_REQUEST[$sort]) &&
                 isset($data['SORT_TYPES'][
                 $_REQUEST[$sort]])) ? $_REQUEST[$sort] :
@@ -675,8 +675,8 @@ class AdminController extends Controller implements CrawlConstants
         }
         $search_array = [];
         foreach ($comparisons_all as $field) {
-            $field_comparison = $field . "_comparison";
-            $field_sort = $field . "_sort";
+            $field_comparison = $field . $field_postfix . "_comparison";
+            $field_sort = $field . $field_postfix . "_sort";
             $is_timestamp_type = in_array($field, $timestamp_comparison_fields);
             $is_between_type = in_array($field, $between_comparison_fields);
             if ($is_between_type || $is_timestamp_type) {
diff --git a/src/controllers/Controller.php b/src/controllers/Controller.php
index 744e4c67a..1ee2107ca 100755
--- a/src/controllers/Controller.php
+++ b/src/controllers/Controller.php
@@ -502,7 +502,9 @@ abstract class Controller
                 foreach ($search_array as $search_data) {
                     list($column_name, $comparison, $search_value, $sort) =
                         $search_data;
-                    if ($sort == "NONE") { continue; }
+                    if ($sort == "NONE") {
+                        continue;
+                    }
                     if (isset($args[$column_name])) {
                         $column_name = $args[$column_name];
                     }
diff --git a/src/controllers/components/CrawlComponent.php b/src/controllers/components/CrawlComponent.php
index d3ddc4cd0..a0676257b 100644
--- a/src/controllers/components/CrawlComponent.php
+++ b/src/controllers/components/CrawlComponent.php
@@ -2363,7 +2363,7 @@ class CrawlComponent extends Component implements CrawlConstants
         $source_arguments = ["addsource", "deletesource", "editsource",
             "sourcesearch", "testsource"];
         $subsearch_arguments = ["addsubsearch", "deletesubsearch",
-            "editsubsearch", "showsubsearch"];
+            "editsubsearch", "showsubsearch", "subsearchsearch"];
         $possible_arguments = array_merge($source_arguments,
             $subsearch_arguments);
         $request_fields = ['start_row', 'num_show', 'end_row',
@@ -2720,6 +2720,25 @@ class CrawlComponent extends Component implements CrawlConstants
                         $default_search = true;
                     }
                     break;
+                case "subsearchsearch":
+                    $data['SEARCH_FORM_TYPE'] = "search";
+                    $subsearch_search_array =
+                        $parent->tableSearchRequestHandler($data,
+                            "searchSources", ['ALL_FIELDS' => [
+                                'folder_name', 'index_identifier', 'per_page',
+                                'default_query'], 'EQUAL_COMPARISON_TYPES' =>
+                                ['index_identifier'],
+                                'INEQUALITY_COMPARISON_TYPES' =>
+                                ['per_page']], '_subsearch');
+                    if (empty($_SESSION['LAST_SEARCH'][
+                        'searchSources_subsearch'])||isset($_REQUEST['name'])) {
+                        $_SESSION['LAST_SEARCH']['searchSources_subsearch'] =
+                            $_SESSION['SEARCH']['searchSources_subsearch'];
+                        unset($_SESSION['SEARCH']['searchSources_subsearch']);
+                    } else {
+                        $default_search = true;
+                    }
+                    break;
                 case "testsource":
                     $data['SOURCE_FORM_TYPE'] = "testsource";
                     $source = false;
@@ -2779,19 +2798,40 @@ class CrawlComponent extends Component implements CrawlConstants
         }
         $parent->pagingLogic($data, $source_model, "MEDIA_SOURCES",
             C\DEFAULT_ADMIN_PAGING_NUM/5, $media_search_array);
+        if (empty($subsearch_search_array)) {
+            if (!empty($_SESSION['LAST_SEARCH']['searchSources_subsearch'])) {
+                if (!empty($_REQUEST['arg']) &&
+                    $_REQUEST['arg'] == 'subsearchsearch') {
+                    $subsearch_search_array =
+                        $parent->restoreLastSearchFromSession($data,
+                        'searchSources', '_subsearch');
+                } else if (!empty($_REQUEST['context'])) {
+                    $subsearch_search_array =
+                        $_SESSION['LAST_SEARCH']['searchSources_subsearch'][
+                            'SEARCH_ARRAY'];
+                    $data['PAGING'] =
+                        $_SESSION['LAST_SEARCH']['searchSources_subsearch'][
+                            'PAGING'];
+                }
+            }
+            if (empty($subsearch_search_array)) {
+                $subsearch_search_array[] = ["FOLDER_NAME", "", "", "ASC"];
+            }
+        }
         $parent->pagingLogic($data, $source_model,
-            "SUBSEARCHES", C\DEFAULT_ADMIN_PAGING_NUM/5, [
-            ["FOLDER_NAME", "", "", "ASC"]], "SUB",
-            "SUBSEARCH");
+            "SUBSEARCHES", C\DEFAULT_ADMIN_PAGING_NUM/5,
+            $subsearch_search_array, "SUB", "SUBSEARCH");
         foreach ($data["SUBSEARCHES"] as $search) {
             if (!isset($data["SEARCH_LISTS"]
                 [trim($search['INDEX_IDENTIFIER'])])) {
                 $source_model->deleteSubsearch($search["FOLDER_NAME"]);
             }
         }
-        $data['SCRIPT'] .= "source_type = elt('source-type');" .
-            "source_type.onchange = switchSourceType; " .
-            "switchSourceType();";
+        if ($data['SOURCE_FORM_TYPE'] != 'search') {
+            $data['SCRIPT'] .= "source_type = elt('source-type');" .
+                "source_type.onchange = switchSourceType; " .
+                "switchSourceType();";
+        }
         if ($data['SEARCH_FORM_TYPE'] == 'addsubsearch') {
             $data['SCRIPT'] .= "setDisplay('admin-form-row', false);";
         }
diff --git a/src/data/public_default.db b/src/data/public_default.db
index caf5e5ec6..f9fea163c 100644
Binary files a/src/data/public_default.db and b/src/data/public_default.db differ
diff --git a/src/locale/ar/configure.ini b/src/locale/ar/configure.ini
index f3e66c8c3..d3191158b 100755
--- a/src/locale/ar/configure.ini
+++ b/src/locale/ar/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = "اسم المجلد:"
 searchsources_element_indexsource = "فهرسة المصدر:"
 searchsources_element_per_page = "النتائج في الصفحة الواحدة:"
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/bn/configure.ini b/src/locale/bn/configure.ini
index 533237fe9..e9df1aa2d 100755
--- a/src/locale/bn/configure.ini
+++ b/src/locale/bn/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/de/configure.ini b/src/locale/de/configure.ini
index d7ec02777..7fc194086 100755
--- a/src/locale/de/configure.ini
+++ b/src/locale/de/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/en_US/configure.ini b/src/locale/en_US/configure.ini
index 0c8871d86..789ab10c4 100644
--- a/src/locale/en_US/configure.ini
+++ b/src/locale/en_US/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = "Folder Name:"
 searchsources_element_indexsource = "Index Source:"
 searchsources_element_per_page = "Results Per Page:"
 searchsources_element_defaultquery = "Default Query:"
+searchsources_element_search = "Search"
 ;
 ; SecurityElement.php
 security_element_auth_captcha = "Auth, Access, Privacy, Captcha, and Recovery"
diff --git a/src/locale/es/configure.ini b/src/locale/es/configure.ini
index b421fdc40..c46c0f211 100755
--- a/src/locale/es/configure.ini
+++ b/src/locale/es/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/fa/configure.ini b/src/locale/fa/configure.ini
index 402289e7e..d686c7fab 100755
--- a/src/locale/fa/configure.ini
+++ b/src/locale/fa/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = "نام پوشه:"
 searchsources_element_indexsource = "منبع نمایه:"
 searchsources_element_per_page = "تعداد نتایج در هر صفحه:"
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/fr_FR/configure.ini b/src/locale/fr_FR/configure.ini
index 402ec7fc7..6e6265f84 100755
--- a/src/locale/fr_FR/configure.ini
+++ b/src/locale/fr_FR/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/he/configure.ini b/src/locale/he/configure.ini
index 8b2a8514e..82f3146a2 100755
--- a/src/locale/he/configure.ini
+++ b/src/locale/he/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/hi/configure.ini b/src/locale/hi/configure.ini
index 9e29d05bc..e80611aea 100755
--- a/src/locale/hi/configure.ini
+++ b/src/locale/hi/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/in_ID/configure.ini b/src/locale/in_ID/configure.ini
index efaeebc8e..0beedf0cc 100755
--- a/src/locale/in_ID/configure.ini
+++ b/src/locale/in_ID/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/it/configure.ini b/src/locale/it/configure.ini
index 4ff99a6ab..1e8f65de9 100755
--- a/src/locale/it/configure.ini
+++ b/src/locale/it/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/ja/configure.ini b/src/locale/ja/configure.ini
index 86969f4ea..f563684c6 100755
--- a/src/locale/ja/configure.ini
+++ b/src/locale/ja/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/kn/configure.ini b/src/locale/kn/configure.ini
index 4fe8f49bf..3bcf50f85 100755
--- a/src/locale/kn/configure.ini
+++ b/src/locale/kn/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/ko/configure.ini b/src/locale/ko/configure.ini
index a673dadc7..8f6bf9c6b 100755
--- a/src/locale/ko/configure.ini
+++ b/src/locale/ko/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/nl/configure.ini b/src/locale/nl/configure.ini
index dec956086..918a2f3ab 100644
--- a/src/locale/nl/configure.ini
+++ b/src/locale/nl/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = "Mapnaam:"
 searchsources_element_indexsource = "Index Bron:"
 searchsources_element_per_page = "Resultaten per pagina:"
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = "Authenticatie en Captcha Soorten"
diff --git a/src/locale/pl/configure.ini b/src/locale/pl/configure.ini
index c3c15904c..11bcbbef8 100755
--- a/src/locale/pl/configure.ini
+++ b/src/locale/pl/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/pt/configure.ini b/src/locale/pt/configure.ini
index 929d2dad4..ceed898e2 100755
--- a/src/locale/pt/configure.ini
+++ b/src/locale/pt/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/ru/configure.ini b/src/locale/ru/configure.ini
index f520ac126..58dff7aa6 100755
--- a/src/locale/ru/configure.ini
+++ b/src/locale/ru/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/te/configure.ini b/src/locale/te/configure.ini
index 4f8a929bf..63dffd6b8 100644
--- a/src/locale/te/configure.ini
+++ b/src/locale/te/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/th/configure.ini b/src/locale/th/configure.ini
index b657f4c82..92e361368 100755
--- a/src/locale/th/configure.ini
+++ b/src/locale/th/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/tr/configure.ini b/src/locale/tr/configure.ini
index 3b64905f9..c23f1ea75 100755
--- a/src/locale/tr/configure.ini
+++ b/src/locale/tr/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/vi_VN/configure.ini b/src/locale/vi_VN/configure.ini
index 0b8971271..c46806b72 100755
--- a/src/locale/vi_VN/configure.ini
+++ b/src/locale/vi_VN/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/locale/zh_CN/configure.ini b/src/locale/zh_CN/configure.ini
index 620cd9eac..b2461b80c 100755
--- a/src/locale/zh_CN/configure.ini
+++ b/src/locale/zh_CN/configure.ini
@@ -1237,6 +1237,7 @@ searchsources_element_foldername = ""
 searchsources_element_indexsource = ""
 searchsources_element_per_page = ""
 searchsources_element_defaultquery = ""
+searchsources_element_search = ""
 ;
 ; SecurityElement.php
 security_element_auth_captcha = ""
diff --git a/src/models/Model.php b/src/models/Model.php
index 23a73c08f..c4ca6894a 100755
--- a/src/models/Model.php
+++ b/src/models/Model.php
@@ -532,12 +532,13 @@ class Model implements CrawlConstants
                     $where .= $where_and;
                     switch ($comparison) {
                         case "=":
-                             $where .= "$field_name='" .
-                                $db->escapeString($value) . "'";
-                            break;
                         case "!=":
-                             $where .= "$field_name!='".
-                                $db->escapeString($value)."'";
+                        case "<":
+                        case ">":
+                        case "<=":
+                        case ">=":
+                             $where .= "$field_name$comparison'" .
+                                $db->escapeString($value) . "'";
                             break;
                         case "CONTAINS":
                              $where .= "LOWER($field_name) LIKE LOWER('%".
diff --git a/src/views/elements/SearchsourcesElement.php b/src/views/elements/SearchsourcesElement.php
index 6f5665f90..c6b96b688 100644
--- a/src/views/elements/SearchsourcesElement.php
+++ b/src/views/elements/SearchsourcesElement.php
@@ -134,7 +134,9 @@ class SearchsourcesElement extends Element
         $data['VIEW'] = $this->view;
         $data['NO_SEARCH'] = false;
         if (in_array($data['SOURCE_FORM_TYPE'], ['editsource', 'search'])) {
-            $data['FORM_TYPE'] = 'search';
+            if ($data['SOURCE_FORM_TYPE'] == 'search') {
+                $data['FORM_TYPE'] = 'search';
+            }
             $data['DISABLE_ADD_TOGGLE'] = true;
         }
         $paging_items = ['SUBstart_row', 'SUBend_row', 'SUBnum_show'];
@@ -254,22 +256,27 @@ class SearchsourcesElement extends Element
         <?php
         $data['TOGGLE_ID'] = "";
         $data['SUBFORM_TYPE'] = "";
+        $data['SEARCH_ARG'] = 'subsearchsearch';
         $data['TABLE_TITLE'] = tl('searchsources_element_subsearches');
         $data['NO_FLOAT_TABLE'] = false;
         $data['ACTIVITY'] = 'searchSources';
         $data['VIEW'] = $this->view;
         $data['VAR_PREFIX'] = "SUB";
         $data['PAGING'] = $paging2;
+        $data['DEFAULT_ARG'] = "showSubsearch";
         $num_columns = $_SERVER["MOBILE"] ? 5 : 8;
         $data['DISABLE_ADD_TOGGLE'] = false;
         if (in_array($data['SEARCH_FORM_TYPE'], ['editsubsearch', 'search'])) {
+            if ($data['SEARCH_FORM_TYPE'] == 'search') {
+                $data['SUBFORM_TYPE'] = 'search';
+            }
             $data['DISABLE_ADD_TOGGLE'] = true;
         }
         ?>
         <table class="admin-table">
         <tr><td class="no-border" colspan="<?=
-            $num_columns ?>"><?php $this->view->helper(
-            "pagingtable")->render($data);
+            $num_columns ?>"><?php
+            $this->view->helper("pagingtable")->render($data);
             if ($data['SEARCH_FORM_TYPE'] != "editsubsearch") { ?>
                 <div id='admin-form-row' class='admin-form-row'><?php
                 if ($data['SEARCH_FORM_TYPE'] == "search") {
@@ -719,7 +726,7 @@ class SearchsourcesElement extends Element
         $controller = "admin";
         $activity = "searchSources";
         $view = $this->view;
-        $title = tl('manageusers_element_search_user');
+        $title = tl('searchsources_element_search');
         $fields = [
             tl('searchsources_element_sourcename') => "name",
             tl('searchsources_element_sourcetype') =>
@@ -737,4 +744,32 @@ class SearchsourcesElement extends Element
             $view, $title, $fields, $dropdowns,
             $postfix);
     }
+    /**
+     * Draws the search for media source forms
+     *
+     * @param array $data consists of values of search source fields set
+     *     so far as well as values of the drops downs on the form
+     */
+    public function renderSubsearchSearchForm($data)
+    {
+        $controller = "admin";
+        $activity = "searchSources";
+        $view = $this->view;
+        $title = tl('searchsources_element_search');
+        $fields = [
+            tl('searchsources_element_foldername') => "folder_name",
+            tl('searchsources_element_indexsource') =>
+                ["index_identifier", $data['EQUAL_COMPARISON_TYPES']],
+            tl('searchsources_element_per_page') => ["per_page",
+                $data['INEQUALITY_COMPARISON_TYPES']],
+            tl('searchsources_element_defaultquery') => "default_query",
+        ];
+        $postfix = "subsearch";
+        $dropdowns = [
+            "per_page" => $data['PER_PAGE']
+        ];
+        $view->helper("searchform")->render($data, $controller, $activity,
+            $view, $title, $fields, $dropdowns,
+            $postfix);
+    }
 }
diff --git a/src/views/helpers/PagingtableHelper.php b/src/views/helpers/PagingtableHelper.php
index 90489f504..2df7c034e 100644
--- a/src/views/helpers/PagingtableHelper.php
+++ b/src/views/helpers/PagingtableHelper.php
@@ -267,9 +267,9 @@ class PagingtableHelper extends Helper
                 if (empty($data['NO_SEARCH'])) {
                     $add_browse = (empty($data['browse'])) ? "":
                         "&amp;browse=" . $data['browse'];
+                    $add_arg = (empty($data['DEFAULT_ARG'])) ? "":
+                        "&amp;arg=" . $data['DEFAULT_ARG'];
                     if($data[$d['FORM_TYPE']] != "search") {
-                        $add_browse = (empty($data['browse'])) ? "":
-                            "&amp;browse=" . $data['browse'];
                         $search_url = $base_url . '&amp;arg=' . $search_arg .
                         $add_browse;
                         ?>
@@ -277,7 +277,7 @@ class PagingtableHelper extends Helper
                             ?>resources/search-button.png" alt="<?=
                             tl('pagingtable_helper_search')?>" /></a><?php
                     } else { ?>
-                        <a href="<?= $base_url .
+                        <a href="<?= $base_url . $add_arg .
                             $add_browse ?>"><img src="<?=C\BASE_URL
                             ?>resources/search-button.png" alt="<?=
                             tl('pagingtable_helper_search')?>" /></a><?php
diff --git a/src/views/helpers/SearchformHelper.php b/src/views/helpers/SearchformHelper.php
index e5dce49fb..74af2b6cd 100644
--- a/src/views/helpers/SearchformHelper.php
+++ b/src/views/helpers/SearchformHelper.php
@@ -72,7 +72,7 @@ class SearchformHelper extends Helper
             $data['SEARCH_ARG'];
         $browse = false;
         if (isset($data['browse'])) {
-            $base_url .= "&amp;browse=".$data['browse'];
+            $base_url .= "&amp;browse=" . $data['browse'];
             $browse = true;
         }
         ?>
@@ -105,34 +105,35 @@ class SearchformHelper extends Helper
             e("<tr><td class='table-label'><label for='{$name}-id'>".
                 "$label</label>");
             e($item_sep);
-            $view->helper("options")->render(
-                "{$name}-comparison", "${name}_comparison",
-                $comparison_types, $data["{$name}_comparison"], false,
-                ['class' => 'full-width']);
-            e($item_sep_center);
             $out_name = $name;
             if ($postfix != "") {
                 $out_name = $name . "_$postfix";
+                $out_id_name = $name . "-$postfix";
             }
+            $view->helper("options")->render(
+                "{$out_id_name}-comparison", "${out_name}_comparison",
+                $comparison_types, $data["{$out_name}_comparison"], false,
+                ['class' => 'full-width']);
+            e($item_sep_center);
             if (isset($dropdowns[$name]) && in_array($dropdowns[$name],
                 ['date', 'time'])) {
                 e("<div class='range-field' ><input type='".
                     $dropdowns[$name]. "' " .
-                    "id='{$name}-id-low' name='".$out_name . "_low' ".
-                    "value='".$data[$out_name . "_low"] .
+                    "id='{$out_id_name}-id-low' name='".$out_name . "_low' ".
+                    "value='" . $data[$out_name . "_low"] .
                     "' class='narrow-field'  /> <hr /> ");
                 e("<input type='". $dropdowns[$name]. "' " .
-                    "id='{$name}-id-high' name='" . $out_name . "_high' ".
-                    "value='" . $data[$out_name . "_high"] .
+                    "id='{$out_id_name}-id-high' name='" . $out_name .
+                    "_high' value='" . $data[$out_name . "_high"] .
                     "' class='narrow-field'  /></div>");
             } else if (isset($dropdowns[$name]) && in_array($dropdowns[$name],
                 ['range'])) {
                 e("<div class='range-field' ><input type='number' " .
-                    "id='{$name}-id-low' name='".$out_name."_low' ".
+                    "id='{$out_id_name}-id-low' name='".$out_name."_low' ".
                     "value='" . $data[$out_name . "_low"].
                     "' class='narrow-field'  /> <hr /> ");
                 e("<input type='number' " .
-                    "id='{$name}-id-high' name='" . $out_name."_high' ".
+                    "id='{$out_id_name}-id-high' name='" . $out_name."_high' ".
                     "value='" . $data[$out_name . "_high"] .
                     "' class='narrow-field'  /></div>");
             } else if (isset($dropdowns[$name])) {
@@ -142,19 +143,20 @@ class SearchformHelper extends Helper
                 if ($data["{$out_name}"] == "") {
                     $data["{$out_name}"] = '-1';
                 }
-                $view->helper("options")->render("{$name}-id",
+                $view->helper("options")->render("{$out_id_name}-id",
                     "{$out_name}", $dropdowns[$name], $data["{$out_name}"],
                     false, ['class' => 'full-width']);
                 ?><?php
             } else {
-                e("<input type='text' id='{$name}-id' name='$out_name' ".
+                e("<input type='text' id='{$out_id_name}-id' name='$out_name' ".
                     "maxlength='". C\LONG_NAME_LEN. "' ".
                     "value='{$data[$out_name]}' ".
                     "class='narrow-field'  />");
             }
             e($item_sep);
-            $view->helper("options")->render("{$name}-sort",
-                "{$name}_sort", $data['SORT_TYPES'], $data["{$name}_sort"]);
+            $view->helper("options")->render("{$out_id_name}-sort",
+                "{$out_name}_sort", $data['SORT_TYPES'],
+                $data["{$out_name}_sort"]);
             e("</td></tr>");
         }
         ?>
ViewGit