mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
c000940e36
Closes #2213, Support multiple plugin paths. Closes #2234, filepaths to behavior classes should be cached in class.paths.php also Closes #2345, ability to group components into subfolders Closes #2645, Improvement to basic.php for class loading. Fixes #3526, Cache::write, when using just the config name, it fails. Fixes #3559, loading plugin model as assoc don't work. Closes #3567 Controller Folders (Note this does not need routing to work, but controller names can not conflict with others in the same application so naming must still be unique) Fixes #3579, email.php component: Parse error with php 4. Adding new class and file importer. Updated most of the core to use the importer. Added ClassRegsitry::init() that will create and instance of an object and store it in the registry. Deprecated most of the load functions in basics.php Plugin model loading now forces using the dot notation, to use models within a plugin, all the model associations must be in the PluginName.Model syntax, if this is not used, the plugin will look for the models in the main app/models directory first, if not found then it will search the plugin directories recursively until it finds a model. var $belongsTo = array('SomeModel'); will look for some_model.php in the app/models var $belongsTo = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models var $belongsTo = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php The controllers of the plugin will still look for the default models inside the plugin if var $uses is not set: var $uses = array('SomeModel'); will look for some_model.php in the app/models var $uses = array('MyPlugin.SomeModel'); will look for some_model.php in my_plugin/models var $uses = array('MyPlugin.MyPlugin', 'SomeModel'); will used my_plugin/models/my_plugin.php and app/models/some_model.php All of the above will work between plugins and main app These changes also allow placing model and controllers is sub directories Removed old class.paths.php file generation git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6001 3807eeeb-6ff5-0310-8944-8be069107fe0
396 lines
No EOL
11 KiB
PHP
396 lines
No EOL
11 KiB
PHP
<?php
|
|
/* SVN FILE: $Id$ */
|
|
/**
|
|
* Short description for file.
|
|
*
|
|
* Long description for file
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
|
|
* Copyright 2005-2007, 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-2007, 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$
|
|
* @modifiedby $LastChangedBy$
|
|
* @lastmodified $Date$
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
*/
|
|
uses('sanitize');
|
|
/**
|
|
* 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) {
|
|
parent::__construct();
|
|
static $__previousError = null;
|
|
|
|
$allow = array('.', '/', '_', ' ', '-', '~');
|
|
if (substr(PHP_OS,0,3) == "WIN") {
|
|
$allow = array_merge($allow, array('\\', ':') );
|
|
}
|
|
$clean = new Sanitize();
|
|
$messages = $clean->paranoid($messages, $allow);
|
|
if (!class_exists('dispatcher')) {
|
|
require CAKE . 'dispatcher.php';
|
|
}
|
|
$this->__dispatch =& new Dispatcher();
|
|
if (!class_exists('appcontroller')) {
|
|
App::import('Controller', 'App');
|
|
}
|
|
|
|
if ($__previousError != array($method, $messages)) {
|
|
$__previousError = array($method, $messages);
|
|
|
|
$this->controller =& new AppController();
|
|
if (!empty($this->controller->uses)) {
|
|
$this->controller->constructClasses();
|
|
}
|
|
$this->controller->_initComponents();
|
|
$this->controller->cacheAction = false;
|
|
$this->__dispatch->start($this->controller);
|
|
|
|
if (method_exists($this->controller, 'apperror')) {
|
|
return $this->controller->appError($method, $messages);
|
|
}
|
|
} else {
|
|
$this->controller =& new AppController();
|
|
$this->controller->cacheAction = false;
|
|
}
|
|
if (Configure::read() > 0 || $method == 'error') {
|
|
call_user_func_array(array(&$this, $method), $messages);
|
|
} else {
|
|
call_user_func_array(array(&$this, 'error404'), $messages);
|
|
}
|
|
}
|
|
/**
|
|
* Displays an error page (e.g. 404 Not found).
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function error($params) {
|
|
extract($params);
|
|
$this->controller->base = $base;
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->set(array('code' => $code,
|
|
'name' => $name,
|
|
'message' => $message,
|
|
'title' => $code . ' ' . $name));
|
|
$this->controller->render('error404');
|
|
exit();
|
|
}
|
|
/**
|
|
* Convenience method to display a 404 page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function error404($params) {
|
|
extract($params);
|
|
|
|
if (!isset($url)) {
|
|
$url = $action;
|
|
}
|
|
if (!isset($message)) {
|
|
$message = '';
|
|
}
|
|
if (!isset($base)) {
|
|
$base = '';
|
|
}
|
|
|
|
header("HTTP/1.0 404 Not Found");
|
|
$this->error(array('code' => '404',
|
|
'name' => __('Not Found', true),
|
|
'message' => sprintf(__("The requested address %s was not found on this server.", true), "<strong>'{$url}'</strong>", $message),
|
|
'base' => $base));
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Controller web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingController($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->webroot = $webroot;
|
|
$this->controller->viewPath ='errors';
|
|
$controllerName = str_replace('Controller', '', $className);
|
|
$this->controller->set(array('controller' => $className,
|
|
'controllerName' => $controllerName,
|
|
'title' => __('Missing Controller', true)));
|
|
$this->controller->render('missingController');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Action web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingAction($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->webroot = $webroot;
|
|
$this->controller->viewPath = 'errors';
|
|
$controllerName = str_replace('Controller', '', $className);
|
|
$this->controller->set(array('controller' => $className,
|
|
'controllerName' => $controllerName,
|
|
'action' => $action,
|
|
'title' => __('Missing Method in Controller', true)));
|
|
$this->controller->render('missingAction');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Private Action web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function privateAction($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->webroot = $webroot;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->set(array('controller' => $className,
|
|
'action' => $action,
|
|
'title' => __('Trying to access private method in class', true)));
|
|
$this->controller->render('privateAction');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Table web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingTable($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('model' => $className,
|
|
'table' => $table,
|
|
'title' => __('Missing Database Table', true)));
|
|
$this->controller->render('missingTable');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Database web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingDatabase($params = array()) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('title' => __('Scaffold Missing Database Connection', true)));
|
|
$this->controller->render('missingScaffolddb');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing View web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingView($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('controller' => $className,
|
|
'action' => $action,
|
|
'file' => $file,
|
|
'title' => __('Missing View', true)));
|
|
$this->controller->render('missingView');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Layout web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingLayout($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->layout = 'default';
|
|
$this->controller->set(array('file' => $file,
|
|
'title' => __('Missing Layout', true)));
|
|
$this->controller->render('missingLayout');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Database Connection web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingConnection($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('model' => $className,
|
|
'title' => __('Missing Database Connection', true)));
|
|
$this->controller->render('missingConnection');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Helper file web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingHelperFile($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
|
|
'file' => $file,
|
|
'title' => __('Missing Helper File', true)));
|
|
$this->controller->render('missingHelperFile');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Helper class web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingHelperClass($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('helperClass' => Inflector::camelize($helper) . "Helper",
|
|
'file' => $file,
|
|
'title' => __('Missing Helper Class', true)));
|
|
$this->controller->render('missingHelperClass');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Component file web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingComponentFile($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('controller' => $className,
|
|
'component' => $component,
|
|
'file' => $file,
|
|
'title' => __('Missing Component File', true)));
|
|
$this->controller->render('missingComponentFile');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Component class web page.
|
|
*
|
|
* @param array $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingComponentClass($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('controller' => $className,
|
|
'component' => $component,
|
|
'file' => $file,
|
|
'title' => __('Missing Component Class', true)));
|
|
$this->controller->render('missingComponentClass');
|
|
exit();
|
|
}
|
|
/**
|
|
* Renders the Missing Model class web page.
|
|
*
|
|
* @param unknown_type $params Parameters for controller
|
|
* @access public
|
|
*/
|
|
function missingModel($params) {
|
|
extract(Router::getPaths());
|
|
extract($params, EXTR_OVERWRITE);
|
|
|
|
$this->controller->base = $base;
|
|
$this->controller->viewPath = 'errors';
|
|
$this->controller->webroot = $this->_webroot();
|
|
$this->controller->set(array('model' => $className,
|
|
'title' => __('Missing Model', true)));
|
|
$this->controller->render('missingModel');
|
|
exit();
|
|
}
|
|
/**
|
|
* Path to the web root.
|
|
*
|
|
* @return string full web root path
|
|
* @access private
|
|
*/
|
|
function _webroot() {
|
|
$this->__dispatch->baseUrl();
|
|
return $this->__dispatch->webroot;
|
|
}
|
|
}
|
|
?>
|