| @@ -103,16 +103,23 @@ | ||
| 103 | 103 | public function __construct($hasView = null, $request = null) { |
| 104 | 104 | // Initialize hookable! |
| 105 | 105 | parent::__construct(); |
| 106 | 106 | // Read request parameters. |
| 107 | - $this->request = $request ? $request : $_REQUEST; | |
| 107 | + $this->request = array_merge(((array) $_REQUEST), ((array) $request)); | |
| 108 | 108 | // Create default model. |
| 109 | 109 | if (isset($this->controllerInfo['model'])) { |
| 110 | - $this->model = CJTModel::create($this->controllerInfo['model'], array(), $this->controllerInfo['model_file']); | |
| 110 | + // E_ALL complain! | |
| 111 | + if (!isset($this->controllerInfo['model_file'])) { | |
| 112 | + $this->controllerInfo['model_file'] = null; | |
| 113 | + } | |
| 114 | + $this->model = CJTModel::create($this->controllerInfo['model'], $this->request, $this->controllerInfo['model_file']); | |
| 111 | 115 | } |
| 112 | 116 | // Create default view. |
| 113 | 117 | if ($hasView === null) { // Default value for $hasView = true |
| 114 | - $view = $this->ongetviewname($this->request['view'] ? $this->request['view'] : $this->controllerInfo['view']); | |
| 118 | + // Request/passed parameters has priority over controller default view! | |
| 119 | + $view = $this->ongetviewname(isset($this->request['view']) ? $this->request['view'] : | |
| 120 | + (isset($this->controllerInfo['view']) ? $this->controllerInfo['view'] : null) | |
| 121 | + ); | |
| 115 | 122 | if ($view) { |
| 116 | 123 | $this->view = self::getView($view) |
| 117 | 124 | // Push data into view. |
| 118 | 125 | ->setModel($this->model) |
| @@ -174,9 +181,9 @@ | ||
| 174 | 181 | * |
| 175 | 182 | */ |
| 176 | 183 | protected function displayAction() { |
| 177 | 184 | // Get view layout! |
| 178 | - $layout = isset($_REQUEST['layout']) ? $_REQUEST['layout'] : 'default'; | |
| 185 | + $layout = isset($this->request['layout']) ? $this->request['layout'] : 'default'; | |
| 179 | 186 | ob_start(); |
| 180 | 187 | $this->view->display($layout); |
| 181 | 188 | $content = ob_get_clean(); |
| 182 | 189 | return $content; |
| @@ -235,9 +242,9 @@ | ||
| 235 | 242 | * |
| 236 | 243 | * @param mixed $name |
| 237 | 244 | */ |
| 238 | 245 | public function getRequestParameter($name) { |
| 239 | - return $this->request; | |
| 246 | + return isset($this->request[$name]) ? $this->request[$name] : null; | |
| 240 | 247 | } |
| 241 | 248 | |
| 242 | 249 | /** |
| 243 | 250 | * |
| @@ -244,9 +251,9 @@ | ||
| 244 | 251 | * Use CJTView:create instrad. |
| 245 | 252 | * |
| 246 | 253 | * @deprecated |
| 247 | 254 | */ |
| 248 | - public static function getView($path) { | |
| 255 | + public static function getView($path, $params = null) { | |
| 249 | 256 | $view = null; |
| 250 | 257 | // Import view file. |
| 251 | 258 | $viewInfo = self::getViewInfo($path); |
| 252 | 259 | require_once $viewInfo['viewFile']; |
| @@ -252,9 +259,9 @@ | ||
| 252 | 259 | require_once $viewInfo['viewFile']; |
| 253 | 260 | // Create view object. |
| 254 | 261 | $name = str_replace(' ', '', ucwords(str_replace('/', ' ',$path))); |
| 255 | 262 | $viewClass = self::getClassName($name, 'view'); |
| 256 | - $view = new $viewClass($viewInfo); | |
| 263 | + $view = new $viewClass($viewInfo, $params); | |
| 257 | 264 | return $view; |
| 258 | 265 | } |
| 259 | 266 | |
| 260 | 267 | /** |