PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.30
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.30
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / layouts / Layout_Default.php

Layout_Default.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 2.30, at layouts/Layout_Default.php

733 lines 31.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Layout Manager to generate the grid layouts and the "Justified Grid" layout, all of which use the same markup. The Justified Grid layout is
5 * modified by JS on the front-end, however the base markup for it is similar to the square and circular thumbnails layout.
6 *
7 * All other layout managers extend this, and might implement their own versions of generate_level_1_gallery and generate_level_2_gallery
8 *
9 * @package Photonic
10 * @subpackage Layouts
11 */
12 class Photonic_Layout {
13 private $library;
14
15 function __construct() {
16 global $photonic_slideshow_library, $photonic_custom_lightbox;
17 if ($photonic_slideshow_library != 'custom') {
18 $this->library = $photonic_slideshow_library;
19 }
20 else {
21 $this->library = $photonic_custom_lightbox;
22 }
23 }
24
25 /**
26 * Generates the markup for a single photo.
27 *
28 * @param $data array Pertinent pieces of information about the photo - the source (src), the photo page (href), title and caption
29 * @param $processor Photonic_Processor The object calling this. A CSS class is created in the header, photonic-single-<code>$processor->provider</code>-photo-header
30 * @return string
31 */
32 function generate_single_photo_markup($data, $processor) {
33 $processor->push_to_stack('Generate single photo markup');
34 $ret = '';
35 $photo = array_merge(
36 array('src' => '', 'href' => '', 'title' => '', 'caption' => ''),
37 $data
38 );
39
40 if (empty($photo['src'])) {
41 $processor->pop_from_stack();
42 return $ret;
43 }
44
45 global $photonic_external_links_in_new_tab;
46 if (!empty($photo['title'])) {
47 $ret .= "\t".'<h3 class="photonic-single-photo-header photonic-single-'.$processor->provider.'-photo-header">'.$photo['title']."</h3>\n";
48 }
49
50 $img = '<img src="'.$photo['src'].'" alt="'.esc_attr(empty($photo['caption']) ? $photo['title'] : $photo['caption']).'" />';
51 if (!empty($photo['href'])) {
52 $img = '<a href="'.$photo['href'].'" title="'.esc_attr(empty($photo['caption']) ? $photo['title'] : $photo['caption']).'" '.
53 (!empty($photonic_external_links_in_new_tab) ? ' target="_blank" ' : '').'>'.$img.'</a>';
54 }
55
56 if (!empty($photo['caption'])) {
57 $ret .= "\t".'<div class="wp-caption">'."\n\t\t".$img."\n\t\t".'<div class="wp-caption-text">'.$photo['caption']."</div>\n\t</div><!-- .wp-caption -->\n";
58 }
59 else {
60 $ret .= $img;
61 }
62
63 $processor->pop_from_stack();
64 return $ret;
65 }
66
67 /**
68 * Generates the HTML for the lowest level gallery, i.e. the photos. This is used for both, in-page and popup displays.
69 * The code for the random layouts is handled in JS, but just the HTML markers for it are provided here.
70 *
71 * @param $photos
72 * @param array $options
73 * @param $short_code
74 * @param $processor Photonic_Processor
75 * @return string
76 */
77 function generate_level_1_gallery($photos, $options, $short_code, $processor) {
78 $processor->push_to_stack('Generate level 1 gallery');
79 $layout = !empty($short_code['layout']) ? $short_code['layout'] : 'square';
80 $columns = !empty($short_code['columns']) && ($layout !== 'random' && $layout !== 'mosaic') ? $short_code['columns'] : 'auto';
81 $display = !empty($short_code['display']) ? $short_code['display'] : 'in-page';
82 $more = !empty($short_code['more']) ? esc_attr($short_code['more']) : '';
83 $more = (empty($more) && !empty($short_code['photo_more'])) ? esc_attr($short_code['photo_more']) : $more;
84 $panel = !empty($short_code['panel']) ? $short_code['panel'] : '';
85
86 $title_position = empty($short_code['title_position']) ? $options['title_position'] : $short_code['title_position'];
87 $row_constraints = isset($options['row_constraints']) && is_array($options['row_constraints']) ? $options['row_constraints'] : array();
88 $sizes = isset($options['sizes']) && is_array($options['sizes']) ? $options['sizes'] : array();
89 $show_lightbox = !isset($options['show_lightbox']) ? true: $options['show_lightbox'];
90 $type = !empty($options['type']) ? $options['type'] : 'photo';
91 $parent = !empty($options['parent']) ? $options['parent'] : 'stream';
92 $pagination = isset($options['level_2_meta']) && is_array($options['level_2_meta']) ? $options['level_2_meta'] : array();
93 $indent = !isset($options['indent']) ? "\t" : $options['indent'];
94
95 if ($short_code['display'] != 'popup') {
96 $container_id = "id='photonic-{$processor->provider}-stream-{$processor->gallery_index}-container'";
97 $container_end = "photonic-{$processor->provider}-stream-{$processor->gallery_index}-container-end";
98 }
99 else {
100 $container_id = "id='photonic-{$processor->provider}-panel-" . $short_code['panel'] . "-container'";
101 $container_end = "photonic-{$processor->provider}-panel-{$short_code['panel']}-container-end";
102 }
103
104 $non_standard = $layout == 'random' || $layout == 'masonry' || $layout == 'mosaic';
105
106 $col_class = '';
107 if (absint($columns)) {
108 $col_class = 'photonic-gallery-'.$columns.'c';
109 }
110
111 if ($col_class == '' && $row_constraints['constraint-type'] == 'padding') {
112 $col_class = 'photonic-pad-photos';
113 }
114 else if ($col_class == '') {
115 $col_class = 'photonic-gallery-'.$row_constraints['count'].'c';
116 }
117 $col_class .= ' photonic-level-1 photonic-thumb photonic-thumb-'.$layout;
118
119 $link_attributes = $this->get_lightbox_attributes($show_lightbox, $panel, $processor);
120 $link_attributes_text = $this->get_text_from_link_attributes($link_attributes);
121
122 $effect = $this->get_thumbnail_effect($short_code, $layout, $title_position);
123 $ul_class = "class='title-display-$title_position photonic-level-1-container ".($non_standard ? 'photonic-'.$layout.'-layout' : 'photonic-standard-layout')." photonic-thumbnail-effect-$effect'";
124 if ($display == 'popup') {
125 $ul_class = "class='slideshow-grid-panel lib-{$this->library} photonic-level-1-container title-display-$title_position'";
126 }
127
128 $ret = '';
129 if (!$non_standard && $display != 'popup') {
130 $container_tag = 'ul';
131 $element_tag = 'li';
132 }
133 else {
134 $container_tag = 'div';
135 $element_tag = 'div';
136 }
137
138 $pagination_data = '';
139 if (!empty($pagination)) {
140 $pagination_data = array();
141 // Should have total, start, end, per-page
142 foreach ($pagination as $meta => $value) {
143 $pagination_data[] = 'data-photonic-stream-'.$meta.'="'.$value.'"';
144 }
145
146 $pagination_data = implode(' ', $pagination_data);
147 if (empty($pagination['provider'])) {
148 $pagination_data .= ' data-photonic-stream-provider="'.$processor->provider.'"';
149 }
150 }
151
152 $to_be_glued = '';
153 if (!empty($short_code)) {
154 $to_be_glued = array();
155 foreach ($short_code as $name => $value) {
156 if (is_scalar($value)) {
157 $to_be_glued[] = $name.'='.$value;
158 }
159 }
160 if (!empty($pagination['next-token'])) {
161 $to_be_glued[] = 'next_token='.$pagination['next-token'];
162 }
163 $to_be_glued = implode('&',$to_be_glued);
164 $to_be_glued = esc_attr($to_be_glued);
165 }
166
167 $pagination_data .= ' data-photonic-stream-query="'.$to_be_glued.'"';
168 $columns_data = ' data-photonic-gallery-columns="'.$columns.'"';
169
170 $start_with = "$indent<$container_tag $container_id $ul_class $pagination_data $columns_data>\n";
171 $ret .= $start_with;
172
173 global $photonic_external_links_in_new_tab;
174 if (!empty($photonic_external_links_in_new_tab)) {
175 $target = " target='_blank' ";
176 }
177 else {
178 $target = '';
179 }
180
181 $counter = 0;
182 $thumbnail_class = " class='$layout' ";
183
184 $element_start = "$indent\t<".$element_tag.' class="photonic-'.$processor->provider.'-image photonic-'.$processor->provider.'-'.$type.' '.$col_class.'">'."\n";
185 foreach ($photos as $photo) {
186 $counter++;
187
188 $thumb = ($non_standard && $display == 'in-page') ? (isset($photo['tile_image']) ? $photo['tile_image'] : $photo['main_image']) : $photo['thumbnail'];
189 $orig = empty($photo['video']) ? $photo['main_image'] : $photo['video'];
190 // $orig = $photo['main_image'];
191 $url = isset($photo['main_page']) ? $photo['main_page'] : '';
192 $title = esc_attr($photo['title']);
193 $description = esc_attr($photo['description']);
194 $alt = esc_attr($photo['alt_title']);
195 $orig = ($this->library == 'none' || !$show_lightbox) ? $url : $orig;
196
197 $title = empty($title) ? ((empty($alt) && $processor->link_lightbox_title && $this->library != 'thickbox') ? apply_filters('photonic_default_lightbox_text', esc_attr__('View', 'photonic')) : $alt) : $title;
198 $ret .= $element_start;
199
200 $deep_value = 'gallery[photonic-'.$processor->provider.'-'.$parent.'-'.(empty($panel) ? $processor->gallery_index : $panel).']/'.(empty($photo['id']) ? $counter : $photo['id']).'/';
201 $deep_link = ' data-photonic-deep="'.$deep_value.'" ';
202
203 $buy = '';
204 if (!empty($photo['buy_link']) && $processor->show_buy_link) {
205 $buy = ' data-photonic-buy="'.$photo['buy_link'].'" ';
206 }
207
208 $style = array();
209 if (!empty($sizes['thumb-width'])) $style[] = 'width:'.$sizes['thumb-width'].'px';
210 if (!empty($sizes['thumb-height'])) $style[] = 'height:'.$sizes['thumb-height'].'px';
211 if (!empty($style)) $style = 'style="'.implode(';', $style).'"'; else $style = '';
212 if ($processor->link_lightbox_title && $this->library != 'thickbox' && !empty($url)) {
213 $title_link_start = esc_attr("<a href='$url' $target>");
214 $title_link_end = esc_attr("</a>");
215 }
216 else {
217 $title_link_start = '';
218 $title_link_end = '';
219 }
220
221 if (!empty($short_code['caption']) && ($short_code['caption'] == 'desc' || ($short_code['caption'] == 'title-desc' && empty($title)) || ($short_code['caption'] == 'desc-title' && !empty($description)))) {
222 $title = $description;
223 }
224 else if (empty($short_code['caption']) || (($short_code['caption'] == 'desc-title' && empty($title)) || $short_code['caption'] == 'none')) {
225 $title = '';
226 }
227
228 if (!empty($title)) {
229 $title_markup = $title_link_start.esc_attr($title).$title_link_end;
230 $title_markup = apply_filters('photonic_lightbox_title_markup', $title_markup);
231 }
232 else {
233 $title_markup = '';
234 }
235
236 if ($processor->link_lightbox_title && $this->library != 'thickbox' && !empty($photo['buy_link']) && $processor->show_buy_link) {
237 $buy_link = esc_attr('<a class="photonic-buy-link" href="'.$photo['buy_link'].'" target="_blank" title="'.__('Buy', 'photonic').'"><div class="icon-buy"></div></a>');
238 $title_markup .= $buy_link;
239 }
240
241 $shown_title = '';
242 if (in_array($title_position, array('below', 'hover-slideup-show', 'hover-slidedown-show', 'slideup-stick')) && !empty($title)) {
243 $shown_title = '<div class="photonic-title-info"><div class="photonic-photo-title photonic-title">'.wp_specialchars_decode($title, ENT_QUOTES).'</div></div>';
244 }
245
246 $photo_data = array('title' => $title_markup, 'deep' => $deep_value, 'raw_title' => $title, 'href' => $orig);
247 if (!empty($photo['download'])) {
248 $photo_data['download'] = $photo['download'];
249 }
250 if (!empty($photo['video'])) {
251 $photo_data['video'] = $photo['video'];
252 }
253 else {
254 $photo_data['image'] = $photo['main_image'];
255 }
256 $photo_data['provider'] = $processor->provider;
257 $photo_data['gallery_index'] = $processor->gallery_index;
258 $photo_data['id'] = $photo['id'];
259
260 $lb_specific_data = $this->get_lightbox_specific_photo_data($photo_data, $processor);
261 if (!empty($photo['video'])) {
262 $lb_specific_data .= ' data-photonic-media-type="video" ';
263 }
264 else {
265 $lb_specific_data .= ' data-photonic-media-type="image" ';
266 }
267 if (!empty($photo['video']) && $this->library == 'lightgallery') {
268 $video_id = $processor->provider.'-'.$processor->gallery_index.'-'.$photo['id'];
269 $ret .= $indent."\t\t".'<div style="display:none;" id="photonic-video-'.$video_id.'">'."\n";
270 $ret .= $indent."\t\t\t".'<video class="lg-video-object lg-html5 photonic" controls preload="none">'."\n";
271 $ret .= $indent."\t\t\t\t".'<source src="'.$photo['video'].'" type="'.(!empty($photo['mime']) ? $photo['mime']: 'video/mp4').'">'."\n";
272 $ret .= $indent."\t\t\t\t".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."\n";
273 $ret .= $indent."\t\t\t".'</video>'."\n";
274 $ret .= $indent."\t\t".'</div>'."\n";
275
276 $orig = ''; // href should be blank
277 }
278 else if (!empty($photo['video']) && (in_array($this->library, array('colorbox', 'fancybox', 'fancybox2', 'magnific', 'photoswipe', 'swipebox', ))
279 || (in_array($this->library, array('fancybox3')) && in_array($processor->provider, array('flickr', 'google')))
280 )) {
281 $video_id = $processor->provider.'-'.$processor->gallery_index.'-'.$photo['id'];
282 $ret .= $indent."\t\t".'<div class="photonic-html5-external" id="photonic-video-'.$video_id.'">'."\n";
283 $ret .= $indent."\t\t\t".'<video class="photonic" controls preload="none">'."\n";
284 $ret .= $indent."\t\t\t\t".'<source src="'.$photo['video'].'" type="'.(!empty($photo['mime']) ? $photo['mime']: 'video/mp4').'">'."\n";
285 $ret .= $indent."\t\t\t\t".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."\n";
286 $ret .= $indent."\t\t\t".'</video>'."\n";
287 $ret .= $indent."\t\t".'</div>'."\n";
288
289 $orig = '#photonic-video-'.$video_id;
290 }
291
292 if ($this->library == 'magnific') {
293 $magnific = !empty($photo['video']) ? 'mfp-inline' : 'mfp-image';
294 $link_attributes['class']['magnific'] = $magnific;
295 $link_attributes_text = $this->get_text_from_link_attributes($link_attributes);
296 }
297
298 if ($title_position == 'tooltip') {
299 $tooltip = 'data-photonic-tooltip="'.esc_attr($title).'" ';
300 }
301 else {
302 $tooltip = '';
303 }
304 $ret .= $indent."\t\t".'<a '.$link_attributes_text.' href="'.$orig.'" title="'.($title_position != 'none' ? esc_attr($title) : '').'" data-title="'.$title_markup.'" '.$tooltip.' '.$lb_specific_data.' '.$target.$deep_link.$buy.">\n";
305 $ret .= $indent."\t\t\t".'<img alt="'.$alt.'" src="'.$thumb.'" '.$style.$thumbnail_class."/>\n";
306 $ret .= $indent."\t\t\t".$shown_title."\n";
307 $ret .= $indent."\t\t"."</a>\n";
308 $ret .= $indent."\t"."</$element_tag>\n";
309 }
310
311 $ret = trim($ret);
312 if ($ret != $start_with) {
313 $trailing = strlen($element_tag) + 3;
314 if (substr($ret, -$trailing) != "</$element_tag>" && $short_code['popup'] == 'show' && !$non_standard) {
315 $ret .= "\n$indent</$element_tag><!-- last $element_tag.photonic-pad-photos -->";
316 }
317
318 $ret .= "\n$indent</$container_tag> <!-- ./photonic-level-1-container -->\n";
319 $ret .= "<span id='$container_end'></span>";
320
321 if (!empty($pagination) && isset($pagination['end']) && isset($pagination['total']) && $pagination['total'] > $pagination['end']) {
322 $ret .= !empty($more) ? "<a href='#' class='photonic-more-button photonic-more-dynamic'>$more</a>\n" : '';
323 }
324 }
325 else {
326 $ret = '';
327 }
328
329 if (is_archive() || is_home()) {
330 global $photonic_archive_thumbs;
331 if (!empty($photonic_archive_thumbs) && $counter < $photonic_archive_thumbs) {
332 $processor->is_more_required = false;
333 }
334 }
335
336 $processor->pop_from_stack();
337 return $ret;
338 }
339
340 /**
341 * Generates the HTML for a group of level-2 items, i.e. Photosets (Albums) and Galleries for Flickr, Albums for Google Photos,
342 * Albums for SmugMug, and Photosets (Galleries and Collections) for Zenfolio. No concept of albums
343 * exists in native WP and Instagram.
344 *
345 * @param $objects
346 * @param $options
347 * @param $short_code
348 * @param $processor Photonic_Processor
349 * @return string
350 */
351 function generate_level_2_gallery($objects, $options, $short_code, $processor) {
352 $processor->push_to_stack('Generate Level 2 Gallery');
353 $row_constraints = isset($options['row_constraints']) && is_array($options['row_constraints']) ? $options['row_constraints'] : array();
354 $type = $options['type'];
355 $singular_type = $options['singular_type'];
356 $title_position = empty($short_code['title_position']) ? $options['title_position'] : $short_code['title_position'];
357 $level_1_count_display = $options['level_1_count_display'];
358 $indent = !isset($options['indent']) ? '' : $options['indent'];
359 $provider = $processor->provider;
360
361 $columns = $short_code['columns'];
362 $layout = !isset($short_code['layout']) ? 'square' : $short_code['layout'];
363 $popup = ' data-photonic-popup="'.$short_code['popup'].'"';
364
365 $non_standard = $layout == 'random' || $layout == 'masonry' || $layout == 'mosaic';
366 $effect = $this->get_thumbnail_effect($short_code, $layout, $title_position);
367 $ul_class = "class='title-display-$title_position photonic-level-2-container ".($non_standard ? 'photonic-'.$layout.'-layout' : 'photonic-standard-layout')." photonic-thumbnail-effect-$effect'";
368
369 if ($short_code['display'] != 'popup') {
370 $container_id = "id='photonic-{$processor->provider}-stream-{$processor->gallery_index}-container'";
371 $container_end = "photonic-{$processor->provider}-stream-{$processor->gallery_index}-container-end";
372 }
373 else {
374 $container_id = "id='photonic-{$processor->provider}-panel-" . $short_code['panel'] . "-container'";
375 $container_end = "photonic-{$processor->provider}-panel-{$short_code['panel']}-container-end";
376 }
377
378 $pagination = isset($options['pagination']) && is_array($options['pagination']) ? $options['pagination'] : array();
379 $more = !empty($short_code['more']) ? esc_attr($short_code['more']) : '';
380
381 $pagination_data = '';
382 if (!empty($pagination)) {
383 $pagination_data = array();
384 // Should have total, start, end, per-page
385 foreach ($pagination as $meta => $value) {
386 $pagination_data[] = 'data-photonic-stream-'.$meta.'="'.$value.'"';
387 }
388
389 $pagination_data = implode(' ', $pagination_data);
390 if (empty($pagination['provider'])) {
391 $pagination_data .= ' data-photonic-stream-provider="'.$processor->provider.'"';
392 }
393 }
394
395 $to_be_glued = '';
396 if (!empty($short_code)) {
397 $to_be_glued = array();
398 foreach ($short_code as $name => $value) {
399 if (is_scalar($value)) {
400 $to_be_glued[] = $name.'='.$value;
401 }
402 }
403 if (!empty($pagination['next-token'])) {
404 $to_be_glued[] = 'next_token='.$pagination['next-token'];
405 }
406 $to_be_glued = implode('&',$to_be_glued);
407 $to_be_glued = esc_attr($to_be_glued);
408 }
409
410 $pagination_data .= ' data-photonic-stream-query="'.$to_be_glued.'"';
411 $columns_data = ' data-photonic-gallery-columns="'.$columns.'"';
412
413 $ret = "\n$indent<ul $container_id $ul_class $pagination_data $columns_data>";
414 if ($non_standard) {
415 $ret = "\n$indent<div $container_id $ul_class $pagination_data $columns_data>";
416 }
417
418 if ($columns != 'auto') {
419 $col_class = 'photonic-gallery-'.$columns.'c';
420 }
421 else if ($row_constraints['constraint-type'] == 'padding') {
422 $col_class = 'photonic-pad-'.$type;
423 }
424 else {
425 $col_class = 'photonic-gallery-'.$row_constraints['count'].'c';
426 }
427
428 $col_class .= ' photonic-level-2 photonic-thumb';
429
430 $counter = 0;
431 foreach ($objects as $object) {
432 $data_attributes = isset($object['data_attributes']) && is_array($object['data_attributes']) ? $object['data_attributes'] : array();
433 $data_attributes['provider'] = $provider;
434 $data_attributes['singular'] = $singular_type;
435 $data_array = array();
436 foreach ($data_attributes as $attr => $value) {
437 $data_array[] = 'data-photonic-'.$attr.'="'.$value.'"';
438 }
439
440 $data_array = implode(' ', $data_array);
441
442
443 $id = empty($object['id_1']) ? '' : $object['id_1'].'-';
444 $id = $id.$processor->gallery_index;
445 $id = empty($object['id_2']) ? $id : ($id.'-'.$object['id_2']);
446 $title = esc_attr($object['title']);
447 $image = "<img src='".(($non_standard && isset($object['tile_image'])) ? $object['tile_image'] : $object['thumbnail'])."' alt='".$title."' class='$layout'/>";
448 $additional_classes = !empty($object['classes']) ? implode(' ', $object['classes']) : '';
449 $realm_class = '';
450 if (!empty($object['classes'])) {
451 foreach ($object['classes'] as $class) {
452 if (stripos($class, 'photonic-'.$provider.'-realm') !== FALSE) {
453 $realm_class = $class;
454 }
455 }
456 }
457 if ($title_position == 'tooltip') {
458 $tooltip = "data-photonic-tooltip='".esc_attr($title)."' ";
459 }
460 else {
461 $tooltip = '';
462 }
463 $anchor = "\n{$indent}\t\t<a href='{$object['main_page']}' class='photonic-{$provider}-{$singular_type}-thumb photonic-level-2-thumb $additional_classes' id='photonic-{$provider}-$singular_type-thumb-$id' title='".($title_position != 'none' ? esc_attr($title) : '')."' data-title='".$title."' $tooltip $data_array$popup>\n$indent\t\t\t".$image;
464 $text = '';
465 if (in_array($title_position, array('below', 'hover-slideup-show', 'hover-slidedown-show', 'slideup-stick'))) {
466 $text = "\n{$indent}\t\t\t<div class='photonic-title-info'>\n{$indent}\t\t\t\t<div class='photonic-$singular_type-title photonic-title'>".$title."";
467 if (!$level_1_count_display && !empty($object['counter'])) {
468 $text .= '<span class="photonic-title-photo-count photonic-'.$singular_type.'-photo-count">'.sprintf(esc_html__('%s photos', 'photonic'), $object['counter']).'</span>';
469 }
470 }
471 if ($text != '') {
472 $text .= "</div>\n{$indent}\t\t\t</div>";
473 }
474
475 $anchor .= $text."\n{$indent}\t\t</a>";
476 $password_prompt = '';
477 if (!empty($object['passworded'])) {
478 $prompt_title = esc_attr__('Protected Content', 'photonic');
479 $prompt_submit = esc_attr__('Access', 'photonic');
480 $password_type = " type='password' ";
481 $prompt_type = 'password';
482 $prompt_text = esc_attr__('This album is password-protected. Please provide a valid password.', 'photonic');
483 if (in_array("photonic-$provider-passworded-authkey", $object['classes'])) {
484 $prompt_text = esc_attr__('This album is protected. Please provide a valid authorization key.', 'photonic');
485 }
486 else if (in_array("photonic-$provider-passworded-link", $object['classes'])) {
487 $prompt_text = esc_attr__('This album is protected. Please provide the short-link for it.', 'photonic');
488 $password_type = '';
489 $prompt_type = 'link';
490 }
491
492 $password_prompt = "
493 <div class='photonic-password-prompter $realm_class' id='photonic-{$provider}-$singular_type-prompter-$id' title='$prompt_title' data-photonic-prompt='$prompt_type'>
494 <div class='photonic-password-prompter-content'>
495 <div class='photonic-prompt-head'>
496 <h3>
497 <span class='title'>$prompt_title</span>
498 <button class='close'>&times;</button>
499 </h3>
500 </div>
501 <div class='photonic-prompt-body'>
502 <p>$prompt_text</p>
503 <input $password_type name='photonic-{$provider}-password' />
504 <button class='photonic-{$provider}-submit photonic-password-submit confirm'>$prompt_submit</button>
505 </div>
506 </div>
507 </div>";
508 }
509
510 if ($non_standard) {
511 $ret .= "\n$indent\t<div class='photonic-{$provider}-image photonic-{$provider}-$singular_type-thumb $col_class' id='photonic-{$provider}-$singular_type-$id'>{$anchor}{$password_prompt}\n$indent\t</div>";
512 }
513 else {
514 $ret .= "\n$indent\t<li class='photonic-{$provider}-image photonic-{$provider}-$singular_type-thumb $col_class' id='photonic-{$provider}-$singular_type-$id'>{$anchor}{$password_prompt}\n$indent\t</li>";
515 }
516 $counter++;
517 }
518
519 if ($ret != "\n$indent<ul $container_id $ul_class $pagination_data $columns_data>" && !$non_standard) {
520 $ret .= "\n$indent</ul>\n";
521 }
522 else if ($non_standard) {
523 $ret .= "\n$indent</div>\n";
524 }
525 else {
526 $ret = '';
527 }
528
529 if (!empty($ret)) {
530 $ret .= "<span id='$container_end'></span>";
531 if (!empty($pagination) && isset($pagination['end']) && isset($pagination['total']) && $pagination['total'] > $pagination['end']) {
532 $ret .= !empty($more) ? "<a href='#' class='photonic-more-button photonic-more-dynamic'>$more</a>\n" : '';
533 }
534 }
535
536 if (is_archive() || is_home()) {
537 global $photonic_archive_thumbs;
538 if (!empty($photonic_archive_thumbs) && $counter < $photonic_archive_thumbs) {
539 $processor->is_more_required = false;
540 }
541 }
542
543 $processor->pop_from_stack();
544 return $ret;
545 }
546
547 /**
548 * Depending on the lightbox library, this function provides the CSS class and the rel tag for the thumbnail. This method borrows heavily from
549 * Justin Tadlock's Cleaner Gallery Plugin.
550 *
551 * @param $show_lightbox
552 * @param $rel_id
553 * @param $processor
554 * @return array
555 */
556 function get_lightbox_attributes($show_lightbox, $rel_id, $processor) {
557 global $photonic_slideshow_mode;
558 $rel = '';
559 $ret = array(
560 'class' => array(),
561 'rel' => array(),
562 'specific' => array(),
563 );
564
565 if ($this->library != 'none' && $show_lightbox) {
566 $ret['class'] = array('photonic-launch-gallery', 'launch-gallery-'.$this->library, $this->library);
567 $rel = 'lightbox-photonic-'.$processor->provider.'-stream-'.(empty($rel_id) ? $processor->gallery_index : $rel_id);
568 $ret['rel'] = array($rel);
569
570 switch ($this->library) {
571 case 'lightbox':
572 case 'jquery_lightbox_plugin':
573 case 'jquery_lightbox_balupton':
574 $ret['class'] = array('launch-gallery-lightbox', 'lightbox');
575 $ret['rel'] = array("lightbox[{$rel}]");
576 break;
577
578 case 'fancybox2':
579 $ret['class'] = array('photonic-launch-gallery', 'launch-gallery-fancybox', 'fancybox');
580 break;
581
582 case 'fancybox3':
583 $ret['class'] = array('photonic-launch-gallery', 'launch-gallery-fancybox', 'fancybox');
584 $ret['specific'] = array(
585 'data-fancybox' => array($rel),
586 );
587 break;
588
589 case 'prettyphoto':
590 $ret['rel'] = array("photonic-prettyPhoto[{$rel}]");
591 break;
592
593 case 'featherlight':
594 $ret['class'] = array('photonic-launch-gallery', 'launch-gallery-featherlight');
595 break;
596
597 case 'lightcase':
598 $ret['specific'] = array(
599 'data-rel' => array('lightcase:lightbox-photonic-'.$processor->provider.'-stream-'.(empty($rel_id) ? $processor->gallery_index : $rel_id).((isset($photonic_slideshow_mode) && $photonic_slideshow_mode == 'on') ? ':slideshow' : '')),
600 );
601 break;
602
603 case 'strip':
604 global $photonic_lightbox_no_loop;
605 $ret['specific'] = array(
606 'data-strip-group' => array($rel),
607 );
608 if (!empty($photonic_lightbox_no_loop)) {
609 $ret['specific']['data-strip-group-options'] = array("loop: false");
610 }
611 break;
612
613 default:
614 $ret['class'] = array('photonic-launch-gallery', 'launch-gallery-'.$this->library, $this->library);
615 $ret['rel'] = array('lightbox-photonic-'.$processor->provider.'-stream-'.(empty($rel_id) ? $processor->gallery_index : $rel_id));
616 break;
617 }
618 }
619
620 return $ret;
621 }
622
623 /**
624 * @param array $link_attributes
625 * @return string
626 */
627 function get_text_from_link_attributes($link_attributes) {
628 $class = '';
629 $rel = '';
630 $specific = '';
631 if (!empty($link_attributes['class'])) {
632 $class = " class='".implode(' ', array_values($link_attributes['class']))."' ";
633 }
634
635 if (!empty($link_attributes['rel'])) {
636 $rel = " rel='".implode(' ', $link_attributes['rel'])."' ";
637 }
638
639 if (!empty($link_attributes['specific'])) {
640 foreach ($link_attributes['specific'] as $key => $val) {
641 $specific .= $key.'="'.implode(' ', $val).'" ';
642 }
643 }
644 return $class.$rel.$specific;
645 }
646
647 /**
648 * Some lightboxes require some additional attributes for individual photos. E.g. Lightgallery requires something to show the title etc.
649 * This method returns such additional information. Not to be confused with <code>get_lightbox_attributes</code>, which
650 * returns information for the gallery as a whole.
651 *
652 * @param $photo_data
653 * @return string
654 */
655 function get_lightbox_specific_photo_data($photo_data, $processor) {
656 if ($this->library == 'lightgallery') {
657 $download = !empty($photo_data['download']) ? 'data-download-url="'.$photo_data['download'].'" ' : '';
658 $video = !empty($photo_data['video']) ? ' data-html="#photonic-video-'.$processor->provider.'-'.$processor->gallery_index.'-'.$photo_data['id'].'" ' : '';
659 return ' data-sub-html="'.$photo_data['title'].'" '.$video.$download;
660 }
661 else if ($this->library == 'strip') {
662 return ' data-strip-caption="'.$photo_data['title'].'" data-strip-options="onShow: function(a) { photonicStripSetHash('."'{$photo_data['deep']}'".'); }, afterHide: function() { photonicStripUnsetHash(); } " ';
663 }
664 else if ($this->library == 'lightcase' && $processor->provider == 'google') {
665 if (empty($photo_data['video'])) {
666 return " data-lc-options='{\"type\": \"image\"}' ";
667 }
668 else {
669 return " data-lc-options='{\"type\": \"video\"}' ";
670 }
671 }
672 else if ($this->library == 'fancybox' && $processor->provider == 'google') {
673 if (empty($photo_data['video'])) {
674 return " data-fancybox='{type: \"image\"}' ";
675 }
676 }
677 else if ($this->library == 'fancybox2' && $processor->provider == 'google') {
678 if (empty($photo_data['video'])) {
679 return " data-fancybox-type='image' ";
680 }
681 }
682 else if (in_array($this->library, array('colorbox', 'fancybox', 'fancybox2', 'photoswipe', 'swipebox', )) ||
683 (in_array($this->library, array('fancybox3', 'lightcase')) && in_array($processor->provider, array('flickr'))) ||
684 (in_array($this->library, array('fancybox3', )) && in_array($processor->provider, array('google')))) {
685 return !empty($photo_data['video']) ? ' data-html5-href="'.$photo_data['video'].'" ': '';
686 }
687 else if ($this->library == 'featherlight') {
688 $mime = (!empty($photo['mime']) ? $photo['mime']: 'video/mp4');
689 if ($processor->provider == 'google' && empty($photo_data['video'])) {
690 return " data-featherlight-type='image' ";
691 }
692 else if ($processor->provider == 'google' && !empty($photo_data['video'])) {
693 return " data-featherlight='<video class=\"photonic\" controls preload=\"none\"><source src=\"".$photo_data['video']."\" type=\"".$mime."\">".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."</video>' data-featherlight-type='html'";
694 }
695
696 return !empty($photo_data['video']) ? " data-featherlight='<video class=\"photonic\" controls preload=\"none\"><source src=\"".$photo_data['video']."\" type=\"".$mime."\">".esc_html__('Your browser does not support HTML5 videos.', 'photonic')."</video>' data-featherlight-type='video'" : '';
697 }
698 return '';
699 }
700
701 /**
702 * Returns the thumbnail effect that should be used for a gallery. Not all effects can be used by all types of layouts.
703 *
704 * @param $short_code
705 * @param $layout
706 * @param $title_position
707 * @return string
708 */
709 function get_thumbnail_effect($short_code, $layout, $title_position) {
710 if (!empty($short_code['thumbnail_effect'])) {
711 $effect = $short_code['thumbnail_effect'];
712 }
713 else {
714 global $photonic_standard_thumbnail_effect, $photonic_justified_thumbnail_effect, $photonic_mosaic_thumbnail_effect, $photonic_masonry_thumbnail_effect;
715 $effect = $layout == 'mosaic' ? $photonic_mosaic_thumbnail_effect :
716 ($layout == 'masonry' ? $photonic_masonry_thumbnail_effect :
717 ($layout == 'random' ? $photonic_justified_thumbnail_effect :
718 $photonic_standard_thumbnail_effect));
719 }
720
721 if ($layout == 'circle' && $effect != 'opacity') { // "Zoom" doesn't work for circle
722 $thumbnail_effect = 'none';
723 }
724 else if (($layout == 'square' || $layout == 'launch' || $layout == 'masonry') && $title_position == 'below') { // For these combinations, Zoom doesn't work
725 $thumbnail_effect = 'none';
726 }
727 else {
728 $thumbnail_effect = $effect;
729 }
730 return apply_filters('photonic_thumbnail_effect', $thumbnail_effect, $short_code, $layout, $title_position);
731 }
732 }
733