M_Ajax

The NextGEN Gallery M Ajax class.

Defined (1)

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

/products/photocrati_nextgen/modules/ajax/module.ajax.php  
  1. class M_Ajax 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-ajax',  
  12. 'AJAX',  
  13. 'Provides AJAX functionality',  
  14. '0.10',  
  15. 'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',  
  16. 'Imagely',  
  17. 'https://www.imagely.com' 
  18. ); 
  19. C_NextGen_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array( 
  20. 'ajax_slug',  
  21. 'ajax_url',  
  22. 'ajax_js_url' 
  23. )); 
  24.  
  25. if (is_multisite()) C_NextGen_Global_Settings::get_instance()->add_option_handler('C_Ajax_Option_Handler', array( 
  26. 'ajax_slug',  
  27. 'ajax_url',  
  28. 'ajax_js_url' 
  29. )); 
  30.  
  31. function _register_utilities() 
  32. $this->get_registry()->add_utility('I_Ajax_Controller', 'C_Ajax_Controller'); 
  33.  
  34.  
  35. /** 
  36. * Hooks into the WordPress framework 
  37. */ 
  38. function _register_hooks() 
  39. add_action('init', array(get_class(), 'register_scripts'), 9); 
  40. add_action('ngg_routes', array(&$this, 'define_routes')); 
  41. add_action('init', array(&$this, 'serve_ajax_request')); 
  42.  
  43. function serve_ajax_request() 
  44. if (isset($_REQUEST[NGG_AJAX_SLUG])) { 
  45. $controller = C_Ajax_Controller::get_instance(); 
  46. $controller->index_action(); 
  47. // E_Clean_Exit may cause a warning to be appended to our response, spoiling any JSON sent 
  48. exit; 
  49.  
  50. function define_routes($router) 
  51. $app = $router->create_app('/photocrati_ajax'); 
  52. $app->route('/', 'I_Ajax_Controller#index'); 
  53.  
  54. /** 
  55. * Loads a single script to provide the photocrati_ajax settings to the web browser 
  56. */ 
  57. static function register_scripts() 
  58. $settings = C_NextGen_Settings::get_instance(); 
  59. $router = C_Router::get_instance(); 
  60.  
  61. wp_register_script('photocrati_ajax', $router->get_static_url('photocrati-ajax#ajax.min.js'), array('jquery'), NGG_SCRIPT_VERSION); 
  62.  
  63. $vars = array( 
  64. 'url' => $settings->get('ajax_url'),  
  65. 'wp_home_url' => $router->get_base_url('home'),  
  66. 'wp_site_url' => $router->get_base_url('site'),  
  67. 'wp_root_url' => $router->get_base_url('root'),  
  68. 'wp_plugins_url' => $router->get_base_url('plugins'),  
  69. 'wp_content_url' => $router->get_base_url('content'),  
  70. 'wp_includes_url' => includes_url(),  
  71. 'ngg_param_slug' => C_NextGen_Settings::get_instance()->get('router_param_slug', 'nggallery') 
  72. ); 
  73. wp_localize_script('photocrati_ajax', 'photocrati_ajax', $vars); 
  74.  
  75. function get_type_list() 
  76. return array( 
  77. 'C_Ajax_Installer' => 'class.ajax_installer.php',  
  78. 'C_Ajax_Controller' => 'class.ajax_controller.php',  
  79. 'M_Ajax' => 'module.ajax.php' 
  80. );