A_NextGen_Basic_Singlepic_Controller

Class A_NextGen_Basic_Singlepic_Controller.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_singlepic/package.module.nextgen_basic_singlepic.php  
  1. class A_NextGen_Basic_Singlepic_Controller extends Mixin 
  2. /** 
  3. * Displays the 'singlepic' display type 
  4. * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery 
  5. */ 
  6. function index_action($displayed_gallery, $return = FALSE) 
  7. $storage = C_Gallery_Storage::get_instance(); 
  8. $dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance(); 
  9. $display_settings = $displayed_gallery->display_settings; 
  10. // use this over get_included_entities() so we can display images marked 'excluded' 
  11. $displayed_gallery->skip_excluding_globally_excluded_images = TRUE; 
  12. $image = array_shift($displayed_gallery->get_entities(1, FALSE, FALSE, 'included')); 
  13. if (!$image) { 
  14. return $this->object->render_partial("photocrati-nextgen_gallery_display#no_images_found", array(), $return); 
  15. switch ($display_settings['float']) { 
  16. case 'left': 
  17. $display_settings['float'] = 'ngg-left'; 
  18. break; 
  19. case 'right': 
  20. $display_settings['float'] = 'ngg-right'; 
  21. break; 
  22. case 'center': 
  23. $display_settings['float'] = 'ngg-center'; 
  24. break; 
  25. default: 
  26. $display_settings['float'] = ''; 
  27. break; 
  28. $params = array(); 
  29. if (!empty($display_settings['link'])) { 
  30. $target = $display_settings['link_target']; 
  31. $effect_code = ''; 
  32. } else { 
  33. $display_settings['link'] = $storage->get_image_url($image, 'full', TRUE); 
  34. $target = '_self'; 
  35. $effect_code = $this->object->get_effect_code($displayed_gallery); 
  36. $params['target'] = $target; 
  37. // mode is a legacy parameter 
  38. if (!is_array($display_settings['mode'])) { 
  39. $display_settings['mode'] = explode(', ', $display_settings['mode']); 
  40. if (in_array('web20', $display_settings['mode'])) { 
  41. $display_settings['display_reflection'] = TRUE; 
  42. if (in_array('watermark', $display_settings['mode'])) { 
  43. $display_settings['display_watermark'] = TRUE; 
  44. if (isset($display_settings['w'])) { 
  45. $display_settings['width'] = $display_settings['w']; 
  46. } elseif (isset($display_settings['h'])) { 
  47. unset($display_settings['width']); 
  48. if (isset($display_settings['h'])) { 
  49. $display_settings['height'] = $display_settings['h']; 
  50. } elseif (isset($display_settings['w'])) { 
  51. unset($display_settings['height']); 
  52. // legacy assumed no width/height meant full size unlike generate_thumbnail: force a full resolution 
  53. if (!isset($display_settings['width']) && !isset($display_settings['height'])) { 
  54. $display_settings['width'] = $image->meta_data['width']; 
  55. if (isset($display_settings['width'])) { 
  56. $params['width'] = $display_settings['width']; 
  57. if (isset($display_settings['height'])) { 
  58. $params['height'] = $display_settings['height']; 
  59. $params['quality'] = $display_settings['quality']; 
  60. $params['crop'] = $display_settings['crop']; 
  61. $params['watermark'] = $display_settings['display_watermark']; 
  62. $params['reflection'] = $display_settings['display_reflection']; 
  63. // Fall back to full in case dynamic images aren't available 
  64. $size = 'full'; 
  65. if ($dynthumbs != null) { 
  66. $size = $dynthumbs->get_size_name($params); 
  67. $thumbnail_url = $storage->get_image_url($image, $size); 
  68. if (!empty($display_settings['template']) && $display_settings['template'] != 'default') { 
  69. $this->object->add_mixin('A_NextGen_Basic_Template_Form'); 
  70. $this->object->add_mixin('Mixin_NextGen_Basic_Templates'); 
  71. $params = $this->object->prepare_legacy_parameters(array($image), $displayed_gallery, array('single_image' => TRUE)); 
  72. // the wrapper is a lazy-loader that calculates variables when requested. We here override those to always 
  73. // return the same precalculated settings provided 
  74. $params['image']->container[0]->_cache_overrides['caption'] = $displayed_gallery->inner_content; 
  75. $params['image']->container[0]->_cache_overrides['classname'] = 'ngg-singlepic ' . $display_settings['float']; 
  76. $params['image']->container[0]->_cache_overrides['imageURL'] = $display_settings['link']; 
  77. $params['image']->container[0]->_cache_overrides['thumbnailURL'] = $thumbnail_url; 
  78. $params['target'] = $target; 
  79. // if a link is present we temporarily must filter out the effect code 
  80. if (empty($effect_code)) { 
  81. add_filter('ngg_get_thumbcode', array(&$this, 'strip_thumbcode'), 10); 
  82. $retval = $this->object->legacy_render($display_settings['template'], $params, $return, 'singlepic'); 
  83. if (empty($effect_code)) { 
  84. remove_filter('ngg_get_thumbcode', array(&$this, 'strip_thumbcode'), 10); 
  85. return $retval; 
  86. } else { 
  87. $params = $display_settings; 
  88. $params['storage'] =& $storage; 
  89. $params['image'] =& $image; 
  90. $params['effect_code'] = $effect_code; 
  91. $params['inner_content'] = $displayed_gallery->inner_content; 
  92. $params['settings'] = $display_settings; 
  93. $params['thumbnail_url'] = $thumbnail_url; 
  94. $params['target'] = $target; 
  95. $params = $this->object->prepare_display_parameters($displayed_gallery, $params); 
  96. return $this->object->render_partial('photocrati-nextgen_basic_singlepic#nextgen_basic_singlepic', $params, $return); 
  97. /** 
  98. * Intentionally disable the application of the effect code 
  99. */ 
  100. function strip_thumbcode($thumbcode) 
  101. return ''; 
  102. /** 
  103. * Enqueues all static resources required by this display type 
  104. * @param C_Displayed_Gallery $displayed_gallery 
  105. */ 
  106. function enqueue_frontend_resources($displayed_gallery) 
  107. $this->call_parent('enqueue_frontend_resources', $displayed_gallery); 
  108. wp_enqueue_style('nextgen_basic_singlepic_style', $this->get_static_url('photocrati-nextgen_basic_singlepic#nextgen_basic_singlepic.css'), FALSE, NGG_SCRIPT_VERSION); 
  109. $this->enqueue_ngg_styles();