M_Ajax

{ Module: photocrati-ajax, Depends: { photocrati-mvc } }.

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