PageRenderTime 39ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/plugins/system/zlframework/zlframework/elements/pro/tmpl/render/widgetkit/gallery/wall/template.php

https://gitlab.com/vnsoftdev/amms
PHP | 147 lines | 93 code | 31 blank | 23 comment | 41 complexity | 08a14055552eeeb521e76554214b7264 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-3.0, GPL-2.0
  1. <?php
  2. /**
  3. * @package ZOOlanders
  4. * @version 3.3.15
  5. * @author ZOOlanders - http://zoolanders.com
  6. * @license GNU General Public License v2 or later
  7. */
  8. defined('_JEXEC') or die();
  9. $widget_id = $widget->id.'-'.uniqid();
  10. $settings = $widget->settings;
  11. $zoom = in_array($settings['effect'], array('zoom', 'polaroid')) ? 1.4 : 1;
  12. // get lightbox settings and remove them
  13. $lbsettings = $settings['lightbox_settings'];
  14. unset($settings['lightbox_settings']);
  15. // create the settings object
  16. $settings = $this->app->data->create($settings);
  17. // ZL integration
  18. $bigimg = $this->getRenderedValues($params, $widget->mode, array('file2' => true, 'width' => $settings->get('width') * $zoom, 'height' => $settings->get('height') * $zoom, 'avoid_cropping' => $settings->get('avoid_cropping')));
  19. $bigimg = $bigimg['result'];
  20. $images = $this->getRenderedValues($params, $widget->mode); // get size from element specific
  21. $images = $images['result'];
  22. // add the big image into image, important if reordering
  23. foreach ($images as $key => &$img) {
  24. $img['bigimg'] = $bigimg[$key];
  25. }
  26. $css_classes = ($settings['corners'] == 'round') ? 'round ' : '';
  27. $css_classes .= ($settings['effect'] == 'zoom') ? 'zoom ' : '';
  28. $css_classes .= ($settings['effect'] == 'polaroid') ? 'polaroid ' : '';
  29. $css_classes .= ($settings['margin']) ? 'margin ' : '';
  30. // workaround for the main dimensions
  31. $settings->set('width', $params->find('specific._width', 'auto'));
  32. $settings->set('height', $params->find('specific._height', 'auto'));
  33. $lightbox_options = '';
  34. if(isset($lbsettings['lightbox_overide'])) foreach($lbsettings as $name => $value){
  35. $lightbox_options .= "$name:$value;";
  36. };
  37. // random order
  38. if (count($images) && isset($settings['order']) && $settings['order'] =="random") {
  39. shuffle($images);
  40. }
  41. ?>
  42. <?php if (count($images)) : ?>
  43. <div class="yoo-wk wk-gallery wk-gallery-wall clearfix <?php echo $css_classes; ?>">
  44. <?php foreach ($images as $key => $image) : ?>
  45. <?php
  46. $lightbox = '';
  47. $spotlight = '';
  48. $overlay = '';
  49. /* Prepare Caption */
  50. $caption = '';
  51. if($settings->get('zl_captions') == 2 && $title = $settings->get('_custom_caption')){
  52. $caption = $title;
  53. } elseif(strlen($image['caption'])){
  54. $caption = strip_tags($image['caption']);
  55. } else {
  56. $caption = $image['filename'];
  57. }
  58. /* Prepare Lightbox */
  59. if ($settings->get('lightbox') && !$params->find('specific._link_to_item')) // no compatible with item link
  60. {
  61. // set dimensions
  62. $lightbox_options .= $settings->get('width') && $settings->get('width') != 'auto' ? 'width:'.$settings->get('width').';' : '';
  63. $lightbox_options .= $settings->get('height') && $settings->get('width') != 'auto' ? 'height:'.$settings->get('height').';' : '';
  64. $lightbox = 'data-lightbox="group:'.$widget_id.';'.$lightbox_options.'"';
  65. // override caption options
  66. $lbc = $caption;
  67. if($settings->get('lightbox_caption') == 0){
  68. $lbc = '';
  69. } if($settings->get('lightbox_caption') == 2 && $title = $settings->get('_lightbox_custom_title')){
  70. $lbc = $title;
  71. }
  72. if (strlen($lbc)) $lightbox .= ' title="'.$lbc.'"';
  73. }
  74. /* Prepare Spotlight */
  75. if ($settings->get('effect') == 'spotlight')
  76. {
  77. // override caption
  78. if($settings->get('zl_captions') == 0) $caption = '';
  79. $spotlight_opts = $settings->get('spotlight_effect') ? 'effect:'.$settings->get('spotlight_effect') : '';
  80. $spotlight_opts .= $settings->get('spotlight_duration') ? ';duration:'.$settings->get('spotlight_duration') : '';
  81. if (strlen($spotlight_opts) && strlen($caption)) {
  82. $spotlight = 'data-spotlight="'.$spotlight_opts.'"';
  83. $overlay = '<div class="overlay">'.$caption.'</div>';
  84. } elseif (!$settings->get('spotlight_effect')) {
  85. $spotlight = 'data-spotlight="on"';
  86. }
  87. }
  88. /* Prepare Polaroid */
  89. if ($settings->get('effect') == 'polaroid') {
  90. // it overides Spotlight
  91. (strlen($caption)) && $overlay = '<p class="title">'.$caption.'</p>';
  92. }
  93. /* Prepare Link */
  94. $rel = $this->config->find('specific._custom_link') ? '' : 'rel="nofollow" ';
  95. $link = $this->config->find('specific._custom_link') && $image['link'] ? $image['link'] : $image['bigimg']['fileurl'];
  96. $link = 'href="'.$link.'"'.($image['target'] ? ' target="_blank"' : '');
  97. /* Prepare Image */
  98. $content = '<img src="'.$image['fileurl'].'" width="'.$image['width'].'" height="'.$image['height'].'" alt="'.$image['filename'].'" />'.$overlay;
  99. $content = ($settings->get('effect') == 'polaroid') ? '<div>'.$content.'</div>' : $content ;
  100. /* Separator - if separator tag present wrap each item */
  101. if(preg_match('/(^tag|\stag)=\[(.*)\]/U', $separator, $separated_by)){
  102. $content = $this->app->zlfw->applySeparators($separated_by[0], $content, $params->find('separator._class'), $params->find('separator._fixhtml'));
  103. }
  104. ?>
  105. <?php if ($settings->get('lightbox') || $image['link']) : ?>
  106. <a <?php echo $rel ?>class="" <?php echo $link; ?> <?php echo $lightbox; ?> <?php echo $spotlight; ?>><?php echo $content; ?></a>
  107. <?php elseif ($settings->get('effect') == 'spotlight') : ?>
  108. <div <?php echo $spotlight; ?>><?php echo $content; ?></div>
  109. <?php else : ?>
  110. <?php echo $content; ?>
  111. <?php endif; ?>
  112. <?php endforeach; ?>
  113. </div>
  114. <?php else : ?>
  115. <?php echo "No images found."; ?>
  116. <?php endif; ?>