/
Comment.php
52 lines (44 loc) · 1.4 KB
/
Comment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
require_once 'Dase/DBO/Autogen/Comment.php';
class Dase_DBO_Comment extends Dase_DBO_Autogen_Comment
{
public $item = null;
function getItem()
{
if (!$this->item) {
$this->item = Dase_DBO_Item::get($this->db,$this->p_collection_ascii_id,$this->p_serial_number);
}
return $this->item;
}
function getTitle()
{
list($first_line) = explode("\n",$this->text);
if (strlen($first_line) > 100) {
$first_line = substr($first_line,0,100);
}
return $first_line;
}
function getUrl($app_root)
{
return $app_root.'/item/'.$this->p_collection_ascii_id.'/'.$this->p_serial_number.'/comments/'.$this->id;
}
function injectAtomEntryData(Dase_Atom_Entry_Comment $entry,$app_root)
{
if (!$this->id) { return false; }
$item = $this->getItem();
$entry->setTitle($this->getTitle());
$entry->addAuthor($this->updated_by_eid);
//for AtomPub -- is this correct??
$entry->addLink($this->getUrl($app_root));
$entry->addLink($this->getUrl($app_root).'.atom','self','application/atom+xml');
$entry->addLink($this->getUrl($app_root).'.atom','edit','application/atom+xml');
$entry->setUpdated($this->updated);
$entry->setId($this->getUrl($app_root));
if (!$this->type) { $this->type = 'text/html'; }
$entry->setContent($this->text,$this->type);
//add in-reply-to link
$item_url = $item->getUrl($app_root);
$entry->addInReplyTo($item_url,$this->type,$item_url);
return $entry;
}
}