From 918fb61f41f170c8d98227c38553b1c58bb2508b Mon Sep 17 00:00:00 2001 From: diml Date: Thu, 12 Jul 2007 12:32:15 +0000 Subject: [PATCH] renew of the global search engine --- blocks/search/README.txt | 15 ++++ blocks/search/block_search.php | 19 +++- blocks/search/config_global.html | 147 +++++++++++++++++++++++++++---- blocks/search/db/install.xml | 27 ++++++ blocks/search/db/mysql.php | 10 ++- blocks/search/db/mysql.sql | 13 +++ blocks/search/db/postgres7.php | 2 +- blocks/search/db/postgres7.sql | 12 +++ 8 files changed, 221 insertions(+), 24 deletions(-) create mode 100644 blocks/search/README.txt create mode 100644 blocks/search/db/install.xml diff --git a/blocks/search/README.txt b/blocks/search/README.txt new file mode 100644 index 0000000000..48dfb9f467 --- /dev/null +++ b/blocks/search/README.txt @@ -0,0 +1,15 @@ +This block is a revamping of the Google Summer Of Code Project (2006) on Global Search engine +for Moodle. New block version is completed and internationalized according to Moodle multilengual support. + +This block instanciates a startup database model for the search engine. + +## Installing + +You need installing the following elements in order the global search to be available : + +1. The global search bloc (this block) +2. update the /search root package from CVS +3. The antiword libraries +4. The xpdf libraries + +Both last libraries are provided as a patch called "global_search_libraries" in the contrib section. \ No newline at end of file diff --git a/blocks/search/block_search.php b/blocks/search/block_search.php index 286b258eb7..f696c716f0 100644 --- a/blocks/search/block_search.php +++ b/blocks/search/block_search.php @@ -14,8 +14,9 @@ class block_search extends block_base { function init() { - $this->title = "Global Search"; //get_string() - $this->version = 2006062500; + $this->title = get_string('blockname', 'block_search'); + $this->cron = 1; + $this->version = 2007062900; } //init // only one instance of this block is required @@ -45,8 +46,8 @@ //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"; + $label = (isset($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search'); + $button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search'); //basic search form $this->content->text = @@ -68,6 +69,16 @@ function specialisation() { //empty! } //specialisation + + /** + * wraps up to search engine cron + * + */ + function cron(){ + global $CFG; + + include($CFG->dirroot.'/search/cron.php'); + } } //block_search diff --git a/blocks/search/config_global.html b/blocks/search/config_global.html index 4f69a7da16..d60de30daa 100644 --- a/blocks/search/config_global.html +++ b/blocks/search/config_global.html @@ -1,19 +1,132 @@
- - "/>
- - - "/>

- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ : + +
+
+ : + +

+
+ : + + block_search_enable_file_indexing) && $CFG->block_search_enable_file_indexing) { + echo " checked=\"checked\" "; + } ?> /> - + block_search_enable_file_indexing) || !$CFG->block_search_enable_file_indexing) { + echo " checked=\"checked\" "; + } ?> /> +

+
+ : + + "/>

+
+ : + + ostype == 'WINDOWS'){ + p("lib/xpdf/win32/pdftotext.exe -eol dos $encoding -q"); + } + else{ + p("lib/xpdf/linux/pdftotext $encoding -eol unix -q"); + } + } ?>"/>

+
+ : + + "/>

+
+ : + + dirroot}\\lib\\antiword\\win32"); + } + else{ + p("ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword"); + } + } ?>"/>

+
+ : + +

+
+ +
diff --git a/blocks/search/db/install.xml b/blocks/search/db/install.xml new file mode 100644 index 0000000000..724409018b --- /dev/null +++ b/blocks/search/db/install.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/blocks/search/db/mysql.php b/blocks/search/db/mysql.php index 9914857349..48244ee91a 100644 --- a/blocks/search/db/mysql.php +++ b/blocks/search/db/mysql.php @@ -13,8 +13,14 @@ function search_upgrade($oldversion=0) { $result = true; - if ($oldversion < 2006062500 and $result) { - $result = true; //Nothing to do + if ($oldversion < 2007080100 and $result) { + modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` ADD `item_type` VARCHAR( 32 ) NOT NULL AFTER `doctype` ; "); + modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` ADD INDEX ( `item_type` ) ; "); + modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `doctype` `doctype` VARCHAR( 32 ) DEFAULT 'none' ; "); + modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `title` `title` VARCHAR( 255 ) ; "); + modify_database ("", "ALTER TABLE `{$CFG->prefix}search_documents` CHANGE `url` `url` VARCHAR( 255 ) ; "); + modify_database ("", "ALTER TABLE `{$CFG->prefix}mdl_search_documents` CHANGE `docid` `docid` VARCHAR( 32 ) ; "); + $result = true; } ////// DO NOT ADD NEW THINGS HERE!! USE upgrade.php and the lib/ddllib.php functions. diff --git a/blocks/search/db/mysql.sql b/blocks/search/db/mysql.sql index e69de29bb2..0f7969c345 100644 --- a/blocks/search/db/mysql.sql +++ b/blocks/search/db/mysql.sql @@ -0,0 +1,13 @@ +CREATE TABLE IF NOT EXISTS `prefix_search_documents` ( + `id` int(11) NOT NULL auto_increment, + `docid` varchar(32) NOT NULL, + `doctype` varchar(32) NOT NULL default 'none', + `itemtype` varchar(32) NOT NULL default 'standard', + `title` varchar(255) NOT NULL default '', + `url` varchar(255) NOT NULL default '', + `docdate` timestamp NOT NULL default 0, + `updated` timestamp NOT NULL default CURRENT_TIMESTAMP, + `courseid` int(11) NOT NULL default 0, + `groupid` int(11) NOT NULL default 0, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=1; diff --git a/blocks/search/db/postgres7.php b/blocks/search/db/postgres7.php index d4729fe687..b2d71b6bdd 100644 --- a/blocks/search/db/postgres7.php +++ b/blocks/search/db/postgres7.php @@ -13,7 +13,7 @@ function search_upgrade($oldversion=0) { $result = true; - if ($oldversion < 2006062500 and $result) { + if ($oldversion < 2007080100 and $result) { $result = true; //Nothing to do } diff --git a/blocks/search/db/postgres7.sql b/blocks/search/db/postgres7.sql index e69de29bb2..f8249b04a1 100644 --- a/blocks/search/db/postgres7.sql +++ b/blocks/search/db/postgres7.sql @@ -0,0 +1,12 @@ +CREATE TABLE prefix_search_documents ( + id SERIAL8 PRIMARY KEY, + docid int4 NOT NULL, + doctype varchar(12) NOT NULL default 'none', + itemtype varchar(32) NOT NULL default 'standard', + title varchar(255) NOT NULL default '', + url varchar(255) NOT NULL default '', + docdate timestamp NOT NULL, + updated timestamp NOT NULL default NOW(), + courseid int4, + groupid int4 +); -- 2.39.5