diff --git a/blocks/search/block_search.php b/blocks/search/block_search.php index 3cafd10da72..c370ca2925e 100644 --- a/blocks/search/block_search.php +++ b/blocks/search/block_search.php @@ -6,7 +6,7 @@ this block, the broadest possible selection of documents is searched. Author: Michael Champanis (mchampan) - Date: 2006 06 23 + Date: 2006 06 25 Todo: make strings -> get_string() */ @@ -15,7 +15,7 @@ function init() { $this->title = "Global Search"; //get_string() - $this->version = 20060625; + $this->version = 2006062500; } //init // only one instance of this block is required @@ -46,7 +46,7 @@ //basic search form $this->content->text = - '
@@ -77,27 +105,65 @@ if ($no_index and isadmin()) { print_simple_box_start('center', '50%', 'white', 10); search_stopwatch(); - $hits = $index->find(strtolower($query_string)); - - if (count($hits) > 0) { - $link_function = $hits[0]->type.'_make_link'; - } //if + $hits = $index->find(strtolower($query_string)); + $hit_count = count($hits); print "Server Time: '.date('r',time()));
+ mtrace("Testing global search capabilities:\n");
+
+ $phpversion = phpversion();
+
+ if (!search_check_php5()) {
+ mtrace("ERROR: PHP 5.0.0 or later required (currently using version $phpversion).");
+ exit(0);
+ } else {
+ mtrace("Success: PHP 5.0.0 or later is installed ($phpversion).\n");
+ } //else
+
+ //fix paths for testing
+ set_include_path(get_include_path().":../");
+ require_once("$CFG->dirroot/search/Zend/Search/Lucene.php");
+
+ mtrace("Checking activity modules:\n");
+
+ //the presence of the required search functions -
+ // * mod_iterator
+ // * mod_get_content_for_index
+ //are the sole basis for including a module in the index at the moment.
+
+ if ($mods = get_records_select('modules')) {
+ foreach ($mods as $mod) {
+ $class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
+
+ if (file_exists($class_file)) {
+ include_once($class_file);
+
+ if (!defined('SEARCH_'.strtoupper($mod->name).'_TYPE')) {
+ mtrace("ERROR: Constant 'SEARCH_".strtoupper($mod->name)."_TYPE' is not defined in /search/lib.php");
+ continue;
+ } //if
+
+ $iter_function = $mod->name.'_iterator';
+ $index_function = $mod->name.'_get_content_for_index';
+
+ if (function_exists($index_function) && function_exists($iter_function)) {
+ if (is_array($iter_function())) {
+ $documents = $index_function(array_pop($iter_function()));
+
+ if (is_array($documents)) {
+ mtrace("Success: '$mod->name' module seems to be ready for indexing.");
+ } else {
+ mtrace("ERROR: $index_function() doesn't seem to be returning an array.");
+ } //else
+ } else {
+ mtrace("ERROR: $iter_function() doesn't seem to be returning an object array.");
+ } //else
+ } else {
+ mtrace("ERROR: $iter_function() and/or $index_function() does not exist in $class_file");
+ } //else
+ } else {
+ mtrace("Notice: $class_file does not exist, this module will not be indexed.");
+ } //else
+ } //foreach
+ } //if
+
+ //finished modules
+ mtrace("\nFinished checking activity modules.");
+
+ //now blocks...
+ //
+
+ mtrace("
Back to query page or Start indexing.");
+ mtrace('');
+
+?>
\ No newline at end of file