/
Component.php
67 lines (58 loc) · 2.55 KB
/
Component.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
class Kwc_Blog_Detail_Component extends Kwc_Directories_Item_Detail_Component
{
public static function getSettings($param = null)
{
$ret = parent::getSettings($param);
$ret['generators']['child']['component']['content'] = 'Kwc_Paragraphs_Component';
$ret['rootElementClass'] = 'kwfUp-webStandard';
$ret['placeholder']['backLink'] = trlKwfStatic('Back to overview');
$ret['placeholder']['nextLink'] = false;
$ret['placeholder']['previousLink'] = false;
$ret['editComponents'] = array('content');
$ret['flags']['hasFulltext'] = true;
$ret['generators']['child']['component']['comments'] = 'Kwc_Blog_Comments_Directory_Component';
return $ret;
}
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
{
$ret = parent::getTemplateVars($renderer);
$ret['title'] = $this->getData()->row->title;
$ret['publish_date'] = $this->getData()->row->publish_date;
$ret['author'] = $this->getData()->row->author_firstname.' '.$this->getData()->row->author_lastname;
if ($this->_getPlaceholder('nextLink')) {
$s = new Kwf_Component_Select();
$s->whereGenerator('detail');
$s->order('publish_date', 'ASC');
$s->where(new Kwf_Model_Select_Expr_Higher('publish_date', new Kwf_Date($this->getData()->row->publish_date)));
$ret['nextPost'] = $this->getData()->parent->getChildComponent($s);
}
if ($this->_getPlaceholder('previousLink')) {
$s = new Kwf_Component_Select();
$s->whereGenerator('detail');
$s->order('publish_date', 'DESC');
$s->where(new Kwf_Model_Select_Expr_Lower('publish_date', new Kwf_Date($this->getData()->row->publish_date)));
$ret['previousPost'] = $this->getData()->parent->getChildComponent($s);
}
return $ret;
}
public function hasContent()
{
return $this->getData()->getChildComponent('-content')->hasContent();
}
public static function modifyItemData(Kwf_Component_Data $new)
{
parent::modifyItemData($new);
$new->publish_date = $new->row->publish_date;
$new->author = $new->row->author_firstname.' '.$new->row->author_lastname;
}
public function getFulltextContent()
{
$ret = array();
$ret['type'] = 'blog';
if (isset($this->getData()->row->publish_date)) {
$ret['created'] = new Kwf_DateTime($this->getData()->row->publish_date);
}
return $ret;
}
}