PluginProbe
CSS & JavaScript Toolbox / 11
CSS & JavaScript Toolbox v11
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 / framework / access-points / access-point.class.php

access-point.class.php in CSS & JavaScript Toolbox 11, at framework/access-points/access-point.class.php

221 lines 4.1 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 * Access Point interface
11 */
12 interface CJTIAccessPoint {
13
14 /**
15 * put your comment there...
16 *
17 */
18 public function listen();
19
20 }
21
22 /**
23 *
24 */
25 abstract class CJTAccessPoint extends CJTHookableClass implements CJTIAccessPoint {
26
27 /**
28 * put your comment there...
29 *
30 * @var mixed
31 */
32 protected static $connected;
33
34 /**
35 * put your comment there...
36 *
37 * @var mixed
38 */
39 protected $controller;
40
41 /**
42 * put your comment there...
43 *
44 * @var mixed
45 */
46 protected $controllerName;
47
48 /**
49 * put your comment there...
50 *
51 * @var mixed
52 */
53 protected $name;
54
55 /**
56 * put your comment there...
57 *
58 * @var mixed
59 */
60 protected $onconnected = array('parameters' => array('state'));
61
62 /**
63 * put your comment there...
64 *
65 * @var mixed
66 */
67 protected $ongetdefaultcontrollername = array('parameters' => array('controller'));
68
69 /**
70 * put your comment there...
71 *
72 * @var mixed
73 */
74 protected $onlisten = array('hookType' =>CJTWordpressEvents::HOOK_ACTION);
75
76 /**
77 * put your comment there...
78 *
79 * @var mixed
80 */
81 protected $onsetcontroller = array('parameters' => array('controller'));
82
83 /**
84 * put your comment there...
85 *
86 * @var mixed
87 */
88 protected $overrideControllersPath = null;
89
90 /**
91 * put your comment there...
92 *
93 * @var mixed
94 */
95 protected $overrideControllersPrefix = null;
96
97 /**
98 * put your comment there...
99 *
100 * @var mixed
101 */
102 protected $pageId = CJTPlugin::PLUGIN_REQUEST_ID;
103
104 /**
105 * put your comment there...
106 *
107 */
108 public function __construct($defaultController = 'blocks') {
109 // Initialize Hookable.
110 parent::__construct();
111 // Overrides controllers path using current Access Point model class path
112 $accessPointClassLoader =& CJT_Framework_Autoload_Loader::findClassLoader(get_class($this));
113 if ($accessPointClassLoader) {
114 $this->overrideControllersPath = $accessPointClassLoader->getPath() . DIRECTORY_SEPARATOR . 'controllers';
115 $this->overrideControllersPrefix = $accessPointClassLoader->getPrefix();
116 }
117 // Initialize!
118 $this->controllerName = $this->ongetdefaultcontrollername(isset($_REQUEST['controller']) ? $_REQUEST['controller'] : $defaultController);
119 }
120
121 /**
122 * put your comment there...
123 *
124 * @return Boolean TRUE if it wasn't connected! FALSE otherwise.
125 */
126 protected function connected() {
127 // Do connect only if not connected yet
128 if ($returns = !self::$connected) {
129 // Fire connected event!
130 $this->onconnected(true);
131 // Set current instance as the connected object!
132 self::$connected = $this;
133 }
134 return $returns;
135 }
136
137 /**
138 * put your comment there...
139 *
140 */
141 protected abstract function doListen();
142
143 /**
144 * put your comment there...
145 *
146 */
147 public function & getController() {
148 return $this->controller;
149 }
150
151 /**
152 * put your comment there...
153 *
154 */
155 public function getControllerName() {
156 return $this->controllerName;
157 }
158
159 /**
160 * put your comment there...
161 *
162 */
163 public function getName() {
164 return $this->name;
165 }
166
167 /**
168 * put your comment there...
169 *
170 */
171 public static function & isConnected() {
172 return self::$connected;
173 }
174
175 /**
176 * put your comment there...
177 *
178 */
179 public function hasAccess() {
180 return current_user_can('administrator');
181 }
182
183 /**
184 * put your comment there...
185 *
186 */
187 public function listen() {
188 // Fire listen event!
189 $this->onlisten();
190 // Allow access points to bind their hooks
191 $this->doListen();
192 return $this;
193 }
194
195 /**
196 * put your comment there...
197 *
198 * @param mixed $request
199 */
200 public function route($loadView = null, $request = null) {
201 // Only loading one controller is allowed.
202 if (!$this->controller) {
203 // Import view class.
204 require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php';
205 // Instantiate controller!
206 $this->controller = $this->onsetcontroller(
207 CJTController::getInstance(
208 $this->controllerName,
209 $loadView,
210 $request,
211 $this->overrideControllersPath,
212 $this->overrideControllersPrefix
213 ));
214 }
215 return $this->controller;
216 }
217
218 } // End class.
219
220 // Hookable!
221 CJTAccessPoint::define('CJTAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER));