Initial commit
[moodle.git] / search / documents / wiki_document.php
1 <?php
3   require_once("$CFG->dirroot/search/documents/document.php");
4   
5   class WikiSearchDocument extends SearchDocument {  
6     public function __construct(&$page, $wiki_id, $cid, $uid, $gid) {
7       $this->addField(Zend_Search_Lucene_Field::Text('title', $page->pagename));
8       $this->addField(Zend_Search_Lucene_Field::Text('author', $page->author));
9       $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $page->content));
10       
11       $this->addField(Zend_Search_Lucene_Field::Keyword('id', $page->id));
12       $this->addField(Zend_Search_Lucene_Field::Keyword('version', $page->version));
13       $this->addField(Zend_Search_Lucene_Field::Keyword('wiki', $wiki_id));
14       
15       parent::__construct(SEARCH_WIKI_TYPE, $cid, $uid, $gid);
16     } //constructor    
17   } //WikiSearchDocument
18   
19   function wiki_name_convert($str) {
20     return str_replace(' ', '+', $str);
21   } //wiki_name_convert
22   
23   function wiki_make_link(&$doc) {
24     global $CFG;    
25     return $CFG->wwwroot.'/mod/wiki/view.php?wid='.$doc->wiki.'&page='.wiki_name_convert($doc->title).'&version='.$doc->version;
26   } //wiki_make_link
27   
28 ?>