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
This commit is contained in:
gwoo 2006-11-27 02:31:18 +00:00
parent dfcc29f6bf
commit 2beb0f2f06
2 changed files with 13 additions and 10 deletions

View file

@ -73,7 +73,7 @@ class Controller extends Object {
* @var mixed A single name as a string or a list of names as an array. * @var mixed A single name as a string or a list of names as an array.
* @access protected * @access protected
*/ */
var $uses = null; var $uses = false;
/** /**
* An array of names of built-in helpers to include. * An array of names of built-in helpers to include.
* *
@ -263,7 +263,7 @@ class Controller extends Object {
$uses = $appVars['uses']; $uses = $appVars['uses'];
$merge = array('components', 'helpers'); $merge = array('components', 'helpers');
if ($uses == $this->uses && $this->uses !== null) { if ($uses == $this->uses && $this->uses !== false) {
array_unshift($this->uses, $this->modelClass); array_unshift($this->uses, $this->modelClass);
} elseif ($this->uses !== null && $this->uses !== false) { } elseif ($this->uses !== null && $this->uses !== false) {
$merge[] = 'uses'; $merge[] = 'uses';
@ -304,7 +304,7 @@ class Controller extends Object {
loadModel($this->modelClass); loadModel($this->modelClass);
} }
} }
if (class_exists($this->modelClass) && ($this->uses === false)) { if (class_exists($this->modelClass) && ($this->uses === false)) {
if ($this->persistModel === true) { if ($this->persistModel === true) {
$cached = $this->_persist($this->modelClass, null, $object); $cached = $this->_persist($this->modelClass, null, $object);
@ -693,7 +693,7 @@ class Controller extends Object {
if (isset($fieldNames[$column['name']]['foreignKey'])) { if (isset($fieldNames[$column['name']]['foreignKey'])) {
$fieldNames[$column['name']]['type'] = 'select'; $fieldNames[$column['name']]['type'] = 'select';
$fieldNames[$column['name']]['options'] = array(); $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 (is_object($otherModelObj)) {
if ($doCreateOptions) { if ($doCreateOptions) {
$fieldNames[$column['name']]['options'] = $otherModelObj->generateList(); $fieldNames[$column['name']]['options'] = $otherModelObj->generateList();

View file

@ -101,8 +101,8 @@ class Scaffold extends Object {
$this->action = $controller->action; $this->action = $controller->action;
$this->modelClass = Inflector::classify($this->name); $this->modelClass = Inflector::classify($this->name);
$this->modelKey = Inflector::underscore($this->modelClass); $this->modelKey = Inflector::underscore($this->modelClass);
$this->scaffoldTitle = Inflector::humanize($this->name);
$this->viewPath = Inflector::underscore($this->name); $this->viewPath = Inflector::underscore($this->name);
$this->scaffoldTitle = Inflector::humanize($this->viewPath);
$this->controller->pageTitle= 'Scaffold :: ' . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle; $this->controller->pageTitle= 'Scaffold :: ' . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle;
$path = '/'; $path = '/';
/*if(is_null($controller->plugin)) { /*if(is_null($controller->plugin)) {
@ -116,17 +116,20 @@ class Scaffold extends Object {
$this->controller->set('modelClass', $this->modelClass); $this->controller->set('modelClass', $this->modelClass);
$this->controller->set('modelKey', $this->modelKey); $this->controller->set('modelKey', $this->modelKey);
$this->controller->set('viewPath', $this->viewPath); $this->controller->set('viewPath', $this->viewPath);
$this->controller->set('humanSingularName', Inflector::humanize($this->modelClass)); $this->controller->set('humanSingularName', Inflector::humanize($this->modelKey));
$this->controller->set('humanPluralName', $this->scaffoldTitle); $this->controller->set('humanPluralName', Inflector::humanize($this->viewPath));
if (!in_array('Form', $this->controller->helpers)) { if (!in_array('Form', $this->controller->helpers)) {
$this->controller->helpers[] = 'Form'; $this->controller->helpers[] = 'Form';
} }
$this->controller->constructClasses(); $this->controller->constructClasses();
$this->ScaffoldModel = &$this->controller->{$this->modelClass}; $this->ScaffoldModel = &$this->controller->{$this->modelClass};
$alias = null;
$alias = array_combine(array_keys($this->ScaffoldModel->alias), array_keys($this->ScaffoldModel->alias)); 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('alias', $alias);
$this->controller->set('primaryKey', $this->ScaffoldModel->primaryKey); $this->controller->set('primaryKey', $this->ScaffoldModel->primaryKey);
$this->controller->set('displayField', $this->ScaffoldModel->getDisplayfield()); $this->controller->set('displayField', $this->ScaffoldModel->getDisplayfield());
@ -206,7 +209,7 @@ class Scaffold extends Object {
$this->controller->set('formName', ucwords($action)); $this->controller->set('formName', ucwords($action));
if ($action == 'edit') { if ($action == 'edit') {
$this->controller->data = $this->ScaffoldModel->find(); $this->controller->data = $this->ScaffoldModel->find();
$this->controller->set('fieldNames', $this->controller->set('fieldNames',
$this->controller->generateFieldNames($this->controller->data)); $this->controller->generateFieldNames($this->controller->data));
$this->controller->set('data', $this->controller->data); $this->controller->set('data', $this->controller->data);