Skip to content

Commit

Permalink
General syncback from HEAD branch (2.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
diml committed Nov 8, 2007
1 parent 386aed2 commit 603042b
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 70 deletions.
15 changes: 15 additions & 0 deletions 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.
21 changes: 16 additions & 5 deletions blocks/search/block_search.php
Expand Up @@ -14,8 +14,9 @@
class block_search extends block_base { class block_search extends block_base {


function init() { function init() {
$this->title = "Global Search"; //get_string() $this->title = get_string('blockname', 'block_search');
$this->version = 2006062500; $this->cron = 1;
$this->version = 2007081100;
} //init } //init


// only one instance of this block is required // only one instance of this block is required
Expand Down Expand Up @@ -45,8 +46,8 @@ function get_content() {
//lazy check for the moment //lazy check for the moment
if (check_php_version("5.0.0")) { if (check_php_version("5.0.0")) {
//fetch values if defined in admin, otherwise use defaults //fetch values if defined in admin, otherwise use defaults
$label = (isset($CFG->block_search_text)) ? $CFG->block_search_text : "Search Moodle"; $label = (!empty($CFG->block_search_text)) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
$button = (isset($CFG->block_search_button)) ? $CFG->block_search_button : "Go"; $button = (!empty($CFG->block_search_button)) ? $CFG->block_search_button : get_string('go', 'block_search');


//basic search form //basic search form
$this->content->text = $this->content->text =
Expand All @@ -68,7 +69,17 @@ function get_content() {
function specialisation() { function specialisation() {
//empty! //empty!
} //specialisation } //specialisation

/**
* wraps up to search engine cron
*
*/
function cron(){
global $CFG;

include($CFG->dirroot.'/search/cron.php');
}


} //block_search } //block_search


?> ?>
147 changes: 130 additions & 17 deletions blocks/search/config_global.html
@@ -1,19 +1,132 @@
<div style="text-align:center;"> <div style="text-align:center;">
<label for="block_search_text">Search label</label> <table cellspacing="5">
<input id="block_search_text" type="text" name="block_search_text" value="<?php <tr>
if(isset($CFG->block_search_text)) { <td valign="top" align="right">
p($CFG->block_search_text); <b><?php print_string('configsearchtext', 'block_search') ?>:</b>
} else { </td>
p("Search Moodle"); <td valign="top" align="left">
} ?>"/><br/> <input id="block_search_text" type="text" name="block_search_text" value="<?php

if(isset($CFG->block_search_text)) {
<label for="block_search_button">Button label</label> p($CFG->block_search_text);
<input id="block_search_button" type="text" name="block_search_button" value="<?php } else {
if(isset($CFG->block_search_button)) { p(get_string('searchmoodle', 'block_search'));
p($CFG->block_search_button); } ?>"/><br/>
} else { </td>
p("Go"); </tr>
} ?>"/><br/><br/> <tr>

<td valign="top" align="right">
<input type="submit" value="<?php print_string('savechanges'); ?>" /> <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> </div>
30 changes: 30 additions & 0 deletions blocks/search/db/install.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="blocks/search/db" VERSION="20070811" COMMENT="XMLDB file for Moodle search engine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="block_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" SEQUENCE="false" ENUM="false" PREVIOUS="itemtype" NEXT="url"/>
<FIELD NAME="url" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="title" NEXT="docdate"/>
<FIELD NAME="docdate" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="url" NEXT="updated"/>
<FIELD NAME="updated" TYPE="datetime" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="docdate" NEXT="courseid"/>
<FIELD NAME="courseid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="updated" NEXT="groupid"/>
<FIELD NAME="groupid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="courseid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" />
</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>
24 changes: 0 additions & 24 deletions blocks/search/db/mysql.php

This file was deleted.

24 changes: 0 additions & 24 deletions blocks/search/db/postgres7.php

This file was deleted.

75 changes: 75 additions & 0 deletions blocks/search/db/upgrade.php
Expand Up @@ -31,6 +31,81 @@ function xmldb_block_search_upgrade($oldversion=0) {
/// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php
/// $result = result of "/lib/ddllib.php" function calls /// $result = result of "/lib/ddllib.php" function calls
/// } /// }
if ($result && $oldversion < 2007071302) {

/// Define table search_documents to be created
$table = new XMLDBTable('search_documents');

/// Drop it if it existed before

drop_table($table, true, false);

/// Adding fields to table search_documents
$table->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; return $result;
} }
Expand Down

0 comments on commit 603042b

Please sign in to comment.