1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34:
35: $plugin_is_filter = 9 | THEME_PLUGIN | ADMIN_PLUGIN;
36: $plugin_description = gettext("Slideshow plugin based on the Cycle2 jQuery plugin.");
37: $plugin_author = "Malte Müller (acrylian)";
38: $plugin_disable = (extensionEnabled('slideshow')) ? sprintf(gettext('Only one slideshow plugin may be enabled. <a href="#%1$s"><code>%1$s</code></a> is already enabled.'), 'slideshow') : '';
39:
40: $option_interface = 'cycle';
41:
42: global $_zp_gallery, $_zp_gallery_page;
43: if (($_zp_gallery_page == 'slideshow.php' && getOption('cycle-slideshow_mode') == 'cycle') || getOption('cycle_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page))) {
44: zp_register_filter('theme_head', 'cycle::cycleJS');
45: }
46: zp_register_filter('content_macro', 'cycle::macro');
47:
48: 49: 50: 51:
52: class cycle {
53:
54: function __construct() {
55: global $_zp_gallery;
56: if (OFFSET_PATH == 2) {
57:
58: setOptionDefault('cycle-slideshow_width', '595');
59: setOptionDefault('cycle-slideshow_height', '595');
60: setOptionDefault('cycle-slideshow_mode', 'cycle');
61: setOptionDefault('cycle-slideshow_effect', 'fade');
62: setOptionDefault('cycle-slideshow_speed', '1000');
63: setOptionDefault('cycle-slideshow_timeout', '3000');
64: setOptionDefault('cycle-slideshow_showdesc', 0);
65:
66: setOptionDefault('cycle-slideshow_colorbox_transition', 'fade');
67: setOptionDefault('cycle-slideshow_colorbox_imagetype', 'sizedimage');
68: setOptionDefault('cycle-slideshow_colorbox_imagetitle', 1);
69: if (class_exists('cacheManager')) {
70: cacheManager::deleteThemeCacheSizes('cycle');
71: cacheManager::addThemeCacheSize('cycle', NULL, getOption('cycle-slideshow_width'), getOption('cycle-slideshow_height'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, true);
72: }
73: }
74: }
75:
76: function getOptionsSupported() {
77:
78: 79: 80:
81: $options = array(
82: gettext('Slideshow: Mode') => array('key' => 'cycle-slideshow_mode', 'type' => OPTION_TYPE_SELECTOR,
83: 'order' => 0,
84: 'selections' => array(gettext("jQuery Cycle") => "cycle", gettext("jQuery Colorbox") => "colorbox"),
85: 'desc' => gettext('<em>jQuery Cycle</em> for slideshow using the jQuery Cycle2 plugin<br /><em>jQuery Colorbox</em> for slideshow using Colorbox (Colorbox plugin required).<br />NOTE: The jQuery Colorbox mode is attached to the link the printSlideShowLink() function prints and can neither be called directly nor used on the slideshow.php theme page.')),
86: gettext('Slideshow: Speed') => array('key' => 'cycle-slideshow_speed', 'type' => OPTION_TYPE_TEXTBOX,
87: 'order' => 1,
88: 'desc' => gettext("Speed of the transition in milliseconds."))
89: );
90:
91: switch (getOption('cycle-slideshow_mode')) {
92: case 'cycle':
93: $options = array_merge($options, array(gettext('Slideshow: Slide width') => array('key' => 'cycle-slideshow_width', 'type' => OPTION_TYPE_TEXTBOX,
94: 'order' => 5,
95: 'desc' => gettext("Width of the images in the slideshow.")),
96: gettext('Slideshow: Slide height') => array('key' => 'cycle-slideshow_height', 'type' => OPTION_TYPE_TEXTBOX,
97: 'order' => 6,
98: 'desc' => gettext("Height of the images in the slideshow.")),
99: gettext('Slideshow: Effect') => array('key' => 'cycle-slideshow_effect', 'type' => OPTION_TYPE_SELECTOR,
100: 'order' => 2,
101: 'selections' => array(
102: gettext('none') => "none",
103: gettext('fade') => "fade",
104: gettext('fadeOut') => "fadeOut",
105: gettext('shuffle') => "shuffle",
106: gettext('Scroll horizontal') => "scrollHorz",
107: gettext('Scroll vertical') => "scrollVert",
108: gettext('Flip horizontal') => "flipHorz",
109: gettext('Flip vertical') => "flipVert",
110: gettext('Tile slide') => "tileSlide",
111: gettext('Tile blind') => "tileBlind"),
112: 'desc' => gettext("The cycle slide effect to be used. Flip transitions are only supported on browsers that support CSS3 3D transforms. (IE10+, current Chrome, Firefox, Opera and Safari.)")),
113: gettext('Slideshow: Tile Effect - Extra') => array('key' => 'cycle-slideshow_tileeffect', 'type' => OPTION_TYPE_SELECTOR,
114: 'order' => 3,
115: 'selections' => array(
116: gettext('Horziontal') => "tileVert",
117: gettext('Vertical') => "tileHorz"),
118: 'desc' => gettext("If one of the tile effects is selected, this is its orientation.")),
119: gettext('Slideshow: Timeout') => array('key' => 'cycle-slideshow_timeout', 'type' => OPTION_TYPE_TEXTBOX,
120: 'order' => 4,
121: 'desc' => gettext("Milliseconds between slide transitions (0 to disable auto advance.)")),
122: gettext('Slideshow: Description') => array('key' => 'cycle-slideshow_showdesc', 'type' => OPTION_TYPE_CHECKBOX,
123: 'order' => 7,
124: 'desc' => gettext("Check if you want to show the image’s description below the slideshow.")),
125: gettext('Slideshow: Swipe gestures') => array('key' => 'cycle-slideshow_swipe', 'type' => OPTION_TYPE_CHECKBOX,
126: 'order' => 8,
127: 'desc' => gettext("Check if you want to enable touch screen swipe gestures.")),
128: gettext('Slideshow: Pause on hover') => array('key' => 'cycle-slideshow_pausehover', 'type' => OPTION_TYPE_CHECKBOX,
129: 'order' => 9,
130: 'desc' => gettext("Check if you want the slidesshow to pause on hover."))
131: ));
132: break;
133:
134: case 'colorbox':
135: $options = array_merge($options, array(gettext('Colorbox: Transition') => array('key' => 'cycle-slideshow_colorbox_transition', 'type' => OPTION_TYPE_SELECTOR,
136: 'order' => 2,
137: 'selections' => array(
138: gettext('elastic') => "elastic",
139: gettext('fade') => "fade",
140: gettext('none') => "none"),
141: 'desc' => gettext("The Colorbox transition slide effect to be used.")),
142: gettext('Colorbox: Image type') => array('key' => 'cycle-slideshow_colorbox_imagetype', 'type' => OPTION_TYPE_SELECTOR,
143: 'order' => 3,
144: 'selections' => array(gettext('full image') => "fullimage", gettext("sized image") => "sizedimage"),
145: 'desc' => gettext("The image type you wish to use for the Colorbox. If you choose “sized image” the slideshow width value will be used for the longest side of the image.")),
146: gettext('Colorbox: Image title') => array('key' => 'cycle-slideshow_colorbox_imagetitle', 'type' => OPTION_TYPE_CHECKBOX,
147: 'order' => 4,
148: 'desc' => gettext("If the image title should be shown at the bottom of the Colorbox."))
149: ));
150: if (getOption('cycle-slideshow_colorbox_imagetype') == 'sizedimage') {
151: $options = array_merge($options, array(gettext('Colorbox: Slide width') => array('key' => 'cycle-slideshow_width', 'type' => OPTION_TYPE_TEXTBOX,
152: 'order' => 3.5,
153: 'desc' => gettext("Width of the images in the slideshow."))
154: ));
155: }
156: break;
157: }
158:
159: foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php', 'slideshow.php', 'functions.php', 'password.php', 'sidebar.php', 'register.php', 'contact.php')) as $theme => $scripts) {
160: $list = array();
161: foreach ($scripts as $script) {
162: $list[$script] = 'cycle_' . $theme . '_' . stripSuffix($script);
163: }
164: $options2[$theme] = array('key' => 'cycle_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
165: 'checkboxes' => $list,
166: 'desc' => gettext('The scripts for which the cycle2 plugin is enabled. {If themes require it they might set this, otherwise you need to do it manually!}')
167: );
168: }
169:
170: $options = array_merge($options, $options2);
171:
172: return $options;
173: }
174:
175: function handleOption($option, $currentValue) {
176:
177: }
178:
179: static function getSlideshowPlayer($album, $controls = false, $width = NULL, $height = NULL) {
180: $albumobj = NULL;
181: if (!empty($album)) {
182: $albumobj = newAlbum($album, NULL, true);
183: }
184: if (is_object($albumobj) && $albumobj->loaded) {
185: $returnpath = rewrite_path(pathurlencode($albumobj->name) . '/', '/index.php?album=' . urlencode($albumobj->name));
186: return cycle::getShow(false, false, $albumobj, NULL, $width, $height, false, false, false, $controls, $returnpath, 0);
187: } else {
188: return '<div class="errorbox" id="message"><h2>' . gettext('Invalid slideshow album name!') . '</h2></div>';
189: }
190: }
191:
192: static function getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber) {
193: global $_zp_gallery, $_zp_gallery_page;
194: setOption('cycle-slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
195: if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
196: return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
197: }
198:
199: if (empty($width) || empty($height)) {
200: $width = getOption('cycle-slideshow_width');
201: $height = getOption('cycle-slideshow_height');
202: }
203: if ($crop) {
204: $cropw = $width;
205: $croph = $height;
206: } else {
207: $cropw = NULL;
208: $croph = NULL;
209: }
210:
211: $slides = $albumobj->getImages(0);
212: $numslides = $albumobj->getNumImages();
213: if ($shuffle) {
214: shuffle($slides);
215: }
216:
217:
218:
219:
220:
221: if ($imagenumber != 0) {
222: $count = -1;
223: $extractslides = array();
224: foreach ($slides as $slide) {
225: $count++;
226: if ($count < $imagenumber) {
227: $extractslides[] = $slide;
228: unset($slides[$count]);
229: }
230: }
231: $slides = array_merge($slides, $extractslides);
232: }
233:
234:
235:
236:
237: if (getOption('cycle-slideshow_swipe')) {
238: $option_swipe = 'true';
239: } else {
240: $option_swipe = 'false';
241: }
242: if (getOption('cycle-slideshow_pausehover')) {
243: $option_pausehover = 'true';
244: } else {
245: $option_pausehover = 'false';
246: }
247: $option_fx = getOption('cycle-slideshow_effect');
248: $option_tilevertical = '';
249: if ($option_fx == 'tileSlide' || $option_fx == 'tileBlind') {
250: $option_tileextra = getOption('cycle-slideshow_tileeffect');
251: switch ($option_tileextra) {
252: case 'tileVert':
253: $option_tilevertical = 'data-cycle-tile-vertical=true';
254: break;
255: case 'tileHorz':
256: $option_tilevertical = 'data-cycle-tile-vertical=false';
257: break;
258: default:
259: $option_tilevertical = '';
260: break;
261: }
262: }
263: if ($numslides == 0) {
264: return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
265: }
266: $slideshow = '<section class="slideshow"><!-- extra class with album id so we can address slides! -->' . "\n";
267: if ($controls) {
268: $slideshow .= '<ul class="slideshow_controls">' . "\n";
269: $slideshow .= '<li><a href="#" data-cycle-cmd="prev" class="cycle-slideshow-prev icon-backward" title="' . gettext('prev') . '"></a></li>' . "\n";
270: $slideshow .= '<li><a href="' . $returnpath . '" class="cycle-slideshow-stop icon-stop" title="' . gettext('stop') . '"></a></li>' . "\n";
271: $slideshow .= '<li><a href="#" data-cycle-cmd="pause" class="cycle-slideshow-pause icon-pause" title="' . gettext('pause') . '"></a></li>' . "\n";
272: $slideshow .= '<li><a href="#" data-cycle-cmd="resume" class="cycle-slideshow-resume icon-play" title="' . gettext('play') . '"></a></li>' . "\n";
273: $slideshow .= '<li><a href="#" data-cycle-cmd="next" class="cycle-slideshow-next icon-forward" title="' . gettext('next') . '"></a></li>' . "\n";
274: $slideshow .= '</ul>' . "\n";
275: }
276:
277: $slideshow .= '<div class="cycle-slideshow"' . "\n";
278: $slideshow .= 'data-cycle-pause-on-hover=' . $option_pausehover . "\n";
279: $slideshow .= 'data-cycle-fx="' . $option_fx . '"' . "\n";
280: $slideshow .= $option_tilevertical . "\n";
281: $slideshow .= 'data-cycle-speed=' . getOption('cycle-slideshow_speed') . "\n";
282: $slideshow .= 'data-cycle-timeout=' . getOption('cycle-slideshow_timeout') . "\n";
283: $slideshow .= 'data-cycle-slides=".slide"' . "\n";
284: $slideshow .= 'data-cycle-auto-height=true' . "\n";
285: $slideshow .= 'data-cycle-center-horz=true' . "\n";
286: $slideshow .= 'data-cycle-center-vert=true' . "\n";
287: $slideshow .= 'data-cycle-swipe=' . $option_swipe . "\n";
288: $slideshow .= 'data-cycle-loader=true' . "\n";
289: $slideshow .= 'data-cycle-progressive=".slides"' . "\n";
290: $slideshow .= '>';
291:
292: $firstslide = array_shift($slides);
293: 294: 295: 296: 297: 298:
299: $slideobj = cycle::getSlideObj($firstslide, $albumobj);
300:
301:
302: $slideshow .= cycle::getSlide($albumobj, $slideobj, $width, $height, $cropw, $croph, $linkslides, false);
303:
304: $slideshow .= '<script class="slides" type="text/cycle" data-cycle-split="---">' . "\n";
305: $count = '';
306: foreach ($slides as $slide) {
307: $count++;
308: $slideobj = cycle::getSlideObj($slide, $albumobj);
309: $slideshow .= cycle::getSlide($albumobj, $slideobj, $width, $height, $cropw, $croph, $linkslides, false);
310: if ($count != $numslides) {
311: $slideshow .= "---\n";
312: }
313: }
314: $slideshow .='</script>' . "\n";
315: $slideshow .='</div>' . "\n";
316: $slideshow .='</section>' . "\n";
317: return $slideshow;
318: }
319:
320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333:
334: static function getSlide($albumobj, $imgobj, $width, $height, $cropw, $croph, $linkslides, $crop = false, $carousel = false) {
335: global $_zp_current_image;
336: if ($crop) {
337: $imageurl = $imgobj->getCustomImage(NULL, $width, $height, $cropw, $croph, NULL, NULL, true, NULL);
338: } else {
339: $maxwidth = $width;
340: $maxheight = $height;
341: getMaxSpaceContainer($maxwidth, $maxheight, $imgobj);
342: $imageurl = $imgobj->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
343: }
344: $slidecontent = '<div class="slide">' . "\n";
345:
346: if (!$carousel) {
347: $slidecontent .= '<h4>' . html_encode($albumobj->getTitle()) . ': ' . html_Encode($imgobj->getTitle()) . '</h4>' . "\n";
348: }
349: if ($carousel) {
350:
351: if ($linkslides) {
352: $url = pathurlencode($imgobj->getFullImageURL());
353: } else {
354: $url = $imgobj->getLink();
355: }
356: $slidecontent .= '<a href="' . $url . '">' . "\n";
357: } else if (!$carousel && $linkslides) {
358: $slidecontent .= '<a href="' . $imgobj->getLink() . '">' . "\n";
359: }
360: $active = '';
361: if ($carousel && !is_null($_zp_current_image)) {
362: if ($_zp_current_image->filename == $imgobj->filename) {
363: $active = ' class="activeslide"';
364: } else {
365: $active = '';
366: }
367: }
368: $slidecontent .='<img src="' . pathurlencode($imageurl) . '" alt=""' . $active . '>' . "\n";
369: if ($linkslides || $carousel) {
370: $slidecontent .= '</a>' . "\n";
371: }
372:
373: if (getOption("cycle-slideshow_showdesc") && !$carousel) {
374: $slidecontent .= '<div class="slide_desc">' . html_encodeTagged($imgobj->getDesc()) . '</div>' . "\n";
375: }
376: $slidecontent .= '</div>' . "\n";
377: return $slidecontent;
378: }
379:
380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393:
394: static function printSlide($albumobj, $imgobj, $width, $height, $cropw, $croph, $linkslides, $crop = false, $carousel = false) {
395: echo getSlide($albumobj, $imgobj, $width, $height, $cropw, $croph, $linkslides, $crop, $carousel);
396: }
397:
398: 399: 400: 401: 402: 403: 404:
405: static function getSlideObj($slide, $albumobj) {
406: return newImage($albumobj, $slide);
407: }
408:
409: static function macro($macros) {
410: $macros['SLIDESHOW'] = array(
411: 'class' => 'function',
412: 'params' => array('string', 'bool*', 'int*', 'int*'),
413: 'value' => 'cycle::getSlideshowPlayer',
414: 'owner' => 'cycle',
415: 'desc' => gettext('provide the album name as %1 and (optionally) <code>true</code> (or <code>false</code>) as %2 to show (hide) controls. Hiding the controls is the default. Width(%3) and height(%4) may also be specified to override the defaults.')
416: );
417: return $macros;
418: }
419:
420: static function cycleJS() {
421: ?>
422: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.min.js" type="text/javascript"></script>
423: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.center.min.js" type="text/javascript"></script>
424: <!-- effect plugins -->
425:
426: <?php if (getOption('cycle-slideshow_effect') == 'flipHorz' || getOption('cycle-slideshow_effect') == 'flipVert') { ?>
427: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.flip.min.js" type="text/javascript"></script>
428: <?php } ?>
429:
430: <!--[if lt IE 9]>
431: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.ie-fade.min.js" type="text/javascript"></script>
432: <![endif]-->
433:
434: <?php if (getOption('cycle-slideshow_effect') == 'shuffle') { ?>
435: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.shuffle.min.js" type="text/javascript"></script>
436: <?php } ?>
437:
438: <?php if (getOption('cycle-slideshow_effect') == 'tileSlide' || getOption('cycle-slideshow_effect') == 'tileBlind') { ?>
439: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.tile.min.js" type="text/javascript"></script>
440: <?php } ?>
441:
442: <?php if (getOption('cycle-slideshow_effect') == 'scrollVert') { ?>
443: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.scrollVert.min.js" type="text/javascript"></script>
444: <?php } ?>
445:
446: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.carousel.min.js" type="text/javascript"></script>
447:
448: <!-- swipe with iOS fix -->
449: <?php if (getOption('cycle-slideshow_swipe')) { ?>
450: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/jquery.cycle2.swipe.min.js" type="text/javascript"></script>
451: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/ios6fix.js" type="text/javascript"></script>
452: <?php }
453: $theme = getCurrentTheme();
454: $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/slideshow2.css';
455: if (file_exists($css)) {
456: $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/slideshow2.css';
457: } else {
458: $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow2/slideshow2.css';
459: }
460: ?>
461: <link rel="stylesheet" type="text/css" href="<?php echo $css ?>" />
462: <!--[if lte IE 7]>
463: <link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/fonts/ie7.css" />
464: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow2/fonts/ie7.js" type="text/javascript"></script>
465: <![endif]-->
466: <?php
467: }
468:
469: 470: 471: 472: 473: 474: 475:
476: static function is_valid($image, $valid_types) {
477: if (is_object($image)) {
478: $image = $image->filename;
479: }
480: $ext = getSuffix($image);
481: if (in_array($ext, $valid_types)) {
482: return $ext;
483: }
484: return false;
485: }
486:
487: }
488:
489:
490:
491: if ($plugin_disable) {
492: enableExtension('slideshow2', 0);
493: }
494: if (extensionEnabled('slideshow2')) {
495:
496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506:
507: function printSlideShowLink($linktext = NULL, $linkstyle = Null) {
508: global $_zp_gallery, $_zp_current_image, $_zp_current_album, $_zp_current_search, $slideshow_instance, $_zp_gallery_page, $_myFavorites;
509: if (is_null($linktext)) {
510: $linktext = gettext('View Slideshow');
511: }
512: if (empty($_GET['page'])) {
513: $pagenr = 1;
514: } else {
515: $pagenr = sanitize_numeric($_GET['page']);
516: }
517: $slideshowhidden = '';
518: $numberofimages = 0;
519: if (in_context(ZP_SEARCH)) {
520: $imagenumber = '';
521: $imagefile = '';
522: $albumnr = 0;
523: $slideshowlink = rewrite_path(_PAGE_ . '/slideshow/', "index.php?p=slideshow");
524: $slideshowhidden = '<input type="hidden" name="preserve_search_params" value="' . html_encode($_zp_current_search->getSearchParams()) . '" />';
525: } else {
526: if (in_context(ZP_IMAGE)) {
527: $imagenumber = imageNumber();
528: $imagefile = $_zp_current_image->filename;
529: } else {
530: $imagenumber = '';
531: $imagefile = '';
532: }
533: if (in_context(ZP_SEARCH_LINKED)) {
534: $albumnr = -$_zp_current_album->getID();
535: $slideshowhidden = '<input type="hidden" name="preserve_search_params" value="' . html_encode($_zp_current_search->getSearchParams()) . '" />';
536: } else {
537: $albumnr = $_zp_current_album->getID();
538: }
539: if ($albumnr) {
540: $slideshowlink = rewrite_path(pathurlencode($_zp_current_album->getFolder()) . '/' . _PAGE_ . '/slideshow/', "index.php?p=slideshow&album=" . urlencode($_zp_current_album->getFolder()));
541: } else {
542: $slideshowlink = rewrite_path(_PAGE_ . '/slideshow', "index.php?p=slideshow");
543: $slideshowhidden = '<input type="hidden" name="favorites_page" value="1" />' . "\n" . '<input type="hidden" name="title" value="' . $_myFavorites->instance . '" />';
544: }
545: }
546: $numberofimages = getNumImages();
547: $option = getOption('cycle-slideshow_mode');
548: switch ($option) {
549: case 'cycle':
550: if ($numberofimages > 1) {
551: ?>
552: <form name="slideshow_<?php echo $slideshow_instance; ?>" method="post" action="<?php echo $slideshowlink; ?>">
553: <?php echo $slideshowhidden; ?>
554: <input type="hidden" name="pagenr" value="<?php echo html_encode($pagenr); ?>" />
555: <input type="hidden" name="albumid" value="<?php echo $albumnr; ?>" />
556: <input type="hidden" name="numberofimages" value="<?php echo $numberofimages; ?>" />
557: <input type="hidden" name="imagenumber" value="<?php echo $imagenumber; ?>" />
558: <input type="hidden" name="imagefile" value="<?php echo html_encode($imagefile); ?>" />
559: <?php if (!empty($linkstyle)) echo '<p style="' . $linkstyle . '">'; ?>
560: <a class="slideshowlink" id="slideshowlink_<?php echo $slideshow_instance; ?>" href="javascript:document.slideshow_<?php echo $slideshow_instance; ?>.submit()"><?php echo $linktext; ?></a>
561: <?php if (!empty($linkstyle)) echo '</p>'; ?>
562: </form>
563: <?php
564: }
565: $slideshow_instance++;
566: break;
567: case 'colorbox':
568: $theme = $_zp_gallery->getCurrentTheme();
569: $script = stripSuffix($_zp_gallery_page);
570: if (!getOption('colorbox_' . $theme . '_' . $script)) {
571: setOptionDefault('colorbox_' . $theme . '_' . $script, 1);
572: $themes = $_zp_gallery->getThemes();
573: ?>
574: <div class="errorbox"><?php printf(gettext('Slideshow not available because colorbox is not enabled on %1$s <em>%2$s</em> pages.'), $themes[$theme]['name'], $script); ?></div>
575: <?php
576: break;
577: }
578: if ($numberofimages > 1) {
579: if ((in_context(ZP_SEARCH_LINKED) && !in_context(ZP_ALBUM_LINKED)) || in_context(ZP_SEARCH) && is_null($_zp_current_album)) {
580: $images = $_zp_current_search->getImages(0);
581: } else {
582: $images = $_zp_current_album->getImages(0);
583: }
584: $count = '';
585: ?>
586: <script type="text/javascript">
587: $(document).ready(function() {
588: $("a[rel='slideshow']").colorbox({
589: slideshow: true,
590: loop: true,
591: transition: '<?php echo getOption('cycle-slideshow_colorbox_transition'); ?>',
592: slideshowSpeed: <?php echo getOption('cycle-slideshow_speed'); ?>,
593: slideshowStart: '<?php echo gettext("start slideshow"); ?>',
594: slideshowStop: '<?php echo gettext("stop slideshow"); ?>',
595: previous: '<?php echo gettext("prev"); ?>',
596: next: '<?php echo gettext("next"); ?>',
597: close: '<?php echo gettext("close"); ?>',
598: current: '<?php printf(gettext('image %1$s of %2$s'), '{current}', '{total}'); ?>',
599: maxWidth: '98%',
600: maxHeight: '98%',
601: photo: true
602: });
603: });
604: </script>
605: <?php
606: foreach ($images as $image) {
607: if (is_array($image)) {
608: $suffix = getSuffix($image['filename']);
609: } else {
610: $suffix = getSuffix($image);
611: }
612: $suffixes = array('jpg', 'jpeg', 'gif', 'png');
613: if (in_array($suffix, $suffixes)) {
614: $count++;
615: if (is_array($image)) {
616: $albobj = newAlbum($image['folder']);
617: $imgobj = newImage($albobj, $image['filename']);
618: } else {
619: $imgobj = newImage($_zp_current_album, $image);
620: }
621: if (in_context(ZP_SEARCH_LINKED) || $_zp_gallery_page != 'image.php') {
622: if ($count == 1) {
623: $style = '';
624: } else {
625: $style = ' style="display:none"';
626: }
627: } else {
628: if ($_zp_current_image->filename == $image) {
629: $style = '';
630: } else {
631: $style = ' style="display:none"';
632: }
633: }
634: switch (getOption('cycle-slideshow_colorbox_imagetype')) {
635: case 'fullimage':
636: $imagelink = getFullImageURL($imgobj);
637: break;
638: case 'sizedimage':
639: $imagelink = $imgobj->getCustomImage(getOption("cycle-slideshow_width"), NULL, NULL, NULL, NULL, NULL, NULL, false, NULL);
640: break;
641: }
642: $imagetitle = '';
643: if (getOption('cycle-slideshow_colorbox_imagetitle')) {
644: $imagetitle = html_encode(getBare($imgobj->getTitle()));
645: }
646: ?>
647: <a class="slideshowlink" href="<?php echo html_encode(pathurlencode($imagelink)); ?>" rel="slideshow"<?php echo $style; ?> title="<?php echo $imagetitle; ?>"><?php echo $linktext; ?></a>
648: <?php
649: }
650: }
651: }
652: break;
653: }
654: }
655:
656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682:
683: function printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true) {
684: global $_myFavorites, $_zp_conf_vars;
685: if (!isset($_POST['albumid']) AND ! is_object($albumobj)) {
686: return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
687: }
688:
689: if (!empty($_POST['imagenumber']) AND ! is_object($imageobj)) {
690: $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
691: } elseif (is_object($imageobj)) {
692: $imagenumber = $imageobj->getIndex();
693: } else {
694: $imagenumber = 0;
695: }
696:
697: if (isset($_POST['pagenr'])) {
698: $pagenumber = sanitize_numeric($_POST['pagenr']);
699: } else {
700: $pagenumber = 1;
701: }
702:
703: if (!empty($_POST['numberofimages'])) {
704: $numberofimages = sanitize_numeric($_POST['numberofimages']);
705: } elseif (is_object($albumobj)) {
706: $numberofimages = $albumobj->getNumImages();
707: } else {
708: $numberofimages = 0;
709: }
710: if ($numberofimages < 2 || $imagenumber > $numberofimages) {
711: $imagenumber = 0;
712: }
713:
714:
715: if (!empty($_POST['albumid']) && !is_object($albumobj)) {
716: $albumid = sanitize_numeric($_POST['albumid']);
717: } elseif (is_object($albumobj)) {
718: $albumid = $albumobj->getID();
719: } else {
720: $albumid = 0;
721: }
722:
723: if (isset($_POST['preserve_search_params'])) {
724: $search = new SearchEngine();
725: $params = sanitize($_POST['preserve_search_params']);
726: $search->setSearchParams($params);
727: $searchwords = $search->getSearchWords();
728: $searchdate = $search->getSearchDate();
729: $searchfields = $search->getSearchFields(true);
730: $page = $search->page;
731: $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
732: $albumobj = new AlbumBase(NULL, false);
733: $albumobj->setTitle(gettext('Search'));
734: $albumobj->images = $search->getImages(0);
735: } else {
736: if (isset($_POST['favorites_page'])) {
737: $albumobj = $_myFavorites;
738: $returnpath = $_myFavorites->getLink($pagenumber);
739: } else {
740: $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
741: $albumobj = newAlbum($albumq['folder']);
742: if (empty($_POST['imagenumber'])) {
743: $returnpath = $albumobj->getLink($pagenumber);
744: } else {
745: $image = newImage($albumobj, sanitize($_POST['imagefile']));
746: $returnpath = $image->getLink();
747: }
748: }
749: }
750: echo cycle::getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber);
751: }
752:
753: }