mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 08:55:15 +02:00
Resource doc type and Zend readme changed.
This commit is contained in:
parent
c629cfed33
commit
56e924061e
@ -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
|
||||
|
60
search/documents/resource_document.php
Normal file
60
search/documents/resource_document.php
Normal file
@ -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 " "
|
||||
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
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user