Refactoring View and SecurityComponent

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3327 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-07-31 23:55:29 +00:00
parent a75f33f430
commit 2b69e99ae3
2 changed files with 15 additions and 30 deletions

View file

@ -48,7 +48,7 @@ class SecurityComponent extends Object {
var $requireLogin = array(); var $requireLogin = array();
var $loginOptions = array(); var $loginOptions = array('type' => '');
var $loginUsers = array(); var $loginUsers = array();
@ -116,9 +116,6 @@ class SecurityComponent extends Object {
if (is_array($this->requireLogin) && !empty($this->requireLogin)) { if (is_array($this->requireLogin) && !empty($this->requireLogin)) {
if (in_array($controller->action, $this->requireLogin) || $this->requireLogin == array('*')) { if (in_array($controller->action, $this->requireLogin) || $this->requireLogin == array('*')) {
if (!isset($this->loginOptions['type'])) {
$this->loginOptions['type'] = '';
}
$login = $this->loginCredentials($this->loginOptions['type']); $login = $this->loginCredentials($this->loginOptions['type']);
if ($login == null) { if ($login == null) {
// User hasn't been authenticated yet // User hasn't been authenticated yet

View file

@ -207,31 +207,21 @@ class View extends Object{
*/ */
var $plugin = null; var $plugin = null;
var $__passedVars = array('_viewVars', 'action', 'autoLayout', 'autoRender', 'base', 'webroot', 'helpers', 'here', 'layout', 'modelNames', 'name', 'pageTitle', 'viewPath', 'params', 'data', 'webservices', 'plugin', 'namedArgs', 'argSeparator');
/** /**
* Constructor * Constructor
* *
* @return View * @return View
*/ */
function __construct(&$controller) { function __construct(&$controller) {
if(is_object($controller)){ if(is_object($controller)) {
$this->controller =& $controller; $this->controller =& $controller;
$this->_viewVars = $this->controller->_viewVars;
$this->action = $this->controller->action; $c = count($this->__passedVars);
$this->autoLayout = $this->controller->autoLayout; for ($j = 0; $j < $c; $j++) {
$this->autoRender = $this->controller->autoRender; $var = $this->__passedVars[$j];
$this->base = $this->controller->base; $this->{$var} = $controller->{$var};
$this->webroot = $this->controller->webroot; }
$this->helpers = $this->controller->helpers;
$this->here = $this->controller->here;
$this->layout = $this->controller->layout;
$this->modelNames = $this->controller->modelNames;
$this->name = $this->controller->name;
$this->pageTitle = $this->controller->pageTitle;
$this->viewPath = $this->controller->viewPath;
$this->params = $this->controller->params;
$this->data = $this->controller->data;
$this->webservices = $this->controller->webservices;
$this->plugin = $this->controller->plugin;
} }
parent::__construct(); parent::__construct();
} }
@ -663,15 +653,13 @@ class View extends Object{
${$camelBackedHelper} =& new $helperCn; ${$camelBackedHelper} =& new $helperCn;
${$camelBackedHelper}->view =& $this; ${$camelBackedHelper}->view =& $this;
${$camelBackedHelper}->base = $this->base;
${$camelBackedHelper}->webroot = $this->webroot;
${$camelBackedHelper}->here = $this->here;
${$camelBackedHelper}->params = $this->params;
${$camelBackedHelper}->action = $this->action;
${$camelBackedHelper}->data = $this->data;
${$camelBackedHelper}->themeWeb = $this->themeWeb;
${$camelBackedHelper}->tags = $tags; ${$camelBackedHelper}->tags = $tags;
${$camelBackedHelper}->plugin = $this->plugin;
$vars = array('base', 'webroot', 'here', 'params', 'action', 'data', 'themeWeb', 'plugin', 'namedArgs', 'argSeparator');
$c = count($vars);
for ($j = 0; $j < $c; $j++) {
${$camelBackedHelper}->{$vars[$j]} = $this->{$vars[$j]};
}
if (!empty($this->validationErrors)) { if (!empty($this->validationErrors)) {
${$camelBackedHelper}->validationErrors = $this->validationErrors; ${$camelBackedHelper}->validationErrors = $this->validationErrors;