1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK ---------------------------------- |
---|
3 | # |
---|
4 | # This file is part of ColorBox, a plugin for Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2010 Philippe aka amalgame and Tomtom |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ------------------------------------ |
---|
12 | |
---|
13 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
14 | |
---|
15 | if (!$core->auth->check('admin',$core->blog->id)) { return; } |
---|
16 | |
---|
17 | #Lightbox enabled test |
---|
18 | |
---|
19 | if ($core->plugins->moduleExists('lightbox')) { |
---|
20 | if ($core->blog->settings->lightbox->lightbox_enabled) { |
---|
21 | $core->error->add(__('Lightbox plugin is enabled. Please disable it before using ColorBox.')); |
---|
22 | return; |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | #Settings |
---|
27 | $s =& $core->blog->settings->colorbox; |
---|
28 | |
---|
29 | # Init var |
---|
30 | $p_url = 'plugin.php?p='.basename(dirname(__FILE__)); |
---|
31 | $default_tab = isset($_GET['tab']) ? $_GET['tab'] : 'modal'; |
---|
32 | $themes = array( |
---|
33 | '1' => __("Dark Mac"), |
---|
34 | '2' => __("Simple White"), |
---|
35 | '3' => __("Lightbox Classic"), |
---|
36 | '4' => __("White Mac"), |
---|
37 | '5' => __("Thick Grey"), |
---|
38 | '6' => __("Vintage Lightbox"), |
---|
39 | ); |
---|
40 | |
---|
41 | # Saving configurations |
---|
42 | if (isset($_POST['save'])) |
---|
43 | { |
---|
44 | $type = $_POST['type']; |
---|
45 | |
---|
46 | $core->blog->triggerBlog(); |
---|
47 | |
---|
48 | if ($type === 'modal') |
---|
49 | { |
---|
50 | $s->put('colorbox_enabled',!empty($_POST['colorbox_enabled'])); |
---|
51 | |
---|
52 | if (isset($_POST['colorbox_theme'])) { |
---|
53 | $s->put('colorbox_theme',$_POST['colorbox_theme']); |
---|
54 | } |
---|
55 | |
---|
56 | http::redirect($p_url.'&upd=1'); |
---|
57 | } |
---|
58 | elseif ($type === 'zoom') |
---|
59 | { |
---|
60 | $s->put('colorbox_zoom_icon',!empty($_POST['colorbox_zoom_icon'])); |
---|
61 | $s->put('colorbox_zoom_icon_permanent',!empty($_POST['colorbox_zoom_icon_permanent'])); |
---|
62 | $s->put('colorbox_position',!empty($_POST['colorbox_position'])); |
---|
63 | |
---|
64 | http::redirect($p_url.'&tab=zoom&upd=2'); |
---|
65 | } |
---|
66 | elseif ($type === 'advanced') |
---|
67 | { |
---|
68 | $opts = array( |
---|
69 | 'transition' => $_POST['transition'], |
---|
70 | 'speed' => !empty($_POST['speed']) ? $_POST['speed'] : '350', |
---|
71 | 'title' => $_POST['title'], |
---|
72 | 'width' => $_POST['width'], |
---|
73 | 'height' => $_POST['height'], |
---|
74 | 'innerWidth' => $_POST['innerWidth'], |
---|
75 | 'innerHeight' => $_POST['innerHeight'], |
---|
76 | 'initialWidth' => !empty($_POST['initialWidth']) ? $_POST['initialWidth'] : '300', |
---|
77 | 'initialHeight' => !empty($_POST['initialHeight']) ? $_POST['initialHeight'] : '100', |
---|
78 | 'maxWidth' => $_POST['maxWidth'], |
---|
79 | 'maxHeight' => $_POST['maxHeight'], |
---|
80 | 'scalePhotos' => !empty($_POST['scalePhotos']), |
---|
81 | 'scrolling' => !empty($_POST['scrolling']), |
---|
82 | 'iframe' => !empty($_POST['iframe']), |
---|
83 | 'opacity' => !empty($_POST['opacity']) ? $_POST['opacity'] : '0.85', |
---|
84 | 'open' => !empty($_POST['open']), |
---|
85 | 'preloading' => !empty($_POST['preloading']), |
---|
86 | 'overlayClose' => !empty($_POST['overlayClose']), |
---|
87 | 'loop' => !empty($_POST['loop']), |
---|
88 | 'slideshow' => !empty($_POST['slideshow']), |
---|
89 | 'slideshowSpeed' => !empty($_POST['slideshowSpeed']) ? $_POST['slideshowSpeed'] : '2500', |
---|
90 | 'slideshowAuto' => !empty($_POST['slideshowAuto']), |
---|
91 | 'slideshowStart' => $_POST['slideshowStart'], |
---|
92 | 'slideshowStop' => $_POST['slideshowStop'], |
---|
93 | 'current' => $_POST['current'], |
---|
94 | 'previous' => $_POST['previous'], |
---|
95 | 'next' => $_POST['next'], |
---|
96 | 'close' => $_POST['close'], |
---|
97 | 'onOpen' => $_POST['onOpen'], |
---|
98 | 'onLoad' => $_POST['onLoad'], |
---|
99 | 'onComplete' => $_POST['onComplete'], |
---|
100 | 'onCleanup' => $_POST['onCleanup'], |
---|
101 | 'onClosed' => $_POST['onClosed'] |
---|
102 | ); |
---|
103 | |
---|
104 | $s->put('colorbox_advanced',serialize($opts)); |
---|
105 | $s->put('colorbox_selectors',$_POST['colorbox_selectors']); |
---|
106 | $s->put('colorbox_user_files',$_POST['colorbox_user_files']); |
---|
107 | http::redirect($p_url.'&tab=advanced&upd=3'); |
---|
108 | } |
---|
109 | } |
---|
110 | |
---|
111 | ?> |
---|
112 | |
---|
113 | <html> |
---|
114 | <head> |
---|
115 | <title><?php echo(__('ColorBox')); ?></title> |
---|
116 | <script type="text/javascript"> |
---|
117 | $(document).ready(function() { |
---|
118 | $("input[type=radio][name=colorbox_theme]").click(function() { |
---|
119 | var p = $(this).attr('value'); |
---|
120 | $("img#thumbnail").attr('src','index.php?pf=colorbox/themes/'+p+'/images/thumbnail.jpg'); |
---|
121 | }); |
---|
122 | $("#colorbox_zoom_icon").click(function() { |
---|
123 | if (!$("#colorbox_zoom_icon").is(":checked")) { |
---|
124 | $("#colorbox_zoom_icon_permanent").attr('checked', false); |
---|
125 | } |
---|
126 | }); |
---|
127 | }); |
---|
128 | </script> |
---|
129 | <?php echo dcPage::jsPageTabs($default_tab); ?> |
---|
130 | <style type="text/css"> |
---|
131 | #content.with-help #help{ width:40%; } |
---|
132 | #content.with-help #help-button {right:40%; } |
---|
133 | #thumbnail { border: 1px solid #ccc; } |
---|
134 | </style> |
---|
135 | </head> |
---|
136 | <body> |
---|
137 | |
---|
138 | <?php |
---|
139 | |
---|
140 | # Display messages |
---|
141 | |
---|
142 | if (isset($_GET['upd'])) |
---|
143 | { |
---|
144 | $p_msg = '<p class="message">%s</p>'; |
---|
145 | |
---|
146 | $a_msg = array( |
---|
147 | __('Modal window configuration successfully saved'), |
---|
148 | __('Zoom icon configuration successfully saved'), |
---|
149 | __('Advanced configuration successfully saved') |
---|
150 | ); |
---|
151 | |
---|
152 | $k = (integer) $_GET['upd']-1; |
---|
153 | |
---|
154 | if (array_key_exists($k,$a_msg)) { |
---|
155 | echo sprintf($p_msg,$a_msg[$k]); |
---|
156 | } |
---|
157 | } |
---|
158 | |
---|
159 | # Baseline |
---|
160 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('ColorBox').'</h2>'; |
---|
161 | |
---|
162 | # Modal tab |
---|
163 | $theme_choice = ''; |
---|
164 | foreach ($themes as $k => $v) { |
---|
165 | $theme_choice .= '<p><label class="classic">'. |
---|
166 | form::radio(array('colorbox_theme'),$k,$s->colorbox_theme == $k). |
---|
167 | ' '.$v.'</label></p>'; |
---|
168 | } |
---|
169 | $thumb_url = 'index.php?pf=colorbox/themes/'.$s->colorbox_theme.'/images/thumbnail.jpg'; |
---|
170 | |
---|
171 | echo |
---|
172 | '<div class="multi-part" id="modal" title="'.__('Modal Window').'">'. |
---|
173 | '<form action="'.$p_url.'" method="post">'. |
---|
174 | '<fieldset><legend>'.__('Activation').'</legend>'. |
---|
175 | '<p><label class="classic">'. |
---|
176 | form::checkbox('colorbox_enabled','1',$s->colorbox_enabled). |
---|
177 | __('Enable ColorBox').'</label></p>'. |
---|
178 | '</fieldset>'. |
---|
179 | '<fieldset><legend>'.__('Theme').'</legend>'. |
---|
180 | '<div class="two-cols clear">'. |
---|
181 | '<div class="col">'. |
---|
182 | '<p class="classic">'.__('Choose your theme for ColorBox:').'</p>'. |
---|
183 | $theme_choice. |
---|
184 | '</div>'. |
---|
185 | '<div class="col">'. |
---|
186 | '<p><img id="thumbnail" src="'.$thumb_url.'" alt="'.__('Window').'" title="'.__('Window').'" /></p>'. |
---|
187 | '</div>'. |
---|
188 | '</div>'. |
---|
189 | '</fieldset>'. |
---|
190 | '<p>'.form::hidden(array('type'),'modal').'</p>'. |
---|
191 | '<p class="clear"><input type="submit" name="save" value="'.__('Save configuration').'" />'.$core->formNonce().'</p>'. |
---|
192 | '</form>'. |
---|
193 | '</div>'; |
---|
194 | |
---|
195 | # Zoom tab |
---|
196 | |
---|
197 | echo |
---|
198 | '<div class="multi-part" id="zoom" title="'.__('Zoom Icon').'">'. |
---|
199 | '<form action="'.$p_url.'" method="post">'. |
---|
200 | '<fieldset><legend>'.__('Parameters').'</legend>'. |
---|
201 | '<p><label class="classic">'. |
---|
202 | form::checkbox('colorbox_zoom_icon','1',$s->colorbox_zoom_icon). |
---|
203 | __('Enable zoom icon on thumbnails').'</label></p>'. |
---|
204 | '<p style="margin-left:1em;"><label class="classic">'. |
---|
205 | form::radio(array('colorbox_position'),true,$s->colorbox_position). |
---|
206 | __('on the left').'</label></p>'. |
---|
207 | '<p style="margin-left:1em;"><label class="classic">'. |
---|
208 | form::radio(array('colorbox_position'),false,!$s->colorbox_position). |
---|
209 | __('on the right').'</label></p>'. |
---|
210 | '<p><label class="classic">'. |
---|
211 | form::checkbox('colorbox_zoom_icon_permanent','1',$s->colorbox_zoom_icon_permanent). |
---|
212 | __('Always show zoom icon on thumbnails').'</label></p>'. |
---|
213 | '</fieldset>'. |
---|
214 | '<p>'.form::hidden(array('type'),'zoom').'</p>'. |
---|
215 | '<p class="clear"><input type="submit" name="save" value="'.__('Save configuration').'" />'.$core->formNonce().'</p>'. |
---|
216 | '</form>'. |
---|
217 | '</div>'; |
---|
218 | |
---|
219 | # Advanced tab |
---|
220 | |
---|
221 | $effects = array( |
---|
222 | __('Elastic') => 'elastic', |
---|
223 | __('Fade') => 'fade', |
---|
224 | __('None') => 'none' |
---|
225 | ); |
---|
226 | $as = unserialize($s->colorbox_advanced); |
---|
227 | echo |
---|
228 | '<div class="multi-part" id="advanced" title="'.__('Advanced configuration').'">'. |
---|
229 | '<form action="'.$p_url.'" method="post">'. |
---|
230 | '<fieldset><legend>'.__('Personnal files').'</legend>'. |
---|
231 | '<p>'.__('Store personnal CSS and image files in:').'</p>'. |
---|
232 | '<p><label class="classic">'. |
---|
233 | form::radio(array('colorbox_user_files'),true,$s->colorbox_user_files). |
---|
234 | __('public folder').'</label></p>'. |
---|
235 | '<p><label class="classic">'. |
---|
236 | form::radio(array('colorbox_user_files'),false,!$s->colorbox_user_files). |
---|
237 | __('theme folder').'</label></p>'. |
---|
238 | |
---|
239 | '</fieldset>'. |
---|
240 | '<fieldset><legend>'.__('Selectors').'</legend>'. |
---|
241 | '<p><label>'.__('Apply ColorBox to the following supplementary selectors (ex: div#sidebar,div#pictures):'). |
---|
242 | form::field('colorbox_selectors',80,255,$s->colorbox_selectors). |
---|
243 | '</label></p>'. |
---|
244 | '<p class="form-note">'.__('Leave blank to default: (div.post)').'</p>'. |
---|
245 | '</fieldset>'. |
---|
246 | '<fieldset><legend>'.__('Effects').'</legend>'. |
---|
247 | '<div class="two-cols"><div class="col">'. |
---|
248 | '<p class="field"><label class="classic">'.__('Transition type').' '. |
---|
249 | form::combo('transition',$effects,$as['transition']). |
---|
250 | '</label></p>'. |
---|
251 | '<p class="field"><label class="classic">'.__('Transition speed').' '. |
---|
252 | form::field('speed',30,10,$as['speed']). |
---|
253 | '</label></p>'. |
---|
254 | '<p class="field"><label class="classic">'.__('Opacity').' '. |
---|
255 | form::field('opacity',30,10,$as['opacity']). |
---|
256 | '</label></p>'. |
---|
257 | '<p class="field"><label class="classic">'. |
---|
258 | form::checkbox('open',1,$as['open']). |
---|
259 | __('Auto open ColorBox').'</label></p>'. |
---|
260 | '<p class="field"><label class="classic">'. |
---|
261 | form::checkbox('preloading',1,$as['preloading']). |
---|
262 | __('Enable preloading for photo group').'</label></p>'. |
---|
263 | '<p class="field"><label class="classic">'. |
---|
264 | form::checkbox('overlayClose',1,$as['overlayClose']). |
---|
265 | __('Enable close by clicking on overlay').'</label></p>'. |
---|
266 | '</div><div class="col">'. |
---|
267 | '<p class="field"><label class="classic">'. |
---|
268 | form::checkbox('slideshow',1,$as['slideshow']). |
---|
269 | __('Enable slideshow').'</label></p>'. |
---|
270 | '<p class="field"><label class="classic">'. |
---|
271 | form::checkbox('slideshowAuto',1,$as['slideshowAuto']). |
---|
272 | __('Auto start slideshow').'</label></p>'. |
---|
273 | '<p class="field"><label class="classic">'.__('Slideshow speed').' '. |
---|
274 | form::field('slideshowSpeed',30,10,$as['slideshowSpeed']). |
---|
275 | '</label></p>'. |
---|
276 | '<p class="field"><label class="classic">'.__('Slideshow start display text').' '. |
---|
277 | form::field('slideshowStart',30,255,$as['slideshowStart']). |
---|
278 | '</label></p>'. |
---|
279 | '<p class="field"><label class="classic">'.__('Slideshow stop display text').' '. |
---|
280 | form::field('slideshowStop',30,255,$as['slideshowStop']). |
---|
281 | '</label></p>'. |
---|
282 | '</div></div>'. |
---|
283 | '</fieldset>'. |
---|
284 | '<fieldset><legend>'.__('Modal window').'</legend>'. |
---|
285 | '<div class="two-cols"><div class="col">'. |
---|
286 | '<p class="field"><label class="classic">'.__('Default title').' '. |
---|
287 | form::field('title',30,255,$as['title']). |
---|
288 | '</label></p>'. |
---|
289 | '<p class="field"><label class="classic">'.__('Current text').' '. |
---|
290 | form::field('current',30,255,$as['current']). |
---|
291 | '</label></p>'. |
---|
292 | '<p class="field"><label class="classic">'.__('Previous text').' '. |
---|
293 | form::field('previous',30,255,$as['previous']). |
---|
294 | '</label></p>'. |
---|
295 | '<p class="field"><label class="classic">'.__('Next text').' '. |
---|
296 | form::field('next',30,255,$as['next']). |
---|
297 | '</label></p>'. |
---|
298 | '<p class="field"><label class="classic">'.__('Close text').' '. |
---|
299 | form::field('close',30,255,$as['close']). |
---|
300 | '</label></p>'. |
---|
301 | '</div><div class="col">'. |
---|
302 | '<p class="field"><label class="classic">'. |
---|
303 | form::checkbox('loop',1,$as['loop']). |
---|
304 | __('Loop on slideshow images').'</label></p>'. |
---|
305 | '<p class="field"><label class="classic">'. |
---|
306 | form::checkbox('iframe',1,$as['iframe']). |
---|
307 | __('Display content in an iframe').'</label></p>'. |
---|
308 | '</div></div>'. |
---|
309 | '</fieldset>'. |
---|
310 | '<fieldset><legend>'.__('Dimensions').'</legend>'. |
---|
311 | '<div class="two-cols"><div class="col">'. |
---|
312 | '<p class="field"><label class="classic">'.__('Fixed width').' '. |
---|
313 | form::field('width',30,10,$as['width']). |
---|
314 | '</label></p>'. |
---|
315 | '<p class="field"><label class="classic">'.__('Fixed height').' '. |
---|
316 | form::field('height',30,10,$as['height']). |
---|
317 | '</label></p>'. |
---|
318 | '<p class="field"><label class="classic">'.__('Fixed inner width').' '. |
---|
319 | form::field('innerWidth',30,10,$as['innerWidth']). |
---|
320 | '</label></p>'. |
---|
321 | '<p class="field"><label class="classic">'.__('Fixed inner height').' '. |
---|
322 | form::field('innerHeight',30,10,$as['innerHeight']). |
---|
323 | '</label></p>'. |
---|
324 | '<p class="field"><label class="classic">'. |
---|
325 | form::checkbox('scalePhotos',1,$as['scalePhotos']). |
---|
326 | __('Scale photos').'</label></p>'. |
---|
327 | '<p class="field"><label class="classic">'. |
---|
328 | form::checkbox('scrolling',1,$as['scrolling']). |
---|
329 | __('Hide overflowing content').'</label></p>'. |
---|
330 | '</div><div class="col">'. |
---|
331 | '<p class="field"><label class="classic">'.__('Initial width').' '. |
---|
332 | form::field('initialWidth',30,10,$as['initialWidth']). |
---|
333 | '</label></p>'. |
---|
334 | '<p class="field"><label class="classic">'.__('Initial height').' '. |
---|
335 | form::field('initialHeight',30,10,$as['initialHeight']). |
---|
336 | '</label></p>'. |
---|
337 | '<p class="field"><label class="classic">'.__('Max width').' '. |
---|
338 | form::field('maxWidth',30,10,$as['maxWidth']). |
---|
339 | '</label></p>'. |
---|
340 | '<p class="field"><label class="classic">'.__('Max height').' '. |
---|
341 | form::field('maxHeight',30,10,$as['maxHeight']). |
---|
342 | '</label></p>'. |
---|
343 | '</div></div>'. |
---|
344 | '</fieldset>'. |
---|
345 | '<fieldset><legend>'.__('Javascript').'</legend>'. |
---|
346 | '<div class="two-cols"><div class="col">'. |
---|
347 | '<p class="field"><label class="classic">'.__('Callback name for onOpen event').' '. |
---|
348 | form::field('onOpen',30,255,$as['onOpen']). |
---|
349 | '</label></p>'. |
---|
350 | '<p class="field"><label class="classic">'.__('Callback name for onLoad event').' '. |
---|
351 | form::field('onLoad',30,255,$as['onLoad']). |
---|
352 | '</label></p>'. |
---|
353 | '<p class="field"><label class="classic">'.__('Callback name for onComplete event').' '. |
---|
354 | form::field('onComplete',30,255,$as['onComplete']). |
---|
355 | '</label></p>'. |
---|
356 | '</div><div class="col">'. |
---|
357 | '<p class="field"><label class="classic">'.__('Callback name for onCleanup event').' '. |
---|
358 | form::field('onCleanup',30,255,$as['onCleanup']). |
---|
359 | '</label></p>'. |
---|
360 | '<p class="field"><label class="classic">'.__('Callback name for onClosed event').' '. |
---|
361 | form::field('onClosed',30,255,$as['onClosed']). |
---|
362 | '</label></p>'. |
---|
363 | '</div></div>'. |
---|
364 | '</fieldset>'. |
---|
365 | '<p>'.form::hidden(array('type'),'advanced').'</p>'. |
---|
366 | '<p class="clear"><input type="submit" name="save" value="'.__('Save configuration').'" />'.$core->formNonce().'</p>'. |
---|
367 | '</form>'. |
---|
368 | '</div>'; |
---|
369 | |
---|
370 | dcPage::helpBlock('colorbox'); |
---|
371 | |
---|
372 | ?> |
---|
373 | |
---|
374 | </body> |
---|
375 | </html> |
---|