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()
|
||||
|
|
|
@ -262,6 +262,7 @@ class View extends Object
|
|||
{
|
||||
$action = $this->action;
|
||||
}
|
||||
|
||||
if ($layout)
|
||||
{
|
||||
$this->setLayout($layout);
|
||||
|
@ -281,14 +282,9 @@ class View extends Object
|
|||
return $this->pluginView($action, $layout);
|
||||
}
|
||||
|
||||
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName))
|
||||
if (!is_file($viewFileName) && !$viewFileName = fileExistsInPath($viewFileName) && !$viewFileName === DS)
|
||||
{
|
||||
if (strtolower(get_class($this)) == 'template')
|
||||
{
|
||||
return array('action' => $action, 'layout' => $layout, 'viewFn' => $viewFileName);
|
||||
}
|
||||
|
||||
// check to see if the missing view is due to a custom missingAction
|
||||
if (strpos($action, 'missingAction') !== false)
|
||||
{
|
||||
$errorAction = 'missingAction';
|
||||
|
@ -298,7 +294,6 @@ class View extends Object
|
|||
$errorAction = 'missingView';
|
||||
}
|
||||
|
||||
// check for controller-level view handler
|
||||
foreach(array($this->name, 'errors') as $viewDir)
|
||||
{
|
||||
$errorAction =Inflector::underscore($errorAction);
|
||||
|
@ -308,13 +303,13 @@ class View extends Object
|
|||
}
|
||||
elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml'))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$missingViewFileName = false;
|
||||
}
|
||||
|
||||
|
||||
$missingViewExists = is_file($missingViewFileName);
|
||||
if ($missingViewExists)
|
||||
{
|
||||
|
@ -342,7 +337,6 @@ class View extends Object
|
|||
|
||||
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);
|
||||
|
@ -351,7 +345,6 @@ class View extends Object
|
|||
{
|
||||
$this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +365,6 @@ class View extends Object
|
|||
{
|
||||
$out = $this->renderLayout($out);
|
||||
}
|
||||
|
||||
print $out;
|
||||
$this->hasRendered = true;
|
||||
}
|
||||
|
@ -381,7 +373,6 @@ class View extends Object
|
|||
$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