MDL-47613 wiki: allow searching several words
authorMarina Glancy <marina@moodle.com>
Fri, 10 Oct 2014 06:15:19 +0000 (14:15 +0800)
committerMarina Glancy <marina@moodle.com>
Fri, 10 Oct 2014 08:35:13 +0000 (16:35 +0800)
Thanks to Sandeep B for suggested solution

mod/wiki/pagelib.php
mod/wiki/renderer.php
mod/wiki/search.php
mod/wiki/tests/behat/wiki_search.feature

index be29771..6097e37 100644 (file)
@@ -111,7 +111,7 @@ abstract class page_wiki {
         $PAGE->set_activity_record($wiki);
         // the search box
         if (!empty($subwiki->id)) {
-            $search = optional_param('searchstring', null, PARAM_ALPHANUMEXT);
+            $search = optional_param('searchstring', null, PARAM_TEXT);
             $PAGE->set_button(wiki_search_form($cm, $search, $subwiki));
         }
     }
index 560c7c7..0e34a3d 100644 (file)
@@ -310,7 +310,7 @@ class mod_wiki_renderer extends plugin_renderer_base {
                     array('wid' => $wiki->id, 'title' => $page->title, 'pageid' => $page->id));
             break;
         case 'search':
-            $search = optional_param('searchstring', null, PARAM_ALPHANUMEXT);
+            $search = optional_param('searchstring', null, PARAM_TEXT);
             $searchcontent = optional_param('searchwikicontent', 0, PARAM_INT);
             $baseurl = new moodle_url('/mod/wiki/search.php',
                     array('cmid' => $cm->id, 'courseid' => $cm->course,
index ef1f6c8..17b8d2d 100644 (file)
@@ -26,7 +26,7 @@ require_once($CFG->dirroot . '/mod/wiki/lib.php');
 require_once($CFG->dirroot . '/mod/wiki/locallib.php');
 require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
 
-$search = optional_param('searchstring', null, PARAM_ALPHANUMEXT);
+$search = optional_param('searchstring', null, PARAM_TEXT);
 $courseid = optional_param('courseid', 0, PARAM_INT);
 $searchcontent = optional_param('searchwikicontent', 0, PARAM_INT);
 $cmid = optional_param('cmid', 0, PARAM_INT);
index ee0a687..3f564c9 100644 (file)
@@ -52,6 +52,10 @@ Feature: Users can search wikis
     And I press "Search wikis"
     And I should not see "New page created by student1"
     And I should see "Collaborative teacher1 page"
+    And I set the field "searchstring" to "teacher1 page"
+    And I press "Search wikis"
+    And I should not see "New page created by student1"
+    And I should see "Collaborative teacher1 page"
     And I log out