PluginProbe
CSS & JavaScript Toolbox / 9.3
CSS & JavaScript Toolbox v9.3
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / access.points / ajax.accesspoint.php

ajax.accesspoint.php in CSS & JavaScript Toolbox 9.3, at access.points/ajax.accesspoint.php

77 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 // Disallow direct access.
7 defined('ABSPATH') or die("Access denied");
8
9 /**
10 *
11 */
12 class CJTAjaxAccessPoint extends CJTAccessPoint {
13
14 /**
15 * put your comment there...
16 *
17 */
18 public function __construct() {
19 // Initialize Access Point base!
20 parent::__construct();
21 // Set access point name!
22 $this->name = 'ajax';
23 }
24
25 /**
26 * put your comment there...
27 *
28 */
29 protected function doListen() {
30 // Define CJT AJAX access point!
31 add_action("wp_ajax_{$this->pageId}_api", array(&$this, 'route'), 10, 0);
32 }
33
34 /**
35 * put your comment there...
36 *
37 */
38 public function route($loadView = null, $request = null) {
39 // Initializing!
40 $controller = false;
41 // Controllers allowed to be Loaded if not installed
42 $notInstalledAllowedControllers = array('installer', 'setup');
43 // Veil access point unless CJT installed or the controller is installer (to allow instalaltion throught AJAX)!
44 if (CJTPlugin::getInstance()->isInstalled() || in_array($this->controllerName, $notInstalledAllowedControllers)) {
45 // Connected!
46 $this->connected();
47 // IF Module-Prefix passed THEN Point to correct Controller path
48 if (isset($_REQUEST['cjtajaxmodule'])) {
49 # try to get module associated to passed module
50 $accessPointClassLoader = CJT_Framework_Autoload_Loader::autoLoad($_REQUEST['cjtajaxmodule']);
51
52 // CODE MODIFIED BY RBJ -- START
53 if ($accessPointClassLoader) {
54 if ($_REQUEST['cjtajaxmodule'] == 'ECMEHD') {
55 $this->overrideControllersPath = dirname(__DIR__) . '-plus/CJTEnv/controllers';
56 } else {
57 $this->overrideControllersPath = $accessPointClassLoader->getPath() . DIRECTORY_SEPARATOR . 'controllers';
58 }
59 $this->overrideControllersPrefix = $accessPointClassLoader->getPrefix();
60 }
61 // CODE MODIFIED BY RBJ -- END
62 }
63 // Instantiate controller.
64 $controller = parent::route($loadView, $request);
65 // Dispatch the call as its originally requested from ajax action!
66 $action = "wp_ajax_{$this->pageId}_{$_REQUEST['CJTAjaxAction']}";
67 // Fire Ajax action.
68 do_action($action);
69 }
70 return $controller;
71 }
72
73 } // End class.
74
75 // Hookable!
76 CJTAjaxAccessPoint::define('CJTAjaxAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
77