PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 2.21
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v2.21
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.21, at layouts/Layout_Default.php

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