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: 36: 37: 38:
39: $plugin_is_filter = 9 | THEME_PLUGIN | ADMIN_PLUGIN;
40: $plugin_description = gettext("Adds a theme function to call a slideshow either based on jQuery (default) or Colorbox.");
41: $plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard), Don Peterson (dpeterson)";
42: $plugin_disable = (extensionEnabled('slideshow2')) ? sprintf(gettext('Only one slideshow plugin may be enabled. <a href="#%1$s"><code>%1$s</code></a> is already enabled.'), 'slideshow2') : '';
43:
44: $option_interface = 'slideshow';
45:
46: global $_zp_gallery, $_zp_gallery_page;
47: if ($_zp_gallery_page == 'slideshow.php' || getOption('slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page))) {
48: zp_register_filter('theme_head', 'slideshow::header_js');
49: }
50: zp_register_filter('content_macro', 'slideshow::macro');
51:
52:
53:
54:
55:
56: 57: 58: 59:
60: class slideshow {
61:
62: function __construct() {
63: global $_zp_gallery;
64: if (OFFSET_PATH == 2) {
65:
66: setOptionDefault('slideshow_width', '595');
67: setOptionDefault('slideshow_height', '595');
68: setOptionDefault('slideshow_mode', 'jQuery');
69: setOptionDefault('slideshow_effect', 'fade');
70: setOptionDefault('slideshow_speed', '1000');
71: setOptionDefault('slideshow_timeout', '3000');
72: setOptionDefault('slideshow_showdesc', '');
73: setOptionDefault('slideshow_colorbox_transition', 'fade');
74:
75: setOptionDefault('slideshow_colorbox_imagetype', 'sizedimage');
76: setOptionDefault('slideshow_colorbox_imagetitle', 1);
77: if (class_exists('cacheManager')) {
78: cacheManager::deleteThemeCacheSizes('slideshow');
79: cacheManager::addThemeCacheSize('slideshow', NULL, getOption('slideshow_width'), getOption('slideshow_height'), NULL, NULL, NULL, NULL, NULL, NULL, NULL, true);
80: }
81: }
82: }
83:
84: function getOptionsSupported() {
85: $options = array(gettext('Mode') => array('key' => 'slideshow_mode', 'type' => OPTION_TYPE_SELECTOR,
86: 'order' => 0,
87: 'selections' => array(gettext("jQuery Cycle") => "jQuery", gettext("jQuery Colorbox") => "colorbox"),
88: 'desc' => gettext('<em>jQuery Cycle</em> for slideshow using the jQuery Cycle 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.')),
89: gettext('Speed') => array('key' => 'slideshow_speed', 'type' => OPTION_TYPE_TEXTBOX,
90: 'order' => 1,
91: 'desc' => gettext("Speed of the transition in milliseconds."))
92: );
93: 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) {
94: $list = array();
95: foreach ($scripts as $script) {
96: $list[$script] = 'slideshow_' . $theme . '_' . stripSuffix($script);
97: }
98: $opts[$theme] = array('key' => 'slideshow_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
99: 'checkboxes' => $list,
100: 'desc' => gettext('The scripts for which the slideshow is enabled. {Should have been set by the themes!}')
101: );
102: }
103: $options = array_merge($options, $opts);
104:
105: switch (getOption('slideshow_mode')) {
106: case 'jQuery':
107: $options = array_merge($options, array(gettext('Slide width') => array('key' => 'slideshow_width', 'type' => OPTION_TYPE_TEXTBOX,
108: 'order' => 5,
109: 'desc' => gettext("Width of the images in the slideshow.")),
110: gettext('Slide height') => array('key' => 'slideshow_height', 'type' => OPTION_TYPE_TEXTBOX,
111: 'order' => 6,
112: 'desc' => gettext("Height of the images in the slideshow.")),
113: gettext('Cycle Effect') => array('key' => 'slideshow_effect', 'type' => OPTION_TYPE_SELECTOR,
114: 'order' => 2,
115: 'selections' => array(gettext('fade') => "fade", gettext('shuffle') => "shuffle", gettext('zoom') => "zoom", gettext('slide X') => "slideX", gettext('slide Y') => "slideY", gettext('scroll up') => "scrollUp", gettext('scroll down') => "scrollDown", gettext('scroll left') => "scrollLeft", gettext('scroll right') => "scrollRight"),
116: 'desc' => gettext("The cycle slide effect to be used.")),
117: gettext('Timeout') => array('key' => 'slideshow_timeout', 'type' => OPTION_TYPE_TEXTBOX,
118: 'order' => 3,
119: 'desc' => gettext("Milliseconds between slide transitions (0 to disable auto advance.)")),
120: gettext('Description') => array('key' => 'slideshow_showdesc', 'type' => OPTION_TYPE_CHECKBOX,
121: 'order' => 4,
122: 'desc' => gettext("Check if you want to show the image’s description below the slideshow."))
123: ));
124: break;
125: case 'colorbox':
126: $options = array_merge($options, array(gettext('Colorbox transition') => array('key' => 'slideshow_colorbox_transition', 'type' => OPTION_TYPE_SELECTOR,
127: 'order' => 2,
128: 'selections' => array(gettext('elastic') => "elastic", gettext('fade') => "fade", gettext('none') => "none"),
129: 'desc' => gettext("The Colorbox transition slide effect to be used.")),
130: gettext('Colorbox image type') => array('key' => 'slideshow_colorbox_imagetype', 'type' => OPTION_TYPE_SELECTOR,
131: 'order' => 3,
132: 'selections' => array(gettext('full image') => "fullimage", gettext('sized image') => "sizedimage"),
133: '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.")),
134: gettext('Colorbox image title') => array('key' => 'slideshow_colorbox_imagetitle', 'type' => OPTION_TYPE_CHECKBOX,
135: 'order' => 4,
136: 'desc' => gettext("If the image title should be shown at the bottom of the Colorbox."))
137: ));
138: if (getOption('slideshow_colorbox_imagetype') == 'sizedimage') {
139: $options = array_merge($options, array(gettext('Slide width') => array('key' => 'slideshow_width', 'type' => OPTION_TYPE_TEXTBOX,
140: 'order' => 3.5,
141: 'desc' => gettext("Width of the images in the slideshow."))
142: ));
143: }
144: break;
145: }
146: return $options;
147: }
148:
149: function handleOption($option, $currentValue) {
150:
151: }
152:
153: static function getPlayer($album, $controls = false, $width = NULL, $height = NULL) {
154: $albumobj = NULL;
155: if (!empty($album)) {
156: $albumobj = newAlbum($album, NULL, true);
157: }
158: if (is_object($albumobj) && $albumobj->loaded) {
159: $returnpath = $albumobj->getLink();
160: return slideshow::getShow(false, false, $albumobj, NULL, $width, $height, false, false, false, $controls, $returnpath, 0);
161: } else {
162: return '<div class="errorbox" id="message"><h2>' . gettext('Invalid slideshow album name!') . '</h2></div>';
163: }
164: }
165:
166: static function getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber) {
167: global $_zp_gallery, $_zp_gallery_page;
168: setOption('slideshow_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
169: if (!$albumobj->isMyItem(LIST_RIGHTS) && !checkAlbumPassword($albumobj)) {
170: return '<div class="errorbox" id="message"><h2>' . gettext('This album is password protected!') . '</h2></div>';
171: }
172: $slideshow = '';
173: $numberofimages = $albumobj->getNumImages();
174:
175: if ($width) {
176: $wrapperwidth = $width;
177: } else {
178: $width = $wrapperwidth = getOption("slideshow_width");
179: }
180: if ($height) {
181: $wrapperheight = $height;
182: } else {
183: $height = $wrapperheight = getOption("slideshow_height");
184: }
185: if ($numberofimages == 0) {
186: return '<div class="errorbox" id="message"><h2>' . gettext('No images for the slideshow!') . '</h2></div>';
187: }
188: $option = getOption("slideshow_mode");
189:
190:
191:
192: $showdesc = getOption("slideshow_showdesc");
193:
194: $validtypes = array('jpg', 'jpeg', 'gif', 'png', 'mov', '3gp');
195: $slideshow .= '
196: <script type="text/javascript">
197: // <!-- <![CDATA[
198: $(document).ready(function(){
199: $(function() {
200: var ThisGallery = "' . html_encode($albumobj->getTitle()) . '";
201: var ImageList = new Array();
202: var TitleList = new Array();
203: var DescList = new Array();
204: var ImageNameList = new Array();
205: var DynTime=(' . (int) getOption("slideshow_timeout") . ');
206: ';
207: $images = $albumobj->getImages(0);
208: if ($shuffle) {
209: shuffle($images);
210: }
211: for ($imgnr = 0, $cntr = 0, $idx = $imagenumber; $imgnr < $numberofimages; $imgnr++, $idx++) {
212: if (is_array($images[$idx])) {
213: $filename = $images[$idx]['filename'];
214: $album = newAlbum($images[$idx]['folder']);
215: $image = newImage($album, $filename);
216: } else {
217: $filename = $images[$idx];
218: $image = newImage($albumobj, $filename);
219: }
220: $ext = slideshow::is_valid($filename, $validtypes);
221: if ($ext) {
222: if ($crop) {
223: $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
224: } else {
225: $maxwidth = $width;
226: $maxheight = $height;
227: getMaxSpaceContainer($maxwidth, $maxheight, $image);
228: $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
229: }
230: $slideshow .= 'ImageList[' . $cntr . '] = "' . $img . '";' . "\n";
231: $slideshow .= 'TitleList[' . $cntr . '] = "' . js_encode($image->getTitle()) . '";' . "\n";
232: if ($showdesc) {
233: $desc = $image->getDesc();
234: $desc = str_replace("\r\n", '<br />', $desc);
235: $desc = str_replace("\r", '<br />', $desc);
236: $slideshow .= 'DescList[' . $cntr . '] = "' . js_encode($desc) . '";' . "\n";
237: } else {
238: $slideshow .= 'DescList[' . $cntr . '] = "";' . "\n";
239: }
240: if ($idx == $numberofimages - 1) {
241: $idx = -1;
242: }
243: $slideshow .= 'ImageNameList[' . $cntr . '] = "' . urlencode($filename) . '";' . "\n";
244: $cntr++;
245: }
246: }
247:
248: $slideshow .= "\n";
249: $numberofimages = $cntr;
250: $slideshow .= '
251: var countOffset = ' . $imagenumber . ';
252: var totalSlideCount = ' . $numberofimages . ';
253: var currentslide = 2;
254: function onBefore(curr, next, opts) {
255: if (opts.timeout != DynTime) {
256: opts.timeout = DynTime;
257: }
258: if (!opts.addSlide)
259: return;
260: var currentImageNum = currentslide;
261: currentslide++;
262: if (currentImageNum == totalSlideCount) {
263: opts.addSlide = null;
264: return;
265: }
266: var relativeSlot = (currentslide + countOffset) % totalSlideCount;
267: if (relativeSlot == 0) {relativeSlot = totalSlideCount;}
268: var htmlblock = "<span class=\"slideimage\"><h4><strong>" + ThisGallery + ":</strong> ";
269: htmlblock += TitleList[currentImageNum] + " (" + relativeSlot + "/" + totalSlideCount + ")</h4>";
270: ';
271: if ($linkslides) {
272: if (MOD_REWRITE) {
273: $slideshow .= 'htmlblock += "<a href=\"' . pathurlencode($albumobj->name) . '/"+ImageNameList[currentImageNum]+"' . getOption('mod_rewrite_image_suffix') . '\">";';
274: } else {
275: $slideshow .= 'htmlblock += "<a href=\"index.php?album=' . pathurlencode($albumobj->name) . '&image="+ImageNameList[currentImageNum]+"\">";';
276: }
277: }
278: $slideshow .= ' htmlblock += "<img src=\"" + ImageList[currentImageNum] + "\"/>";';
279: if ($linkslides) {
280: $slideshow .= ' htmlblock += "</a>";';
281: }
282:
283: $slideshow .= 'htmlblock += "<p class=\"imgdesc\">" + DescList[currentImageNum] + "</p></span>";';
284: $slideshow .= 'opts.addSlide(htmlblock);';
285: $slideshow .= '}';
286:
287: $slideshow .= '
288: function onAfter(curr, next, opts){
289: ';
290: if (!$albumobj->isMyItem(LIST_RIGHTS)) {
291: $slideshow .= '
292: //Only register at hit count the first time the image is viewed.
293: if ($(next).attr("viewed") != 1) {
294: $.get("' . FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow/slideshow-counter.php?album=' . pathurlencode($albumobj->name) . '&img="+ImageNameList[opts.currSlide]);
295: $(next).attr("viewed", 1 );
296: }
297: ';
298: }
299: $slideshow .='}';
300: $slideshow .='
301: $("#slides").cycle({
302: fx: "' . getOption("slideshow_effect") . '",
303: speed: "' . getOption("slideshow_speed") . '",
304: timeout: DynTime,
305: next: "#next",
306: prev: "#prev",
307: cleartype: 1,
308: before: onBefore,
309: after: onAfter
310: });
311:
312: $("#speed").change(function () {
313: DynTime = this.value;
314: return false;
315: });
316:
317: $("#pause").click(function() { $("#slides").cycle("pause"); return false; });
318: $("#play").click(function() { $("#slides").cycle("resume"); return false; });
319: });
320:
321: }); // Documentready()
322: // ]]> -->
323: </script>
324: <div id="slideshow" style="height:' . ($wrapperheight + 40) . 'px; width:' . $wrapperwidth . 'px;">
325: ';
326:
327: if ($speedctl) {
328: $slideshow .= '<div id="speedcontrol">';
329: $minto = getOption("slideshow_speed");
330: while ($minto % 500 != 0) {
331: $minto += 100;
332: if ($minto > 10000) {
333: break;
334: }
335: }
336: $dflttimeout = (int) getOption("slideshow_timeout");
337:
338: $thistimeout = ($minto == getOption("slideshow_speed") ? $minto + 250 : $minto);
339: $slideshow .= 'Select Speed: <select id="speed" name="speed">';
340: while ($thistimeout <= 60000) {
341: $slideshow .= "<option value=$thistimeout " . ($thistimeout == $dflttimeout ? " selected='selected'>" : ">") . round($thistimeout / 1000, 1) . " sec</option>";
342:
343: if ($thistimeout % 500 != 0) {
344: $thistimeout -= 250;
345: }
346: $thistimeout += ($thistimeout < 1000 ? 500 : ($thistimeout < 10000 ? 1000 : 5000));
347: }
348: $slideshow .= '</select> </div>';
349: }
350: if ($controls) {
351: $slideshow .= '
352: <div id="controls">
353: <div>
354: <a href="#" id="prev" title="' . gettext("Previous") . '"></a>
355: <a href="' . html_encode($returnpath) . '" id="stop" title="' . gettext("Stop and return to album or image page") . '"></a>
356: <a href="#" id="pause" title="' . gettext("Pause (to stop the slideshow without returning)") . '"></a>
357: <a href="#" id="play" title="' . gettext("Play") . '"></a>
358: <a href="#" id="next" title="' . gettext("Next") . '"></a>
359: </div>
360: </div>
361: ';
362: }
363: $slideshow .= '
364: <div id="slides" class="pics">
365: ';
366:
367: if ($cntr > 1)
368: $cntr = 1;
369: for ($imgnr = 0, $idx = $imagenumber; $imgnr <= $cntr; $idx++) {
370: if ($idx >= $numberofimages) {
371: $idx = 0;
372: }
373: if (is_array($images[$idx])) {
374: $folder = $images[$idx]['folder'];
375: $dalbum = newAlbum($folder);
376: $filename = $images[$idx]['filename'];
377: $image = newImage($dalbum, $filename);
378: $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
379: } else {
380: $folder = $albumobj->name;
381: $filename = $images[$idx];
382:
383: $image = newImage($albumobj, $filename);
384: $imagepath = FULLWEBPATH . ALBUM_FOLDER_EMPTY . $folder . "/" . $filename;
385: }
386: $ext = slideshow::is_valid($filename, $validtypes);
387: if ($ext) {
388: $imgnr++;
389: $slideshow .= '<span class="slideimage"><h4><strong>' . $albumobj->getTitle() . gettext(":") . '</strong> ' . $image->getTitle() . ' (' . ($idx + 1) . '/' . $numberofimages . ')</h4>';
390:
391: if ($ext == "3gp") {
392: $slideshow .= '</a>
393: <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="352" height="304" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
394: <param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
395: <param name="autoplay" value="false" />
396: <param name="type" value="video/quicktime" />
397: <param name="controller" value="true" />
398: <embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="352" height="304" autoplay="false" controller"true" type="video/quicktime"
399: pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
400: </object>
401: <a>';
402: } elseif ($ext == "mov") {
403: $slideshow .= '</a>
404: <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="640" height="496" codebase="http://www.apple.com/qtactivex/qtplugin.cab">
405: <param name="src" value="' . pathurlencode(internalToFilesystem($imagepath)) . '"/>
406: <param name="autoplay" value="false" />
407: <param name="type" value="video/quicktime" />
408: <param name="controller" value="true" />
409: <embed src="' . pathurlencode(internalToFilesystem($imagepath)) . '" width="640" height="496" autoplay="false" controller"true" type="video/quicktime"
410: pluginspage="http://www.apple.com/quicktime/download/" cache="true"></embed>
411: </object>
412: <a>';
413: } else {
414: if ($linkslides)
415: $slideshow .= '<a href="' . html_encode($image->getLink()) . '">';
416: if ($crop) {
417: $img = $image->getCustomImage(NULL, $width, $height, $width, $height, NULL, NULL, NULL, NULL);
418: } else {
419: $maxwidth = $width;
420: $maxheight = $height;
421: getMaxSpaceContainer($maxwidth, $maxheight, $image);
422: $img = $image->getCustomImage(NULL, $maxwidth, $maxheight, NULL, NULL, NULL, NULL, NULL, NULL);
423: }
424: $slideshow .= '<img src="' . html_encode(pathurlencode($img)) . '" alt="" />';
425: if ($linkslides)
426: $slideshow .= '</a>';
427: }
428: if ($showdesc) {
429: $desc = $image->getDesc();
430: $desc = str_replace("\r\n", '<br />', $desc);
431: $desc = str_replace("\r", '<br />', $desc);
432: $slideshow .= '<p class="imgdesc">' . $desc . '</p>';
433: }
434: $slideshow .= '</span>';
435: }
436: }
437: $slideshow .= '
438: </div>
439: </div>
440: ';
441: return $slideshow;
442: }
443:
444: static function macro($macros) {
445: $macros['SLIDESHOW'] = array(
446: 'class' => 'function',
447: 'params' => array('string', 'bool*', 'int*', 'int*'),
448: 'value' => 'slideshow::getPlayer',
449: 'owner' => 'slideshow',
450: '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.')
451: );
452: return $macros;
453: }
454:
455: static function header_js() {
456: $theme = getCurrentTheme();
457: $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/slideshow.css';
458: if (file_exists($css)) {
459: $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/slideshow.css';
460: } else {
461: $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/slideshow/slideshow.css';
462: }
463: ?>
464: <script src="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER ?>/slideshow/jquery.cycle.all.js" type="text/javascript"></script>
465: <link rel="stylesheet" type="text/css" href="<?php echo $css; ?>" />
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: $ext = getSuffix($image);
480: if (in_array($ext, $valid_types)) {
481: return $ext;
482: }
483: return false;
484: }
485:
486: }
487:
488: if ($plugin_disable) {
489: enableExtension('slideshow', 0);
490: }
491: if (extensionEnabled('slideshow')) {
492: $slideshow_instance = 0;
493:
494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504:
505: function printSlideShowLink($linktext = NULL, $linkstyle = Null) {
506: global $_zp_gallery, $_zp_current_image, $_zp_current_album, $_zp_current_search, $slideshow_instance, $_zp_gallery_page;
507: if (is_null($linktext)) {
508: $linktext = gettext('View Slideshow');
509: }
510: if (empty($_GET['page'])) {
511: $pagenr = 1;
512: } else {
513: $pagenr = sanitize_numeric($_GET['page']);
514: }
515: $slideshowhidden = '';
516: $numberofimages = 0;
517: if (in_context(ZP_SEARCH)) {
518: $imagenumber = '';
519: $imagefile = '';
520: $albumnr = 0;
521: $slideshowlink = rewrite_path(_PAGE_ . '/slideshow/', "index.php?p=slideshow");
522: $slideshowhidden = '<input type="hidden" name="preserve_search_params" value="' . html_encode($_zp_current_search->getSearchParams()) . '" />';
523: } else {
524: if (in_context(ZP_IMAGE)) {
525: $imagenumber = imageNumber();
526: $imagefile = $_zp_current_image->filename;
527: } else {
528: $imagenumber = '';
529: $imagefile = '';
530: }
531: if (in_context(ZP_SEARCH_LINKED)) {
532: $albumnr = -$_zp_current_album->getID();
533: $slideshowhidden = '<input type="hidden" name="preserve_search_params" value="' . html_encode($_zp_current_search->getSearchParams()) . '" />';
534: } else {
535: $albumnr = $_zp_current_album->getID();
536: }
537: if ($albumnr) {
538: $slideshowlink = rewrite_path(pathurlencode($_zp_current_album->getFileName()) . '/' . _PAGE_ . '/slideshow/', "index.php?p=slideshow&album=" . urlencode($_zp_current_album->getFileName()));
539: } else {
540: $slideshowlink = rewrite_path(_PAGE_ . '/slideshow/', "index.php?p=slideshow");
541: $slideshowhidden = '<input type="hidden" name="favorites_page" value="1" />' . "\n" . '<input type="hidden" name="title" value="' . $_myFavorites->instance . '" />';
542: }
543: }
544: $numberofimages = getNumImages();
545: $option = getOption('slideshow_mode');
546: switch ($option) {
547: case 'jQuery':
548: if ($numberofimages > 1) {
549: ?>
550: <form name="slideshow_<?php echo $slideshow_instance; ?>" method="post" action="<?php echo zp_apply_filter('getLink', $slideshowlink, 'slideshow.php', NULL); ?>">
551: <?php echo $slideshowhidden; ?>
552: <input type="hidden" name="pagenr" value="<?php echo html_encode($pagenr); ?>" />
553: <input type="hidden" name="albumid" value="<?php echo $albumnr; ?>" />
554: <input type="hidden" name="numberofimages" value="<?php echo $numberofimages; ?>" />
555: <input type="hidden" name="imagenumber" value="<?php echo $imagenumber; ?>" />
556: <input type="hidden" name="imagefile" value="<?php echo html_encode($imagefile); ?>" />
557: <?php if (!empty($linkstyle)) echo '<p style="' . $linkstyle . '">'; ?>
558: <a class="slideshowlink" id="slideshowlink_<?php echo $slideshow_instance; ?>" href="javascript:document.slideshow_<?php echo $slideshow_instance; ?>.submit()"><?php echo $linktext; ?></a>
559: <?php if (!empty($linkstyle)) echo '</p>'; ?>
560: </form>
561: <?php
562: }
563: $slideshow_instance++;
564: break;
565: case 'colorbox':
566: $theme = $_zp_gallery->getCurrentTheme();
567: $script = stripSuffix($_zp_gallery_page);
568: if (!getOption('colorbox_' . $theme . '_' . $script)) {
569: setOptionDefault('colorbox_' . $theme . '_' . $script, 1);
570: $themes = $_zp_gallery->getThemes();
571: ?>
572: <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>
573: <?php
574: break;
575: }
576: if ($numberofimages > 1) {
577: if ((in_context(ZP_SEARCH_LINKED) && !in_context(ZP_ALBUM_LINKED)) || in_context(ZP_SEARCH) && is_null($_zp_current_album)) {
578: $images = $_zp_current_search->getImages(0);
579: } else {
580: $images = $_zp_current_album->getImages(0);
581: }
582: $count = '';
583: ?>
584: <script type="text/javascript">
585: $(document).ready(function() {
586: $("a[rel='slideshow']").colorbox({
587: slideshow: true,
588: loop: true,
589: transition: '<?php echo getOption('slideshow_colorbox_transition'); ?>',
590: slideshowSpeed: <?php echo getOption('slideshow_speed'); ?>,
591: slideshowStart: '<?php echo gettext("start slideshow"); ?>',
592: slideshowStop: '<?php echo gettext("stop slideshow"); ?>',
593: previous: '<?php echo gettext("prev"); ?>',
594: next: '<?php echo gettext("next"); ?>',
595: close: '<?php echo gettext("close"); ?>',
596: current: '<?php printf(gettext('image %1$s of %2$s'), '{current}', '{total}'); ?>',
597: maxWidth: '98%',
598: maxHeight: '98%',
599: photo: true
600: });
601: });
602: </script>
603: <?php
604: foreach ($images as $image) {
605: if (is_array($image)) {
606: $suffix = getSuffix($image['filename']);
607: } else {
608: $suffix = getSuffix($image);
609: }
610: $suffixes = array('jpg', 'jpeg', 'gif', 'png');
611: if (in_array($suffix, $suffixes)) {
612: $count++;
613: if (is_array($image)) {
614: $albobj = newAlbum($image['folder']);
615: $imgobj = newImage($albobj, $image['filename']);
616: } else {
617: $imgobj = newImage($_zp_current_album, $image);
618: }
619: if (in_context(ZP_SEARCH_LINKED) || $_zp_gallery_page != 'image.php') {
620: if ($count == 1) {
621: $style = '';
622: } else {
623: $style = ' style="display:none"';
624: }
625: } else {
626: if ($_zp_current_image->filename == $image) {
627: $style = '';
628: } else {
629: $style = ' style="display:none"';
630: }
631: }
632: switch (getOption('slideshow_colorbox_imagetype')) {
633: case 'fullimage':
634: $imagelink = getFullImageURL($imgobj);
635: break;
636: case 'sizedimage':
637: $imagelink = $imgobj->getCustomImage(getOption("slideshow_width"), NULL, NULL, NULL, NULL, NULL, NULL, false, NULL);
638: break;
639: }
640: $imagetitle = '';
641: if (getOption('slideshow_colorbox_imagetitle')) {
642: $imagetitle = html_encode(getBare($imgobj->getTitle()));
643: }
644: ?>
645: <a href="<?php echo html_encode(pathurlencode($imagelink)); ?>" rel="slideshow"<?php echo $style; ?> title="<?php echo $imagetitle; ?>"><?php echo $linktext; ?></a>
646: <?php
647: }
648: }
649: }
650: break;
651: }
652: }
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: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699:
700: function printSlideShow($heading = true, $speedctl = false, $albumobj = NULL, $imageobj = NULL, $width = NULL, $height = NULL, $crop = false, $shuffle = false, $linkslides = false, $controls = true) {
701: global $_myFavorites, $_zp_conf_vars;
702: if (!isset($_POST['albumid']) AND ! is_object($albumobj)) {
703: return '<div class="errorbox" id="message"><h2>' . gettext('Invalid linking to the slideshow page.') . '</h2></div>';
704: }
705:
706: if (!empty($_POST['imagenumber']) AND ! is_object($imageobj)) {
707: $imagenumber = sanitize_numeric($_POST['imagenumber']) - 1;
708: } elseif (is_object($imageobj)) {
709: $imagenumber = $imageobj->getIndex();
710: } else {
711: $imagenumber = 0;
712: }
713:
714: if (isset($_POST['pagenr'])) {
715: $pagenumber = sanitize_numeric($_POST['pagenr']);
716: } else {
717: $pagenumber = 1;
718: }
719:
720: if (!empty($_POST['numberofimages'])) {
721: $numberofimages = sanitize_numeric($_POST['numberofimages']);
722: } elseif (is_object($albumobj)) {
723: $numberofimages = $albumobj->getNumImages();
724: } else {
725: $numberofimages = 0;
726: }
727: if ($imagenumber < 2 || $imagenumber > $numberofimages) {
728: $imagenumber = 0;
729: }
730:
731: if (!empty($_POST['albumid']) && !is_object($albumobj)) {
732: $albumid = sanitize_numeric($_POST['albumid']);
733: } elseif (is_object($albumobj)) {
734: $albumid = $albumobj->getID();
735: } else {
736: $albumid = 0;
737: }
738:
739: if (isset($_POST['preserve_search_params'])) {
740: $search = new SearchEngine();
741: $params = sanitize($_POST['preserve_search_params']);
742: $search->setSearchParams($params);
743: $searchwords = $search->getSearchWords();
744: $searchdate = $search->getSearchDate();
745: $searchfields = $search->getSearchFields(true);
746: $page = $search->page;
747: $returnpath = getSearchURL($searchwords, $searchdate, $searchfields, $page);
748: $albumobj = new AlbumBase(NULL, false);
749: $albumobj->setTitle(gettext('Search'));
750: $albumobj->images = $search->getImages(0);
751: } else {
752: if (isset($_POST['favorites_page'])) {
753: $albumobj = $_myFavorites;
754: $returnpath = $_myFavorites->getLink($pagenumber);
755: } else {
756: $albumq = query_single_row("SELECT title, folder FROM " . prefix('albums') . " WHERE id = " . $albumid);
757: $albumobj = newAlbum($albumq['folder']);
758: if (empty($_POST['imagenumber'])) {
759: $returnpath = $albumobj->getLink($pagenumber);
760: } else {
761: $image = newImage($albumobj, sanitize($_POST['imagefile']));
762: $returnpath = $image->getLink();
763: }
764: }
765: }
766: echo slideshow::getShow($heading, $speedctl, $albumobj, $imageobj, $width, $height, $crop, $shuffle, $linkslides, $controls, $returnpath, $imagenumber);
767: }
768:
769: }
770: ?>
771: