PageRenderTime 63ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/grand-media/module/minima/init.php

https://gitlab.com/che234/smproducciones
PHP | 108 lines | 90 code | 5 blank | 13 comment | 13 complexity | 4163c7354fedd15e0f5fba8eaf64267e MD5 | raw file
  1. <?php
  2. /** @var $gmDB
  3. * @var $gmCore
  4. * @var $gmGallery
  5. * @var $gallery
  6. * @var $module
  7. * @var $settings
  8. * @var $terms
  9. * @var $gmedia
  10. * @var $is_bot
  11. **/
  12. $content = array();
  13. if (! isset($is_bot)) {
  14. $is_bot = false;
  15. }
  16. if (! isset($shortcode_raw)) {
  17. $shortcode_raw = false;
  18. }
  19. $tab = sanitize_title($gallery['name']);
  20. foreach ($terms as $term) {
  21. $c = array(
  22. 'gid' => "{$tab}_{$term->term_id}",
  23. 'name' => sanitize_key($term->name),
  24. 'title' => $term->name,
  25. 'description' => str_replace(array("\r\n", "\r", "\n"), '', wpautop($term->description)),
  26. 'path' => $gmCore->upload['url'],
  27. 'data' => array()
  28. );
  29. foreach ($gmedia[$term->term_id] as $item) {
  30. if ('image' != substr($item->mime_type, 0, 5)) {
  31. continue;
  32. }
  33. $meta['views'] = intval($gmDB->get_metadata('gmedia', $item->ID, 'views', true));
  34. $meta['likes'] = intval($gmDB->get_metadata('gmedia', $item->ID, 'likes', true));
  35. $_metadata = $gmDB->get_metadata('gmedia', $item->ID, '_metadata', true);
  36. if (! empty($item->link)) {
  37. $item->title = '<a href="' . $item->link . '"><b>' . $item->title . '</b></a>';
  38. }
  39. $c['data'][] = array(
  40. 'pid' => $item->ID,
  41. 'filename' => "/{$gmGallery->options['folder']['image']}/{$item->gmuid}",
  42. 'thumb' => "/{$gmGallery->options['folder']['image_thumb']}/{$item->gmuid}",
  43. 'alttext' => $item->title,
  44. 'description' => str_replace(array("\r\n", "\r", "\n"), '', wpautop($item->description)),
  45. 'link' => $item->link,
  46. 'date' => $item->date,
  47. 'views' => $meta['views'],
  48. 'likes' => $meta['likes'],
  49. 'websize' => array_values($_metadata['web']),
  50. 'thumbsize' => array_values($_metadata['thumb'])
  51. );
  52. }
  53. if (! count($c['data'])) {
  54. continue;
  55. }
  56. $content[] = $c;
  57. }
  58. if (! empty($content)) {
  59. $settings = array_merge($settings, array(
  60. 'ID' => $gallery['term_id'],
  61. 'moduleName' => $gallery['name'],
  62. 'moduleUrl' => $module['url'],
  63. 'pluginUrl' => $gmCore->gmedia_url,
  64. 'libraryUrl' => $gmCore->upload['url']
  65. ));
  66. ?>
  67. <div id="gmMinima_ID<?php echo $gallery['term_id']; ?>_Container">
  68. <?php if ($shortcode_raw) { echo '<pre style="display:none">'; }
  69. ?><script type="text/javascript">
  70. var GmediaGallery_<?php echo $gallery['term_id']; ?>;
  71. jQuery(function () {
  72. var settings = <?php echo json_encode($settings); ?>;
  73. var content = <?php echo json_encode($content); ?>;
  74. GmediaGallery_<?php echo $gallery['term_id']; ?> = jQuery('#GmediaGallery_<?php echo $gallery['term_id'] ?>').gmMinima([content, settings]);
  75. });
  76. </script><?php if ($shortcode_raw) { echo '</pre>'; } ?>
  77. <?php if (! $is_bot) { echo '<script type="text/html" id="flashmodule_alternative_' . $gallery['term_id'] . '">'; }
  78. ?><div class="flashmodule_alternative <?php if (! $is_bot) { echo 'delay'; } ?> noLightbox">
  79. <div class="gmcatlinks"><?php foreach ($content as $cat) { echo "<a class='gmcat' href='#{$cat['gid']}'>{$cat['title']}</a>"; } ?></div>
  80. <?php foreach ($content as $cat) { ?>
  81. <div class="gmcategory" id="<?php echo $cat['gid']; ?>">
  82. <div class="gmcatmeta"><h4><?php echo $cat['title']; ?></h4><?php echo $cat['description']; ?></div>
  83. <?php $i = 0;
  84. foreach ($cat['data'] as $item) {
  85. $orientation = (1 < $item['thumbsize'][0] / $item['thumbsize'][1]) ? 'landscape' : 'portrait';
  86. ?><div class="gmcatimage gm_<?php echo $i; ?>" id="gmid_<?php echo $item['pid']; ?>"><?php
  87. ?><a class="photoswipe" href="<?php echo $settings['libraryUrl'] . $item['filename']; ?>" title="<?php echo esc_attr($item['alttext']); ?>" rel="<?php echo $cat['gid']; ?>" data-id="<?php echo $item['pid']; ?>" data-width="<?php echo $item['websize'][0]; ?>" data-height="<?php echo $item['websize'][1]; ?>" data-date="<?php echo $item['date']; ?>"><?php
  88. ?><img class="<?php echo $orientation; ?>" src="<?php echo $settings['libraryUrl'] . $item['thumb']; ?>" alt="<?php echo esc_attr($item['alttext']); ?>" /><?php
  89. //$views = (intval($item['views']) < 10000) ? $item['views'] : round($item['views']/1000, 1).'k';
  90. //$likes = (intval($item['likes']) < 10000) ? $item['likes'] : round($item['likes']/1000, 1).'k';
  91. //echo '<span class="gmcatimage_counters"><i>'.$views.'</i><b>'.$likes.'</b></span>';
  92. ?></a><?php
  93. ?><div class="gmcatimage_caption"><div class="gmcatimage_title"><?php echo $item['alttext']; ?></div><div class="gmcatimage_description"><?php echo $item['description']; ?></div></div><?php
  94. ?></div><?php
  95. $i++;
  96. } ?></div>
  97. <?php } ?>
  98. </div><?php if (! $is_bot) { echo '</script>'; } ?>
  99. </div>
  100. <?php
  101. } else {
  102. echo GMEDIA_GALLERY_EMPTY;
  103. }