-
Notifications
You must be signed in to change notification settings - Fork 39
/
Component.php
78 lines (71 loc) · 2.28 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
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @package Kwc
* @subpackage Basic
*/
class Kwc_Basic_Html_Component extends Kwc_Abstract_Composite_Component
{
public static function getSettings($param = null)
{
$ret = array_merge(parent::getSettings($param), array(
'componentName' => trlKwfStatic('Html'),
'componentIcon' => 'tag',
'ownModel' => 'Kwc_Basic_Html_Model'
));
$ret['componentCategory'] = 'admin';
$ret['flags']['searchContent'] = true;
$ret['flags']['hasFulltext'] = true;
$ret['throwHasContentChangedOnRowColumnsUpdate'] = 'content';
return $ret;
}
private function _getContent($renderer)
{
$childComponents = array();
foreach ($this->getData()->getChildComponents(array('generator' => 'child')) as $c) {
$childComponents[$c->id] = $c;
}
$c = $this->_getRow()->content;
preg_match_all('#{([a-z0-9]+)}#', $c, $m);
if ($m[0]) {
$helper = new Kwf_Component_View_Helper_Component;
$helper->setRenderer($renderer);
foreach ($m[1] as $i) {
if (isset($childComponents[$i]) && $childComponents[$i] instanceof Kwf_Component_Data) {
$c = str_replace('{'.$i.'}', $helper->component($childComponents[$i]), $c);
}
}
}
return $c;
}
public function getExportData()
{
$ret = parent::getExportData();
$ret['content'] = $this->_getContent(new Kwf_Component_Renderer());
return $ret;
}
public function getTemplateVars(Kwf_Component_Renderer_Abstract $renderer)
{
$ret = parent::getTemplateVars($renderer);
if (!$renderer) {
throw new Kwf_Exception('renderer required');
}
$ret['content'] = $this->_getContent($renderer);
return $ret;
}
public function hasContent()
{
return trim($this->getRow()->content) != '';
}
public function getSearchContent()
{
return strip_tags($this->_getRow()->content);
}
public function getFulltextContent()
{
$ret = array();
$text = strip_tags($this->_getRow()->content);
$ret['content'] = $text;
$ret['normalContent'] = $text;
return $ret;
}
}