Permalink
Browse files

Resource doc type and Zend readme changed.

  • Loading branch information...
1 parent c629cfe commit 56e924061e04eff42919e3e47bc1d55b0e83efe0 mchampan committed Aug 2, 2006
Showing with 64 additions and 3 deletions.
  1. +4 −3 search/Zend/IMPORTANT.txt
  2. +60 −0 search/documents/resource_document.php
@@ -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
@@ -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
+
+?>

0 comments on commit 56e9240

Please sign in to comment.