1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: $plugin_description = gettext("Responsive jQuery bxSlider thumb nav plugin based on <a href='http://bxslider.com'>http://bxslider.com</a>");
16: $plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard), Fred Sondaar (fretzl)";
17: $plugin_disable = (extensionEnabled('jcarousel_thumb_nav')) ? sprintf(gettext('Only one Carousel plugin may be enabled. <a href="#%1$s"><code>%1$s</code></a> is already enabled.'), 'jcarousel_thumb_nav') : '';
18: $option_interface = 'bxslider';
19:
20: 21: 22: 23:
24: class bxslider {
25:
26: function __construct() {
27: if (OFFSET_PATH == 2) {
28: setOptionDefault('bxslider_minitems', '3');
29: setOptionDefault('bxslider_maxitems', '8');
30: setOptionDefault('bxslider_width', '50');
31: setOptionDefault('bxslider_height', '50');
32: setOptionDefault('bxslider_croph', '50');
33: setOptionDefault('bxslider_cropw', '50');
34: setOptionDefault('bxslider_speed', '500');
35: setOptionDefault('bxslider_fullimagelink', '');
36: setOptionDefault('bxslider_mode', 'horizontal');
37: if (class_exists('cacheManager')) {
38: cacheManager::deleteThemeCacheSizes('bxslider_thumb_nav');
39: cacheManager::addThemeCacheSize('bxslider_thumb_nav', NULL, getOption('bxslider_width'), getOption('bxslider_height'), getOption('bxslider_cropw'), getOption('bxslider_croph'), NULL, NULL, true, NULL, NULL, NULL);
40: }
41: }
42: }
43:
44: function getOptionsSupported() {
45: global $_zp_gallery;
46: $options = array(
47: gettext('Minimum items') => array('key' => 'bxslider_minitems', 'type' => OPTION_TYPE_TEXTBOX,
48: 'desc' => gettext("The minimum number of slides to be shown. Slides will be sized down if carousel becomes smaller than the original size."),
49: 'order' => 1),
50: gettext('Maximum items') => array('key' => 'bxslider_maxitems', 'type' => OPTION_TYPE_TEXTBOX,
51: 'desc' => gettext("The maximum number of slides to be shown. Slides will be sized up if carousel becomes larger than the original size."),
52: 'order' => 2),
53: gettext('Width') => array('key' => 'bxslider_width', 'type' => OPTION_TYPE_TEXTBOX,
54: 'desc' => gettext("Width of the thumb. Note that the CSS might need to be adjusted."),
55: 'order' => 3),
56: gettext('Height') => array('key' => 'bxslider_height', 'type' => OPTION_TYPE_TEXTBOX,
57: 'desc' => gettext("Height of the thumb. Note that the CSS might need to be adjusted."),
58: 'order' => 4),
59: gettext('Crop width') => array('key' => 'bxslider_cropw', 'type' => OPTION_TYPE_TEXTBOX,
60: 'desc' => "",
61: 'order' => 5),
62: gettext('Crop height') => array('key' => 'bxslider_croph', 'type' => OPTION_TYPE_TEXTBOX,
63: 'desc' => "",
64: 'order' => 6),
65: gettext('Speed') => array('key' => 'bxslider_speed', 'type' => OPTION_TYPE_TEXTBOX,
66: 'desc' => gettext("The speed in miliseconds the slides advance when clicked.)"),
67: 'order' => 7),
68: gettext('Full image link') => array('key' => 'bxslider_fullimagelink', 'type' => OPTION_TYPE_CHECKBOX,
69: 'desc' => gettext("If checked the thumbs link to the full image instead of the image page."),
70: 'order' => 8),
71: gettext('Mode') => array('key' => 'bxslider_mode', 'type' => OPTION_TYPE_SELECTOR,
72: 'selections' => array(
73: gettext('Horizontal') => "horizontal",
74: gettext('Vertical') => "vertical",
75: gettext('Fade') => "fade"),
76: 'desc' => gettext("The mode of the thumb nav. Note this might require theme changes."),
77: 'order' => 9)
78: );
79: foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php', 'functions.php', 'password.php', 'sidebar.php', 'register.php', 'contact.php')) as $theme => $scripts) {
80: $list = array();
81: foreach ($scripts as $script) {
82: $list[$script] = 'bxslider_' . $theme . '_' . stripSuffix($script);
83: }
84: $options[$theme] = array('key' => 'bxslider_' . $theme . '_scripts', 'type' => OPTION_TYPE_CHECKBOX_ARRAY,
85: 'checkboxes' => $list,
86: 'desc' => gettext('The scripts for which BxSlider is enabled. {If themes require it they might set this, otherwise you need to do it manually!}')
87: );
88: }
89: return $options;
90: }
91:
92: static function themeJS() {
93: $theme = getCurrentTheme();
94: $css = SERVERPATH . '/' . THEMEFOLDER . '/' . internalToFilesystem($theme) . '/jquery.bxslider.css';
95: if (file_exists($css)) {
96: $css = WEBPATH . '/' . THEMEFOLDER . '/' . $theme . '/jquery.bxslider.css';
97: } else {
98: $css = WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/bxslider_thumb_nav/jquery.bxslider.css';
99: }
100: ?>
101:
102: <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/bxslider_thumb_nav/jquery.bxslider.min.js"></script>
103: <link rel="stylesheet" type="text/css" href="<?php echo html_encode($css); ?>" />
104: <?php
105: }
106:
107: }
108:
109: if (!$plugin_disable && !OFFSET_PATH && getOption('bxslider_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page))) {
110: zp_register_filter('theme_head', 'bxslider::themeJS');
111:
112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124:
125: function printThumbNav($minitems = NULL, $maxitems = NULL, $width = NULL, $height = NULL, $cropw = NULL, $croph = NULL, $fullimagelink = NULL, $mode = NULL, $speed = NULL) {
126: global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_search, $_zp_gallery_page;
127:
128: setOptionDefault('bxslider_' . $_zp_gallery->getCurrentTheme() . '_' . stripSuffix($_zp_gallery_page), 1);
129: $items = "";
130: if (is_object($_zp_current_album) && $_zp_current_album->getNumImages() >= 2) {
131: if (is_null($minitems)) {
132: $minitems = getOption('bxslider_minitems');
133: } else {
134: $minitems = sanitize_numeric($minitems);
135: }
136: $minitems = max(1, (int) $minitems);
137: if (is_null($maxitems)) {
138: $maxitems = getOption('bxslider_maxitems');
139: } else {
140: $maxitems = sanitize_numeric($maxitems);
141: }
142: $maxitems = max(1, (int) $maxitems);
143: if (is_null($width)) {
144: $width = getOption('bxslider_width');
145: } else {
146: $width = sanitize_numeric($width);
147: }
148: if (is_null($height)) {
149: $height = getOption('bxslider_height');
150: } else {
151: $height = sanitize_numeric($height);
152: }
153: if (is_null($cropw)) {
154: $cropw = getOption('bxslider_cropw');
155: } else {
156: $cropw = sanitize_numeric($cropw);
157: }
158: if (is_null($croph)) {
159: $croph = getOption('bxslider_croph');
160: } else {
161: $croph = sanitize_numeric($croph);
162: }
163: if (is_null($fullimagelink)) {
164: $fullimagelink = getOption('bxslider_fullimagelink');
165: } else {
166: $fullimagelink = sanitize($fullimagelink);
167: }
168: if (is_null($mode)) {
169: $mode = getOption('bxslider_mode');
170: } else {
171: $mode = sanitize($mode);
172: }
173: if (is_null($speed)) {
174: $speed = getOption('bxslider_speed');
175: } else {
176: $speed = sanitize_numeric($speed);
177: }
178: if (in_context(ZP_SEARCH_LINKED)) {
179: if ($_zp_current_search->getNumImages() === 0) {
180: $searchimages = false;
181: } else {
182: $searchimages = true;
183: }
184: } else {
185: $searchimages = false;
186: }
187: if (in_context(ZP_SEARCH_LINKED) && $searchimages) {
188: $bxslider_items = $_zp_current_search->getImages();
189: } else {
190: $bxslider_items = $_zp_current_album->getImages();
191: }
192: if (count($bxslider_items) >= 2) {
193: foreach ($bxslider_items as $item) {
194: if (is_array($item)) {
195: if (in_context(ZP_SEARCH_LINKED)) {
196: $albumobj = newAlbum($item['folder']);
197: } else {
198: $albumobj = $_zp_current_album;
199: }
200: $imgobj = newImage($albumobj, $item['filename']);
201: } else {
202: $imgobj = newImage($_zp_current_album, $item);
203: }
204: if ($fullimagelink) {
205: $link = $imgobj->getFullImageURL();
206: } else {
207: $link = $imgobj->getLink();
208: }
209: if (!is_null($_zp_current_image)) {
210: if ($_zp_current_album->isDynamic()) {
211: if ($_zp_current_image->filename == $imgobj->filename && $_zp_current_image->getAlbum()->name == $imgobj->getAlbum()->name) {
212: $active = ' class="activeimg" ';
213: } else {
214: $active = '';
215: }
216: } else {
217: if ($_zp_current_image->filename == $imgobj->filename) {
218: $active = ' class="activeimg" ';
219: } else {
220: $active = '';
221: }
222: }
223: } else {
224: $active = '';
225: }
226: $imageurl = $imgobj->getCustomImage(NULL, $width, $height, $cropw, $croph, NULL, NULL, true);
227: $items[] = '<li' . $active . '><a href="' . $link . '"><img src="' . html_encode($imageurl) . '" alt="' . html_encode($imgobj->getTitle()) . '"></a></li>';
228: }
229: }
230: $albumid = $_zp_current_album->get('id');
231:
232: $numimages = getNumImages();
233: if (!is_null($_zp_current_image)) {
234: $imgnumber = (imageNumber() - 1);
235: } else {
236: $imgnumber = 0;
237: }
238: ?>
239: <ul class="bxslider<?php echo $albumid; ?>">
240: <?php
241: $count = '';
242: foreach ($items as $item) {
243: echo $item;
244: }
245: ?>
246: </ul>
247: <script type="text/javascript">
248: $(document).ready(function() {
249: var index = $('.bxslider<?php echo $albumid; ?> li.activeimg').index();
250: index = ++index;
251: currentPager = parseInt(index / <?php echo $maxitems; ?>)
252: $('.bxslider<?php echo $albumid; ?>').bxSlider({
253: mode: '<?php echo $mode; ?>',
254: minSlides: <?php echo $minitems; ?>,
255: maxSlides: <?php echo $maxitems; ?>,
256: speed: <?php echo $speed; ?>,
257: slideWidth: <?php echo $width; ?>,
258: slideMargin: 5,
259: moveSlides: <?php echo $maxitems; ?> - 1,
260: pager: false,
261: adaptiveHeight: true,
262: useCSS: false,
263: startSlide: currentPager
264: });
265: });
266: </script>
267: <?php
268: }
269: }
270:
271: }
272: ?>