Permalink
Browse files

Date field added to documents.

  • Loading branch information...
mchampan
mchampan committed Aug 16, 2006
1 parent b3e900c commit ecebdf0e6e6ae98fccb49fe0c41a88b49778c592
View
@@ -1,10 +1,12 @@
CREATE TABLE IF NOT EXISTS `prefix_search_documents` (
`id` int(11) NOT NULL auto_increment,
+ `docid` int(11) NOT NULL,
`doctype` varchar(12) NOT NULL default 'none',
`title` varchar(100) NOT NULL default '',
`url` varchar(100) NOT NULL default '',
+ `docdate` timestamp NOT NULL default '0',
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP,
`courseid` int(11) NOT NULL default '0',
`groupid` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=1;
+) ENGINE=MyISAM AUTO_INCREMENT=1;
View
@@ -1,9 +1,11 @@
CREATE TABLE prefix_search_documents (
id SERIAL8 PRIMARY KEY,
+ docid int4 NOT NULL,
doctype varchar(12) NOT NULL DEFAULT 'none',
title varchar(100) NOT NULL default '',
url varchar(100) NOT NULL default '',
+ docdate timestamp NOT NULL,
updated timestamp NOT NULL DEFAULT NOW(),
courseid int4,
groupid int4
-);
+);
@@ -10,6 +10,7 @@ public function __construct(&$doc, &$data, $document_type, $course_id, $group_id
$this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author));
$this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents));
$this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url));
+ $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date));
$this->addField(Zend_Search_Lucene_Field::Binary('data', serialize($data)));
@@ -12,6 +12,7 @@ public function __construct(&$post, $forum_id, $course_id, $group_id) {
$doc->title = $post['subject'];
$doc->author = $post['firstname']." ".$post['lastname'];
$doc->contents = $post['message'];
+ $doc->date = $post['created'];
$doc->url = forum_make_link($post['discussion'], $post['id']);
@@ -14,6 +14,7 @@ public function __construct(&$entry, $glossary_id, $course_id, $group_id) {
// generic information; required
$doc->docid = $entry['id'];
$doc->title = $entry['concept'];
+ $doc->date = $entry['timecreated'];
$user = get_recordset('user', 'id', $entry['userid'])->fields;
@@ -38,7 +39,7 @@ function glossary_make_link($entry_id) {
//preserve glossary pop-up, be careful where you place your ' and "s
//this function is meant to return a url that is placed between href='[url here]'
return "$CFG->wwwroot/mod/glossary/showentry.php?eid=$entry_id' onclick='return openpopup(\"/mod/glossary/showentry.php?eid=$entry_id\", \"entry\", \"menubar=0,location=0,scrollbars,resizable,width=600,height=450\", 0);";
- } //glossary_make_link
+ } //glossary_make_link
function glossary_iterator() {
return get_all_instances_in_courses("glossary", get_courses());
@@ -61,9 +62,23 @@ function glossary_get_content_for_index(&$glossary) {
return $documents;
} //glossary_get_content_for_index
+
+ function glossary_single_document($id) {
+ $entries = get_recordset('glossary_entries', 'id', $id);
+ $entry = $entries->fields;
+
+ $glossaries = get_recordset('glossary', 'id', $entry['glossaryid']);
+ $glossary = $glossaries->fields;
+
+ return new GlossarySearchDocument($entry, $entry['glossaryid'], $glossary['course'], -1);
+ } //glossary_single_document
function glossary_delete($info) {
return $info;
- } //glossary_delete
+ } //glossary_delete
+
+ function glossary_db_names() {
+ return array('id', 'glossary_entries', 'timemodified');
+ } //glossary_db_names
?>
@@ -7,6 +7,7 @@ public function __construct(&$resource) {
// generic information; required
$doc->docid = $resource['id'];
$doc->title = strip_tags($resource['name']);
+ $doc->date = $resource['timemodified'];
$doc->author = '';
$doc->contents = strip_tags($resource['summary']).' '.strip_tags($resource['alltext']);
@@ -21,6 +21,7 @@ public function __construct(&$page, $wiki_id, $course_id, $group_id) {
// generic information; required
$doc->docid = $page->id;
$doc->title = $page->pagename;
+ $doc->date = $page->timemodified;
//remove '(ip.ip.ip.ip)' from wiki author field
$doc->author = preg_replace('/\(.*?\)/', '', $page->author);

0 comments on commit ecebdf0

Please sign in to comment.