moodle/blocks/search/block_search.php
mchampan a25a3912f7 Search functions moved from mod/name/lib.php to search/documents/mod_document.php.
Pagination added to query page. Various small changes and amendments.
2006-07-11 17:15:22 +00:00

70 lines
2.1 KiB
PHP

<?php
/* This is the global search shortcut block - a single query can be entered, and
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.
Author: Michael Champanis (mchampan)
Date: 2006 06 25
Todo: make strings -> get_string()
*/
class block_search extends block_base {
function init() {
$this->title = "Global Search"; //get_string()
$this->version = 2006062500;
} //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;
//cache block contents
if ($this->content !== NULL) {
return $this->content;
} //if
$this->content = new stdClass;
//lazy check for the moment
if (check_php_version("5.0.0")) {
//fetch values if defined in admin, otherwise use defaults
$label = (isset($CFG->block_search_text)) ? $CFG->block_search_text : "Search Moodle";
$button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : "Go";
//basic search form
$this->content->text =
'<form name="query" method="get" action="search/query.php">'
. "<label for=''>$label</label>"
. '<input type="text" name="query_string" length="50" value=""/>'
. '<input type="submit" value="'.$button.'"/>'
. '</form>';
} else {
$this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
} //else
//no footer, thanks
$this->content->footer = '';
return $this->content;
} //get_content
function specialisation() {
//empty!
} //specialisation
} //block_search
?>