1 | <?php |
||
15 | class SlickBlock extends BaseSlickBlock |
||
16 | { |
||
17 | /** |
||
18 | * @var bool Choose whether a block can be cached trough the caching component. Be carefull with caching container blocks. |
||
19 | */ |
||
20 | public $cacheEnabled = false; |
||
21 | /** |
||
22 | * @var int The cache lifetime for this block in seconds (3600 = 1 hour), only affects when cacheEnabled is true |
||
23 | */ |
||
24 | public $cacheExpiration = 3600; |
||
25 | |||
26 | /** |
||
27 | * {@inheritdoc} |
||
28 | */ |
||
29 | 1 | public function blockGroup() |
|
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | 1 | public function name() |
|
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | 1 | public function icon() |
|
49 | |||
50 | /** |
||
51 | * {@inheritdoc} |
||
52 | */ |
||
53 | 1 | public function config() |
|
86 | |||
87 | protected function responsiveImages($parent) |
||
88 | { |
||
89 | $respImagesInput = $parent['responsive_images']; |
||
90 | $respImages = []; |
||
91 | foreach ($respImagesInput as $item) { |
||
92 | $respImages[] = [ |
||
93 | 'breakpoint' => isset($item['breakpoint']) ? $item['breakpoint'] : '0', |
||
94 | 'orientation' => isset($item['orientation']) ? $item['orientation'] : 'portrait', |
||
95 | 'image' => isset($item['image']) ? BlockHelper::imageUpload($item['image'], false, true) : null, |
||
96 | 'imageHD' => isset($item['image_hd']) ? BlockHelper::imageUpload($item['image'], false, true) : null, |
||
97 | ]; |
||
98 | } |
||
99 | |||
100 | return $respImages; |
||
101 | } |
||
102 | |||
103 | 1 | protected function images() |
|
104 | { |
||
105 | 1 | $imagesInput = $this->getVarValue('images', []); |
|
106 | 1 | $images = []; |
|
107 | 1 | foreach ($imagesInput as $item) { |
|
108 | $images[] = [ |
||
109 | 'image' => isset($item['image']) ? BlockHelper::imageUpload($item['image'], false, true) : null, |
||
110 | 'alt' => isset($item['alt']) ? $item['alt'] : 'no-alt-text-set', |
||
111 | 'title' => isset($item['title']) ? $item['title'] : '', |
||
112 | 'link' => isset($item['link']) ? BlockHelper::linkObject($item['link']) : null, |
||
113 | 'isPublished' => isset($item['isPublished']) ? true : false, |
||
114 | 'responsive_images' => $this->responsiveImages($item), |
||
115 | |||
116 | ]; |
||
117 | } |
||
118 | |||
119 | 1 | return $images; |
|
120 | } |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 1 | public function extraVars() |
|
131 | |||
132 | /** |
||
133 | * {@inheritdoc} |
||
134 | * |
||
135 | * @param {{extras.image}} |
||
136 | * @param {{vars.image}} |
||
137 | * @param {{vars.isPublished}} |
||
138 | * @param {{vars.link}} |
||
139 | * @param {{vars.title}} |
||
140 | */ |
||
141 | 1 | public function admin() |
|
145 | } |
||
146 |