A_NextGen_Basic_Thumbnails_Controller

Class A_NextGen_Basic_Thumbnails_Controller.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_basic_gallery/package.module.nextgen_basic_gallery.php  
  1. class A_NextGen_Basic_Thumbnails_Controller extends Mixin 
  2. /** 
  3. * Adds framework support for thumbnails 
  4. */ 
  5. function initialize() 
  6. $this->add_mixin('Mixin_NextGen_Basic_Pagination'); 
  7. /** 
  8. * Displays the ngglegacy thumbnail gallery. 
  9. * This method deprecates the use of the nggShowGallery() function. 
  10. * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery 
  11. */ 
  12. function index_action($displayed_gallery, $return = FALSE) 
  13. $display_settings = $displayed_gallery->display_settings; 
  14. $gallery_id = $displayed_gallery->id(); 
  15. if (!$display_settings['disable_pagination']) { 
  16. $current_page = (int) $this->param('nggpage', $gallery_id, 1); 
  17. } else { 
  18. $current_page = 1; 
  19. $offset = $display_settings['images_per_page'] * ($current_page - 1); 
  20. $storage = C_Gallery_Storage::get_instance(); 
  21. $total = $displayed_gallery->get_entity_count(); 
  22. // Get the images to be displayed 
  23. if ($display_settings['images_per_page'] > 0 && $display_settings['show_all_in_lightbox']) { 
  24. // the "Add Hidden Images" feature works by loading ALL images and then marking the ones not on this page 
  25. // as hidden (style="display: none") 
  26. $images = $displayed_gallery->get_included_entities(); 
  27. $i = 0; 
  28. foreach ($images as &$image) { 
  29. if ($i < $display_settings['images_per_page'] * ($current_page - 1)) { 
  30. $image->hidden = TRUE; 
  31. } elseif ($i >= $display_settings['images_per_page'] * $current_page) { 
  32. $image->hidden = TRUE; 
  33. $i++; 
  34. } else { 
  35. // just display the images for this page, as normal 
  36. $images = $displayed_gallery->get_included_entities($display_settings['images_per_page'], $offset); 
  37. if (in_array($displayed_gallery->source, array('random_images', 'recent_images'))) { 
  38. $display_settings['disable_pagination'] = TRUE; 
  39. // Are there images to display? 
  40. if ($images) { 
  41. // Create pagination 
  42. if ($display_settings['images_per_page'] && !$display_settings['disable_pagination']) { 
  43. $pagination_result = $this->object->create_pagination($current_page, $total, $display_settings['images_per_page'], urldecode($this->object->param('ajax_pagination_referrer'))); 
  44. $this->object->remove_param('ajax_pagination_referrer'); 
  45. $pagination_prev = $pagination_result['prev']; 
  46. $pagination_next = $pagination_result['next']; 
  47. $pagination = $pagination_result['output']; 
  48. } else { 
  49. list($pagination_prev, $pagination_next, $pagination) = array(NULL, NULL, NULL); 
  50. $thumbnail_size_name = 'thumbnail'; 
  51. if ($display_settings['override_thumbnail_settings']) { 
  52. $dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance(); 
  53. if ($dynthumbs != null) { 
  54. $dyn_params = array('width' => $display_settings['thumbnail_width'], 'height' => $display_settings['thumbnail_height']); 
  55. if ($display_settings['thumbnail_quality']) { 
  56. $dyn_params['quality'] = $display_settings['thumbnail_quality']; 
  57. if ($display_settings['thumbnail_crop']) { 
  58. $dyn_params['crop'] = true; 
  59. if ($display_settings['thumbnail_watermark']) { 
  60. $dyn_params['watermark'] = true; 
  61. $thumbnail_size_name = $dynthumbs->get_size_name($dyn_params); 
  62. // Generate a slideshow link 
  63. $slideshow_link = ''; 
  64. if ($display_settings['show_slideshow_link']) { 
  65. // origin_url is necessary for ajax operations. slideshow_link_origin will NOT always exist. 
  66. $origin_url = $this->object->param('ajax_pagination_referrer'); 
  67. $slideshow_link = $this->object->get_url_for_alternate_display_type($displayed_gallery, NGG_BASIC_SLIDESHOW, $origin_url); 
  68. // This setting 1) points all images to an imagebrowser display & 2) disables the lightbox effect 
  69. if ($display_settings['use_imagebrowser_effect']) { 
  70. // // this hook *MUST* be removed later; it should not apply to galleries that may come after this one! 
  71. // $storage->add_post_hook( 
  72. // 'get_image_url',  
  73. // 'imagebrowser alternate url replacer',  
  74. // 'Hook_NextGen_Basic_Imagebrowser_Alt_URLs',  
  75. // 'get_image_url' 
  76. // ); 
  77. // $effect_code = ''; 
  78. $effect_code = "class='use_imagebrowser_effect'"; 
  79. } else { 
  80. $effect_code = $this->object->get_effect_code($displayed_gallery); 
  81. // The render functions require different processing 
  82. if (!empty($display_settings['template']) && $display_settings['template'] != 'default') { 
  83. $this->object->add_mixin('A_NextGen_Basic_Template_Form'); 
  84. $this->object->add_mixin('Mixin_NextGen_Basic_Templates'); 
  85. $params = $this->object->prepare_legacy_parameters($images, $displayed_gallery, array('next' => empty($pagination_next) ? FALSE : $pagination_next, 'prev' => empty($pagination_prev) ? FALSE : $pagination_prev, 'pagination' => $pagination, 'slideshow_link' => $slideshow_link, 'effect_code' => $effect_code)); 
  86. $output = $this->object->legacy_render($display_settings['template'], $params, $return, 'gallery'); 
  87. } else { 
  88. $params = $display_settings; 
  89. $params['storage'] =& $storage; 
  90. $params['images'] =& $images; 
  91. $params['displayed_gallery_id'] = $gallery_id; 
  92. $params['current_page'] = $current_page; 
  93. $params['effect_code'] = $effect_code; 
  94. $params['pagination'] = $pagination; 
  95. $params['thumbnail_size_name'] = $thumbnail_size_name; 
  96. $params['slideshow_link'] = $slideshow_link; 
  97. $params = $this->object->prepare_display_parameters($displayed_gallery, $params); 
  98. $output = $this->object->render_view('photocrati-nextgen_basic_gallery#thumbnails/index', $params, $return); 
  99. return $output; 
  100. } else { 
  101. if ($display_settings['display_no_images_error']) { 
  102. return $this->object->render_partial("photocrati-nextgen_gallery_display#no_images_found", array(), $return); 
  103. /** 
  104. * Enqueues all static resources required by this display type 
  105. * @param C_Displayed_Gallery $displayed_gallery 
  106. */ 
  107. function enqueue_frontend_resources($displayed_gallery) 
  108. $this->call_parent('enqueue_frontend_resources', $displayed_gallery); 
  109. wp_enqueue_style('nextgen_basic_thumbnails_style', $this->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.css'), FALSE, NGG_SCRIPT_VERSION); 
  110. if ($displayed_gallery->display_settings['ajax_pagination']) { 
  111. wp_enqueue_script('nextgen-basic-thumbnails-ajax-pagination', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/ajax_pagination.js'), FALSE, NGG_SCRIPT_VERSION); 
  112. wp_enqueue_style('nextgen_pagination_style', $this->get_static_url('photocrati-nextgen_pagination#style.css'), FALSE, NGG_SCRIPT_VERSION); 
  113. $this->enqueue_ngg_styles(); 
  114. /** 
  115. * Provides the url of the JavaScript library required for 
  116. * NextGEN Basic Thumbnails to display 
  117. * @return string 
  118. */ 
  119. function _get_js_lib_url() 
  120. return $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.js');