PluginProbe
CSS & JavaScript Toolbox / 6.0.6
CSS & JavaScript Toolbox v6.0.6
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 +26 -66 106.0.6 View file →
@@ -97,16 +97,11 @@
97 97 * put your comment there...
98 98 *
99 99 * @param mixed $hasView
100 100 * @param mixed $request
101 - * @param mixed $overrideControllerPath
102 - * @param mixed $overrideContollerPrefix
103 101 * @return CJTController
104 102 */
105 - public function __construct($hasView = null,
106 - $request = null,
107 - $overrideControllerPath = null,
108 - $overrideContollerPrefix = null) {
103 + public function __construct($hasView = null, $request = null) {
109 104 // Initialize hookable!
110 105 parent::__construct();
111 106 // Read request parameters.
112 107 $this->request = array_merge(((array) $_REQUEST), ((array) $request));
@@ -115,13 +110,9 @@
115 110 // E_ALL complain!
116 111 if (!isset($this->controllerInfo['model_file'])) {
117 112 $this->controllerInfo['model_file'] = null;
118 113 }
119 - $this->model = CJTModel::create($this->controllerInfo['model'],
120 - $this->request,
121 - $this->controllerInfo['model_file'],
122 - dirname($overrideControllerPath),
123 - $overrideContollerPrefix);
114 + $this->model = CJTModel::create($this->controllerInfo['model'], array(), $this->controllerInfo['model_file']);
124 115 }
125 116 // Create default view.
126 117 if ($hasView === null) { // Default value for $hasView = true
127 118 // Request/passed parameters has priority over controller default view!
@@ -128,12 +119,9 @@
128 119 $view = $this->ongetviewname(isset($this->request['view']) ? $this->request['view'] :
129 120 (isset($this->controllerInfo['view']) ? $this->controllerInfo['view'] : null)
130 121 );
131 122 if ($view) {
132 - $this->view = self::getView($view,
133 - null,
134 - dirname($overrideControllerPath),
135 - $overrideContollerPrefix)
123 + $this->view = self::getView($view)
136 124 // Push data into view.
137 125 ->setModel($this->model)
138 126 ->setRequest($this->request);
139 127 }
@@ -162,27 +150,22 @@
162 150
163 151 /**
164 152 * put your comment there...
165 153 *
154 + * @deprecated Use CJTController::getInstance() instead!
155 + *
166 156 * @param mixed $name
167 - * @param mixed $hasView
168 157 * @param mixed $request
169 - * @param mixed $overrideControllersPath
170 - * @param mixed $overrideControllersPrefix
171 158 */
172 - public static function create($name,
173 - $hasView = null,
174 - $request = null,
175 - $overrideControllersPath = null,
176 - $overrideControllersPrefix = null) {
159 + public static function create($name, $hasView = null, $request = null) {
177 160 // Import controller file.
178 - $pathToControllers = $overrideControllersPath ? $overrideControllersPath : CJTOOLBOX_CONTROLLERS_PATH;
161 + $pathToControllers = CJTOOLBOX_CONTROLLERS_PATH;
179 162 $controllerFile = "{$pathToControllers}/{$name}.php";
180 163 require_once self::trigger('CJTController.loadcontroller', $controllerFile, $name);
181 164 // Get controller class name.
182 - $class = self::getClassName($name, 'Controller', $overrideControllersPrefix);
165 + $class = self::getClassName($name, 'Controller');
183 166 // Instantiate controller class.
184 - return new $class($hasView, $request, $overrideControllersPath, $overrideControllersPrefix);
167 + return new $class($hasView, $request);
185 168 }
186 169
187 170 /**
188 171 * put your comment there...
@@ -198,15 +181,15 @@
198 181 *
199 182 */
200 183 protected function displayAction() {
201 184 // Get view layout!
202 - $layout = isset($this->request['layout']) ? $this->request['layout'] : 'default';
185 + $layout = isset($_REQUEST['layout']) ? $_REQUEST['layout'] : 'default';
203 186 ob_start();
204 187 $this->view->display($layout);
205 188 $content = ob_get_clean();
206 189 return $content;
207 190 }
208 -
191 +
209 192 /**
210 193 * put your comment there...
211 194 *
212 195 * @param mixed $name
@@ -211,16 +194,11 @@
211 194 *
212 195 * @param mixed $name
213 196 * @param mixed $hasView
214 197 * @param mixed $request
215 - * @param mixed $overrideControllersPath
216 198 */
217 - public static function getInstance($name,
218 - $hasView = null,
219 - $request = null,
220 - $overrideControllersPath = null,
221 - $overrideControllersPrefix = null) {
222 - return self::create($name, $hasView, $request, $overrideControllersPath, $overrideControllersPrefix);
199 + public static function getInstance($name, $hasView = null, $request = null) {
200 + return self::create($name, $hasView, $request);
223 201 }
224 202
225 203 /**
226 204 * Use CJTModel::create instead.
@@ -226,15 +204,11 @@
226 204 * Use CJTModel::create instead.
227 205 *
228 206 * @deprecated No longer used.
229 207 */
230 - public static function getModel($name,
231 - $params = array(),
232 - $file = null,
233 - $overrideModelsPath = null,
234 - $overrideModelsPrefix = null) {
208 + public static function getModel($name, $params = array(), $file = null) {
235 209 $model = null;
236 - $pathToModels = $overrideModelsPath ? ($overrideModelsPath . DIRECTORY_SEPARATOR . 'models') : CJTOOLBOX_MODELS_PATH;
210 + $pathToModels = CJTOOLBOX_MODELS_PATH;
237 211 if (!$file) {
238 212 $file = $name;
239 213 }
240 214 // Import model file.
@@ -240,9 +214,9 @@
240 214 // Import model file.
241 215 $modelFile = "{$pathToModels}/{$file}.php";
242 216 require_once $modelFile;
243 217 // Create model object.
244 - $modelClass = self::getClassName($name, 'Model', $overrideModelsPrefix);
218 + $modelClass = self::getClassName($name, 'Model');
245 219 if (!class_exists($modelClass)) {
246 220 throw new Exception("Model class {$modelClass} doesn't exists!!!");
247 221 }
248 222 $model = new $modelClass($params);
@@ -251,21 +225,16 @@
251 225
252 226 /**
253 227 * @deprecated No longer used.
254 228 */
255 - public static function getClassName($name, $type, $prefix = null) {
256 - // Init vars
229 + public static function getClassName($name, $type) {
257 230 $className = '';
258 - // Getting default prefix
259 - if (!$prefix) {
260 - $prefix = 'CJT';
261 - }
262 231 // Every word start with uppercase character.
263 232 $sanitizedName = ucfirst(str_replace(array('-', '_'), ' ', "{$name} {$type}"));
264 233 // Remove spaces.
265 234 $sanitizedName = str_replace(' ', '', $sanitizedName);
266 235 // Filter.
267 - $className = self::trigger('CJTController.getclassname', "{$prefix}{$sanitizedName}", $name, $type);
236 + $className = self::trigger('CJTController.getclassname', "CJT{$sanitizedName}", $name, $type);
268 237 return $className;
269 238 }
270 239
271 240 /**
@@ -273,9 +242,9 @@
273 242 *
274 243 * @param mixed $name
275 244 */
276 245 public function getRequestParameter($name) {
277 - return isset($this->request[$name]) ? $this->request[$name] : null;
246 + return $this->request;
278 247 }
279 248
280 249 /**
281 250 *
@@ -282,20 +251,17 @@
282 251 * Use CJTView:create instrad.
283 252 *
284 253 * @deprecated
285 254 */
286 - public static function getView($path,
287 - $params = null,
288 - $overrideViewsPath = null,
289 - $overrideViewsPrefix = null) {
255 + public static function getView($path) {
290 256 $view = null;
291 257 // Import view file.
292 - $viewInfo = self::getViewInfo($path, $overrideViewsPath, $overrideViewsPrefix);
258 + $viewInfo = self::getViewInfo($path);
293 259 require_once $viewInfo['viewFile'];
294 260 // Create view object.
295 261 $name = str_replace(' ', '', ucwords(str_replace('/', ' ',$path)));
296 - $viewClass = self::getClassName($name, 'view', $overrideViewsPrefix);
297 - $view = new $viewClass($viewInfo, $params);
262 + $viewClass = self::getClassName($name, 'view');
263 + $view = new $viewClass($viewInfo);
298 264 return $view;
299 265 }
300 266
301 267 /**
@@ -301,24 +267,18 @@
301 267 /**
302 268 * put your comment there...
303 269 *
304 270 */
305 - public static function getViewInfo($path, $overrideViewsPath = null, $overrideViewsPrefix = null) {
306 - // Plugin views Url
307 - $viewsUrl = $overrideViewsPath ?
308 - WP_PLUGIN_URL . '/' . basename(dirname($overrideViewsPath)) :
309 - CJTOOLBOX_VIEWS_URL;
271 + public static function getViewInfo($path) {
310 272 // Path to views dir.
311 - $pathToViews = $overrideViewsPath ? ($overrideViewsPath . DIRECTORY_SEPARATOR . 'views') : CJTOOLBOX_VIEWS_PATH;
273 + $pathToViews = CJTOOLBOX_VIEWS_PATH;
312 274 // Get view name.
313 275 $name = basename($path);
314 276 // View info struct.
315 277 $viewInfo = array(
316 278 'name' => $path,
317 - 'url' => "{$viewsUrl}/{$path}",
279 + 'url' => (CJTOOLBOX_VIEWS_URL . "/{$path}"),
318 280 'path' => "{$pathToViews}/{$path}",
319 - 'viewsPath' => $pathToViews,
320 - 'viewsUrl' => $viewsUrl,
321 281 'viewFile' => "{$pathToViews}/{$path}/view.php",
322 282 );
323 283 return $viewInfo;
324 284 }