M_NextGen_Basic_Gallery

The NextGEN Gallery M NextGen Basic Gallery class.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_gallery/module.nextgen_basic_gallery.php  
  1. class M_NextGen_Basic_Gallery extends C_Base_Module 
  2. function define($id = 'pope-module',  
  3. $name = 'Pope Module',  
  4. $description = '',  
  5. $version = '',  
  6. $uri = '',  
  7. $author = '',  
  8. $author_uri = '',  
  9. $context = FALSE) 
  10. parent::define( 
  11. 'photocrati-nextgen_basic_gallery',  
  12. 'NextGEN Basic Gallery',  
  13. "Provides NextGEN Gallery's basic thumbnail/slideshow integrated gallery",  
  14. '0.16',  
  15. 'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',  
  16. 'Imagely',  
  17. 'https://www.imagely.com' 
  18. ); 
  19.  
  20. C_Photocrati_Installer::add_handler($this->module_id, 'C_NextGen_Basic_Gallery_Installer'); 
  21.  
  22. function initialize() 
  23. parent::initialize(); 
  24. if (is_admin()) { 
  25. $forms = C_Form_Manager::get_instance(); 
  26. $forms->add_form(NGG_DISPLAY_SETTINGS_SLUG, NGG_BASIC_THUMBNAILS); 
  27. $forms->add_form(NGG_DISPLAY_SETTINGS_SLUG, NGG_BASIC_SLIDESHOW); 
  28.  
  29.  
  30. function get_type_list() 
  31. return array( 
  32. 'C_Nextgen_Basic_Gallery_Installer' => 'class.nextgen_basic_gallery_installer.php',  
  33. 'A_Nextgen_Basic_Gallery_Mapper' => 'adapter.nextgen_basic_gallery_mapper.php',  
  34. 'A_Nextgen_Basic_Gallery_Urls' => 'adapter.nextgen_basic_gallery_urls.php',  
  35. 'A_Nextgen_Basic_Gallery_Validation' => 'adapter.nextgen_basic_gallery_validation.php',  
  36. 'A_Nextgen_Basic_Slideshow_Controller' => 'adapter.nextgen_basic_slideshow_controller.php',  
  37. 'A_Nextgen_Basic_Slideshow_Form' => 'adapter.nextgen_basic_slideshow_form.php',  
  38. 'A_Nextgen_Basic_Thumbnail_Form' => 'adapter.nextgen_basic_thumbnail_form.php',  
  39. 'A_Nextgen_Basic_Thumbnails_Controller' => 'adapter.nextgen_basic_thumbnails_controller.php',  
  40. 'Mixin_Nextgen_Basic_Gallery_Controller' => 'mixin.nextgen_basic_gallery_controller.php',  
  41. 'A_NextGen_Basic_Gallery_Controller' => 'adapter.nextgen_basic_gallery_controller.php' 
  42. ); 
  43.  
  44.  
  45. function _register_adapters() 
  46. if (M_Attach_To_Post::is_atp_url() || is_admin()) 
  47. // Provides the display type forms 
  48. $this->get_registry()->add_adapter( 
  49. 'I_Form',  
  50. 'A_NextGen_Basic_Slideshow_Form',  
  51. NGG_BASIC_SLIDESHOW 
  52. ); 
  53. $this->get_registry()->add_adapter( 
  54. 'I_Form',  
  55. 'A_NextGen_Basic_Thumbnail_Form',  
  56. NGG_BASIC_THUMBNAILS 
  57. ); 
  58.  
  59. // Frontend-only components 
  60. if (apply_filters('ngg_load_frontend_logic', TRUE, $this->module_id)) 
  61. // Provides the controllers for the display types 
  62. $this->get_registry()->add_adapter( 
  63. 'I_Display_Type_Controller',  
  64. 'A_NextGen_Basic_Slideshow_Controller',  
  65. NGG_BASIC_SLIDESHOW 
  66. ); 
  67. $this->get_registry()->add_adapter( 
  68. 'I_Display_Type_Controller',  
  69. 'A_NextGen_Basic_Thumbnails_Controller',  
  70. NGG_BASIC_THUMBNAILS 
  71. ); 
  72.  
  73. $this->get_registry()->add_adapter( 
  74. 'I_Display_Type_Controller',  
  75. 'A_NextGen_Basic_Gallery_Controller',  
  76. NGG_BASIC_SLIDESHOW 
  77. ); 
  78. $this->get_registry()->add_adapter( 
  79. 'I_Display_Type_Controller',  
  80. 'A_NextGen_Basic_Gallery_Controller',  
  81. NGG_BASIC_THUMBNAILS 
  82. ); 
  83.  
  84. // Provide defaults for the display types 
  85. $this->get_registry()->add_adapter( 
  86. 'I_Display_Type_Mapper',  
  87. 'A_NextGen_Basic_Gallery_Mapper' 
  88. ); 
  89.  
  90. // Provides validation for the display types 
  91. $this->get_registry()->add_adapter( 
  92. 'I_Display_Type',  
  93. 'A_NextGen_Basic_Gallery_Validation' 
  94. ); 
  95.  
  96. // Provides url generation support for the display types 
  97. $this->get_registry()->add_adapter( 
  98. 'I_Routing_App',  
  99. 'A_NextGen_Basic_Gallery_Urls' 
  100. ); 
  101.  
  102. function _register_hooks() 
  103. if (apply_filters('ngg_load_frontend_logic', TRUE, $this->module_id) 
  104. && (!defined('NGG_DISABLE_LEGACY_SHORTCODES') || !NGG_DISABLE_LEGACY_SHORTCODES)) 
  105. C_NextGen_Shortcode_Manager::add('random', array(&$this, 'render_random_images')); 
  106. C_NextGen_Shortcode_Manager::add('recent', array(&$this, 'render_recent_images')); 
  107. C_NextGen_Shortcode_Manager::add('thumb', array(&$this, 'render_thumb_shortcode')); 
  108. C_NextGen_Shortcode_Manager::add('slideshow', array(&$this, 'render_slideshow')); 
  109. C_NextGen_Shortcode_Manager::add('nggallery', array(&$this, 'render')); 
  110. C_NextGen_Shortcode_Manager::add('nggtags', array(&$this, 'render_based_on_tags')); 
  111. C_NextGen_Shortcode_Manager::add('nggslideshow', array(&$this, 'render_slideshow')); 
  112. C_NextGen_Shortcode_Manager::add('nggrandom', array(&$this, 'render_random_images')); 
  113. C_NextGen_Shortcode_Manager::add('nggrecent', array(&$this, 'render_recent_images')); 
  114. C_NextGen_Shortcode_Manager::add('nggthumb', array(&$this, 'render_thumb_shortcode')); 
  115.  
  116. add_action('ngg_routes', array(&$this, 'define_routes')); 
  117.  
  118. add_filter('ngg_atp_show_display_type', array($this, 'atp_show_basic_galleries'), 10, 2); 
  119.  
  120. function define_routes($router) 
  121. $slug = '/'.C_NextGen_Settings::get_instance()->router_param_slug; 
  122. $router->rewrite("{*}{$slug}{*}/image/{*}", "{1}{$slug}{2}/pid--{3}"); 
  123. $router->rewrite("{*}{$slug}{*}/slideshow/{*}", "{1}{$slug}{2}/show--" . NGG_BASIC_SLIDESHOW . "/{3}"); 
  124. $router->rewrite("{*}{$slug}{*}/thumbnails/{*}", "{1}{$slug}{2}/show--". NGG_BASIC_THUMBNAILS . "/{3}"); 
  125. $router->rewrite("{*}{$slug}{*}/show--slide/{*}", "{1}{$slug}{2}/show--" . NGG_BASIC_SLIDESHOW . "/{3}"); 
  126. $router->rewrite("{*}{$slug}{*}/show--gallery/{*}", "{1}{$slug}{2}/show--" . NGG_BASIC_THUMBNAILS . "/{3}"); 
  127. $router->rewrite("{*}{$slug}{*}/page/{\\d}{*}", "{1}{$slug}{2}/nggpage--{3}{4}"); 
  128.  
  129. /** 
  130. * ATP filters display types by not displaying those whose name attribute isn't an active POPE module. This 
  131. * is a workaround/hack to compensate for basic slideshow & thumbnails sharing a module. 
  132. * @param bool $available 
  133. * @param C_Display_Type $display_type 
  134. * @return bool 
  135. */ 
  136. function atp_show_basic_galleries($available, $display_type) 
  137. if (in_array($display_type->name, array(NGG_BASIC_THUMBNAILS, NGG_BASIC_SLIDESHOW))) 
  138. $available = TRUE; 
  139. return $available; 
  140.  
  141. /** 
  142. * Gets a value from the parameter array, and if not available, uses the default value 
  143. * @param string $name 
  144. * @param mixed $default 
  145. * @param array $params 
  146. * @return mixed 
  147. */ 
  148. function _get_param($name, $default, $params) 
  149. return (isset($params[$name])) ? $params[$name] : $default; 
  150.  
  151. /** 
  152. * Short-cut for rendering an thumbnail gallery 
  153. * @param array $params 
  154. * @param null $inner_content 
  155. * @return string 
  156. */ 
  157. function render($params, $inner_content=NULL) 
  158. $params['gallery_ids'] = $this->_get_param('id', NULL, $params); 
  159. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_THUMBNAILS, $params); 
  160. if (isset($params['images'])) 
  161. $params['images_per_page'] = $this->_get_param('images', NULL, $params); 
  162. unset($params['id']); 
  163. unset($params['images']); 
  164.  
  165. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  166. return $renderer->display_images($params, $inner_content); 
  167.  
  168. function render_based_on_tags($params, $inner_content=NULL) 
  169. $params['tag_ids'] = $this->_get_param('gallery', $this->_get_param('album', array(), $params), $params); 
  170. $params['source'] = $this->_get_param('source', 'tags', $params); 
  171. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_THUMBNAILS, $params); 
  172. unset($params['gallery']); 
  173.  
  174. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  175. return $renderer->display_images($params, $inner_content); 
  176.  
  177. function render_random_images($params, $inner_content=NULL) 
  178. $params['source'] = $this->_get_param('source', 'random', $params); 
  179. $params['images_per_page'] = $this->_get_param('max', NULL, $params); 
  180. $params['disable_pagination'] = $this->_get_param('disable_pagination', TRUE, $params); 
  181. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_THUMBNAILS, $params); 
  182.  
  183. // inside if because Mixin_Displayed_Gallery_Instance_Methods->get_entities() doesn't handle NULL container_ids 
  184. // correctly 
  185. if (isset($params['id'])) 
  186. $params['container_ids'] = $this->_get_param('id', NULL, $params); 
  187.  
  188. unset($params['max']); 
  189. unset($params['id']); 
  190.  
  191. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  192. return $renderer->display_images($params, $inner_content); 
  193.  
  194. function render_recent_images($params, $inner_content=NULL) 
  195. $params['source'] = $this->_get_param('source', 'recent', $params); 
  196. $params['images_per_page'] = $this->_get_param('max', NULL, $params); 
  197. $params['disable_pagination'] = $this->_get_param('disable_pagination', TRUE, $params); 
  198. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_THUMBNAILS, $params); 
  199.  
  200. if (isset($params['id'])) 
  201. $params['container_ids'] = $this->_get_param('id', NULL, $params); 
  202.  
  203. unset($params['max']); 
  204. unset($params['id']); 
  205.  
  206. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  207. return $renderer->display_images($params, $inner_content); 
  208.  
  209. function render_thumb_shortcode($params, $inner_content=NULL) 
  210. $params['entity_ids'] = $this->_get_param('id', NULL, $params); 
  211. $params['source'] = $this->_get_param('source', 'galleries', $params); 
  212. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_THUMBNAILS, $params); 
  213. unset($params['id']); 
  214.  
  215. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  216. return $renderer->display_images($params, $inner_content); 
  217.  
  218. function render_slideshow($params, $inner_content=NULL) 
  219. $params['gallery_ids'] = $this->_get_param('id', NULL, $params); 
  220. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_SLIDESHOW, $params); 
  221. $params['gallery_width'] = $this->_get_param('w', NULL, $params); 
  222. $params['gallery_height'] = $this->_get_param('h', NULL, $params); 
  223. unset($params['id'], $params['w'], $params['h']); 
  224.  
  225. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  226. return $renderer->display_images($params, $inner_content); 
  227. }