1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
|
<?php
/* SVN FILE: $Id: error.php 7296 2008-06-27 09:09:03Z gwoo $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs
* @since CakePHP(tm) v 0.10.5.1732
* @version $Revision: 7296 $
* @modifiedby $LastChangedBy: gwoo $
* @lastmodified $Date: 2008-06-27 02:09:03 -0700 (Fri, 27 Jun 2008) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Controller', 'App');
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs
*/
class CakeErrorController extends AppController {
var $name = 'CakeError';
var $uses = array();
function __construct() {
parent::__construct();
$this->_set(Router::getPaths());
$this->params = Router::getParams();
$this->constructClasses();
$this->Component->initialize($this);
$this->_set(array('cacheAction' => false, 'viewPath' => 'errors'));
}
}
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs
*/
class ErrorHandler extends Object {
/**
* Controller instance.
*
* @var object
* @access public
*/
var $controller = null;
/**
* Class constructor.
*
* @param string $method Method producing the error
* @param array $messages Error messages
*/
function __construct($method, $messages) {
App::import('Core', 'Sanitize');
$this->controller =& new CakeErrorController();
$allow = array('.', '/', '_', ' ', '-', '~');
if (substr(PHP_OS, 0, 3) == "WIN") {
$allow = array_merge($allow, array('\\', ':'));
}
$messages = Sanitize::paranoid($messages, $allow);
if (!isset($messages[0])) {
$messages = array($messages);
}
if (method_exists($this->controller, 'apperror')) {
return $this->controller->appError($method, $messages);
}
if (!in_array(strtolower($method), array_map('strtolower', get_class_methods($this)))) {
$method = 'error';
}
if ($method !== 'error') {
if (Configure::read() == 0){
$method = 'error404';
if(isset($code) && $code == 500) {
$method = 'error500';
}
}
}
$this->dispatchMethod($method, $messages);
$this->_stop();
}
/**
* Displays an error page (e.g. 404 Not found).
*
* @param array $params Parameters for controller
* @access public
*/
function error($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array(
'code' => $code,
'name' => $name,
'message' => $message,
'title' => $code . ' ' . $name
));
$this->__outputMessage('error404');
}
/**
* Convenience method to display a 404 page.
*
* @param array $params Parameters for controller
* @access public
*/
function error404($params) {
extract($params, EXTR_OVERWRITE);
if (!isset($url)) {
$url = $this->controller->here;
}
$url = Router::normalize($url);
header("HTTP/1.0 404 Not Found");
$this->controller->set(array(
'code' => '404',
'name' => __('Not Found', true),
'message' => h($url),
'base' => $this->controller->base
));
$this->__outputMessage('error404');
}
/**
* Renders the Missing Controller web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingController($params) {
extract($params, EXTR_OVERWRITE);
$controllerName = str_replace('Controller', '', $className);
$this->controller->set(array('controller' => $className,
'controllerName' => $controllerName,
'title' => __('Missing Controller', true)));
$this->__outputMessage('missingController');
}
/**
* Renders the Missing Action web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingAction($params) {
extract($params, EXTR_OVERWRITE);
$controllerName = str_replace('Controller', '', $className);
$this->controller->set(array('controller' => $className,
'controllerName' => $controllerName,
'action' => $action,
'title' => __('Missing Method in Controller', true)));
$this->__outputMessage('missingAction');
}
/**
* Renders the Private Action web page.
*
* @param array $params Parameters for controller
* @access public
*/
function privateAction($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('controller' => $className,
'action' => $action,
'title' => __('Trying to access private method in class', true)));
$this->__outputMessage('privateAction');
}
/**
* Renders the Missing Table web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingTable($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('model' => $className,
'table' => $table,
'title' => __('Missing Database Table', true)));
$this->__outputMessage('missingTable');
}
/**
* Renders the Missing Database web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingDatabase($params = array()) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('title' => __('Scaffold Missing Database Connection', true)));
$this->__outputMessage('missingScaffolddb');
}
/**
* Renders the Missing View web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingView($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('controller' => $className,
'action' => $action,
'file' => $file,
'title' => __('Missing View', true)));
$this->__outputMessage('missingView');
}
/**
* Renders the Missing Layout web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingLayout($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->layout = 'default';
$this->controller->set(array('file' => $file,
'title' => __('Missing Layout', true)));
$this->__outputMessage('missingLayout');
}
/**
* Renders the Database Connection web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingConnection($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('model' => $className,
'title' => __('Missing Database Connection', true)));
$this->__outputMessage('missingConnection');
}
/**
* Renders the Missing Helper file web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingHelperFile($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
'file' => $file,
'title' => __('Missing Helper File', true)));
$this->__outputMessage('missingHelperFile');
}
/**
* Renders the Missing Helper class web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingHelperClass($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
'file' => $file,
'title' => __('Missing Helper Class', true)));
$this->__outputMessage('missingHelperClass');
}
/**
* Renders the Missing Component file web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingComponentFile($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('controller' => $className,
'component' => $component,
'file' => $file,
'title' => __('Missing Component File', true)));
$this->__outputMessage('missingComponentFile');
}
/**
* Renders the Missing Component class web page.
*
* @param array $params Parameters for controller
* @access public
*/
function missingComponentClass($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('controller' => $className,
'component' => $component,
'file' => $file,
'title' => __('Missing Component Class', true)));
$this->__outputMessage('missingComponentClass');
}
/**
* Renders the Missing Model class web page.
*
* @param unknown_type $params Parameters for controller
* @access public
*/
function missingModel($params) {
extract($params, EXTR_OVERWRITE);
$this->controller->set(array('model' => $className,
'title' => __('Missing Model', true)));
$this->__outputMessage('missingModel');
}
/**
* Output message
*
* @access private
*/
function __outputMessage($template) {
$this->controller->render($template);
$this->controller->afterFilter();
echo $this->controller->output;
}
}
?>
|