3 /** This is the global search shortcut block - a single query can be entered, and
4 * the user will be redirected to the query page where they can enter more
5 * advanced queries, and view the results of their search. When searching from
6 * this block, the broadest possible selection of documents is searched.
9 * @subpackage search block
10 * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
14 class block_search extends block_base {
17 $this->title = get_string('pluginname', 'block_search');
19 $this->version = 2008031500;
22 // only one instance of this block is required
23 function instance_allow_multiple() {
25 } //instance_allow_multiple
27 // label and button values can be set in admin
28 function has_config() {
32 function get_content() {
35 if (empty($CFG->enableglobalsearch)) {
39 //cache block contents
40 if ($this->content !== NULL) {
41 return $this->content;
44 $this->content = new stdClass;
46 //lazy check for the moment
47 //fetch values if defined in admin, otherwise use defaults
48 $label = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
49 $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
52 $this->content->text =
53 '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
54 . '<label for="block_search_q">'. $label .'</label>'
55 . '<input id="block_search_q" type="text" name="query_string" />'
56 . '<input type="submit" value="'.$button.'" />'
60 $this->content->footer = '';
62 return $this->content;
65 function specialisation() {
70 * wraps up to search engine cron
75 include($CFG->dirroot.'/search/cron.php');