M_NextGen_Basic_Singlepic

The NextGEN Gallery M NextGen Basic Singlepic class.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_singlepic/module.nextgen_basic_singlepic.php  
  1. class M_NextGen_Basic_Singlepic 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. NGG_BASIC_SINGLEPIC,  
  12. 'NextGen Basic Singlepic',  
  13. 'Provides a singlepic gallery for NextGEN Gallery',  
  14. '0.14',  
  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_SinglePic_Installer'); 
  21.  
  22. function initialize() 
  23. parent::initialize(); 
  24. if (is_admin()) { 
  25. $forms = C_Form_Manager::get_instance(); 
  26. $forms->add_form( 
  27. NGG_DISPLAY_SETTINGS_SLUG, NGG_BASIC_SINGLEPIC 
  28. ); 
  29.  
  30.  
  31. function _register_adapters() 
  32. // Provides default values for the display type 
  33. $this->get_registry()->add_adapter( 
  34. 'I_Display_Type_Mapper',  
  35. 'A_NextGen_Basic_Singlepic_Mapper' 
  36. ); 
  37.  
  38. if (M_Attach_To_Post::is_atp_url() || is_admin()) 
  39. // Provides the display settings form for the SinglePic display type 
  40. $this->get_registry()->add_adapter( 
  41. 'I_Form',  
  42. 'A_NextGen_Basic_SinglePic_Form',  
  43. $this->module_id 
  44. ); 
  45.  
  46. if (apply_filters('ngg_load_frontend_logic', TRUE, $this->module_id)) 
  47. // Provides settings fields and frontend rendering 
  48. $this->get_registry()->add_adapter( 
  49. 'I_Display_Type_Controller',  
  50. 'A_NextGen_Basic_Singlepic_Controller',  
  51. $this->module_id 
  52. ); 
  53.  
  54. function _register_hooks() 
  55. if (apply_filters('ngg_load_frontend_logic', TRUE, $this->module_id) 
  56. && (!defined('NGG_DISABLE_LEGACY_SHORTCODES') || !NGG_DISABLE_LEGACY_SHORTCODES)) 
  57. C_NextGen_Shortcode_Manager::add('singlepic', array(&$this, 'render_singlepic')); 
  58. C_NextGen_Shortcode_Manager::add('nggsinglepic', array(&$this, 'render_singlepic')); 
  59.  
  60. // enqueue the singlepic CSS if an inline image has the ngg-singlepic class 
  61. add_filter('the_content', array(&$this, 'enqueue_singlepic_css'), PHP_INT_MAX, 1); 
  62.  
  63. /** 
  64. * Examines 'the_content' string for img.ngg-singlepic and enqueues styling when found 
  65. * @param string $content 
  66. * @return string $content 
  67. */ 
  68. function enqueue_singlepic_css($content) 
  69. if (preg_match("#<img.*ngg-singlepic.*>#", $content, $matches)) { 
  70. $router = C_Router::get_instance(); 
  71. wp_enqueue_style( 
  72. 'nextgen_basic_singlepic_style',  
  73. $router->get_static_url(NGG_BASIC_SINGLEPIC . '#nextgen_basic_singlepic.css'),  
  74. FALSE,  
  75. NGG_SCRIPT_VERSION 
  76. ); 
  77.  
  78. return $content; 
  79.  
  80. /** 
  81. * Gets a value from the parameter array, and if not available, uses the default value 
  82. * @param string $name 
  83. * @param mixed $default 
  84. * @param array $params 
  85. * @return mixed 
  86. */ 
  87. function _get_param($name, $default, $params) 
  88. return (isset($params[$name])) ? $params[$name] : $default; 
  89.  
  90. function render_singlepic($params, $inner_content=NULL) 
  91. $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_SINGLEPIC, $params); 
  92. $params['image_ids'] = $this->_get_param('id', NULL, $params); 
  93. unset($params['id']); 
  94.  
  95. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  96. return $renderer->display_images($params, $inner_content); 
  97.  
  98. function get_type_list() 
  99. return array( 
  100. 'A_Nextgen_Basic_Singlepic' => 'adapter.nextgen_basic_singlepic.php',  
  101. 'A_Nextgen_Basic_Singlepic_Controller' => 'adapter.nextgen_basic_singlepic_controller.php',  
  102. 'A_Nextgen_Basic_Singlepic_Form' => 'adapter.nextgen_basic_singlepic_form.php',  
  103. 'C_NextGen_Basic_SinglePic_Installer' => 'class.nextgen_basic_singlepic_installer.php',  
  104. 'A_Nextgen_Basic_Singlepic_Mapper' => 'adapter.nextgen_basic_singlepic_mapper.php' 
  105. );