Permalink
Browse files

Option for additional search types added.

  • Loading branch information...
1 parent 01e6afe commit c629cfed336dd0b0f8b0759560fc30da0e38fd82 mchampan committed Aug 2, 2006
Showing with 27 additions and 5 deletions.
  1. +5 −4 search/indexer.php
  2. +20 −1 search/lib.php
  3. +2 −0 search/tests/index.php
View
@@ -104,9 +104,10 @@
// * mod_get_content_for_index
//are the sole basis for including a module in the index at the moment.
- if ($mods = get_records_select('modules' /*'index this module?' where statement*/)) {
- foreach ($mods as $mod) {
- if ($mod->name == 'forum') continue;
+ if ($mods = get_records_select('modules' /*'index this module?' where statement*/)) {
+ $mods = array_merge($mods, search_get_additional_modules());
+
+ foreach ($mods as $mod) {
$class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';
if (file_exists($class_file)) {
@@ -141,7 +142,7 @@
$id = insert_record('search_documents', $doc);
//synchronise db with index
- $document->addField(Zend_Search_Lucene_Field::Keyword('db_id', $id));
+ $document->addField(Zend_Search_Lucene_Field::Keyword('dbid', $id));
//add document to index
$index->addDocument($document);
View
@@ -14,7 +14,8 @@
define('SEARCH_TYPE_NONE', 'none');
define('SEARCH_TYPE_WIKI', 'wiki');
define('SEARCH_TYPE_FORUM', 'forum');
- define('SEARCH_TYPE_GLOSSARY', 'glossary');
+ define('SEARCH_TYPE_GLOSSARY', 'glossary');
+ define('SEARCH_TYPE_RESOURCE', 'resource');
//returns all the document type constants
function search_get_document_types($prefix='SEARCH_TYPE') {
@@ -28,6 +29,24 @@ function search_get_document_types($prefix='SEARCH_TYPE') {
return $ret;
} //search_get_document_types
+
+ // additional virtual modules to index
+ //
+ // By adding 'moo' to the extras array, an additional document type
+ // documents/moo_document.php will be indexed - this allows for
+ // virtual modules to be added to the index, i.e. non-module specific
+ // information.
+ function search_get_additional_modules() {
+ $extras = array(/* additional keywords go here */);
+ $ret = array();
+
+ foreach($extras as $extra) {
+ $temp->name = $extra;
+ $ret[] = clone($temp);
+ } //foreach
+
+ return $ret;
+ } //search_get_additional_modules
//shortens a url so it can fit on the results page
function search_shorten_url($url, $length=30) {
View
@@ -43,6 +43,8 @@
//are the sole basis for including a module in the index at the moment.
if ($mods = get_records_select('modules')) {
+ $mods = array_merge($mods, search_get_additional_modules());
+
foreach ($mods as $mod) {
$class_file = $CFG->dirroot.'/search/documents/'.$mod->name.'_document.php';

0 comments on commit c629cfe

Please sign in to comment.