mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merging fixes and enhancements into trunk.
Revision: [2098] Removed check for database class to load model classes from the models directory. Fixed missing views not being found. Revision: [2097] Fixed the WWW_ROOT setting Revision: [2096] Changed the way Sessions component is added to the components array Revision: [2095] Moved the WWW_ROOT define. Revision: [2094] Components/Helpers etc. in AppController are now automatically added to all controllers git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2099 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e16bb286e0
commit
d2bd117486
7 changed files with 138 additions and 128 deletions
|
@ -6,4 +6,4 @@
|
||||||
// +---------------------------------------------------------------------------------------------------+ //
|
// +---------------------------------------------------------------------------------------------------+ //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
0.10.8.2093
|
0.10.8.2099
|
|
@ -70,8 +70,9 @@ if (!defined('WEBROOT_DIR'))
|
||||||
define ('WEBROOT_DIR', basename(dirname(__FILE__)));
|
define ('WEBROOT_DIR', basename(dirname(__FILE__)));
|
||||||
}
|
}
|
||||||
|
|
||||||
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
|
define('WWW_ROOT', dirname(__FILE__));
|
||||||
|
|
||||||
|
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
|
||||||
|
|
||||||
require 'cake'.DS.'bootstrap.php';
|
require 'cake'.DS.'bootstrap.php';
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ require LIBS.'model'.DS.'connection_manager.php';
|
||||||
|
|
||||||
config('database');
|
config('database');
|
||||||
|
|
||||||
if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel'))
|
if (!class_exists('AppModel'))
|
||||||
{
|
{
|
||||||
require LIBS.'model'.DS.'model.php';
|
require LIBS.'model'.DS.'model.php';
|
||||||
loadModels();
|
loadModels();
|
||||||
|
|
|
@ -116,11 +116,6 @@ define ('LOGS', ROOT.DS.'logs'.DS);
|
||||||
*/
|
*/
|
||||||
define ('MODULES', ROOT.DS.'modules'.DS);
|
define ('MODULES', ROOT.DS.'modules'.DS);
|
||||||
|
|
||||||
/**
|
|
||||||
* Path to the public directory.
|
|
||||||
*/
|
|
||||||
define ('WWW_ROOT', APP.WEBROOT_DIR.DS);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the public directory.
|
* Path to the public directory.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -49,6 +49,8 @@ class RequestHandlerComponent extends Object
|
||||||
|
|
||||||
var $ajaxLayout = 'ajax';
|
var $ajaxLayout = 'ajax';
|
||||||
|
|
||||||
|
var $disableStartup = false;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup
|
* Startup
|
||||||
|
@ -59,6 +61,7 @@ class RequestHandlerComponent extends Object
|
||||||
function startup(&$controller)
|
function startup(&$controller)
|
||||||
{
|
{
|
||||||
$this->setAjax($controller);
|
$this->setAjax($controller);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,6 +72,11 @@ class RequestHandlerComponent extends Object
|
||||||
*/
|
*/
|
||||||
function setAjax(&$controller)
|
function setAjax(&$controller)
|
||||||
{
|
{
|
||||||
|
if ($this->disableStartup)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isAjax())
|
if ($this->isAjax())
|
||||||
{
|
{
|
||||||
$controller->layout = $this->ajaxLayout;
|
$controller->layout = $this->ajaxLayout;
|
||||||
|
|
|
@ -211,15 +211,30 @@ class Controller extends Object
|
||||||
$this->viewPath = Inflector::underscore($this->name);
|
$this->viewPath = Inflector::underscore($this->name);
|
||||||
$this->modelClass = Inflector::singularize($this->name);
|
$this->modelClass = Inflector::singularize($this->name);
|
||||||
$this->modelKey = Inflector::underscore($this->modelClass);
|
$this->modelKey = Inflector::underscore($this->modelClass);
|
||||||
|
|
||||||
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
|
||||||
{
|
{
|
||||||
array_push($this->components, 'Session');
|
$this->components[] = 'Session';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_subclass_of($this, 'AppController'))
|
||||||
|
{
|
||||||
|
$appVars = get_class_vars('AppController');
|
||||||
|
foreach(array('components', 'helpers', 'uses') as $var)
|
||||||
|
{
|
||||||
|
if (isset($appVars[$var]) && !empty($appVars[$var]))
|
||||||
|
{
|
||||||
|
$diff = array_diff($appVars[$var], $this->{$var});
|
||||||
|
$this->{$var} = array_merge($this->{$var}, $diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Loads and instantiates classes required by this controller,
|
||||||
|
* including components and models
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function constructClasses()
|
function constructClasses()
|
||||||
|
|
|
@ -250,140 +250,131 @@ class View extends Object
|
||||||
function render($action=null, $layout=null, $file=null)
|
function render($action=null, $layout=null, $file=null)
|
||||||
{
|
{
|
||||||
if (isset($this->hasRendered) && $this->hasRendered)
|
if (isset($this->hasRendered) && $this->hasRendered)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->hasRendered = false;
|
$this->hasRendered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$action)
|
if (!$action)
|
||||||
{
|
{
|
||||||
$action = $this->action;
|
$action = $this->action;
|
||||||
}
|
}
|
||||||
if ($layout)
|
|
||||||
{
|
|
||||||
$this->setLayout($layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($file)
|
if ($layout)
|
||||||
{
|
{
|
||||||
$viewFileName = $file;
|
$this->setLayout($layout);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$viewFileName = $this->_getViewFileName($action);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($this->plugin) && is_null($file))
|
if ($file)
|
||||||
{
|
{
|
||||||
return $this->pluginView($action, $layout);
|
$viewFileName = $file;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$viewFileName = $this->_getViewFileName($action);
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName))
|
if(!is_null($this->plugin) && is_null($file))
|
||||||
{
|
{
|
||||||
if (strtolower(get_class($this)) == 'template')
|
return $this->pluginView($action, $layout);
|
||||||
{
|
}
|
||||||
return array('action' => $action, 'layout' => $layout, 'viewFn' => $viewFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check to see if the missing view is due to a custom missingAction
|
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName) && !$viewFileName === DS)
|
||||||
if (strpos($action, 'missingAction') !== false)
|
{
|
||||||
{
|
|
||||||
$errorAction = 'missingAction';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$errorAction = 'missingView';
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for controller-level view handler
|
if (strpos($action, 'missingAction') !== false)
|
||||||
foreach(array($this->name, 'errors') as $viewDir)
|
|
||||||
{
|
|
||||||
$errorAction =Inflector::underscore($errorAction);
|
|
||||||
if(file_exists(VIEWS.$viewDir.DS.$errorAction.$this->ext))
|
|
||||||
{
|
|
||||||
$missingViewFileName = VIEWS.$viewDir.DS.$errorAction.$this->ext;
|
|
||||||
}
|
|
||||||
elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml'))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$missingViewFileName = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$missingViewExists = is_file($missingViewFileName);
|
|
||||||
if ($missingViewExists)
|
|
||||||
{
|
{
|
||||||
break;
|
$errorAction = 'missingAction';
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strpos($action, 'missingView') === false)
|
|
||||||
{
|
|
||||||
return $this->cakeError('missingView',
|
|
||||||
array(array('className' => $this->controller->name,
|
|
||||||
'action' => $action,
|
|
||||||
'file' => $viewFileName)));
|
|
||||||
|
|
||||||
$isFatal = isset($this->isFatal) ? $this->isFatal : false;
|
|
||||||
if (!$isFatal)
|
|
||||||
{
|
|
||||||
$viewFileName = $missingViewFileName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$missingViewExists = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$missingViewExists || $isFatal)
|
|
||||||
{
|
|
||||||
// app/view/errors/missing_view.thtml view is missing!
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
trigger_error(sprintf(__("No template file for view %s (expected %s), create it first'"), $action, $viewFileName), E_USER_ERROR);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
|
$errorAction = 'missingView';
|
||||||
}
|
}
|
||||||
|
|
||||||
die();
|
foreach(array($this->name, 'errors') as $viewDir)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($viewFileName && !$this->hasRendered)
|
|
||||||
{
|
|
||||||
if(substr($viewFileName, -5) === 'thtml')
|
|
||||||
{
|
|
||||||
$out = View::_render($viewFileName, $this->_viewVars, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$out = $this->_render($viewFileName, $this->_viewVars, 0);
|
|
||||||
}
|
|
||||||
if ($out !== false)
|
|
||||||
{
|
|
||||||
if ($this->layout && $this->autoLayout)
|
|
||||||
{
|
{
|
||||||
$out = $this->renderLayout($out);
|
$errorAction =Inflector::underscore($errorAction);
|
||||||
|
if(file_exists(VIEWS.$viewDir.DS.$errorAction.$this->ext))
|
||||||
|
{
|
||||||
|
$missingViewFileName = VIEWS.$viewDir.DS.$errorAction.$this->ext;
|
||||||
|
}
|
||||||
|
elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml'))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$missingViewFileName = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$missingViewExists = is_file($missingViewFileName);
|
||||||
|
if ($missingViewExists)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print $out;
|
if (strpos($action, 'missingView') === false)
|
||||||
$this->hasRendered = true;
|
{
|
||||||
}
|
return $this->cakeError('missingView',
|
||||||
else
|
array(array('className' => $this->controller->name,
|
||||||
{
|
'action' => $action,
|
||||||
$out = $this->_render($viewFileName, $this->_viewVars, false);
|
'file' => $viewFileName)));
|
||||||
trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
$isFatal = isset($this->isFatal) ? $this->isFatal : false;
|
||||||
}
|
if (!$isFatal)
|
||||||
|
{
|
||||||
|
$viewFileName = $missingViewFileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$missingViewExists = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$missingViewExists || $isFatal)
|
||||||
|
{
|
||||||
|
if (DEBUG)
|
||||||
|
{
|
||||||
|
trigger_error(sprintf(__("No template file for view %s (expected %s), create it first'"), $action, $viewFileName), E_USER_ERROR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
|
||||||
|
}
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($viewFileName && !$this->hasRendered)
|
||||||
|
{
|
||||||
|
if(substr($viewFileName, -5) === 'thtml')
|
||||||
|
{
|
||||||
|
$out = View::_render($viewFileName, $this->_viewVars, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = $this->_render($viewFileName, $this->_viewVars, 0);
|
||||||
|
}
|
||||||
|
if ($out !== false)
|
||||||
|
{
|
||||||
|
if ($this->layout && $this->autoLayout)
|
||||||
|
{
|
||||||
|
$out = $this->renderLayout($out);
|
||||||
|
}
|
||||||
|
print $out;
|
||||||
|
$this->hasRendered = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = $this->_render($viewFileName, $this->_viewVars, false);
|
||||||
|
trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue