]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes bug MDL-6896, "Global search block - relative form URL broken"
authornfreear <nfreear>
Tue, 10 Oct 2006 10:58:29 +0000 (10:58 +0000)
committernfreear <nfreear>
Tue, 10 Oct 2006 10:58:29 +0000 (10:58 +0000)
blocks/search/block_search.php
search/query.php

index c370ca2925e739ab4558783a7bceb9ab928a722a..778dc6bf39ca405ec3b7e19af82090dbbd6d70f4 100644 (file)
         
         //basic search form
         $this->content->text =
-            '<form name="query" method="get" action="search/query.php">'
-          . "<label for=''>$label</label>"
-          . '<input type="text" name="query_string" length="50" value=""/>'
-          . '<input type="submit" value="'.$button.'"/>'
+            '<form name="query" method="get" action="'. $CFG->wwwroot .'/search/query.php">'
+          . '<label for="block_search_q">'. $label .'</label>'
+          . '<input id="block_search_q" type="text" name="query_string" length="50" />'
+          . '<input type="submit" value="'.$button.'" />'
           . '</form>';
       } else {
         $this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
index 7426833d0e50a5847938bd5049e26a2a7c852c7c..fbefcfa7552f05d87f7d158d364ccb3fe9b179b3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-
-  /* The query page - accepts a user-entered query string and returns results.
+  /**
+   * The query page - accepts a user-entered query string and returns results.
    *
    * Queries are boolean-aware, e.g.:
    *
    * '+author:helen +author:foster'
    *   All articles written by Helen Foster
    *
-   * */
+   */
 
   require_once('../config.php');
   require_once("$CFG->dirroot/search/lib.php");
 
+  $adv = new Object();
+
   //check for php5, but don't die yet (see line 52)
   if ($check = search_check_php5()) {
     require_once("$CFG->dirroot/search/querylib.php");
 
   $vars = get_object_vars($adv);
 
-  foreach ($vars as $key => $value) {
-    $adv->$key = stripslashes(htmlentities($value));
-  } //foreach
-
+  if (isset($vars)) {
+    foreach ($vars as $key => $value) {
+      $adv->$key = stripslashes(htmlentities($value));
+    } //foreach
+  }
 ?>
 
 <form name="query" method="get" action="query.php">
   <?php if (!$advanced) { ?>
-    <input type="text" name="query_string" length="50" value="<?php print stripslashes(htmlentities($query_string)) ?>"/>
-    &nbsp;<input type="submit" value="Search"/>&nbsp;&nbsp;
-    <a href="query.php?a=1">Advanced search</a>
+    <input type="text" name="query_string" length="50" value="<?php print stripslashes(htmlentities($query_string)) ?>" />
+    &nbsp;<input type="submit" value="Search" /> &nbsp;
+    <a href="query.php?a=1">Advanced search</a> |
     <a href="stats.php">Statistics</a>
   <?php } else {
     print_simple_box_start('center', '', 'white', 10);
 
     <tr>
       <td width="240">These words must appear:</td>
-      <td><input type="text" name="mustappear" length="50" value="<?php print $adv->mustappear; ?>"/></td>
+      <td><input type="text" name="mustappear" length="50" value="<?php print $adv->mustappear; ?>" /></td>
     </tr>
 
     <tr>
       <td>These words must not appear:</td>
-      <td><input type="text" name="notappear" length="50" value="<?php print $adv->notappear; ?>"/></td>
+      <td><input type="text" name="notappear" length="50" value="<?php print $adv->notappear; ?>" /></td>
     </tr>
 
     <tr>
       <td>These words help improve rank:</td>
-      <td><input type="text" name="canappear" length="50" value="<?php print $adv->canappear; ?>"/></td>
+      <td><input type="text" name="canappear" length="50" value="<?php print $adv->canappear; ?>" /></td>
     </tr>
 
     <tr>
 
     <tr>
       <td>Words in title:</td>
-      <td><input type="text" name="title" length="50" value="<?php print $adv->title; ?>"/></td>
+      <td><input type="text" name="title" length="50" value="<?php print $adv->title; ?>" /></td>
     </tr>
 
     <tr>
       <td>Author name:</td>
-      <td><input type="text" name="author" length="50" value="<?php print $adv->author; ?>"/></td>
+      <td><input type="text" name="author" length="50" value="<?php print $adv->author; ?>" /></td>
     </tr>
 
     <tr>
-      <td colspan="3" align="center"><br><input type="submit" value="Search"/></td>
+      <td colspan="3" align="center"><br /><input type="submit" value="Search" /></td>
     </tr>
 
     <tr>
       <td colspan="3" align="center">
         <table border="0" cellpadding="0" cellspacing="0">
           <tr>
-            <td><a href="query.php">Normal search</a>&nbsp;</td>
+            <td><a href="query.php">Normal search</a> |</td>
             <td>&nbsp;<a href="stats.php">Statistics</a></td>
           </tr>
         </table>
   print ' documents.';
 
   if (!$sq->is_valid_index() and isadmin()) {
-    print "<br><br>Admin: There appears to be no index, click <a href='indexersplash.php'>here</a> to create one.";
+    print "<p>Admin: There appears to be no search index. Please <a href='indexersplash.php'>create an index</a>.</p>\n";
   } //if
 
   print '</div>';
     search_stopwatch();
     $hit_count = $sq->count();
 
-    print "<br>";
+    print "<br />";
 
     print $hit_count." results returned for '".stripslashes($query_string)."'.";
-    print "<br>";
+    print "<br />";
 
     if ($hit_count > 0) {
       $page_links = $sq->page_numbers();
       print "<ol>";
 
       foreach ($hits as $listing) {
-        print "<li value='".($listing->number+1)."'><a href='".$listing->url."'>$listing->title</a><br>\n"
-             ."<em>".search_shorten_url($listing->url, 70)."</em><br>\n"
-             ."Type: ".$listing->doctype.", score: ".round($listing->score, 3).", author: ".$listing->author."<br>\n"
-             ."<br></li>\n";
+        print "<li value='".($listing->number+1)."'><a href='".$listing->url."'>$listing->title</a><br />\n"
+             ."<em>".search_shorten_url($listing->url, 70)."</em><br />\n"
+             ."Type: ".$listing->doctype.", score: ".round($listing->score, 3).", author: ".$listing->author."\n"
+             ."</li>\n";
       } //for
 
       print "</ol>";