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:
phpnut 2006-02-23 08:24:23 +00:00
parent e16bb286e0
commit d2bd117486
7 changed files with 138 additions and 128 deletions

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ // // +---------------------------------------------------------------------------------------------------+ //
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
0.10.8.2093 0.10.8.2099

View file

@ -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';

View file

@ -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();

View file

@ -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.
*/ */

View file

@ -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;

View file

@ -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()

View file

@ -262,6 +262,7 @@ class View extends Object
{ {
$action = $this->action; $action = $this->action;
} }
if ($layout) if ($layout)
{ {
$this->setLayout($layout); $this->setLayout($layout);
@ -281,14 +282,9 @@ class View extends Object
return $this->pluginView($action, $layout); 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) if (strpos($action, 'missingAction') !== false)
{ {
$errorAction = 'missingAction'; $errorAction = 'missingAction';
@ -298,7 +294,6 @@ class View extends Object
$errorAction = 'missingView'; $errorAction = 'missingView';
} }
// check for controller-level view handler
foreach(array($this->name, 'errors') as $viewDir) foreach(array($this->name, 'errors') as $viewDir)
{ {
$errorAction =Inflector::underscore($errorAction); $errorAction =Inflector::underscore($errorAction);
@ -308,13 +303,13 @@ class View extends Object
} }
elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml')) elseif($missingViewFileName = fileExistsInPath(LIBS.'view'.DS.'templates'.DS.$viewDir.DS.$errorAction.'.thtml'))
{ {
} }
else else
{ {
$missingViewFileName = false; $missingViewFileName = false;
} }
$missingViewExists = is_file($missingViewFileName); $missingViewExists = is_file($missingViewFileName);
if ($missingViewExists) if ($missingViewExists)
{ {
@ -342,7 +337,6 @@ class View extends Object
if (!$missingViewExists || $isFatal) if (!$missingViewExists || $isFatal)
{ {
// app/view/errors/missing_view.thtml view is missing!
if (DEBUG) if (DEBUG)
{ {
trigger_error(sprintf(__("No template file for view %s (expected %s), create it first'"), $action, $viewFileName), E_USER_ERROR); 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}\"")); $this->error('404', 'Not found', sprintf("The requested address %s was not found on this server.", '', "missing view \"{$action}\""));
} }
die(); die();
} }
} }
@ -372,7 +365,6 @@ class View extends Object
{ {
$out = $this->renderLayout($out); $out = $this->renderLayout($out);
} }
print $out; print $out;
$this->hasRendered = true; $this->hasRendered = true;
} }
@ -381,7 +373,6 @@ class View extends Object
$out = $this->_render($viewFileName, $this->_viewVars, false); $out = $this->_render($viewFileName, $this->_viewVars, false);
trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR); trigger_error(sprintf(__("Error in view %s, got: <blockquote>%s</blockquote>"), $viewFileName, $out), E_USER_ERROR);
} }
return true; return true;
} }
} }