From 603042b740a3c1a539c3a4070b100111a0938a43 Mon Sep 17 00:00:00 2001 From: diml Date: Thu, 8 Nov 2007 20:13:14 +0000 Subject: [PATCH] General syncback from HEAD branch (2.0) --- blocks/search/README.txt | 15 ++++ blocks/search/block_search.php | 21 +++-- blocks/search/config_global.html | 147 +++++++++++++++++++++++++++---- blocks/search/db/install.xml | 30 +++++++ blocks/search/db/mysql.php | 24 ----- blocks/search/db/postgres7.php | 24 ----- blocks/search/db/upgrade.php | 75 ++++++++++++++++ 7 files changed, 266 insertions(+), 70 deletions(-) create mode 100644 blocks/search/README.txt create mode 100644 blocks/search/db/install.xml delete mode 100644 blocks/search/db/mysql.php delete mode 100644 blocks/search/db/postgres7.php diff --git a/blocks/search/README.txt b/blocks/search/README.txt new file mode 100644 index 0000000000000..48dfb9f4679cd --- /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 286b258eb7942..f75fa1668ef65 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 = 2007081100; } //init // only one instance of this block is required @@ -45,8 +46,8 @@ function get_content() { //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 = (!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 = @@ -68,7 +69,17 @@ function get_content() { function specialisation() { //empty! } //specialisation + + /** + * wraps up to search engine cron + * + */ + function cron(){ + global $CFG; + + include($CFG->dirroot.'/search/cron.php'); + } } //block_search -?> \ No newline at end of file +?> diff --git a/blocks/search/config_global.html b/blocks/search/config_global.html index 4f69a7da169b7..d60de30daaf85 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 0000000000000..b118e4e1b2ced --- /dev/null +++ b/blocks/search/db/install.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
diff --git a/blocks/search/db/mysql.php b/blocks/search/db/mysql.php deleted file mode 100644 index 9914857349ae0..0000000000000 --- a/blocks/search/db/mysql.php +++ /dev/null @@ -1,24 +0,0 @@ -addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null); + $table->addFieldInfo('docid', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, null); + $table->addFieldInfo('doctype', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'none'); + $table->addFieldInfo('itemtype', XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'standard'); + $table->addFieldInfo('title', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null); + $table->addFieldInfo('url', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null); + $table->addFieldInfo('docdate', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL, null, null, null); + $table->addFieldInfo('updated', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL, null, null, null); + $table->addFieldInfo('courseid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + $table->addFieldInfo('groupid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0'); + + /// Adding keys to table search_documents + $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id')); + + /// Adding indexes to table search_documents + $table->addIndexInfo('mdl_search_docid', XMLDB_INDEX_NOTUNIQUE, array('docid')); + $table->addIndexInfo('mdl_search_doctype', XMLDB_INDEX_NOTUNIQUE, array('doctype')); + $table->addIndexInfo('mdl_search_itemtype', XMLDB_INDEX_NOTUNIQUE, array('itemtype')); + + /// Launch create table for search_documents + $result = $result && create_table($table); + } + +/// Rename table search_documents to block_search_documents and +/// fix some defaults (MDL-10572) + if ($result && $oldversion < 2007081100) { + + /// Define table search_documents to be renamed to block_search_documents + $table = new XMLDBTable('search_documents'); + + /// Launch rename table for block_search_documents + $result = $result && rename_table($table, 'block_search_documents'); + + /// Changing the default of field doctype on table block_search_documents to none + $table = new XMLDBTable('block_search_documents'); + $field = new XMLDBField('doctype'); + $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'none', 'docid'); + + /// Launch change of default for field doctype + $result = $result && change_field_default($table, $field); + + /// Changing the default of field itemtype on table block_search_documents to standard + $table = new XMLDBTable('block_search_documents'); + $field = new XMLDBField('itemtype'); + $field->setAttributes(XMLDB_TYPE_CHAR, '32', null, XMLDB_NOTNULL, null, null, null, 'standard', 'doctype'); + + /// Launch change of default for field itemtype + $result = $result && change_field_default($table, $field); + + /// Changing the default of field title on table block_search_documents to drop it + $table = new XMLDBTable('block_search_documents'); + $field = new XMLDBField('title'); + $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'itemtype'); + + /// Launch change of default for field title + $result = $result && change_field_default($table, $field); + + /// Changing the default of field url on table block_search_documents to drop it + $table = new XMLDBTable('block_search_documents'); + $field = new XMLDBField('url'); + $field->setAttributes(XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'title'); + + /// Launch change of default for field url + $result = $result && change_field_default($table, $field); + } return $result; }