changed search funcitonality so it can be called as either
authorPaul J R <me@pjr.cc>
Tue, 2 Oct 2012 00:34:33 +0000 (10:34 +1000)
committerPaul J R <me@pjr.cc>
Tue, 2 Oct 2012 00:34:33 +0000 (10:34 +1000)
http://host/gwvp/search/<searchstring>
or via its form

Also does a 30x on the form submission so the returning search page can
be gone back to rather then ending in a form re-submission request

gwvpmini/gwvpmini_search.php

index cf2681f..6e72fe9 100644 (file)
@@ -16,7 +16,10 @@ function gwvpmini_SearchCallMe()
                // error_log("in repoadmin callme, for Q");\r
                $query = $_REQUEST["q"];\r
                $qspl = explode("/", $query);\r
-               if(isset($qspl[0])) {\r
+               if(isset($qspl[0])) {
+                       if($qspl[0] == "search_redirs") {
+                               return "gwvpmini_SearchMainPageRedir";
+                       }\r
                        if($qspl[0] == "search") {\r
                                return "gwvpmini_SearchMainPage";\r
                        } else return false;\r
@@ -32,7 +35,7 @@ function gwvpmini_SearchBuilder()
 {
        global $BASE_URL;
        
-       echo "<form method=\"post\" action=\"$BASE_URL/search\">";
+       echo "<form method=\"post\" action=\"$BASE_URL/search_redirs\">";
        echo "<input type=\"text\" name=\"searchstring\"><input type=\"submit\" name=\"Search\" value=\"Seach\">";
        echo "</form>";
                
@@ -43,11 +46,31 @@ function gwvpmini_SearchMainPage()
        gwvpmini_goMainPage("gwvpmini_SearchMainPageBody");
 }
 
+function gwvpmini_SearchMainPageRedir()
+{
+       global $BASE_URL;
+       
+       $_SESSION["search"] = $_REQUEST["searchstring"];
+       header("Location: $BASE_URL/search");
+       
+       return;
+}
+
 function gwvpmini_SearchMainPageBody()
 {
        global $BASE_URL;
        
-       $search = $_REQUEST["searchstring"];
+       $search = "";
+       if(isset($_SESSION["search"])) {
+               $search = $_SESSION["search"];
+               unset($_SESSION["search"]);
+       } else {
+               $query = $_REQUEST["q"];\r
+               $qspl = explode("/", $query);\r
+               if(isset($qspl[1])) {
+                       $search = $qspl[1];
+               }
+       }
        
        $reps = gwvpmini_findReposLike($search);
        $ppls = gwvpmini_findPeopleLike($search);