]> git.mjollnir.org Git - moodle.git/commitdiff
Resource doc type and Zend readme changed.
authormchampan <mchampan>
Wed, 2 Aug 2006 15:31:59 +0000 (15:31 +0000)
committermchampan <mchampan>
Wed, 2 Aug 2006 15:31:59 +0000 (15:31 +0000)
search/Zend/IMPORTANT.txt
search/documents/resource_document.php [new file with mode: 0644]

index 56ecab0ccea0c3fd0b3a18052a3886858170ad8d..d8b80df59e8833fad0f1187e25ecad05dece5d69 100644 (file)
@@ -1,8 +1,9 @@
 We are running cutting-edge (i.e. HEAD) Zend Framework:
   URL: http://framework.zend.com/svn/framework/trunk
-  Revision: 696
-  Last Changed Rev: 696
-  Last Changed Date: 2006-06-23 02:14:54 +0200 (Fri, 23 Jun 2006)
+  Revision: 924
+  Last Changed Rev: 924
+  Last Changed Date: 2006-07-27 10:23:04 +0200 (Thu, 27 Jul 2006)
+
 
 This Zend Framework present in this directory only contains the minimum
 to run Zend_Search_Lucene - I don't foresee any problems, since the license
diff --git a/search/documents/resource_document.php b/search/documents/resource_document.php
new file mode 100644 (file)
index 0000000..ee5b6f2
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+  require_once("$CFG->dirroot/search/documents/document.php");
+  
+  class ResourceSearchDocument extends SearchDocument {  
+    public function __construct(&$resource) {
+      // generic information; required
+      $doc->docid     = $resource['id'];
+      $doc->title     = strip_tags($resource['name']);
+                      
+      $doc->author    = '';
+      $doc->contents  = strip_tags($resource['summary']).' '.strip_tags($resource['alltext']);
+      $doc->url       = resource_make_link($resource['id']);      
+      
+      // module specific information; optional
+      $data = array();
+      
+      // construct the parent class
+      parent::__construct($doc, $data, SEARCH_TYPE_RESOURCE, $resource['course'], -1);
+    } //constructor    
+  } //ResourceSearchDocument  
+
+  function resource_make_link($resource_id) {
+    global $CFG;    
+    return $CFG->wwwroot.'/mod/resource/view.php?r='.$resource_id;    
+  } //resource_make_link
+    
+  function resource_iterator() {
+    //trick to leave search indexer functionality intact, but allow
+    //this document to only use the below function to return info
+    //to be searched
+    return array(true);   
+  } //resource_iterator
+  
+  //this function does not need a content iterator, returns all the info
+  //itself; remember to fake the iterator array though
+  function resource_get_content_for_index(&$notneeded) {
+    $documents = array();
+    
+    $resources = get_recordset_sql('SELECT *
+                              FROM `resource`
+                              WHERE alltext NOT LIKE ""
+                              AND alltext NOT LIKE " "
+                              AND alltext NOT LIKE "&nbsp;"
+                              AND TYPE != "file"');       
+    
+    while (!$resources->EOF) {
+      $resource = $resources->fields;
+      
+      if ($resource) {
+        $documents[] = new ResourceSearchDocument($resource);
+      } //if
+      
+      $resources->MoveNext();
+    } //foreach
+    
+    return $documents;
+  } //resource_get_content_for_index
+  
+?>
\ No newline at end of file