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 * Todo: make strings -> get_string()
12 * @subpackage search block
13 * @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
17 class block_search
extends block_base
{
20 $this->title
= get_string('blockname', 'block_search');
22 $this->version
= 2008031500;
25 // only one instance of this block is required
26 function instance_allow_multiple() {
28 } //instance_allow_multiple
30 // label and button values can be set in admin
31 function has_config() {
35 function get_content() {
38 if (empty($CFG->enableglobalsearch
)) {
42 //cache block contents
43 if ($this->content
!== NULL) {
44 return $this->content
;
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');
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.'" />'
63 $this->content
->text
= "Sorry folks, PHP 5 is needed for the new search module.";
67 $this->content
->footer
= '';
69 return $this->content
;
72 function specialisation() {
77 * wraps up to search engine cron
83 include($CFG->dirroot
.'/search/cron.php');