2006-06-25 23:07:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/* This is the global search shortcut block - a single query can be entered, and
|
2008-04-15 22:11:11 +00:00
|
|
|
* the user will be redirected to the query page where they can enter more
|
|
|
|
* advanced queries, and view the results of their search. When searching from
|
|
|
|
* this block, the broadest possible selection of documents is searched.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Todo: make strings -> get_string()
|
|
|
|
*
|
|
|
|
* @package search
|
|
|
|
* @subpackage search block
|
|
|
|
* @author: Michael Champanis (mchampan), reengineered by Valery Fremaux
|
|
|
|
* @date: 2006 06 25
|
2006-06-25 23:07:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class block_search extends block_base {
|
|
|
|
|
|
|
|
function init() {
|
2007-07-12 12:32:15 +00:00
|
|
|
$this->title = get_string('blockname', 'block_search');
|
|
|
|
$this->cron = 1;
|
2008-04-15 22:11:11 +00:00
|
|
|
$this->version = 2008031500;
|
2006-06-25 23:07:36 +00:00
|
|
|
} //init
|
|
|
|
|
|
|
|
// only one instance of this block is required
|
|
|
|
function instance_allow_multiple() {
|
|
|
|
return false;
|
|
|
|
} //instance_allow_multiple
|
|
|
|
|
|
|
|
// label and button values can be set in admin
|
|
|
|
function has_config() {
|
|
|
|
return true;
|
|
|
|
} //has_config
|
|
|
|
|
|
|
|
function get_content() {
|
|
|
|
global $CFG;
|
2006-10-30 21:01:47 +00:00
|
|
|
|
|
|
|
if (empty($CFG->enableglobalsearch)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2006-06-25 23:07:36 +00:00
|
|
|
//cache block contents
|
|
|
|
if ($this->content !== NULL) {
|
|
|
|
return $this->content;
|
|
|
|
} //if
|
|
|
|
|
|
|
|
$this->content = new stdClass;
|
|
|
|
|
|
|
|
//lazy check for the moment
|
2008-05-01 21:22:01 +00:00
|
|
|
//fetch values if defined in admin, otherwise use defaults
|
|
|
|
$label = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
|
|
|
|
$button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');
|
|
|
|
|
|
|
|
//basic search form
|
|
|
|
$this->content->text =
|
2007-01-04 21:32:36 +00:00
|
|
|
'<form id="searchquery" method="get" action="'. $CFG->wwwroot .'/search/query.php"><div>'
|
2006-10-10 10:58:29 +00:00
|
|
|
. '<label for="block_search_q">'. $label .'</label>'
|
2007-01-10 06:31:51 +00:00
|
|
|
. '<input id="block_search_q" type="text" name="query_string" />'
|
2006-10-10 10:58:29 +00:00
|
|
|
. '<input type="submit" value="'.$button.'" />'
|
2007-01-04 12:44:58 +00:00
|
|
|
. '</div></form>';
|
2008-05-01 21:22:01 +00:00
|
|
|
|
2006-06-25 23:07:36 +00:00
|
|
|
//no footer, thanks
|
|
|
|
$this->content->footer = '';
|
|
|
|
|
|
|
|
return $this->content;
|
|
|
|
} //get_content
|
|
|
|
|
|
|
|
function specialisation() {
|
|
|
|
//empty!
|
|
|
|
} //specialisation
|
2007-07-12 12:32:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* wraps up to search engine cron
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function cron(){
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
include($CFG->dirroot.'/search/cron.php');
|
|
|
|
}
|
2006-06-25 23:07:36 +00:00
|
|
|
|
|
|
|
} //block_search
|
|
|
|
|
2008-06-25 17:31:23 +00:00
|
|
|
?>
|