... | ... |
@@ -9,6 +9,7 @@ |
9 | 9 |
*/ |
10 | 10 |
|
11 | 11 |
use Contao\Backend; |
12 |
+use Contao\BackendUser; |
|
12 | 13 |
use Contao\ContentModel; |
13 | 14 |
use Contao\Database; |
14 | 15 |
use Contao\DataContainer; |
... | ... |
@@ -329,6 +330,10 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['multiSRC']['load_callback'][] = arra |
329 | 330 |
|
330 | 331 |
class tl_content_eSM_slider extends Backend |
331 | 332 |
{ |
333 |
+ /** |
|
334 |
+ * @var BackendUser |
|
335 |
+ */ |
|
336 |
+ protected $User; |
|
332 | 337 |
|
333 | 338 |
/** |
334 | 339 |
* Import the back end user object |
... | ... |
@@ -336,7 +341,7 @@ class tl_content_eSM_slider extends Backend |
336 | 341 |
public function __construct() |
337 | 342 |
{ |
338 | 343 |
parent::__construct(); |
339 |
- $this->import('BackendUser', 'User'); |
|
344 |
+ $this->User = BackendUser::getInstance(); |
|
340 | 345 |
} |
341 | 346 |
|
342 | 347 |
/** |
... | ... |
@@ -8,6 +8,12 @@ |
8 | 8 |
* @license LGPL-3.0+ |
9 | 9 |
*/ |
10 | 10 |
|
11 |
+use Contao\Backend; |
|
12 |
+use Contao\ContentModel; |
|
13 |
+use Contao\Database; |
|
14 |
+use Contao\DataContainer; |
|
15 |
+use Contao\Input; |
|
16 |
+use Contao\Message; |
|
11 | 17 |
|
12 | 18 |
/** |
13 | 19 |
* Table tl_content |
... | ... |
@@ -321,7 +327,7 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgOpacity'] = array |
321 | 327 |
$GLOBALS['TL_DCA']['tl_content']['fields']['multiSRC']['load_callback'][] = array('tl_content_eSM_slider', 'setMultiSrcFlags'); |
322 | 328 |
|
323 | 329 |
|
324 |
-class tl_content_eSM_slider extends \Backend |
|
330 |
+class tl_content_eSM_slider extends Backend |
|
325 | 331 |
{ |
326 | 332 |
|
327 | 333 |
/** |
... | ... |
@@ -336,11 +342,11 @@ class tl_content_eSM_slider extends \Backend |
336 | 342 |
/** |
337 | 343 |
* Show a hint if a JavaScript library needs to be included in the page layout |
338 | 344 |
* |
339 |
- * @param object |
|
345 |
+ * @param DataContainer $dc |
|
340 | 346 |
*/ |
341 |
- public function showJsLibraryHint($dc) |
|
347 |
+ public function showJsLibraryHint(DataContainer $dc) |
|
342 | 348 |
{ |
343 |
- if ($_POST || \Input::get('act') != 'edit') |
|
349 |
+ if ($_POST || Input::get('act') != 'edit') |
|
344 | 350 |
{ |
345 | 351 |
return; |
346 | 352 |
} |
... | ... |
@@ -351,7 +357,7 @@ class tl_content_eSM_slider extends \Backend |
351 | 357 |
return; |
352 | 358 |
} |
353 | 359 |
|
354 |
- $objCte = \ContentModel::findByPk($dc->id); |
|
360 |
+ $objCte = ContentModel::findByPk($dc->id); |
|
355 | 361 |
|
356 | 362 |
if ($objCte === null) |
357 | 363 |
{ |
... | ... |
@@ -365,7 +371,7 @@ class tl_content_eSM_slider extends \Backend |
365 | 371 |
case 'swiperSliderSlideStart': |
366 | 372 |
case 'swiperSliderSlideStop': |
367 | 373 |
case 'swiperSliderImage': |
368 |
- \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplatesJQuery'], 'js_swiper')); |
|
374 |
+ Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplatesJQuery'], 'js_swiper')); |
|
369 | 375 |
break; |
370 | 376 |
} |
371 | 377 |
} |
... | ... |
@@ -373,9 +379,9 @@ class tl_content_eSM_slider extends \Backend |
373 | 379 |
/** |
374 | 380 |
* Automatically insert end element if start element ist about to be added |
375 | 381 |
* |
376 |
- * @param \DataContainer $dc |
|
382 |
+ * @param DataContainer $dc |
|
377 | 383 |
*/ |
378 |
- public function insertEndElement(\DataContainer $dc) |
|
384 |
+ public function insertEndElement(DataContainer $dc) |
|
379 | 385 |
{ |
380 | 386 |
$activeRecord = $dc->activeRecord; |
381 | 387 |
if (!$activeRecord) { |
... | ... |
@@ -385,7 +391,7 @@ class tl_content_eSM_slider extends \Backend |
385 | 391 |
if ($activeRecord->type === 'swiperSliderStart' || $activeRecord->type === 'swiperSliderSlideStart') { |
386 | 392 |
|
387 | 393 |
// Find the next wrapper element |
388 |
- $nextElement = \Database::getInstance() |
|
394 |
+ $nextElement = Database::getInstance() |
|
389 | 395 |
->prepare(" |
390 | 396 |
SELECT type |
391 | 397 |
FROM tl_content |
... | ... |
@@ -409,7 +415,7 @@ class tl_content_eSM_slider extends \Backend |
409 | 415 |
|| ($activeRecord->type === 'swiperSliderStart' && ($nextElement->type === 'swiperSliderStart')) |
410 | 416 |
|| ($activeRecord->type === 'swiperSliderSlideStart' && ($nextElement->type === 'swiperSliderSlideStart' || $nextElement->type === 'swiperSliderStart' || $nextElement->type === 'swiperSliderStop')) |
411 | 417 |
) { |
412 |
- \Database::getInstance() |
|
418 |
+ Database::getInstance() |
|
413 | 419 |
->prepare('INSERT INTO tl_content %s') |
414 | 420 |
->set(array( |
415 | 421 |
'pid' => $activeRecord->pid, |
... | ... |
@@ -428,11 +434,11 @@ class tl_content_eSM_slider extends \Backend |
428 | 434 |
* Dynamically add flags to the "multiSRC" field |
429 | 435 |
* |
430 | 436 |
* @param mixed $varValue |
431 |
- * @param \DataContainer $dc |
|
437 |
+ * @param DataContainer $dc |
|
432 | 438 |
* |
433 | 439 |
* @return mixed |
434 | 440 |
*/ |
435 |
- public function setMultiSrcFlags($varValue, \DataContainer $dc) |
|
441 |
+ public function setMultiSrcFlags($varValue, DataContainer $dc) |
|
436 | 442 |
{ |
437 | 443 |
if ($dc->activeRecord) |
438 | 444 |
{ |
... | ... |
@@ -191,8 +191,9 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_text'] = array |
191 | 191 |
'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_text'], |
192 | 192 |
'exclude' => true, |
193 | 193 |
'inputType' => 'textarea', |
194 |
- 'eval' => array('rows'=>2,'style'=>'height: 2em;', 'maxlength'=>64), |
|
195 |
- 'sql' => "varchar(64) NOT NULL default ''" |
|
194 |
+ 'eval' => array('rte'=>'tinyMCE', 'helpwizard'=>true), |
|
195 |
+ 'explanation' => 'insertTags', |
|
196 |
+ 'sql' => "mediumtext NULL" |
|
196 | 197 |
); |
197 | 198 |
|
198 | 199 |
$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_url'] = array |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,450 @@ |
1 |
+<?php |
|
2 |
+ |
|
3 |
+/** |
|
4 |
+ * Slick slider for Contao |
|
5 |
+ * |
|
6 |
+ * Copyright (c) 2016 Benjamin Roth |
|
7 |
+ * |
|
8 |
+ * @license LGPL-3.0+ |
|
9 |
+ */ |
|
10 |
+ |
|
11 |
+ |
|
12 |
+/** |
|
13 |
+ * Table tl_content |
|
14 |
+ */ |
|
15 |
+ |
|
16 |
+/** |
|
17 |
+ * Add callback |
|
18 |
+ */ |
|
19 |
+$GLOBALS['TL_DCA']['tl_content']['config']['onload_callback'][] = array('tl_content_eSM_slider', 'showJsLibraryHint'); |
|
20 |
+$GLOBALS['TL_DCA']['tl_content']['config']['onsubmit_callback'][] = array('tl_content_eSM_slider', 'insertEndElement'); |
|
21 |
+ |
|
22 |
+/** |
|
23 |
+ * Add palettes to tl_content |
|
24 |
+ */ |
|
25 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'eSM_addImage'; |
|
26 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'eSM_addText'; |
|
27 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['__selector__'][] = 'eSM_slider_addImageLink'; |
|
28 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['swiperSliderStart'] = '{type_legend},type;{swiper_legend},eSM_slider_autoPlaySpeed,eSM_slider_speed,eSM_slider_initialSlide,eSM_slider_preload,eSM_slider_slidesToShow,eSM_slider_slidesToScroll,eSM_slider_infinite,eSM_slider_arrows,eSM_slider_pagination,eSM_slider_stopOnInteraction,eSM_slider_fade,eSM_slider_adaptiveHeight;{breakpoint_legend:hide},eSM_slider_breakpoints;{image_legend},eSM_addImage;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; |
|
29 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['swiperSliderStop'] = '{type_legend},type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; |
|
30 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['swiperSliderSlideStart'] = '{type_legend},type;{swiper_legend},eSM_addImage;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; |
|
31 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['swiperSliderSlideStop'] = '{type_legend},type;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests;{invisible_legend:hide},invisible,start,stop'; |
|
32 |
+$GLOBALS['TL_DCA']['tl_content']['palettes']['swiperSliderImage'] = '{type_legend},type;{swiper_legend},multiSRC,size,eSM_slider_bgSize,eSM_slider_bgPosition,eSM_slider_minHeight,eSM_slider_bgOpacity,eSM_slider_bgRepeat,eSM_slider_addImageLink,eSM_addText;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID,space;{invisible_legend:hide},invisible,start,stop'; |
|
33 |
+ |
|
34 |
+ |
|
35 |
+$GLOBALS['TL_DCA']['tl_content']['subpalettes']['eSM_addImage'] = 'multiSRC,size,eSM_slider_bgSize,eSM_slider_bgPosition,eSM_slider_minHeight,eSM_slider_bgOpacity,eSM_slider_bgRepeat'; |
|
36 |
+$GLOBALS['TL_DCA']['tl_content']['subpalettes']['eSM_addText'] = 'eSM_slider_text,eSM_slider_url'; |
|
37 |
+$GLOBALS['TL_DCA']['tl_content']['subpalettes']['eSM_slider_addImageLink'] = 'imageUrl,fullsize'; |
|
38 |
+ |
|
39 |
+/** |
|
40 |
+ * Add fields to tl_content |
|
41 |
+ */ |
|
42 |
+ |
|
43 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_autoPlaySpeed'] = array |
|
44 |
+( |
|
45 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_autoPlaySpeed'], |
|
46 |
+ 'exclude' => true, |
|
47 |
+ 'inputType' => 'text', |
|
48 |
+ 'eval' => array('tl_class'=>'w50','rgxp'=>'digit'), |
|
49 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
50 |
+); |
|
51 |
+ |
|
52 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_speed'] = array |
|
53 |
+( |
|
54 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_speed'], |
|
55 |
+ 'exclude' => true, |
|
56 |
+ 'inputType' => 'text', |
|
57 |
+ 'default' => '500', |
|
58 |
+ 'eval' => array('tl_class'=>'w50','rgxp'=>'digit'), |
|
59 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
60 |
+); |
|
61 |
+ |
|
62 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_initialSlide'] = array |
|
63 |
+( |
|
64 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_initialSlide'], |
|
65 |
+ 'exclude' => true, |
|
66 |
+ 'inputType' => 'text', |
|
67 |
+ 'eval' => array('tl_class'=>'w50','rgxp'=>'digit'), |
|
68 |
+ 'sql' => "int(10) unsigned NOT NULL default '0'" |
|
69 |
+); |
|
70 |
+ |
|
71 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_slidesToShow'] = array |
|
72 |
+( |
|
73 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_slidesToShow'], |
|
74 |
+ 'exclude' => true, |
|
75 |
+ 'inputType' => 'text', |
|
76 |
+ 'eval' => array('rgxp'=>'natural','minval'=>1,'tl_class'=>'w50'), |
|
77 |
+ 'sql' => "int(10) unsigned NOT NULL default '1'" |
|
78 |
+); |
|
79 |
+ |
|
80 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_slidesToScroll'] = array |
|
81 |
+( |
|
82 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_slidesToScroll'], |
|
83 |
+ 'exclude' => true, |
|
84 |
+ 'inputType' => 'text', |
|
85 |
+ 'eval' => array('rgxp'=>'natural','minval'=>1,'tl_class'=>'w50'), |
|
86 |
+ 'sql' => "int(10) unsigned NOT NULL default '1'" |
|
87 |
+); |
|
88 |
+ |
|
89 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_infinite'] = array |
|
90 |
+( |
|
91 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_infinite'], |
|
92 |
+ 'exclude' => true, |
|
93 |
+ 'inputType' => 'checkbox', |
|
94 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
95 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
96 |
+); |
|
97 |
+ |
|
98 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_arrows'] = array |
|
99 |
+( |
|
100 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_arrows'], |
|
101 |
+ 'inputType' => 'select', |
|
102 |
+ 'options' => array |
|
103 |
+ ( |
|
104 |
+ 'inside', |
|
105 |
+ 'outside', |
|
106 |
+ ), |
|
107 |
+ 'reference' => &$GLOBALS['TL_LANG']['tl_content']['REF']['eSM_slider_arrows'], |
|
108 |
+ 'eval' => array('tl_class' => 'w50','includeBlankOption'=>true), |
|
109 |
+ 'sql' => "varchar(16) NOT NULL default ''" |
|
110 |
+); |
|
111 |
+ |
|
112 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_pagination'] = array |
|
113 |
+( |
|
114 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_pagination'], |
|
115 |
+ 'exclude' => true, |
|
116 |
+ 'inputType' => 'checkbox', |
|
117 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
118 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
119 |
+); |
|
120 |
+ |
|
121 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_stopOnInteraction'] = array |
|
122 |
+( |
|
123 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_stopOnInteraction'], |
|
124 |
+ 'exclude' => true, |
|
125 |
+ 'inputType' => 'checkbox', |
|
126 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
127 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
128 |
+); |
|
129 |
+ |
|
130 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_preload'] = array |
|
131 |
+( |
|
132 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_preload'], |
|
133 |
+ 'exclude' => true, |
|
134 |
+ 'inputType' => 'checkbox', |
|
135 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
136 |
+ 'sql' => "char(1) NOT NULL default '1'" |
|
137 |
+); |
|
138 |
+ |
|
139 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_fade'] = array |
|
140 |
+( |
|
141 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_fade'], |
|
142 |
+ 'exclude' => true, |
|
143 |
+ 'inputType' => 'checkbox', |
|
144 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
145 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
146 |
+); |
|
147 |
+ |
|
148 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_adaptiveHeight'] = array |
|
149 |
+( |
|
150 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_adaptiveHeight'], |
|
151 |
+ 'exclude' => true, |
|
152 |
+ 'inputType' => 'checkbox', |
|
153 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
154 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
155 |
+); |
|
156 |
+ |
|
157 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_breakpoints'] = array |
|
158 |
+( |
|
159 |
+ 'exclude' => true, |
|
160 |
+ 'inputType' => 'multiColumnWizard', |
|
161 |
+ 'eval' => array |
|
162 |
+ ( |
|
163 |
+ 'columnFields' => array |
|
164 |
+ ( |
|
165 |
+ 'breakpoint_width' => [ |
|
166 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_breakpoints_width'], |
|
167 |
+ 'exclude' => true, |
|
168 |
+ 'inputType' => 'text', |
|
169 |
+ 'eval' => array('rgxp'=>'natural','minval'=>1,'style' => 'width: 95%;'), |
|
170 |
+ ], |
|
171 |
+ 'breakpoint_slidesToShow' => [ |
|
172 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_slidesToShow'], |
|
173 |
+ 'exclude' => true, |
|
174 |
+ 'inputType' => 'text', |
|
175 |
+ 'eval' => array('rgxp'=>'natural','minval'=>1,'style' => 'width: 95%;'), |
|
176 |
+ ], |
|
177 |
+ 'breakpoint_slidesToScroll' => [ |
|
178 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_slidesToScroll'], |
|
179 |
+ 'exclude' => true, |
|
180 |
+ 'inputType' => 'text', |
|
181 |
+ 'eval' => array('rgxp'=>'natural','minval'=>1,'style' => 'width: 95%;'), |
|
182 |
+ ], |
|
183 |
+ ), |
|
184 |
+ ), |
|
185 |
+ 'sql' => 'blob NULL', |
|
186 |
+); |
|
187 |
+ |
|
188 |
+ |
|
189 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_text'] = array |
|
190 |
+( |
|
191 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_text'], |
|
192 |
+ 'exclude' => true, |
|
193 |
+ 'inputType' => 'textarea', |
|
194 |
+ 'eval' => array('rows'=>2,'style'=>'height: 2em;', 'maxlength'=>64), |
|
195 |
+ 'sql' => "varchar(64) NOT NULL default ''" |
|
196 |
+); |
|
197 |
+ |
|
198 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_url'] = array |
|
199 |
+( |
|
200 |
+ 'label' => &$GLOBALS['TL_LANG']['MSC']['url'], |
|
201 |
+ 'exclude' => true, |
|
202 |
+ 'inputType' => 'text', |
|
203 |
+ 'eval' => array('rgxp'=>'url', 'decodeEntities'=>true, 'maxlength'=>255, 'fieldType'=>'radio', 'filesOnly'=>true, 'tl_class'=>'w50 wizard'), |
|
204 |
+ 'wizard' => array |
|
205 |
+ ( |
|
206 |
+ array('tl_content', 'pagePicker') |
|
207 |
+ ), |
|
208 |
+ 'sql' => "varchar(255) NOT NULL default ''" |
|
209 |
+); |
|
210 |
+ |
|
211 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_addImage'] = array |
|
212 |
+( |
|
213 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['addImage'], |
|
214 |
+ 'exclude' => true, |
|
215 |
+ 'inputType' => 'checkbox', |
|
216 |
+ 'eval' => array('submitOnChange'=>true), |
|
217 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
218 |
+); |
|
219 |
+ |
|
220 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_addText'] = array |
|
221 |
+( |
|
222 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_addText'], |
|
223 |
+ 'exclude' => true, |
|
224 |
+ 'inputType' => 'checkbox', |
|
225 |
+ 'eval' => array('tl_class'=>'clr', 'submitOnChange'=>true), |
|
226 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
227 |
+); |
|
228 |
+ |
|
229 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_minHeight'] = array |
|
230 |
+( |
|
231 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_minHeight'], |
|
232 |
+ 'exclude' => true, |
|
233 |
+ 'inputType' => 'checkbox', |
|
234 |
+ 'eval' => array('tl_class'=>'w50 m12'), |
|
235 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
236 |
+); |
|
237 |
+ |
|
238 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_addImageLink'] = array |
|
239 |
+( |
|
240 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_addImageLink'], |
|
241 |
+ 'exclude' => true, |
|
242 |
+ 'inputType' => 'checkbox', |
|
243 |
+ 'eval' => array('tl_class'=>'clr w50','submitOnChange'=>true), |
|
244 |
+ 'sql' => "char(1) NOT NULL default ''" |
|
245 |
+); |
|
246 |
+ |
|
247 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgPosition'] = array |
|
248 |
+( |
|
249 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_bgPosition'], |
|
250 |
+ 'exclude' => true, |
|
251 |
+ 'inputType' => 'select', |
|
252 |
+ 'options' => array |
|
253 |
+ ( |
|
254 |
+ '0 0' => 'Links | Oben', |
|
255 |
+ '50% 0' => 'Mitte | Oben', |
|
256 |
+ '100% 0' => 'Rechts | Oben', |
|
257 |
+ '0 50%' => 'Links | Mitte', |
|
258 |
+ '50% 50%' => 'Mitte | Mitte', |
|
259 |
+ '100% 50%' => 'Rechts | Mitte', |
|
260 |
+ '0 100%' => 'Links | Unten', |
|
261 |
+ '50% 100%' => 'Mitte | Unten', |
|
262 |
+ '100% 100%' => 'Rechts | Unten', |
|
263 |
+ ), |
|
264 |
+ 'eval' => array('tl_class' => 'w50','includeBlankOption'=>true), |
|
265 |
+ 'sql' => "varchar(16) NOT NULL default ''" |
|
266 |
+); |
|
267 |
+ |
|
268 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgSize'] = array |
|
269 |
+( |
|
270 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_bgSize'], |
|
271 |
+ 'exclude' => true, |
|
272 |
+ 'inputType' => 'select', |
|
273 |
+ 'options' => array |
|
274 |
+ ( |
|
275 |
+ 'contain' => 'Proportional', |
|
276 |
+ '100% 100%' => 'Verzerrt', |
|
277 |
+ 'auto auto' => 'Originalgröße', |
|
278 |
+ ), |
|
279 |
+ 'eval' => array('tl_class' => 'w50','includeBlankOption'=>true,'blankOptionLabel'=>'Beschnitten'), |
|
280 |
+ 'sql' => "varchar(16) NOT NULL default ''" |
|
281 |
+); |
|
282 |
+ |
|
283 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgRepeat'] = array |
|
284 |
+( |
|
285 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_bgRepeat'], |
|
286 |
+ 'exclude' => true, |
|
287 |
+ 'inputType' => 'select', |
|
288 |
+ 'options' => array |
|
289 |
+ ( |
|
290 |
+ 'repeat-x' => 'Horizontal wiederholen', |
|
291 |
+ 'repeat-y' => 'Vertikal wiedeholen', |
|
292 |
+ 'no-repeat' => 'Nicht wiederholen', |
|
293 |
+ ), |
|
294 |
+ 'eval' => array('tl_class' => 'w50','includeBlankOption'=>true,'blankOptionLabel'=>'Wiederholen'), |
|
295 |
+ 'sql' => "varchar(16) NOT NULL default ''" |
|
296 |
+); |
|
297 |
+ |
|
298 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['eSM_slider_bgOpacity'] = array |
|
299 |
+( |
|
300 |
+ 'label' => &$GLOBALS['TL_LANG']['tl_content']['eSM_slider_bgOpacity'], |
|
301 |
+ 'exclude' => true, |
|
302 |
+ 'inputType' => 'select', |
|
303 |
+ 'options' => array |
|
304 |
+ ( |
|
305 |
+ '10' => '10%', |
|
306 |
+ '20' => '20%', |
|
307 |
+ '30' => '30%', |
|
308 |
+ '40' => '40%', |
|
309 |
+ '50' => '50%', |
|
310 |
+ '60' => '60%', |
|
311 |
+ '70' => '70%', |
|
312 |
+ '80' => '80%', |
|
313 |
+ '90' => '90%', |
|
314 |
+ '100' => '100%', |
|
315 |
+ ), |
|
316 |
+ 'eval' => array('tl_class' => 'w50','includeBlankOption'=>true), |
|
317 |
+ 'sql' => "varchar(16) NOT NULL default ''" |
|
318 |
+); |
|
319 |
+ |
|
320 |
+$GLOBALS['TL_DCA']['tl_content']['fields']['multiSRC']['load_callback'][] = array('tl_content_eSM_slider', 'setMultiSrcFlags'); |
|
321 |
+ |
|
322 |
+ |
|
323 |
+class tl_content_eSM_slider extends \Backend |
|
324 |
+{ |
|
325 |
+ |
|
326 |
+ /** |
|
327 |
+ * Import the back end user object |
|
328 |
+ */ |
|
329 |
+ public function __construct() |
|
330 |
+ { |
|
331 |
+ parent::__construct(); |
|
332 |
+ $this->import('BackendUser', 'User'); |
|
333 |
+ } |
|
334 |
+ |
|
335 |
+ /** |
|
336 |
+ * Show a hint if a JavaScript library needs to be included in the page layout |
|
337 |
+ * |
|
338 |
+ * @param object |
|
339 |
+ */ |
|
340 |
+ public function showJsLibraryHint($dc) |
|
341 |
+ { |
|
342 |
+ if ($_POST || \Input::get('act') != 'edit') |
|
343 |
+ { |
|
344 |
+ return; |
|
345 |
+ } |
|
346 |
+ |
|
347 |
+ // Return if the user cannot access the layout module (see #6190) |
|
348 |
+ if (!$this->User->hasAccess('themes', 'modules') || !$this->User->hasAccess('layout', 'themes')) |
|
349 |
+ { |
|
350 |
+ return; |
|
351 |
+ } |
|
352 |
+ |
|
353 |
+ $objCte = \ContentModel::findByPk($dc->id); |
|
354 |
+ |
|
355 |
+ if ($objCte === null) |
|
356 |
+ { |
|
357 |
+ return; |
|
358 |
+ } |
|
359 |
+ |
|
360 |
+ switch ($objCte->type) |
|
361 |
+ { |
|
362 |
+ case 'swiperSliderStart': |
|
363 |
+ case 'swiperSliderStop': |
|
364 |
+ case 'swiperSliderSlideStart': |
|
365 |
+ case 'swiperSliderSlideStop': |
|
366 |
+ case 'swiperSliderImage': |
|
367 |
+ \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_content']['includeTemplatesJQuery'], 'js_swiper')); |
|
368 |
+ break; |
|
369 |
+ } |
|
370 |
+ } |
|
371 |
+ |
|
372 |
+ /** |
|
373 |
+ * Automatically insert end element if start element ist about to be added |
|
374 |
+ * |
|
375 |
+ * @param \DataContainer $dc |
|
376 |
+ */ |
|
377 |
+ public function insertEndElement(\DataContainer $dc) |
|
378 |
+ { |
|
379 |
+ $activeRecord = $dc->activeRecord; |
|
380 |
+ if (!$activeRecord) { |
|
381 |
+ return; |
|
382 |
+ } |
|
383 |
+ |
|
384 |
+ if ($activeRecord->type === 'swiperSliderStart' || $activeRecord->type === 'swiperSliderSlideStart') { |
|
385 |
+ |
|
386 |
+ // Find the next wrapper element |
|
387 |
+ $nextElement = \Database::getInstance() |
|
388 |
+ ->prepare(" |
|
389 |
+ SELECT type |
|
390 |
+ FROM tl_content |
|
391 |
+ WHERE pid = ? |
|
392 |
+ AND (ptable = ? OR ptable = ?) |
|
393 |
+ AND type IN ('swiperSliderSlideStart', 'swiperSliderSlideStop','swiperSliderStart', 'swiperSliderStop') |
|
394 |
+ AND sorting > ? |
|
395 |
+ ORDER BY sorting ASC |
|
396 |
+ LIMIT 1 |
|
397 |
+ ") |
|
398 |
+ ->execute( |
|
399 |
+ $activeRecord->pid, |
|
400 |
+ $activeRecord->ptable ?: 'tl_article', |
|
401 |
+ $activeRecord->ptable === 'tl_article' ? '' : $activeRecord->ptable, |
|
402 |
+ $activeRecord->sorting |
|
403 |
+ ); |
|
404 |
+ |
|
405 |
+ // Check if a stop element should be created |
|
406 |
+ if ( |
|
407 |
+ !$nextElement->type |
|
408 |
+ || ($activeRecord->type === 'swiperSliderStart' && ($nextElement->type === 'swiperSliderStart')) |
|
409 |
+ || ($activeRecord->type === 'swiperSliderSlideStart' && ($nextElement->type === 'swiperSliderSlideStart' || $nextElement->type === 'swiperSliderStart' || $nextElement->type === 'swiperSliderStop')) |
|
410 |
+ ) { |
|
411 |
+ \Database::getInstance() |
|
412 |
+ ->prepare('INSERT INTO tl_content %s') |
|
413 |
+ ->set(array( |
|
414 |
+ 'pid' => $activeRecord->pid, |
|
415 |
+ 'ptable' => $activeRecord->ptable ?: 'tl_article', |
|
416 |
+ 'type' => substr($activeRecord->type, 0, -5) . 'Stop', |
|
417 |
+ 'sorting' => $activeRecord->sorting + 1, |
|
418 |
+ 'tstamp' => time(), |
|
419 |
+ )) |
|
420 |
+ ->execute(); |
|
421 |
+ } |
|
422 |
+ |
|
423 |
+ } |
|
424 |
+ } |
|
425 |
+ |
|
426 |
+ /** |
|
427 |
+ * Dynamically add flags to the "multiSRC" field |
|
428 |
+ * |
|
429 |
+ * @param mixed $varValue |
|
430 |
+ * @param \DataContainer $dc |
|
431 |
+ * |
|
432 |
+ * @return mixed |
|
433 |
+ */ |
|
434 |
+ public function setMultiSrcFlags($varValue, \DataContainer $dc) |
|
435 |
+ { |
|
436 |
+ if ($dc->activeRecord) |
|
437 |
+ { |
|
438 |
+ switch ($dc->activeRecord->type) |
|
439 |
+ { |
|
440 |
+ case 'swiperSliderStart': |
|
441 |
+ case 'swiperSliderSlideStart': |
|
442 |
+ case 'swiperSliderImage': |
|
443 |
+ $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['isGallery'] = true; |
|
444 |
+ $GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['extensions'] = \Config::get('validImageTypes').'mp4,ogv,webm,mov'; |
|
445 |
+ break; |
|
446 |
+ } |
|
447 |
+ } |
|
448 |
+ return $varValue; |
|
449 |
+ } |
|
450 |
+} |