From 2beb0f2f06224a1455c47c5b4ce0ec96e9cdee06 Mon Sep 17 00:00:00 2001 From: gwoo Date: Mon, 27 Nov 2006 02:31:18 +0000 Subject: [PATCH] fixed bad check for uses from last commit, update scaffolding git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3984 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/controller.php | 8 ++++---- cake/libs/controller/scaffold.php | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 4d59711cb..0a8daec9c 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -73,7 +73,7 @@ class Controller extends Object { * @var mixed A single name as a string or a list of names as an array. * @access protected */ - var $uses = null; + var $uses = false; /** * An array of names of built-in helpers to include. * @@ -263,7 +263,7 @@ class Controller extends Object { $uses = $appVars['uses']; $merge = array('components', 'helpers'); - if ($uses == $this->uses && $this->uses !== null) { + if ($uses == $this->uses && $this->uses !== false) { array_unshift($this->uses, $this->modelClass); } elseif ($this->uses !== null && $this->uses !== false) { $merge[] = 'uses'; @@ -304,7 +304,7 @@ class Controller extends Object { loadModel($this->modelClass); } } - + if (class_exists($this->modelClass) && ($this->uses === false)) { if ($this->persistModel === true) { $cached = $this->_persist($this->modelClass, null, $object); @@ -693,7 +693,7 @@ class Controller extends Object { if (isset($fieldNames[$column['name']]['foreignKey'])) { $fieldNames[$column['name']]['type'] = 'select'; $fieldNames[$column['name']]['options'] = array(); - $otherModelObj =& ClassRegistry::getObject(Inflector::underscore($fieldNames[$column['name']]['modelKey'])); + $otherModelObj =& ClassRegistry::getObject($fieldNames[$column['name']]['modelKey']); if (is_object($otherModelObj)) { if ($doCreateOptions) { $fieldNames[$column['name']]['options'] = $otherModelObj->generateList(); diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index aa57f7a8d..91a5d9a7a 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -101,8 +101,8 @@ class Scaffold extends Object { $this->action = $controller->action; $this->modelClass = Inflector::classify($this->name); $this->modelKey = Inflector::underscore($this->modelClass); - $this->scaffoldTitle = Inflector::humanize($this->name); $this->viewPath = Inflector::underscore($this->name); + $this->scaffoldTitle = Inflector::humanize($this->viewPath); $this->controller->pageTitle= 'Scaffold :: ' . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle; $path = '/'; /*if(is_null($controller->plugin)) { @@ -116,17 +116,20 @@ class Scaffold extends Object { $this->controller->set('modelClass', $this->modelClass); $this->controller->set('modelKey', $this->modelKey); $this->controller->set('viewPath', $this->viewPath); - $this->controller->set('humanSingularName', Inflector::humanize($this->modelClass)); - $this->controller->set('humanPluralName', $this->scaffoldTitle); + $this->controller->set('humanSingularName', Inflector::humanize($this->modelKey)); + $this->controller->set('humanPluralName', Inflector::humanize($this->viewPath)); if (!in_array('Form', $this->controller->helpers)) { $this->controller->helpers[] = 'Form'; } $this->controller->constructClasses(); $this->ScaffoldModel = &$this->controller->{$this->modelClass}; - - $alias = array_combine(array_keys($this->ScaffoldModel->alias), array_keys($this->ScaffoldModel->alias)); + $alias = null; + if(!empty($this->ScaffoldModel->alias)) { + $alias = array_combine(array_keys($this->ScaffoldModel->alias), array_keys($this->ScaffoldModel->alias)); + } $this->controller->set('alias', $alias); + $this->controller->set('primaryKey', $this->ScaffoldModel->primaryKey); $this->controller->set('displayField', $this->ScaffoldModel->getDisplayfield()); @@ -206,7 +209,7 @@ class Scaffold extends Object { $this->controller->set('formName', ucwords($action)); if ($action == 'edit') { - $this->controller->data = $this->ScaffoldModel->find(); + $this->controller->data = $this->ScaffoldModel->find(); $this->controller->set('fieldNames', $this->controller->generateFieldNames($this->controller->data)); $this->controller->set('data', $this->controller->data);