MDL-22061 removing unnecessary [[ tests
[moodle.git] / blocks / search / block_search.php
CommitLineData
682d4032 1<?php
1428f471 2
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.
7 *
8 * @package search
9 * @subpackage search block
10 * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
11 * @date: 2006 06 25
12 */
13
14class block_search extends block_base {
15
682d4032 16 function init() {
745a9d23 17 $this->title = get_string('pluginname', 'block_search');
918fb61f 18 $this->cron = 1;
d77d0dd5 19 $this->version = 2008031500;
1428f471 20 } //init
21
682d4032 22 // only one instance of this block is required
23 function instance_allow_multiple() {
24 return false;
25 } //instance_allow_multiple
1428f471 26
682d4032 27 // label and button values can be set in admin
28 function has_config() {
29 return true;
30 } //has_config
1428f471 31
682d4032 32 function get_content() {
33 global $CFG;
721d74b0 34
35 if (empty($CFG->enableglobalsearch)) {
36 return '';
37 }
38
682d4032 39 //cache block contents
40 if ($this->content !== NULL) {
41 return $this->content;
42 } //if
1428f471 43
682d4032 44 $this->content = new stdClass;
1428f471 45
682d4032 46 //lazy check for the moment
dd93d8e9 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');
50
51 //basic search form
52 $this->content->text =
b7dc2256 53 '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
6fbe0284 54 . '<label for="block_search_q">'. $label .'</label>'
bf7b68c2 55 . '<input id="block_search_q" type="text" name="query_string" />'
6fbe0284 56 . '<input type="submit" value="'.$button.'" />'
4f24b3e3 57 . '</div></form>';
dd93d8e9 58
682d4032 59 //no footer, thanks
60 $this->content->footer = '';
1428f471 61
62 return $this->content;
682d4032 63 } //get_content
1428f471 64
682d4032 65 function specialisation() {
66 //empty!
67 } //specialisation
1428f471 68
918fb61f 69 /**
1428f471 70 * wraps up to search engine cron
71 */
918fb61f 72 function cron(){
73 global $CFG;
1428f471 74
918fb61f 75 include($CFG->dirroot.'/search/cron.php');
76 }
1428f471 77
682d4032 78 } //block_search
79