MDL-21695 adding help string
[moodle.git] / mod / wiki / search.php
blob750938f2bc1ddf9a165ccf5cc8935a73461522b2
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * @package mod-wiki
20 * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com>
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 require_once('../../config.php');
25 require_once($CFG->dirroot . '/mod/wiki/lib.php');
26 require_once($CFG->dirroot . '/mod/wiki/locallib.php');
27 require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
29 $search = optional_param('searchstring', null, PARAM_ALPHANUMEXT);
30 $courseid = optional_param('courseid', 0, PARAM_INT);
31 $searchcontent = optional_param('searchwikicontent', 0, PARAM_INT);
32 $cmid = optional_param('cmid', 0, PARAM_INT);
34 if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
35 print_error('invalidcourseid');
37 if (! $cm = get_coursemodule_from_id('wiki', $cmid)) {
38 print_error('invalidcoursemodule');
41 require_course_login($course, true, $cm);
43 // @TODO: Fix call to wiki_get_subwiki_by_group
44 if (!$gid = groups_get_activity_group($cm)){
45 $gid = 0;
47 if (!$subwiki = wiki_get_subwiki_by_group($cm->instance, $gid)){
48 return false;
50 if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
51 print_error('incorrectwikiid', 'wiki');
54 $wikipage = new page_wiki_search($wiki, $subwiki, $cm);
56 $wikipage->set_search_string($search, $searchcontent);
58 $wikipage->set_title(get_string('search'));
60 $wikipage->print_header();
62 $wikipage->print_content();
64 $wikipage->print_footer();