|
1
|
|
|
<?php |
|
2
|
|
|
namespace Fab\Vidi\Grid; |
|
3
|
|
|
|
|
4
|
|
|
/* |
|
5
|
|
|
* This file is part of the Fab/Vidi project under GPLv2 or later. |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please read the |
|
8
|
|
|
* LICENSE.md file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
use Fab\Vidi\Module\ModuleLoader; |
|
12
|
|
|
use TYPO3\CMS\Core\Imaging\IconFactory; |
|
13
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
14
|
|
|
use TYPO3\CMS\Lang\LanguageService; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Abstract class for rendering a column in the Grid. |
|
18
|
|
|
*/ |
|
19
|
|
|
abstract class ColumnRendererAbstract implements ColumnRendererInterface |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The content object. |
|
24
|
|
|
* |
|
25
|
|
|
* @var \Fab\Vidi\Domain\Model\Content |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $object; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $fieldName; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var int |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $rowIndex; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var array |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $fieldConfiguration = []; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $gridRendererConfiguration = []; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var array |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $configuration = []; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Constructor of a Generic component in Vidi. |
|
56
|
|
|
* |
|
57
|
|
|
* @param array $configuration |
|
58
|
|
|
* @param array $legacyParameterConfiguration |
|
59
|
|
|
*/ |
|
60
|
|
|
public function __construct($configuration = [], $legacyParameterConfiguration = array()) |
|
61
|
|
|
{ |
|
62
|
|
|
if (is_string($configuration)) { |
|
63
|
|
|
$configuration = $legacyParameterConfiguration; |
|
64
|
|
|
GeneralUtility::deprecationLog('ColumnRendererAbstract: first parameter must now be an array. Please edit me in ' . get_class($this)); |
|
65
|
|
|
} |
|
66
|
|
|
$this->configuration = $configuration; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return array |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getConfiguration() |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->configuration; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return \Fab\Vidi\Domain\Model\Content |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getObject() |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->object; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param \Fab\Vidi\Domain\Model\Content $object |
|
87
|
|
|
* @return $this |
|
88
|
|
|
*/ |
|
89
|
|
|
public function setObject($object) |
|
90
|
|
|
{ |
|
91
|
|
|
$this->object = $object; |
|
92
|
|
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @return string |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getFieldName() |
|
99
|
|
|
{ |
|
100
|
|
|
return $this->fieldName; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @param string $fieldName |
|
105
|
|
|
* @return $this |
|
106
|
|
|
*/ |
|
107
|
|
|
public function setFieldName($fieldName) |
|
108
|
|
|
{ |
|
109
|
|
|
$this->fieldName = $fieldName; |
|
110
|
|
|
return $this; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* @return int |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getRowIndex() |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->rowIndex; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* @param int $rowIndex |
|
123
|
|
|
* @return $this |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setRowIndex($rowIndex) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->rowIndex = $rowIndex; |
|
128
|
|
|
return $this; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* @return array |
|
133
|
|
|
*/ |
|
134
|
|
|
public function getFieldConfiguration() |
|
135
|
|
|
{ |
|
136
|
|
|
return $this->fieldConfiguration; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @param array $fieldConfiguration |
|
141
|
|
|
* @return $this |
|
142
|
|
|
*/ |
|
143
|
|
|
public function setFieldConfiguration($fieldConfiguration) |
|
144
|
|
|
{ |
|
145
|
|
|
$this->fieldConfiguration = $fieldConfiguration; |
|
146
|
|
|
return $this; |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
/** |
|
150
|
|
|
* @return array |
|
151
|
|
|
*/ |
|
152
|
|
|
public function getGridRendererConfiguration() |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->gridRendererConfiguration; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* @param array $gridRendererConfiguration |
|
159
|
|
|
* @return $this |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setGridRendererConfiguration($gridRendererConfiguration) |
|
162
|
|
|
{ |
|
163
|
|
|
$this->gridRendererConfiguration = $gridRendererConfiguration; |
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function. |
|
169
|
|
|
* |
|
170
|
|
|
* @param string $value string to format |
|
171
|
|
|
* @param bool $keepQuotes if TRUE, single and double quotes won't be replaced (sets ENT_NOQUOTES flag) |
|
172
|
|
|
* @param string $encoding |
|
173
|
|
|
* @return string |
|
174
|
|
|
* @see http://www.php.net/manual/function.htmlentities.php |
|
175
|
|
|
* @api |
|
176
|
|
|
*/ |
|
177
|
|
|
protected function secure($value , $keepQuotes = false, $encoding = 'UTF-8') |
|
178
|
|
|
{ |
|
179
|
|
|
$flags = $keepQuotes ? ENT_NOQUOTES : ENT_COMPAT; |
|
180
|
|
|
return htmlspecialchars($value, $flags, $encoding); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* Get the Vidi Module Loader. |
|
185
|
|
|
* |
|
186
|
|
|
* @return object|ModuleLoader |
|
187
|
|
|
*/ |
|
188
|
|
|
protected function getModuleLoader() |
|
189
|
|
|
{ |
|
190
|
|
|
return GeneralUtility::makeInstance(ModuleLoader::class); |
|
191
|
|
|
} |
|
192
|
|
|
|
|
193
|
|
|
/** |
|
194
|
|
|
* @return object|IconFactory |
|
195
|
|
|
*/ |
|
196
|
|
|
protected function getIconFactory() |
|
197
|
|
|
{ |
|
198
|
|
|
return GeneralUtility::makeInstance(IconFactory::class); |
|
199
|
|
|
} |
|
200
|
|
|
|
|
201
|
|
|
/** |
|
202
|
|
|
* @return object|LanguageService |
|
203
|
|
|
*/ |
|
204
|
|
|
protected function getLanguageService() |
|
205
|
|
|
{ |
|
206
|
|
|
return GeneralUtility::makeInstance(LanguageService::class); |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
} |
|
210
|
|
|
|