]> git.mjollnir.org Git - moodle.git/commitdiff
Option for additional search types added.
authormchampan <mchampan>
Wed, 2 Aug 2006 15:17:46 +0000 (15:17 +0000)
committermchampan <mchampan>
Wed, 2 Aug 2006 15:17:46 +0000 (15:17 +0000)
search/indexer.php
search/lib.php
search/tests/index.php

index 12968541d0b71ce02a0100b265d85e90b305170e..c7d8df8ac289707f68ad8fbec686cc5edc2b8be1 100644 (file)
   // * 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)) {
               $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);                  
index a64c776b2fb39c27733af230b17fc03a33b4a702..27c7c26f7176af3b9f6df9ec8e993f9a97f399ba 100644 (file)
@@ -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') {
     
     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) {    
index 49ddb39f99370cb5af97c01517fc4b4c14293e9c..37de0dc00e9a78b16723ce8a7576b65f7b1e178b 100644 (file)
@@ -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';