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)
11 Todo: make strings -> get_string()
14 class block_search
extends block_base
{
17 $this->title
= get_string('blockname', 'block_search');
19 $this->version
= 2007071302;
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 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');
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.'" />'
60 $this->content
->text
= "Sorry folks, PHP 5 is needed for the new search module.";
64 $this->content
->footer
= '';
66 return $this->content
;
69 function specialisation() {
74 * wraps up to search engine cron
80 include($CFG->dirroot
.'/search/cron.php');