fixes to scaffold to use new location of scaffold views

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1598 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-12-23 22:12:49 +00:00
parent fc05f85542
commit 4ce430bdb5

View file

@ -2,9 +2,9 @@
/* SVN FILE: $Id$ */ /* SVN FILE: $Id$ */
/** /**
* Short description for file. * Scaffold.
* *
* Long description for file * Automatic forms and actions generation for rapid web application development.
* *
* PHP versions 4 and 5 * PHP versions 4 and 5
* *
@ -29,7 +29,7 @@
*/ */
/** /**
* Enter description here... * Included libs.
*/ */
uses(DS.'model'.DS.'model', 'inflector', 'object'); uses(DS.'model'.DS.'model', 'inflector', 'object');
@ -48,23 +48,23 @@ uses(DS.'model'.DS.'model', 'inflector', 'object');
class Scaffold extends Object { class Scaffold extends Object {
/** /**
* Enter description here... * Name of view to render
* *
* @var string * @var string
*/ */
var $actionView = null; var $actionView = null;
/** /**
* Enter description here... * Class name of model
* *
* @var unknown_type * @var unknown_type
*/ */
var $modelKey = null; var $modelKey = null;
/** /**
* Enter description here... * Controller object
* *
* @var Object * @var Controller
*/ */
var $controllerClass = null; var $controllerClass = null;
@ -98,18 +98,18 @@ class Scaffold extends Object {
function __construct(&$controller, $params) function __construct(&$controller, $params)
{ {
$this->controllerClass =& $controller; $this->controllerClass =& $controller;
$this->actionView = $controller->action; $this->actionView = $controller->action;
$this->modelKey = Inflector::singularize($controller->name); $this->modelKey = Inflector::singularize($controller->name);
$this->scaffoldTitle = Inflector::humanize($this->modelKey); $this->scaffoldTitle = Inflector::humanize($this->modelKey);
$this->controllerClass->pageTitle = $this->scaffoldTitle; $this->controllerClass->pageTitle = $this->scaffoldTitle;
$this->_renderScaffold($params); $this->_renderScaffold($params);
} }
/** /**
* Enter description here... * Private method to render Scaffold.
* *
* @param unknown_type $params * @param array $params
* @access private * @access private
*/ */
function _renderScaffold($params) function _renderScaffold($params)
@ -142,7 +142,7 @@ class Scaffold extends Object {
$this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read(); $this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read();
$this->controllerClass->set('data', $this->controllerClass->params['data'] ); $this->controllerClass->set('data', $this->controllerClass->params['data'] );
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames( $this->controllerClass->params['data'], false ) );
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml'); return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'show.thtml');
} }
/** /**
@ -156,7 +156,7 @@ class Scaffold extends Object {
{ {
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames(null,false) );
$this->controllerClass->set('data', $this->controllerClass->{$this->modelKey}->findAll()); $this->controllerClass->set('data', $this->controllerClass->{$this->modelKey}->findAll());
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml'); return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'list.thtml');
} }
/** /**
@ -169,7 +169,7 @@ class Scaffold extends Object {
function _scaffoldNew($params) function _scaffoldNew($params)
{ {
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
} }
/** /**
@ -184,7 +184,7 @@ class Scaffold extends Object {
$this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read(); $this->controllerClass->params['data'] = $this->controllerClass->{$this->modelKey}->read();
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) ); $this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames($this->controllerClass->params['data']) );
$this->controllerClass->set('data', $this->controllerClass->params['data']); $this->controllerClass->set('data', $this->controllerClass->params['data']);
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml'); return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'edit.thtml');
} }
@ -227,7 +227,7 @@ class Scaffold extends Object {
} }
$this->controllerClass->set('data', $this->controllerClass->params['data']); $this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey}); $this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml'); return $this->controllerClass->render($this->actionView, '', LIBS.'view'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
} }
} }
@ -263,7 +263,7 @@ class Scaffold extends Object {
} }
} }
else else
{ {
if(is_object($this->controllerClass->Session)) if(is_object($this->controllerClass->Session))
{ {
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/'); $this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/');
@ -272,10 +272,10 @@ class Scaffold extends Object {
} }
else else
{ {
return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'. return $this->controllerClass->flash('There was an error updating the '.Inflector::humanize($this->modelKey),'/'.
Inflector::underscore($this->controllerClass->viewPath)); Inflector::underscore($this->controllerClass->viewPath));
} }
} }
} }
/** /**