<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for chat activity module
* This file contains the mapping between a chat history and it's indexable counterpart,
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/chat/lib.php
*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/chat/lib.php");
-/*
+/**
* a class for representing searchable information
*
-**/
+*/
class ChatTrackSearchDocument extends SearchDocument {
/**
* constructor
- *
*/
public function __construct(&$chatsession, $chat_module_id, $course_id, $group_id, $context_id) {
// generic information; required
// construct the parent class
parent::__construct($doc, $data, $course_id, $group_id, 0, PATH_FOR_SEARCH_TYPE_CHAT);
- } //constructor
-} //ChatTrackSearchDocument
+ }
+}
/**
* @param cm_id the chat course module
* @param start the start time of the session
* @param end th end time of the session
+* @uses CFG
* @return a well formed link to session display
*/
function chat_make_link($cm_id, $start, $end) {
global $CFG;
return $CFG->wwwroot.'/mod/chat/report.php?id='.$cm_id.'&start='.$start.'&end='.$end;
-} //chat_make_link
+}
/**
* fetches all the records for a given session and assemble them as a unique track
* we revamped here the code of report.php for making sessions, but without any output.
* note that we should collect sessions "by groups" if groupmode() is SEPARATEGROUPS.
* @param chat_id the database
+* @uses CFG
* @return an array of objects representing the chat sessions.
*/
function chat_get_session_tracks($chat_id, $fromtime = 0, $totime = 0) {
}
}
return $tracks;
-} //chat_get_session_tracks
+}
/**
* part of search engine API
function chat_iterator() {
$chatrooms = get_records('chat');
return $chatrooms;
-} //chat_iterator
+}
/**
* part of search engine API
return $documents;
}
return array();
-} //chat_get_content_for_index
+}
/**
* returns a single data search document based on a chat_session id
return $document;
}
return null;
-} //chat_single_document
+}
/**
* dummy delete function that packs id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //chat_delete
+}
/**
* returns the var names needed to build a sql query for addition/deletions
function chat_db_names() {
//[primary id], [table name], [time created field name], [time modified field name]
return null;
-} //chat_db_names
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
* points out a session history which is a close sequence of messages.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
+* @uses CFG
* @return true if access is allowed, false elsewhere
*/
function chat_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
}
return true;
-} //chat_check_text_access
+}
/**
* this call back is called when displaying the link for some last post processing
setLocale(LC_TIME, substr(current_language(), 0, 2));
$title = preg_replace('/TT_(.*)_TT/e', "userdate(\\1)", $title);
return $title;
-} //chat_link_post_processing
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for data activity module
* This file contains the mapping between a database object and it's indexable counterpart,
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/data/lib.php
*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/data/lib.php");
-/*
+/**
* a class for representing searchable information (data records)
*
-**/
+*/
class DataSearchDocument extends SearchDocument {
/**
* constructor
- *
*/
public function __construct(&$record, $course_id, $context_id) {
// generic information; required
// construct the parent class
parent::__construct($doc, $data, $course_id, $record['groupid'], $record['userid'], PATH_FOR_SEARCH_TYPE_DATA);
- } //constructor
-} //ChatSearchDocument
+ }
+}
-/*
+/**
* a class for representing searchable information (comments on data records)
*
-**/
+*/
class DataCommentSearchDocument extends SearchDocument {
/**
* constructor
- *
*/
public function __construct(&$comment, $course_id, $context_id) {
// generic information; required
// construct the parent class
parent::__construct($doc, $data, $course_id, $comment['groupid'], $comment['userid'], PATH_FOR_SEARCH_TYPE_DATA);
- } //constructor
-} //ChatCommentSearchDocument
+ }
+}
/**
* constructs a valid link to a data record content
* @param database_id the database reference
* @param record_id the record reference
+* @uses CFG
* @return a valid url top access the information as a string
*/
function data_make_link($database_id, $record_id) {
global $CFG;
return $CFG->wwwroot.'/mod/data/view.php?d='.$database_id.'&rid='.$record_id;
-} //data_make_link
+}
/**
* fetches all the records for a given database
* @param database_id the database
* @param typematch a comma separated list of types that should be considered for searching or *
+* @uses CFG
* @return an array of objects representing the data records.
*/
function data_get_records($database_id, $typematch = '*') {
if($typematch == '*' || preg_match("/\\b{$fieldset[$aDatum->fieldid]->type}\\b/", $typematch)){
if (!isset($records[$aDatum->recordid])){
$records[$aDatum->recordid]['_first'] = $aDatum->content.' '.$aDatum->content1.' '.$aDatum->content2.' '.$aDatum->content3.' '.$aDatum->content4.' ';
- }
- else{
+ } else {
$records[$aDatum->recordid][$fieldset[$aDatum->fieldid]->name] = $aDatum->content.' '.$aDatum->content1.' '.$aDatum->content2.' '.$aDatum->content3.' '.$aDatum->content4.' ';
}
}
}
}
return $records;
-} //data_get_records
+}
/**
* fetches all the comments for a given database
* @param database_id the database
+* @uses CFG
* @return an array of objects representing the data record comments.
*/
function data_get_comments($database_id) {
";
$comments = get_records_sql($query);
return $comments;
-} //data_get_comments
+}
/**
function data_iterator() {
$databases = get_records('data');
return $databases;
-} //data_iterator
+}
/**
* part of search engine API
}
}
return $documents;
-} //data_get_content_for_index
+}
/**
* returns a single data search document based on a data entry id
$recordMetaData->content = $accumulator;
// make document
$documents[] = new DataSearchDocument(get_object_vars($recordMetaData), $record_course, $context->id);
- }
- elseif($itemtype == 'comment'){
+ } elseif($itemtype == 'comment') {
// get main records
$comment = get_record('data_comments', 'id', $id);
$record = get_record('data_records', 'id', $comment->recordid);
$comment->groupid = $record->groupid;
// make document
$documents[] = new DataCommentSearchDocument(get_object_vars($comment), $record_course, $context->id);
- }
- else{
+ } else {
mtrace('Error : bad or missing item type');
}
-} //data_single_document
+}
/**
* dummy delete function that packs id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //data_delete
+}
/**
* returns the var names needed to build a sql query for addition/deletions
array('id', 'data_records', 'timecreated', 'timemodified', 'record'),
array('id', 'data_comments', 'created', 'modified', 'comment')
);
-} //data_db_names
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
* points out an indexed data record page.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
+* @uses CFG
* @return true if access is allowed, false elsewhere
*/
function data_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
}
return true;
-} // data_check_text_access
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* Base search document from which other module/block types can
* extend.
-**/
+*/
+/**
+*
+*/
abstract class SearchDocument extends Zend_Search_Lucene_Document {
public function __construct(&$doc, &$data, $course_id, $group_id, $user_id, $path) {
//document identification and indexing
// of multiple capabilities in their code. This possibility should be left open here.
$this->addField(Zend_Search_Lucene_Field::UnIndexed('capabilities', $caps));
*/
- } //constructor
-} //SearchDocument
+ }
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for forum activity module
* This file contains the mapping between a forum post and it's indexable counterpart,
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/forum/lib.php
*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
-/* see wiki_document.php for descriptions */
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/forum/lib.php");
-/*
+/**
* a class for representing searchable information
*
-**/
+*/
class ForumSearchDocument extends SearchDocument {
/**
* constructor
- *
*/
public function __construct(&$post, $forum_id, $course_id, $itemtype, $context_id) {
// generic information
$data->discussion = $post['discussion'];
parent::__construct($doc, $data, $course_id, $post['groupid'], $post['userid'], PATH_FOR_SEARCH_TYPE_FORUM);
- } //constructor
-} //ForumSearchDocument
+ }
+}
/**
* constructs a valid link to a chat content
global $CFG;
return $CFG->wwwroot.'/mod/forum/discuss.php?d='.$discussion_id.'#'.$post_id;
-} //forum_make_link
+}
/**
* search standard API
function forum_iterator() {
$forums = get_records('forum');
return $forums;
-} //forum_iterator
+}
/**
* search standard API
}
}
return $documents;
-} //forum_get_content_for_index
+}
/**
* returns a single forum search document based on a forum entry id
return new ForumSearchDocument(get_object_vars($post), $discussion->forum, $discussion->course, $itemtype, $context->id);
}
return null;
-} //forum_single_document
+}
/**
* dummy delete function that aggregates id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //forum_delete
+}
/**
* returns the var names needed to build a sql query for addition/deletions
array('id', 'forum_posts', 'created', 'modified', 'head', 'parent = 0'),
array('id', 'forum_posts', 'created', 'modified', 'post', 'parent != 0')
);
-} //forum_db_names
+}
/**
* reworked faster version from /mod/forum/lib.php
* @param forum_id a forum identifier
+* @uses CFG, USER
* @return an array of posts
*/
function forum_get_discussions_fast($forum_id) {
d.timemodified DESC
";
return get_records_sql($query);
-} //forum_get_discussions_fast
+}
/**
* reworked faster version from /mod/forum/lib.php
* @param parent the id of the first post within the discussion
* @param forum_id the forum identifier
+* @uses CFG
* @return an array of posts
*/
function forum_get_child_posts_fast($parent, $forum_id) {
p.created ASC
";
return get_records_sql($query);
-} //forum_get_child_posts_fast
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
* points out the individual post.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
+* @uses CFG, USER
* @return true if access is allowed, false elsewhere
*/
function forum_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
}
return true;
-} //forum_check_text_access
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for glossary activity module
* This file contains a mapping between a glossary entry and it's indexable counterpart,
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/glossary/lib.php
*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
-/*
+/**
* a class for representing searchable information
*
-**/
+*/
class GlossarySearchDocument extends SearchDocument {
/**
// construct the parent class
parent::__construct($doc, $data, $course_id, -1, $entry['userid'], PATH_FOR_SEARCH_TYPE_GLOSSARY);
- } //constructor
-} //GlossarySearchDocument
+ }
+}
-/*
+/**
* a class for representing searchable information
*
-**/
+*/
class GlossaryCommentSearchDocument extends SearchDocument {
/**
* document constructor
- *
*/
public function __construct(&$entry, $glossary_id, $course_id, $context_id) {
// generic information; required
// construct the parent class
parent::__construct($doc, $data, $course_id, -1, $entry['userid'], PATH_FOR_SEARCH_TYPE_GLOSSARY);
- } //constructor
-} //GlossaryCommentSearchDocument
+ }
+}
/**
* constructs valid access links to information
// preserve glossary pop-up, be careful where you place your ' and "s
//this function is meant to return a url that is placed between href='[url here]'
return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid=$entry_id\", \"entry\", DEFAULT_POPUP_SETTINGS, 0);";
-} //glossary_make_link
+}
/**
* part of search engine API
function glossary_iterator() {
$glossaries = get_records('glossary');
return $glossaries;
-} //glossary_iterator
+}
/**
* part of search engine API
}
}
return $documents;
-} //glossary_get_content_for_index
+}
/**
* part of search engine API
elseif ($itemtype == 'comment'){
return new GlossaryCommentSearchDocument(get_object_vars($comment), $entry->glossaryid, $glossary_course, $context->id);
}
-} //glossary_single_document
+}
/**
* dummy delete function that packs id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //glossary_delete
+}
/**
* returns the var names needed to build a sql query for addition/deletions
array('id', 'glossary_entries', 'timecreated', 'timemodified', 'standard'),
array('id', 'glossary_comments', 'timemodified', 'timemodified', 'comment')
);
-} //glossary_db_names
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
}
return true;
-} //glossary_check_text_access
-
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* creation : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for lesson activity module
* This file contains the mapping between a lesson page and it's indexable counterpart,
*
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/lesson/lib.php
-*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
-/* see wiki_document.php for descriptions */
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/lesson/lib.php");
-/*
+/**
* a class for representing searchable information
*
-**/
+*/
class LessonPageSearchDocument extends SearchDocument {
/**
$data->lesson = $page['lessonid'];
parent::__construct($doc, $data, $course_id, 0, 0, PATH_FOR_SEARCH_TYPE_LESSON);
- } //constructor
-} //LessonPageSearchDocument
+ }
+}
/**
* constructs a valid link to a chat content
return "{$CFG->wwwroot}/mod/lesson/view.php?id={$lessonmoduleid}&pageid={$itemid}";
}
return $CFG->wwwroot.'/mod/lesson/view.php?id='.$lessonmoduleid;
-} //lesson_make_link
+}
/**
* search standard API
function lesson_iterator() {
$lessons = get_records('lesson');
return $lessons;
-} //lesson_iterator
+}
/**
* search standard API
}
return $documents;
-} //lesson_get_content_for_index
+}
/**
* returns a single lesson search document based on a lesson page id
return new LessonPageSearchDocument(get_object_vars($page), $cm->id, $lesson->course, $itemtype, $context->id);
}
return null;
-} //lesson_single_document
+}
/**
* dummy delete function that aggregates id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //lesson_delete
+}
/**
* returns the var names needed to build a sql query for addition/deletions
return array(
array('id', 'lesson_pages', 'timecreated', 'timemodified', 'page')
);
-} //lesson_db_names
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
}
return true;
-} //lesson_check_text_access
+}
?>
\ No newline at end of file
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
-/*
+/**
* MS Word extractor
+* @param object $resource
+* @uses CFG, USER
*/
-
function get_text_for_indexing_doc(&$resource){
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) return;
+
+ $moodleroot = (@$CFG->block_search_usemoodleroot) ? "{$CFG->dirroot}/" : '' ;
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_word_to_text_cmd)){
- if (!file_exists("{$CFG->dirroot}/{$CFG->block_search_word_to_text_cmd}")){
- mtrace('Error with MSWord to text converter command : exectuable not found.');
+ if (!file_exists("{$moodleroot}{$CFG->block_search_word_to_text_cmd}")){
+ mtrace('Error with MSWord to text converter command : executable not found.');
}
else{
$file = escapeshellarg($CFG->dataroot.'/'.$resource->course.'/'.$resource->reference);
- $text_converter_cmd = "{$CFG->dirroot}/{$CFG->block_search_word_to_text_cmd} $file";
+ $text_converter_cmd = "\"{$moodleroot}{$CFG->block_search_word_to_text_cmd}\" \"$file\"";
if ($CFG->block_search_word_to_text_env){
putenv($CFG->block_search_word_to_text_env);
}
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
+/**
+* @param object $resource
+* @uses CFG, USER
+*/
function get_text_for_indexing_htm(&$resource){
global $CFG, $USER;
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
*
-* this is a format handler for getting text out of a proprietary binary format
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+*
+* this is a format handler for getting text out of a standard html format
* so it can be indexed by Lucene search engine
*/
+/**
+* @param object $resource
+*/
function get_text_for_indexing_html(&$resource){
// wraps to htm handler
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
+/**
+* @param object $resource
+* @uses CFG, USER
+*/
function get_text_for_indexing_pdf(&$resource){
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) return;
+ $moodleroot = (@$CFG->block_search_usemoodleroot) ? "{$CFG->dirroot}/" : '' ;
+
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_pdf_to_text_cmd)){
preg_match("/^\S+/", $CFG->block_search_pdf_to_text_cmd, $matches);
- if (!file_exists("{$CFG->dirroot}/{$matches[0]}")){
+ if (!file_exists("{$moodleroot}{$matches[0]}")){
mtrace('Error with pdf to text converter command : exectuable not found.');
}
else{
$file = escapeshellarg($CFG->dataroot.'/'.$resource->course.'/'.$resource->reference);
- $text_converter_cmd = "{$CFG->dirroot}/{$CFG->block_search_pdf_to_text_cmd} $file -";
+ $text_converter_cmd = "\"{$moodleroot}{$CFG->block_search_pdf_to_text_cmd}\" \"$file\" -";
$result = shell_exec($text_converter_cmd);
if ($result){
return $result;
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
-/**
+/*
* first implementation is a trivial heuristic based on ppt character stream :
* text sequence always starts with a 00 9F 0F 04 sequence followed by a 15 bytes
* sequence
* based on these following rules, here is a little empiric texte extractor for PPT
*/
+/**
+* @param object $resource
+* @uses CFG, USER
+*/
function get_text_for_indexing_ppt(&$resource){
global $CFG, $USER;
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
+/**
+* @param object $resource
+* @uses CFG, USER
+*/
function get_text_for_indexing_txt(&$resource){
global $CFG, $USER;
<?php
/**
* Global Search Engine for Moodle
-* add-on 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* this is a format handler for getting text out of a proprietary binary format
* so it can be indexed by Lucene search engine
*/
+/**
+* @param object $resource
+* @uses CFG, USER
+*/
function get_text_for_indexing_xml(&$resource){
global $CFG, $USER;
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for all resources
* This file contains the mapping between a resource and it's indexable counterpart,
*
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/resource/lib.php
-**/
+*/
+/**
+* requires and includes
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/resource/lib.php");
-/*
+/* *
* a class for representing searchable information
*
-**/
+*/
class ResourceSearchDocument extends SearchDocument {
public function __construct(&$resource, $context_id) {
// generic information; required
<?php
/**
* Global Search Engine for Moodle
-* Michael Champanis (mchampan) [cynnical@gmail.com]
-* review 1.8+ : Valery Fremaux [valery.fremaux@club-internet.fr]
-* 2007/08/02
+*
+* @package search
+* @category core
+* @subpackage document_wrappers
+* @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
+* @date 2008/03/31
+* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*
* document handling for wiki activity module
* This file contains the mapping between a wiki page and it's indexable counterpart,
*
* Functions for iterating and retrieving the necessary records are now also included
* in this file, rather than mod/wiki/lib.php
-*
-* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
-* @package search
-* @version 2007110400
-**/
+*/
+/**
+* includes and requires
+*/
require_once("$CFG->dirroot/search/documents/document.php");
require_once("$CFG->dirroot/mod/wiki/lib.php");
-/*
+/**
* All the $doc->___ fields are required by the base document class!
* Each and every module that requires search functionality must correctly
* map their internal fields to the five $doc fields (id, title, author, contents
* and url). Any module specific data can be added to the $data object, which is
* serialised into a binary field in the index.
-**/
+*/
class WikiSearchDocument extends SearchDocument {
public function __construct(&$page, $wiki_id, $course_id, $group_id, $user_id, $context_id) {
// generic information; required
// construct the parent class
parent::__construct($doc, $data, $course_id, $group_id, $user_id, PATH_FOR_SEARCH_TYPE_WIKI);
- } //constructor
-} //WikiSearchDocument
+ }
+}
/**
* converts a page name to cope Wiki constraints. Transforms spaces in plus.
*/
function wiki_name_convert($str) {
return str_replace(' ', '+', $str);
-} //wiki_name_convert
+}
/**
* constructs a valid link to a wiki content
-* @param wikiId
-* @param title
-* @param version
+* @param int $wikiId
+* @param string $title
+* @param int $version
+* @uses CFG
*/
function wiki_make_link($wikiId, $title, $version) {
global $CFG;
/**
* rescued and converted from ewikimoodlelib.php
* retrieves latest version of a page
-* @param entry the wiki object as a reference
-* @param pagename the name of the page known by the wiki engine
-* @param version
+* @param object $entry the wiki object as a reference
+* @param string $pagename the name of the page known by the wiki engine
+* @param int $version
*/
function wiki_get_latest_page(&$entry, $pagename, $version = 0) {
$pagename = "'".addslashes($pagename)."'";
} else {
return false;
}
-} //wiki_get_latest_page
+}
/**
* fetches all pages, including old versions
-* @param entry the wiki object as a reference
+* @param object $entry the wiki object as a reference
* @return an array of record objects that represents pages of this wiki object
*/
function wiki_get_pages(&$entry) {
return get_records('wiki_pages', 'wiki', $entry->id);
-} //wiki_get_pages
+}
/**
* fetches all the latest versions of all the pages
-*
+* @param object $entry
*/
function wiki_get_latest_pages(&$entry) {
//== (My)SQL for this
}
}
return $pages;
-} //wiki_get_latest_pages
+}
/**
* part of search engine API
function wiki_iterator() {
$wikis = get_records('wiki');
return $wikis;
-} //wiki_iterator
+}
/**
* part of search engine API
}
}
return $documents;
-} //wiki_get_content_for_index
+}
/**
* returns a single wiki search document based on a wiki_entry id
* @param id the id of the wiki
* @param itemtype the type of information (standard)
-* @retuen a searchable document
+* @return a searchable document
*/
function wiki_single_document($id, $itemtype) {
$page = get_record('wiki_pages', 'id', $id);
$cm = get_record('course_modules', 'course', $entry->course, 'module', $coursemodule, 'instance', $entry->wikiid);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
return new WikiSearchDocument(get_object_vars($page), $entry->wikiid, $entry->course, $entry->groupid, $page->userid, $context->id);
-} //wiki_single_document
+}
/**
* dummy delete function that packs id with itemtype.
$object->id = $info;
$object->itemtype = $itemtype;
return $object;
-} //wiki_delete
+}
//returns the var names needed to build a sql query for addition/deletions
function wiki_db_names() {
//[primary id], [table name], [time created field name], [time modified field name]
return array(array('id', 'wiki_pages', 'created', 'lastmodified', 'standard'));
-} //wiki_db_names
+}
/**
* this function handles the access policy to contents indexed as searchable documents. If this
* points out the indexed wiki page.
* @param user the user record denoting the user who searches
* @param group_id the current group used by the user when searching
+* @uses CFG
* @return true if access is allowed, false elsewhere
*/
function wiki_check_text_access($path, $itemtype, $this_id, $user, $group_id, $context_id){
}
return true;
-} //wiki_check_text_access
+}
?>
\ No newline at end of file
$phpversion = phpversion();
if (!search_check_php5()) {
- mtrace("ERROR: PHP 5.0.0 or later required (currently using version $phpversion).");
+ 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");
+ mtrace("Success: PHP 5.0.0 or later is installed (".phpversion().").\n");
} //else
//fix paths for testing