1 | <?php |
||
19 | class Action extends Column |
||
20 | 1 | { |
|
21 | |||
22 | 1 | use Traits\TButtonTryAddIcon; |
|
23 | 1 | use Traits\TButtonText; |
|
24 | 1 | use Traits\TLink; |
|
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | public static $data_confirm_attribute_name = 'datagrid-confirm'; |
||
30 | |||
31 | /** |
||
32 | * @var DataGrid |
||
33 | */ |
||
34 | protected $grid; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $href; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $name; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $params; |
||
50 | |||
51 | /** |
||
52 | * @var array|callable |
||
53 | */ |
||
54 | protected $confirm; |
||
55 | |||
56 | /** |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $data_attributes = []; |
||
60 | |||
61 | /** |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $attributes = []; |
||
65 | |||
66 | /** |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $parameters = []; |
||
70 | |||
71 | /** |
||
72 | * @var string|callable |
||
73 | */ |
||
74 | private $title; |
||
75 | |||
76 | /** |
||
77 | * @var string|callable |
||
78 | */ |
||
79 | protected $icon; |
||
80 | |||
81 | /** |
||
82 | * @var string|callable |
||
83 | */ |
||
84 | protected $class = 'btn btn-xs btn-default'; |
||
85 | |||
86 | /** |
||
87 | * @var bool |
||
88 | */ |
||
89 | protected $open_in_new_tab = FALSE; |
||
90 | |||
91 | |||
92 | /** |
||
93 | * @param DataGrid $grid |
||
94 | * @param string $href |
||
95 | * @param string $name |
||
96 | * @param array $params |
||
97 | */ |
||
98 | public function __construct(DataGrid $grid, $href, $name, $params) |
||
105 | |||
106 | |||
107 | /** |
||
108 | * Render row item into template |
||
109 | * @param Row $row |
||
110 | * @return mixed |
||
111 | */ |
||
112 | public function render(Row $row) |
||
165 | |||
166 | |||
167 | /** |
||
168 | * Add parameters to link |
||
169 | * @param array $parameters |
||
170 | * @return static |
||
171 | */ |
||
172 | public function addParameters(array $parameters) |
||
178 | |||
179 | |||
180 | /** |
||
181 | * Set attribute title |
||
182 | * @param string|callable $title |
||
183 | * @return static |
||
184 | * @throws DataGridException |
||
185 | */ |
||
186 | public function setTitle($title) |
||
194 | |||
195 | |||
196 | /** |
||
197 | * Get attribute title |
||
198 | * @param Row $row |
||
199 | * @return string |
||
200 | * @throws DataGridException |
||
201 | */ |
||
202 | public function getTitle(Row $row) |
||
209 | |||
210 | |||
211 | /** |
||
212 | * Set attribute class |
||
213 | * @param string|callable $class |
||
214 | * @return static |
||
215 | * @throws DataGridException |
||
216 | */ |
||
217 | public function setClass($class) |
||
225 | |||
226 | |||
227 | /** |
||
228 | * Get attribute class |
||
229 | * @param Row $row |
||
230 | * @return string |
||
231 | * @throws DataGridException |
||
232 | */ |
||
233 | public function getClass(Row $row) |
||
240 | |||
241 | |||
242 | /** |
||
243 | * Set icon |
||
244 | * @param string|callable $icon |
||
245 | * @return static|callable |
||
246 | * @throws DataGridException |
||
247 | */ |
||
248 | public function setIcon($icon) |
||
256 | |||
257 | |||
258 | /** |
||
259 | * Get icon |
||
260 | * @param Row $row |
||
261 | * @return string |
||
262 | * @throws DataGridException |
||
263 | */ |
||
264 | public function getIcon(Row $row) |
||
271 | |||
272 | |||
273 | /** |
||
274 | * Set confirm dialog |
||
275 | * @param string|callable $message |
||
276 | * @param string $column |
||
277 | * @return static |
||
278 | * @throws DataGridException |
||
279 | */ |
||
280 | public function setConfirm($message, $column = NULL) |
||
288 | |||
289 | |||
290 | /** |
||
291 | * Get confirm dialog for particular row item |
||
292 | * @param Row $row |
||
293 | * @return string |
||
294 | * @throws DataGridException |
||
295 | */ |
||
296 | public function getConfirm(Row $row) |
||
319 | |||
320 | |||
321 | /** |
||
322 | * Setting data attributes |
||
323 | * @param string $key |
||
324 | * @param mixed $value |
||
325 | * @return static |
||
326 | */ |
||
327 | public function setDataAttribute($key, $value) |
||
333 | |||
334 | |||
335 | /** |
||
336 | * Set attributes for a element |
||
337 | * @param array $attrs |
||
338 | * @return static |
||
339 | */ |
||
340 | public function addAttributes(array $attrs) |
||
346 | |||
347 | |||
348 | /** |
||
349 | * Check whether given property is string or callable |
||
350 | * @param mixed $property |
||
351 | * @return void |
||
352 | * @throws DataGridException |
||
353 | */ |
||
354 | protected function checkPropertyStringOrCallable($property, $name) |
||
362 | |||
363 | |||
364 | /** |
||
365 | * Check whether given property is string or callable |
||
366 | * in that case call callback and check property and return it |
||
367 | * @param Row $row |
||
368 | * @param string|callable|null $property |
||
369 | * @param string $name |
||
370 | * @return string |
||
371 | * @throws DataGridException |
||
372 | */ |
||
373 | public function getPropertyStringOrCallableGetString(Row $row, $property, $name) |
||
397 | |||
398 | |||
399 | /** |
||
400 | * Translator helper |
||
401 | * @param string $message |
||
402 | * @return string |
||
403 | */ |
||
404 | protected function translate($message) |
||
408 | |||
409 | |||
410 | /** |
||
411 | * Open link in new window/tab? |
||
412 | * @return boolean |
||
413 | */ |
||
414 | public function isOpenInNewTab() |
||
418 | |||
419 | |||
420 | /** |
||
421 | * Set link to open in new tab/window or not |
||
422 | * @param bool $open_in_new_tab |
||
423 | * @return $this |
||
424 | */ |
||
425 | public function setOpenInNewTab($open_in_new_tab = TRUE) |
||
430 | |||
431 | } |
||
432 |