adding some strings
[moodle-linuxchix.git] / blocks / search / block_search.php
blob643a0dfa3e979510490de147637bf3626069f7b0
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.
8 Author: Michael Champanis (mchampan)
9 Date: 2006 06 25
11 Todo: make strings -> get_string()
14 class block_search extends block_base {
16 function init() {
17 $this->title = get_string('blockname', 'block_search');
18 $this->cron = 1;
19 $this->version = 2007071302;
20 } //init
22 // only one instance of this block is required
23 function instance_allow_multiple() {
24 return false;
25 } //instance_allow_multiple
27 // label and button values can be set in admin
28 function has_config() {
29 return true;
30 } //has_config
32 function get_content() {
33 global $CFG;
35 if (empty($CFG->enableglobalsearch)) {
36 return '';
39 //cache block contents
40 if ($this->content !== NULL) {
41 return $this->content;
42 } //if
44 $this->content = new stdClass;
46 //lazy check for the moment
47 if (check_php_version("5.0.0")) {
48 //fetch values if defined in admin, otherwise use defaults
49 $label = (isset($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
50 $button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
52 //basic search form
53 $this->content->text =
54 '<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
55 . '<label for="block_search_q">'. $label .'</label>'
56 . '<input id="block_search_q" type="text" name="query_string" />'
57 . '<input type="submit" value="'.$button.'" />'
58 . '</div></form>';
59 } else {
60 $this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
61 } //else
63 //no footer, thanks
64 $this->content->footer = '';
66 return $this->content;
67 } //get_content
69 function specialisation() {
70 //empty!
71 } //specialisation
73 /**
74 * wraps up to search engine cron
77 function cron(){
78 global $CFG;
80 include($CFG->dirroot.'/search/cron.php');
83 } //block_search