forked from koala-framework/koala-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Component.php
80 lines (72 loc) · 2.38 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
79
80
<?php
class Kwc_Basic_Download_Component extends Kwc_Abstract_Composite_Component
{
private $_fileRow;
public static function getSettings()
{
$ret = parent::getSettings();
$ret['ownModel'] = 'Kwc_Basic_Download_Model';
$ret['componentName'] = trlKwfStatic('Download');
$ret['componentCategory'] = 'special';
$ret['componentIcon'] = 'folder_link';
$ret['showFilesize'] = true;
$ret['showIcon'] = true;
$ret['rootElementClass'] = 'kwfUp-webStandard';
$ret['flags']['searchContent'] = true;
$ret['flags']['hasFulltext'] = true;
$ret['generators']['child']['component']['downloadTag'] = 'Kwc_Basic_DownloadTag_Component';
return $ret;
}
public function getTemplateVars()
{
$return = parent::getTemplateVars();
$fileRow = $this->_getFileRow();
$parentRow = $fileRow->getParentRow('File');
if ($this->_getSetting('showFilesize') && $parentRow) {
$return['filesize'] = $parentRow->getFileSize();
} else {
$return['filesize'] = null;
}
$return['infotext'] = $this->_getRow()->infotext;
if ($return['infotext'] == '' && $parentRow)
$return['infotext'] = $parentRow->filename;
if ($this->_getSetting('showIcon')) {
$return['icon'] = $this->getIcon();
} else {
$return['icon'] = null;
}
if ($parentRow) {
$return['extension'] = $parentRow->extension;
} else {
$return['extension'] = null;
}
return $return;
}
protected function _getFileRow()
{
if (!$this->_fileRow) {
$this->_fileRow = $this->getData()
->getChildComponent('-downloadTag')->
getComponent()->getFileRow();
}
return $this->_fileRow;
}
public function getIcon()
{
$fileRow = $this->_getFileRow()->getParentRow('File');
if (!$fileRow) return 'page_white_get';
return Kwf_Util_FileIcon::getFileIcon($fileRow->extension);
}
public function getSearchContent()
{
return $this->_getRow()->infotext;
}
public function getFulltextContent()
{
$ret = array();
$text = $this->_getRow()->infotext;
$ret['content'] = $text;
$ret['normalContent'] = $text;
return $ret;
}
}