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__)));
|
||||
}
|
||||
|
||||
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';
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ require LIBS.'model'.DS.'connection_manager.php';
|
|||
|
||||
config('database');
|
||||
|
||||
if (class_exists('DATABASE_CONFIG') && !class_exists('AppModel'))
|
||||
if (!class_exists('AppModel'))
|
||||
{
|
||||
require LIBS.'model'.DS.'model.php';
|
||||
loadModels();
|
||||
|
|
|
@ -116,11 +116,6 @@ define ('LOGS', ROOT.DS.'logs'.DS);
|
|||
*/
|
||||
define ('MODULES', ROOT.DS.'modules'.DS);
|
||||
|
||||
/**
|
||||
* Path to the public directory.
|
||||
*/
|
||||
define ('WWW_ROOT', APP.WEBROOT_DIR.DS);
|
||||
|
||||
/**
|
||||
* Path to the public directory.
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,8 @@ class RequestHandlerComponent extends Object
|
|||
|
||||
var $ajaxLayout = 'ajax';
|
||||
|
||||
var $disableStartup = false;
|
||||
|
||||
|
||||
/**
|
||||
* Startup
|
||||
|
@ -59,6 +61,7 @@ class RequestHandlerComponent extends Object
|
|||
function startup(&$controller)
|
||||
{
|
||||
$this->setAjax($controller);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,6 +72,11 @@ class RequestHandlerComponent extends Object
|
|||
*/
|
||||
function setAjax(&$controller)
|
||||
{
|
||||
if ($this->disableStartup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->isAjax())
|
||||
{
|
||||
$controller->layout = $this->ajaxLayout;
|
||||
|
|
|
@ -211,15 +211,30 @@ class Controller extends Object
|
|||
$this->viewPath = Inflector::underscore($this->name);
|
||||
$this->modelClass = Inflector::singularize($this->name);
|
||||
$this->modelKey = Inflector::underscore($this->modelClass);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
* Loads and instantiates classes required by this controller,
|
||||
* including components and models
|
||||
*
|
||||
*/
|
||||
function constructClasses()
|
||||
|
|
|
@ -250,140 +250,131 @@ class View extends Object
|
|||
function render($action=null, $layout=null, $file=null)
|
||||
{
|
||||
if (isset($this->hasRendered) && $this->hasRendered)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hasRendered = false;
|
||||
}
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->hasRendered = false;
|
||||
}
|
||||
|
||||
if (!$action)
|
||||
{
|
||||
$action = $this->action;
|
||||
}
|
||||
if ($layout)
|
||||
{
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
if (!$action)
|
||||
{
|
||||
$action = $this->action;
|
||||
}
|
||||
|
||||
if ($file)
|
||||
{
|
||||
$viewFileName = $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$viewFileName = $this->_getViewFileName($action);
|
||||
}
|
||||
if ($layout)
|
||||
{
|
||||
$this->setLayout($layout);
|
||||
}
|
||||
|
||||
if(!is_null($this->plugin) && is_null($file))
|
||||
{
|
||||
return $this->pluginView($action, $layout);
|
||||
}
|
||||
if ($file)
|
||||
{
|
||||
$viewFileName = $file;
|
||||
}
|
||||
else
|
||||
{
|
||||
$viewFileName = $this->_getViewFileName($action);
|
||||
}
|
||||
|
||||
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName))
|
||||
{
|
||||
if (strtolower(get_class($this)) == 'template')
|
||||
{
|
||||
return array('action' => $action, 'layout' => $layout, 'viewFn' => $viewFileName);
|
||||
}
|
||||
if(!is_null($this->plugin) && is_null($file))
|
||||
{
|
||||
return $this->pluginView($action, $layout);
|
||||
}
|
||||
|
||||
// check to see if the missing view is due to a custom missingAction
|
||||
if (strpos($action, 'missingAction') !== false)
|
||||
{
|
||||
$errorAction = 'missingAction';
|
||||
}
|
||||
else
|
||||
{
|
||||
$errorAction = 'missingView';
|
||||
}
|
||||
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName) && !$viewFileName === DS)
|
||||
{
|
||||
|
||||
// check for controller-level view handler
|
||||
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)
|
||||
if (strpos($action, 'missingAction') !== false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
$errorAction = 'missingAction';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
|
||||
$errorAction = 'missingView';
|
||||
}
|
||||
|
||||
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)
|
||||
foreach(array($this->name, 'errors') as $viewDir)
|
||||
{
|
||||
$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;
|
||||
$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);
|
||||
}
|
||||
if (strpos($action, 'missingView') === false)
|
||||
{
|
||||
return $this->cakeError('missingView',
|
||||
array(array('className' => $this->controller->name,
|
||||
'action' => $action,
|
||||
'file' => $viewFileName)));
|
||||
|
||||
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