]> git.mjollnir.org Git - moodle.git/commitdiff
renew of the global search engine
authordiml <diml>
Thu, 12 Jul 2007 12:32:15 +0000 (12:32 +0000)
committerdiml <diml>
Thu, 12 Jul 2007 12:32:15 +0000 (12:32 +0000)
blocks/search/README.txt [new file with mode: 0644]
blocks/search/block_search.php
blocks/search/config_global.html
blocks/search/db/install.xml [new file with mode: 0644]
blocks/search/db/mysql.php
blocks/search/db/mysql.sql
blocks/search/db/postgres7.php
blocks/search/db/postgres7.sql

diff --git a/blocks/search/README.txt b/blocks/search/README.txt
new file mode 100644 (file)
index 0000000..48dfb9f
--- /dev/null
@@ -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
index 286b258eb794225f5b1aacfa91499357af026953..f696c716f028ee054d214418fb9cf06fe51a95e1 100644 (file)
@@ -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 =
     function specialisation() {
       //empty!
     } //specialisation
+    
+    /**
+    * wraps up to search engine cron
+    *
+    */
+    function cron(){
+        global $CFG;
+        
+        include($CFG->dirroot.'/search/cron.php');
+    }
       
   } //block_search
 
index 4f69a7da169b7129009d301d2f0e888bc76da52d..d60de30daaf85d21afc8eba4d255cfae5716a294 100644 (file)
 <div style="text-align:center;">
-  <label for="block_search_text">Search label</label>
-  <input id="block_search_text" type="text" name="block_search_text" value="<?php 
-    if(isset($CFG->block_search_text)) {
-        p($CFG->block_search_text);
-    } else {
-        p("Search Moodle");
-    } ?>"/><br/>
-  
-  <label for="block_search_button">Button label</label>
-  <input id="block_search_button" type="text" name="block_search_button" value="<?php 
-    if(isset($CFG->block_search_button)) {
-        p($CFG->block_search_button);
-    } else {
-        p("Go");
-    } ?>"/><br/><br/>
-  
-  <input type="submit" value="<?php print_string('savechanges'); ?>" />
+<table cellspacing="5">
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configsearchtext', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_search_text" type="text" name="block_search_text" value="<?php 
+            if(isset($CFG->block_search_text)) {
+                p($CFG->block_search_text);
+            } else {
+                p(get_string('searchmoodle', 'block_search'));
+            } ?>"/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configbuttonlabel', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+          <input id="block_search_button" type="text" name="block_search_button" value="<?php 
+            if(isset($CFG->block_search_button)) {
+                p($CFG->block_search_button);
+            } else {
+                p(get_string('go', 'block_search'));
+            } ?>"/><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configenablefileindexing', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="1" <?php 
+            if(isset($CFG->block_search_enable_file_indexing) && $CFG->block_search_enable_file_indexing) {
+                echo " checked=\"checked\" ";
+            } ?> /> <?php print_string('yes') ?> - 
+            <input id="block_search_enable_file_indexing" type="radio" name="block_search_enable_file_indexing" value="0" <?php 
+            if(!isset($CFG->block_search_enable_file_indexing) || !$CFG->block_search_enable_file_indexing) {
+                echo " checked=\"checked\" ";
+            } ?> /> <?php print_string('no') ?>
+            <br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configfiletypes', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+          <input id="block_search_filetypes" type="text" name="block_search_filetypes" value="<?php 
+            if(isset($CFG->block_search_filetypes)) {
+                p($CFG->block_search_filetypes);
+            } else {
+                p("PDF,TXT,HTML,PPT,XML,DOC,HTM");
+            } ?>"/><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configpdftotextcmd', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_search_pdf_to_text_cmd" type="text" size="60" name="block_search_pdf_to_text_cmd" value="<?php 
+            if(isset($CFG->block_search_pdf_to_text_cmd)) {
+                p($CFG->block_search_pdf_to_text_cmd);
+            } else {
+                $encoding = ($CFG->unicodedb) ? "-enc UTF-8" : "-enc ISO-8859-1" ;
+                if ($CFG->ostype == 'WINDOWS'){
+                    p("lib/xpdf/win32/pdftotext.exe -eol dos $encoding -q");
+                }
+                else{
+                    p("lib/xpdf/linux/pdftotext $encoding -eol unix -q");
+                }
+            } ?>"/><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configwordtotextcmd', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_search_word_to_text_cmd" type="text" size="60" name="block_search_word_to_text_cmd" value="<?php 
+            if(isset($CFG->block_search_word_to_text_cmd)) {
+                p($CFG->block_search_word_to_text_cmd);
+            } else {
+                if ($CFG->ostype == 'WINDOWS'){
+                    p("lib/antiword/win32/antiword/antiword.exe ");
+                }
+                else{
+                    p("lib/antiword/linux/usr/bin/antiword");
+                }
+            } ?>"/><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configwordtotextenv', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_search_word_to_text_env" type="text" size="60" name="block_search_word_to_text_env" value="<?php 
+            if(isset($CFG->block_search_word_to_text_env)) {
+                echo stripslashes($CFG->block_search_word_to_text_env);
+            } else {
+                if ($CFG->ostype == 'WINDOWS'){
+                    p("HOME={$CFG->dirroot}\\lib\\antiword\\win32");
+                }
+                else{
+                    p("ANTIWORDHOME={$CFG->dirroot}/lib/antiword/linux/usr/share/antiword");
+                }
+            } ?>"/><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right">
+            <b><?php print_string('configlimitindexbody', 'block_search') ?>:</b>
+        </td>
+        <td valign="top" align="left">
+            <input id="block_search_limit_index_body" type="text" size="8" name="block_search_limit_index_body" value="<?php 
+            if(isset($CFG->block_search_limit_index_body)) {
+                p($CFG->block_search_limit_index_body);
+            } else {
+                p('');
+            } ?>"/> <?php print_string('bytes', 'block_search') ?><br/><br/>
+        </td>
+    </tr>
+    <tr>
+        <td valign="top" align="right" colspan="2">
+            <input type="submit" value="<?php print_string('savechanges'); ?>" />
+        </td>
+    </tr>
+</table>
 </div>
diff --git a/blocks/search/db/install.xml b/blocks/search/db/install.xml
new file mode 100644 (file)
index 0000000..7244090
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<XMLDB PATH="blocks/search/db" VERSION="20080801" COMMENT="XMLDB file for Moodle search engine">
+  <TABLES>
+    <TABLE NAME="search_documents" COMMENT="table to store search index backups">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="docid"/>
+        <FIELD NAME="docid" TYPE="char" LENGTH="32" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="doctype"/>
+        <FIELD NAME="doctype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="'none'" SEQUENCE="false" ENUM="false" PREVIOUS="docid" NEXT="itemtype"/>
+        <FIELD NAME="itemtype" TYPE="char" LENGTH="32" NOTNULL="true" DEFAULT="'standard'" SEQUENCE="false" ENUM="false" PREVIOUS="doctype" NEXT="title"/>
+        <FIELD NAME="title" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="''" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
+        <FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" DEFAULT="''" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
+        <FIELD NAME="docdate" TYPE="datetime" NOTNULL="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
+        <FIELD NAME="updated" TYPE="datetime" NOTNULL="true" DEFAULT="CURRENT_TIMESTAMP" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
+        <FIELD NAME="courseid" TYPE="int" LENGTH="11" NOTNULL="true" DEFAULT="0" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
+        <FIELD NAME="groupid" TYPE="int" LENGTH="11" NOTNULL="true" DEFAULT="0" UNSIGNED="true" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="Primary key for block"/>
+      </KEYS>
+      <INDEXES>
+        <INDEX NAME="mdl_search_docid" UNIQUE="false" FIELDS="docid" NEXT="mdl_search_doctype"/>
+        <INDEX NAME="mdl_search_doctype" UNIQUE="false" FIELDS="doctype" PREVIOUS="mdl_search_docid" NEXT="mdl_search_itemtype"/>
+        <INDEX NAME="mdl_search_itemtype" UNIQUE="false" FIELDS="itemtype" PREVIOUS="mdl_search_doctype"/>
+      </INDEXES>
+    </TABLE>
+  </TABLES>
+</XMLDB>
\ No newline at end of file
index 9914857349ae0dcb9fed926e5a78eb1307a3f73a..48244ee91ab6d6eedf28b19a84798734905f3504 100644 (file)
@@ -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.
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0f7969c345b802f8d3bedceacc0df70b9b87e39a 100644 (file)
@@ -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;
index d4729fe687feb9246d056326b8c0c776b7178797..b2d71b6bdd13f1089c5596c745fae0a9b25fde11 100644 (file)
@@ -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
     }
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f8249b04a1f6c80be41d31302ef5f9285de0fe36 100644 (file)
@@ -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
+);