Automatic installer.php lang files by installer_builder (20100914)
[moodle.git] / blocks / search / block_search.php
blob7fdddbfb88fc800c135fbb2e4c4cc8c97b12d3ee
1 <?php
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 *
9 * Todo: make strings -> get_string()
11 * @package search
12 * @subpackage search block
13 * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
14 * @date: 2006 06 25
17 class block_search extends block_base {
19 function init() {
20 $this->title = get_string('blockname', 'block_search');
21 $this->cron = 1;
22 $this->version = 2008031500;
23 } //init
25 // only one instance of this block is required
26 function instance_allow_multiple() {
27 return false;
28 } //instance_allow_multiple
30 // label and button values can be set in admin
31 function has_config() {
32 return true;
33 } //has_config
35 function get_content() {
36 global $CFG;
38 if (empty($CFG->enableglobalsearch)) {
39 return get_string('disabledsearch', 'search');
42 //cache block contents
43 if ($this->content !== NULL) {
44 return $this->content;
45 } //if
47 $this->content = new stdClass;
49 //lazy check for the moment
50 if (check_php_version("5.0.0")) {
51 //fetch values if defined in admin, otherwise use defaults
52 $label = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
53 $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
55 //basic search form
56 $this->content->text =
57 '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
58 . '<label for="block_search_q">'. $label .'</label>'
59 . '<input id="block_search_q" type="text" name="query_string" />'
60 . '<input type="submit" value="'.$button.'" />'
61 . '</div></form>';
62 } else {
63 $this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
64 } //else
66 //no footer, thanks
67 $this->content->footer = '';
69 return $this->content;
70 } //get_content
72 function specialisation() {
73 //empty!
74 } //specialisation
76 /**
77 * wraps up to search engine cron
80 function cron(){
81 global $CFG;
83 include($CFG->dirroot.'/search/cron.php');
86 } //block_search