PluginProbe
CSS & JavaScript Toolbox / 10
CSS & JavaScript Toolbox v10
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
← All changes | framework/mvc/controller.inc.php +71 -73 1210 View file →
@@ -11,43 +11,43 @@
11 11 /**
12 12 * CJT controller base class.
13 13 */
14 14 abstract class CJTController extends CJTHookableClass {
15 -
15 +
16 16 /** */
17 17 const NONCE_ACTION = 'cjtoolbox';
18 -
18 +
19 19 /**
20 20 * put your comment there...
21 - *
21 + *
22 22 * @var mixed
23 23 */
24 24 protected $action;
25 -
25 +
26 26 /**
27 27 * put your comment there...
28 - *
28 + *
29 29 * @var mixed
30 30 */
31 31 protected $controllerInfo = null;
32 -
32 +
33 33 /**
34 34 * put your comment there...
35 - *
35 + *
36 36 * @var mixed
37 37 */
38 38 protected $defaultAction = 'index';
39 -
39 +
40 40 /**
41 41 * put your comment there...
42 - *
42 + *
43 43 * @var mixed
44 44 */
45 45 protected $request;
46 -
46 +
47 47 /**
48 48 * put your comment there...
49 - *
49 + *
50 50 * @var mixed
51 51 */
52 52 protected $model = null;
53 53
@@ -52,51 +52,51 @@
52 52 protected $model = null;
53 53
54 54 /**
55 55 * put your comment there...
56 - *
56 + *
57 57 * @var mixed
58 58 */
59 59 protected $oncallback = array('parameters' => array('callback', 'action', 'args'));
60 -
60 +
61 61 /**
62 62 * put your comment there...
63 - *
63 + *
64 64 * @var mixed
65 65 */
66 66 protected $ongetactionname = array('parameters' => array('action'));
67 -
67 +
68 68 /**
69 69 * put your comment there...
70 - *
70 + *
71 71 * @var mixed
72 72 */
73 73 protected static $ongetclassname = array('parameters' => array('class', 'name', 'type'));
74 -
74 +
75 75 /**
76 76 * put your comment there...
77 - *
77 + *
78 78 * @var mixed
79 79 */
80 80 protected $ongetviewname = array('parameters' => array('view'));
81 -
81 +
82 82 /**
83 83 * put your comment there...
84 - *
84 + *
85 85 * @var mixed
86 86 */
87 87 protected static $onloadcontroller = array('parameters' => array('file', 'name'));
88 -
88 +
89 89 /**
90 90 * put your comment there...
91 - *
91 + *
92 92 * @var mixed
93 93 */
94 94 protected $view = null;
95 -
95 +
96 96 /**
97 97 * put your comment there...
98 - *
98 + *
99 99 * @param mixed $hasView
100 100 * @param mixed $request
101 101 * @param mixed $overrideControllerPath
102 102 * @param mixed $overrideContollerPrefix
@@ -101,18 +101,16 @@
101 101 * @param mixed $overrideControllerPath
102 102 * @param mixed $overrideContollerPrefix
103 103 * @return CJTController
104 104 */
105 - public function __construct($hasView = null,
106 - $request = null,
107 - $overrideControllerPath = '',
105 + public function __construct($hasView = null,
106 + $request = null,
107 + $overrideControllerPath = null,
108 108 $overrideContollerPrefix = null) {
109 109 // Initialize hookable!
110 110 parent::__construct();
111 111 // Read request parameters.
112 112 $this->request = array_merge(((array) $_REQUEST), ((array) $request));
113 -
114 - $overrideControllerPath = $overrideControllerPath ? null : '';
115 113 // Create default model.
116 114 if (isset($this->controllerInfo['model'])) {
117 115 // E_ALL complain!
118 116 if (!isset($this->controllerInfo['model_file'])) {
@@ -117,10 +115,10 @@
117 115 // E_ALL complain!
118 116 if (!isset($this->controllerInfo['model_file'])) {
119 117 $this->controllerInfo['model_file'] = null;
120 118 }
121 - $this->model = CJTModel::create($this->controllerInfo['model'],
122 - $this->request,
119 + $this->model = CJTModel::create($this->controllerInfo['model'],
120 + $this->request,
123 121 $this->controllerInfo['model_file'],
124 122 dirname($overrideControllerPath),
125 123 $overrideContollerPrefix);
126 124 }
@@ -126,14 +124,14 @@
126 124 }
127 125 // Create default view.
128 126 if ($hasView === null) { // Default value for $hasView = true
129 127 // Request/passed parameters has priority over controller default view!
130 - $view = $this->ongetviewname(isset($this->request['view']) ? esc_html($this->request['view']) :
128 + $view = $this->ongetviewname(isset($this->request['view']) ? $this->request['view'] :
131 129 (isset($this->controllerInfo['view']) ? $this->controllerInfo['view'] : null)
132 130 );
133 131 if ($view) {
134 - $this->view = self::getView($view,
135 - null,
132 + $this->view = self::getView($view,
133 + null,
136 134 dirname($overrideControllerPath),
137 135 $overrideContollerPrefix)
138 136 // Push data into view.
139 137 ->setModel($this->model)
@@ -140,18 +138,18 @@
140 138 ->setRequest($this->request);
141 139 }
142 140 }
143 141 }
144 -
142 +
145 143 /**
146 144 * put your comment there...
147 - *
145 + *
148 146 */
149 147 public function _doAction() {
150 148 // Force use of internal action untless its empty
151 149 // then look for submitted action or get the default!
152 - $action = $this->action ? $this->action :
153 - (isset($_GET['action']) ? esc_html($_GET['action']) : $this->defaultAction);
150 + $action = $this->action ? $this->action :
151 + (isset($_GET['action']) ? $_GET['action'] : $this->defaultAction);
154 152 // filter action name!
155 153 $action = $this->ongetactionname($action);
156 154 if ($action) {
157 155 $actionHandler = "{$action}Action";
@@ -160,12 +158,12 @@
160 158 // Callback!
161 159 call_user_func($callback);
162 160 }
163 161 }
164 -
162 +
165 163 /**
166 164 * put your comment there...
167 - *
165 + *
168 166 * @param mixed $name
169 167 * @param mixed $hasView
170 168 * @param mixed $request
171 169 * @param mixed $overrideControllersPath
@@ -170,11 +168,11 @@
170 168 * @param mixed $request
171 169 * @param mixed $overrideControllersPath
172 170 * @param mixed $overrideControllersPrefix
173 171 */
174 - public static function create($name,
175 - $hasView = null,
176 - $request = null,
172 + public static function create($name,
173 + $hasView = null,
174 + $request = null,
177 175 $overrideControllersPath = null,
178 176 $overrideControllersPrefix = null) {
179 177 // Import controller file.
180 178 $pathToControllers = $overrideControllersPath ? $overrideControllersPath : CJTOOLBOX_CONTROLLERS_PATH;
@@ -184,12 +182,12 @@
184 182 $class = self::getClassName($name, 'Controller', $overrideControllersPrefix);
185 183 // Instantiate controller class.
186 184 return new $class($hasView, $request, $overrideControllersPath, $overrideControllersPrefix);
187 185 }
188 -
186 +
189 187 /**
190 188 * put your comment there...
191 - *
189 + *
192 190 * @deprecated Use cssJSToolbox::createSecurityToken
193 191 */
194 192 public function createSecurityToken() {
195 193 return wp_create_nonce(self::NONCE_ACTION);
@@ -196,13 +194,13 @@
196 194 }
197 195
198 196 /**
199 197 * put your comment there...
200 - *
198 + *
201 199 */
202 200 protected function displayAction() {
203 201 // Get view layout!
204 - $layout = isset($this->request['layout']) ? esc_html($this->request['layout']) : 'default';
202 + $layout = isset($this->request['layout']) ? $this->request['layout'] : 'default';
205 203 ob_start();
206 204 $this->view->display($layout);
207 205 $content = ob_get_clean();
208 206 return $content;
@@ -209,9 +207,9 @@
209 207 }
210 208
211 209 /**
212 210 * put your comment there...
213 - *
211 + *
214 212 * @param mixed $name
215 213 * @param mixed $hasView
216 214 * @param mixed $request
217 215 * @param mixed $overrideControllersPath
@@ -216,22 +214,22 @@
216 214 * @param mixed $request
217 215 * @param mixed $overrideControllersPath
218 216 */
219 217 public static function getInstance($name,
220 - $hasView = null,
221 - $request = null,
218 + $hasView = null,
219 + $request = null,
222 220 $overrideControllersPath = null,
223 221 $overrideControllersPrefix = null) {
224 222 return self::create($name, $hasView, $request, $overrideControllersPath, $overrideControllersPrefix);
225 223 }
226 -
224 +
227 225 /**
228 226 * Use CJTModel::create instead.
229 - *
227 + *
230 228 * @deprecated No longer used.
231 229 */
232 - public static function getModel($name,
233 - $params = array(),
230 + public static function getModel($name,
231 + $params = array(),
234 232 $file = null,
235 233 $overrideModelsPath = null,
236 234 $overrideModelsPrefix = null) {
237 235 $model = null;
@@ -249,9 +247,9 @@
249 247 }
250 248 $model = new $modelClass($params);
251 249 return $model;
252 250 }
253 -
251 +
254 252 /**
255 253 * @deprecated No longer used.
256 254 */
257 255 public static function getClassName($name, $type, $prefix = null) {
@@ -268,27 +266,27 @@
268 266 // Filter.
269 267 $className = self::trigger('CJTController.getclassname', "{$prefix}{$sanitizedName}", $name, $type);
270 268 return $className;
271 269 }
272 -
270 +
273 271 /**
274 272 * put your comment there...
275 - *
273 + *
276 274 * @param mixed $name
277 275 */
278 276 public function getRequestParameter($name) {
279 - return isset($this->request[$name]) ? esc_html($this->request[$name]) : null;
277 + return isset($this->request[$name]) ? $this->request[$name] : null;
280 278 }
281 -
279 +
282 280 /**
283 - *
281 + *
284 282 * Use CJTView:create instrad.
285 - *
283 + *
286 284 * @deprecated
287 285 */
288 - public static function getView($path,
289 - $params = null,
290 - $overrideViewsPath = null,
286 + public static function getView($path,
287 + $params = null,
288 + $overrideViewsPath = null,
291 289 $overrideViewsPrefix = null) {
292 290 $view = null;
293 291 // Import view file.
294 292 $viewInfo = self::getViewInfo($path, $overrideViewsPath, $overrideViewsPrefix);
@@ -298,16 +296,16 @@
298 296 $viewClass = self::getClassName($name, 'view', $overrideViewsPrefix);
299 297 $view = new $viewClass($viewInfo, $params);
300 298 return $view;
301 299 }
302 -
300 +
303 301 /**
304 302 * put your comment there...
305 - *
303 + *
306 304 */
307 305 public static function getViewInfo($path, $overrideViewsPath = null, $overrideViewsPrefix = null) {
308 306 // Plugin views Url
309 - $viewsUrl = $overrideViewsPath ?
307 + $viewsUrl = $overrideViewsPath ?
310 308 WP_PLUGIN_URL . '/' . basename(dirname($overrideViewsPath)) :
311 309 CJTOOLBOX_VIEWS_URL;
312 310 // Path to views dir.
313 311 $pathToViews = $overrideViewsPath ? ($overrideViewsPath . DIRECTORY_SEPARATOR . 'views') : CJTOOLBOX_VIEWS_PATH;
@@ -323,12 +321,12 @@
323 321 'viewFile' => "{$pathToViews}/{$path}/view.php",
324 322 );
325 323 return $viewInfo;
326 324 }
327 -
325 +
328 326 /**
329 327 * put your comment there...
330 - *
328 + *
331 329 * @param mixed $action
332 330 */
333 331 public function setAction($action) {
334 332 $this->action = $action;
@@ -333,12 +331,12 @@
333 331 public function setAction($action) {
334 332 $this->action = $action;
335 333 return $this;
336 334 }
337 -
335 +
338 336 /**
339 337 * put your comment there...
340 - *
338 + *
341 339 * @param mixed $name
342 340 * @param mixed $value
343 341 */
344 342 public function setRequestParameter($name, $value) {
@@ -344,9 +342,9 @@
344 342 public function setRequestParameter($name, $value) {
345 343 $this->request[$name] = $value;
346 344 return $this;
347 345 }
348 -
346 +
349 347 } // End class.
350 348
351 349 // Hookable!
352 -CJTController::define('CJTController', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
350 +CJTController::define('CJTController', array('hookType' => CJTWordpressEvents::HOOK_FILTER));