PluginProbe
CSS & JavaScript Toolbox / 7.1
CSS & JavaScript Toolbox v7.1
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 7.1, at framework/access-points/access-point.class.php

194 lines 3.4 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 $pageId = CJTPlugin::PLUGIN_REQUEST_ID;
89
90 /**
91 * put your comment there...
92 *
93 */
94 public function __construct($defaultController = 'blocks') {
95 // Initialize Hookable.
96 parent::__construct();
97 // Initialize!
98 $this->controllerName = $this->ongetdefaultcontrollername(isset($_REQUEST['controller']) ? $_REQUEST['controller'] : $defaultController);
99 }
100
101 /**
102 * put your comment there...
103 *
104 * @return Boolean TRUE if it wasn't connected! FALSE otherwise.
105 */
106 protected function connected() {
107 // Do connect only if not connected yet
108 if ($returns = !self::$connected) {
109 // Fire connected event!
110 $this->onconnected(true);
111 // Set current instance as the connected object!
112 self::$connected = $this;
113 }
114 return $returns;
115 }
116
117 /**
118 * put your comment there...
119 *
120 */
121 protected abstract function doListen();
122
123 /**
124 * put your comment there...
125 *
126 */
127 public function & getController() {
128 return $this->controller;
129 }
130
131 /**
132 * put your comment there...
133 *
134 */
135 public function getControllerName() {
136 return $this->controllerName;
137 }
138
139 /**
140 * put your comment there...
141 *
142 */
143 public function getName() {
144 return $this->name;
145 }
146
147 /**
148 * put your comment there...
149 *
150 */
151 public static function & isConnected() {
152 return self::$connected;
153 }
154
155 /**
156 * put your comment there...
157 *
158 */
159 public function hasAccess() {
160 return current_user_can('administrator');
161 }
162
163 /**
164 * put your comment there...
165 *
166 */
167 public function listen() {
168 // Fire listen event!
169 $this->onlisten();
170 // Allow access points to bind their hooks
171 $this->doListen();
172 return $this;
173 }
174
175 /**
176 * put your comment there...
177 *
178 * @param mixed $request
179 */
180 public function route($loadView = null, $request = null) {
181 // Only loading one controller is allowed.
182 if (!$this->controller) {
183 // Import view class.
184 require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php';
185 // Instantiate controller!
186 $this->controller = $this->onsetcontroller(CJTController::getInstance($this->controllerName, $loadView, $request));
187 }
188 return $this->controller;
189 }
190
191 } // End class.
192
193 // Hookable!
194 CJTAccessPoint::define('CJTAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER));