From 427ed988282f72cb160d09b0830f843d462cc93a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de>
Date: Mon, 19 Mar 2018 17:56:23 +0100
Subject: [PATCH] feat(Search): Add search form on results page

Add the search form on the results page itself. This form will be used
to add more options to refine the search further.
---
 inc/Ui/Search.php | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php
index da030d5a2..bff33cae5 100644
--- a/inc/Ui/Search.php
+++ b/inc/Ui/Search.php
@@ -2,6 +2,8 @@
 
 namespace dokuwiki\Ui;
 
+use \dokuwiki\Form\Form;
+
 class Search extends Ui
 {
     protected $query;
@@ -38,6 +40,8 @@ class Search extends Ui
     {
         $searchHTML = '';
 
+        $searchHTML .= $this->getSearchFormHTML($this->query);
+
         $searchHTML .= $this->getSearchIntroHTML($this->query);
 
         $searchHTML .= $this->getPageLookupHTML($this->pageLookupResults);
@@ -47,6 +51,28 @@ class Search extends Ui
         echo $searchHTML;
     }
 
+    /**
+     * Get a form which can be used to adjust/refine the search
+     *
+     * @param string $query
+     *
+     * @return string
+     */
+    protected function getSearchFormHTML($query)
+    {
+        global $lang;
+
+        $searchForm = (new Form())->attrs(['method' => 'get']);
+        $searchForm->setHiddenField('do', 'search');
+
+        $searchForm->addFieldsetOpen();
+        $searchForm->addTextInput('id', '')->val($query);
+        $searchForm->addButton('', $lang['btn_search'])->attr('type', 'submit');
+        $searchForm->addFieldsetClose();
+
+        return $searchForm->toHTML();
+    }
+
     /**
      * Build the intro text for the search page
      *
@@ -69,7 +95,6 @@ class Search extends Ui
         return $intro;
     }
 
-
     /**
      * Build HTML for a list of pages with matching pagenames
      *
-- 
GitLab