cakephp2-php8/cake/libs/controller/scaffold.php

573 lines
22 KiB
PHP
Raw Normal View History

<?php
/* SVN FILE: $Id$ */
/**
* Scaffold.
*
* Automatic forms and actions generation for rapid web application development.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
Merging: Revision: [1638] removing php short tags Revision: [1637] Remove renderElememnts loading of helpers also, forgot it in the last commit Revision: [1636] Refactoring after profiling code. Session was creating a new instance of Dispatcher removed the need for it. Added a check to the Component class to pass the base to the SessionComponent class, will refactor that at a later time. Changed View class so it would not load helpers when rending a layout, no need for that. A great performance boost after the change. Change the loadModels method call in app/webroot/index.php. Will only attempt the loadModels call if the AppModel class is not in memory, and the Database class is in memory. Removed all unnecessary calls to basics uses(). Again another big performance increase. Added fix to the Html::guiListTree() after discussing the output that is expected. A ticket was closed on this already. Revision: [1635] Removing calls to basic uses() Revision: [1634] Removing calls to basics uses() that are not needed. Revision: [1633] Removing calls to basics uses() that are not needed. Moved Object class further up in the loading order Revision: [1632] adding fix for Ticket #132 Revision: [1631] Added fix from Ticket #122 Revision: [1630] Scaffold views can now be placed in a view directory. These will override the core. Example (Must have the scaffold dot name): app/views/posts/scaffold.list.thtml app/views/posts/scaffold.new.thtml app/views/posts/scaffold.edit.thtml app/views/posts/scaffold.show.thtml Revision: [1629] Think I fixed the issue with scaffold showing proper dates prior to January 1 1970 00:00:00. Revision: [1628] Added a few more change to allow saving dates prior to January 1 1970 00:00:00. Still a few issues with this, but will get them figured out soon. Changed scaffold to use only one form view. Revision: [1627] Added fix for Ticket #189 Revision: [1626] Added fix for Ticket #120. Revision: [1625] left justified doc blocks Revision: [1624] remove files from uses() that are loaded by default in app/webroot/index.php no reason to attempt to load them again in the classes Revision: [1623] adding check to the loadModels and loadController that will only attempt to load files if the classes are not already in memory Revision: [1622] Adding fix to time helper that was lost in a previous merge Removing all tabs from code Revision: [1621] Addtional model validation fixes Revision: [1620] fixed parse error Revision: [1619] Fixing ticket #102 Revision: [1618] correcting mime types and keywords Revision: [1617] correcting mime types and keywords Revision: [1616] fixed link in footer Revision: [1615] Fixing ticket #207 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1639 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-12-27 03:33:44 +00:00
* @filesource
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.controller
* @since Cake v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Scaffolding is a set of automatic views, forms and controllers for starting web development work faster.
*
* Scaffold inspects your database tables, and making educated guesses, sets up a
* number of pages for each of your Models. These pages have data forms that work,
* and afford the web developer an early look at the data, and the possibility to over-ride
* scaffolded actions with custom-made ones.
*
* @package cake
* @subpackage cake.cake.libs.controller
*/
class Scaffold extends Object {
/**
* Controller object
*
* @var Controller
*/
var $controller = null;
/**
* Name of the controller to scaffold
*
* @var string Name of controller
* @access public
*/
var $name = null;
/**
* Action to be performed.
*
* @var string Name of action
* @access public
*/
var $action = null;
/**
* Name of current model this view context is attached to
*
* @var string
*/
var $model = null;
/**
* Path to View.
*
* @var string Path to View
*/
var $viewPath;
/**
* Path parts for creating links in views.
*
* @var string Base URL
* @access public
*/
var $base = null;
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Name of layout to use with this View.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @var string
* @access public
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*/
var $layout = 'default';
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Array of parameter data
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @var array Parameter data
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*/
var $params;
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* File extension. Defaults to Cake's template ".ctp".
*
* @var array
*/
var $ext = '.ctp';
/**
* Sub-directory for this view file.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @var string
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*/
var $subDir = null;
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Plugin name. A Plugin is a sub-application. New in Cake RC4.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @link http://wiki.cakephp.org/docs:plugins
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
* @var string
*/
var $plugin = null;
/**
* Controller URL-generation data
*
* @var mixed
*/
var $namedArgs = null;
/**
* Controller URL-generation data
*
* @var string
*/
var $argSeparator = null;
/**
* List of variables to collect from the associated controller
*
* @var array
* @access protected
*/
var $__passedVars = array('action', 'base', 'webroot', 'layout', 'name', 'viewPath', 'ext', 'params', 'data', 'webservices', 'plugin', 'namedArgs', 'argSeparator', 'cacheAction');
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Title HTML element for current scaffolded view
*
* @var string
*/
var $scaffoldTitle = null;
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Construct and set up given controller with given parameters.
*
* @param string $controller_class Name of controller
* @param array $params
*/
function __construct(&$controller, $params) {
$this->controller = &$controller;
$count = count($this->__passedVars);
for ($j = 0; $j < $count; $j++) {
$var = $this->__passedVars[$j];
$this->{$var} = $controller->{$var};
}
$this->redirect = '/' . $this->viewPath;
if(!is_null($this->plugin)) {
$this->redirect = '/' . $this->plugin . '/' . $this->viewPath;
}
if (!in_array('Form', $this->controller->helpers)) {
$this->controller->helpers[] = 'Form';
}
if($this->controller->constructClasses() === false) {
return $this->cakeError('missingModel', array(array('className' => $this->modelKey, 'webroot' => '', 'base' => $this->controller->base)));
}
if(!empty($controller->uses) && class_exists($controller->uses[0])) {
$controller->modelClass = $controller->uses[0];
$controller->modelKey = Inflector::underscore($controller->modelClass);
}
$this->modelClass = $controller->modelClass;
$this->modelKey = $controller->modelKey;
if(!is_object($this->controller->{$this->modelClass})) {
return $this->cakeError('missingModel', array(array('className' => $this->modelClass, 'webroot' => '', 'base' => $controller->base)));
}
$this->ScaffoldModel =& $this->controller->{$this->modelClass};
$this->scaffoldTitle = Inflector::humanize($this->viewPath);
$this->scaffoldActions = $controller->scaffold;
$this->controller->pageTitle= __('Scaffold :: ', true) . Inflector::humanize($this->action) . ' :: ' . $this->scaffoldTitle;
$path = '/';
$this->controller->set('path', $path);
$this->controller->set('controllerName', $this->name);
$this->controller->set('controllerAction', $this->action);
$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->modelKey));
$this->controller->set('humanPluralName', Inflector::humanize($this->viewPath));
$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());
$this->__scaffold($params);
}
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Renders a view action of scaffolded model.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @param array $params
* @return A rendered view of a row from Models database table
* @access private
*/
function __scaffoldView($params) {
if ($this->controller->_beforeScaffold('view')) {
if(isset($params['pass'][0])){
$this->ScaffoldModel->id = $params['pass'][0];
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)),
'/' . Inflector::underscore($this->controller->viewPath));
}
$this->controller->data = $this->ScaffoldModel->read();
$this->controller->set('data', $this->controller->data);
$this->controller->set('fieldNames', $this->controller->generateFieldNames($this->controller->data, false));
$this->controller->render($this->action, $this->layout, $this->__getViewFileName($this->action));
/*
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml')) {
return $this->controller->render($this->action, '',
APP . 'views' . DS . $this->viewPath . DS . 'scaffold.view.thtml');
} elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.view.thtml')) {
return $this->controller->render($this->action, '',
APP . 'views' . DS . 'scaffold' . DS . 'scaffold.view.thtml');
} else {
return $this->controller->render($this->action, '',
LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'view.thtml');
}*/
} elseif ($this->controller->_scaffoldError('view') === false) {
return $this->__scaffoldError();
}
}
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Renders index action of scaffolded model.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @param array $params
* @return A rendered view listing rows from Models database table
* @access private
*/
function __scaffoldIndex($params) {
if ($this->controller->_beforeScaffold('index')) {
$this->controller->set('fieldNames', $this->controller->generateFieldNames(null, false));
$this->ScaffoldModel->recursive = 0;
$this->controller->set('data', $this->controller->paginate());
$this->controller->render($this->action, $this->layout, $this->__getViewFileName($this->action));
/*
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml')) {
return $this->controller->render($this->action, '',
APP . 'views' . DS . $this->viewPath . DS . 'scaffold.index.thtml');
} elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.index.thtml')) {
return $this->controller->render($this->action, '',
APP . 'views' . DS . 'scaffold' . DS . 'scaffold.index.thtml');
} else {
return $this->controller->render($this->action, '',
LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'index.thtml');
}*/
} elseif ($this->controller->_scaffoldError('index') === false) {
return $this->__scaffoldError();
}
}
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Renders an add or edit action for scaffolded model.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @param array $params
* @param string $params add or edit
* @return A rendered view with a form to edit or add a record in the Models database table
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
* @access private
*/
function __scaffoldForm($action = 'edit') {
$this->controller->render($action, $this->layout, $this->__getViewFileName('edit'));
/*
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $action . '.thtml')) {
return $this->controller->render($action, '', APP . 'views' . DS . $this->viewPath . DS . 'scaffold.' . $action . '.thtml');
} elseif(file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $action . '.thtml')) {
return $this->controller->render($action, '', APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $action . '.thtml');
} else {
return $this->controller->render($action, '', LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
}*/
}
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Saves or updates the scaffolded model.
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
*
* @param array $params
* @param string $type create or update
* @return success on save/update, add/edit form if data is empty or error if save or update fails
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
* @access private
*/
function __scaffoldSave($params = array(), $action = 'edit') {
$formName = 'Edit';
$formAction = 'edit';
$viewFileName = 'edit';
$success = __('updated', true);
if ($action === 'add') {
$formName = 'New';
$formAction = 'add';
$viewFileName = 'add';
$success = __('saved', true);
}
$this->controller->set('formName', $formName);
if ($this->controller->_beforeScaffold($action)) {
if (empty($this->controller->data)) {
if ($action == 'edit') {
if(isset($params['pass'][0])){
$this->ScaffoldModel->id = $params['pass'][0];
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__("No id set for %s::edit()", true), Inflector::humanize($this->modelKey)),
'/' . Inflector::underscore($this->controller->viewPath));
}
$this->controller->data = $this->ScaffoldModel->read();
$this->controller->set('fieldNames', $this->controller->generateFieldNames($this->controller->data));
$this->controller->set('data', $this->controller->data);
} else {
$this->controller->set('fieldNames', $this->controller->generateFieldNames());
}
return $this->__scaffoldForm($formAction);
}
$this->controller->set('fieldNames', $this->controller->generateFieldNames());
$this->controller->cleanUpFields();
if ($action == 'create') {
$this->ScaffoldModel->create();
}
if ($this->ScaffoldModel->save($this->controller->data)) {
if ($this->controller->_afterScaffoldSave($action)) {
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('The %1$s has been %2$s', true), Inflector::humanize($this->modelClass), $success), '/' . $this->viewPath);
}
} else {
return $this->controller->_afterScaffoldSaveError($action);
}
} else {
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(__('Please correct errors below.', true));
}
$this->controller->set('data', $this->controller->data);
$this->controller->set('fieldNames', $this->controller->generateFieldNames($this->__rebuild($this->controller->data)));
$this->controller->validateErrors($this->ScaffoldModel);
/*
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.' . $viewFileName . '.thtml')) {
return $this->controller->render($viewFileName, '', APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.' . $viewFileName . '.thtml');
} elseif(file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $viewFileName . '.thtml')) {
return $this->controller->render($viewFileName, '', APP . 'views' . DS . 'scaffold' . DS . 'scaffold.' . $viewFileName . '.thtml');
} else {
return $this->controller->render($viewFileName, '', LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . 'edit.thtml');
}*/
$this->controller->render($viewFileName, $this->layout, $this->__getViewFileName($viewFileName));
}
} else if($this->controller->_scaffoldError($action) === false) {
return $this->__scaffoldError();
}
}
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
/**
* Performs a delete on given scaffolded Model.
*
* @param array $params
* @return success on delete error if delete fails
* @access private
*/
function __scaffoldDelete($params = array()) {
if ($this->controller->_beforeScaffold('delete')) {
if(isset($params['pass'][0])){
$id = $params['pass'][0];
} elseif (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__("No id set for %s::delete()", true), Inflector::humanize($this->modelKey)),
'/' . Inflector::underscore($this->controller->viewPath));
}
if ($this->ScaffoldModel->del($id)) {
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('The %1$s with id: %2$d has been deleted.', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
}
} else {
if (isset($this->controller->Session) && $this->controller->Session->valid != false) {
$this->controller->Session->setFlash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id));
$this->controller->redirect($this->redirect);
} else {
return $this->controller->flash(sprintf(__('There was an error deleting the %1$s with id: %2$d', true), Inflector::humanize($this->modelClass), $id), '/' . $this->viewPath);
}
}
} elseif ($this->controller->_scaffoldError('delete') === false) {
return $this->__scaffoldError();
}
}
Merging fixes and enhancements into trunk. Revision: [2104] Correct changes of names in scaffold. Revision: [2103] Changed methods to protected methods Controller::_beforeScaffold($method) Controller::_scaffoldError($method) Revision: [2102] Added 2 methods to Controller class that must be overridden in child classes if you place to use Scaffold in production applications. This will allow you to perform checks before displaying the forms, and also before performing any Scaffold methods. Each of these methods are passed the name of the method they represent in Scaffold. Controller::beforeScaffold($method) Controller::scaffoldError($method) These 3 name are passed to the methods above, but are not view related 'create' when creating a new record in the database 'update' when updating a record in the database. 'delete' name says what it does These are view related names passed to the methods above 'index' the list of all records shown in scaffold. 'edit' the edit record form. 'show' when displaying a specific record. 'add' add record form. Scaffold can now be used to generate forms and customize these on a per app or per controller basis. Scaffold will first look: Example: app/views/posts/ Then: app/views/scaffold/ There are also specific naming used for these views each related to a scaffold method. scaffold.list.thtml scaffold.edit.thtml scaffold.new.thtml scaffold.show.thtml Added scaffold_error.thtml that is used if a controller does not implement Controller::scaffoldError() when using scaffold and Controller::beforeScaffold() is implemented and returns false Revision: [2101] Corrected some bugs found in View that would cause errors when using scaffold. Revision: [2100] Added fix for Ticket #427 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2105 3807eeeb-6ff5-0310-8944-8be069107fe0
2006-02-23 11:40:52 +00:00
/**
* Enter description here...
*
* @return error
Merging fixes and enhancements into trunk. Revision: [2104] Correct changes of names in scaffold. Revision: [2103] Changed methods to protected methods Controller::_beforeScaffold($method) Controller::_scaffoldError($method) Revision: [2102] Added 2 methods to Controller class that must be overridden in child classes if you place to use Scaffold in production applications. This will allow you to perform checks before displaying the forms, and also before performing any Scaffold methods. Each of these methods are passed the name of the method they represent in Scaffold. Controller::beforeScaffold($method) Controller::scaffoldError($method) These 3 name are passed to the methods above, but are not view related 'create' when creating a new record in the database 'update' when updating a record in the database. 'delete' name says what it does These are view related names passed to the methods above 'index' the list of all records shown in scaffold. 'edit' the edit record form. 'show' when displaying a specific record. 'add' add record form. Scaffold can now be used to generate forms and customize these on a per app or per controller basis. Scaffold will first look: Example: app/views/posts/ Then: app/views/scaffold/ There are also specific naming used for these views each related to a scaffold method. scaffold.list.thtml scaffold.edit.thtml scaffold.new.thtml scaffold.show.thtml Added scaffold_error.thtml that is used if a controller does not implement Controller::scaffoldError() when using scaffold and Controller::beforeScaffold() is implemented and returns false Revision: [2101] Corrected some bugs found in View that would cause errors when using scaffold. Revision: [2100] Added fix for Ticket #427 git-svn-id: https://svn.cakephp.org/repo/trunk/cake@2105 3807eeeb-6ff5-0310-8944-8be069107fe0
2006-02-23 11:40:52 +00:00
*/
function __scaffoldError() {
if (file_exists(APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS. 'scaffold.error.thtml')) {
return $this->controller->render($this->action, $this->layout,
APP . 'views' . DS . $this->viewPath . DS . 'scaffolds' . DS . 'scaffold.error.thtml');
} elseif (file_exists(APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml')) {
return $this->controller->render($this->action, $this->layout,
APP . 'views' . DS . 'scaffold' . DS . 'scaffold.error.thtml');
} else {
return $this->controller->render($this->action, $this->layout,
LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . 'scaffold_error.thtml');
}
}
/**
* When forms are submited the arrays need to be rebuilt if
* an error occured, here the arrays are rebuilt to structure needed
*
* @param array $params data passed to forms
* @return array rebuilds the association arrays to pass back to Controller::generateFieldNames()
*/
function __rebuild($params) {
foreach($params as $model => $field) {
if (!empty($field) && is_array($field)) {
$match=array_keys($field);
if ($model == $match[0]) {
$count = 0;
foreach($field[$model] as $value) {
$params[$model][$count][$this->ScaffoldModel->primaryKey] = $value;
$count++;
}
unset ($params[$model][$model]);
}
}
}
return $params;
}
/**
[1178] Author: phpnut Date: 8:52:12 PM, Sunday, October 23, 2005 Message: adding cakephp power image [1177] Author: phpnut Date: 8:48:32 PM, Sunday, October 23, 2005 Message: Updated scaffold to use new layout template. [1176] Author: phpnut Date: 7:09:27 PM, Sunday, October 23, 2005 Message: renaming cake/conf to cake/config [1175] Author: phpnut Date: 7:06:04 PM, Sunday, October 23, 2005 Message: moving tags.ini.php to cake/conf/tags.ini.php [1174] Author: phpnut Date: 6:52:19 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1173] Author: phpnut Date: 6:46:07 PM, Sunday, October 23, 2005 Message: updating css/cake.deafult.css and default layout [1172] Author: phpnut Date: 6:42:48 PM, Sunday, October 23, 2005 Message: updating css/cake.scaffold.css [1171] Author: phpnut Date: 6:41:00 PM, Sunday, October 23, 2005 Message: Adding spaces to tags.ini file [1170] Author: phpnut Date: 6:37:17 PM, Sunday, October 23, 2005 Message: Removing code that is no longer used [1169] Author: phpnut Date: 6:34:24 PM, Sunday, October 23, 2005 Message: removing files that are no longer used [1168] Author: phpnut Date: 6:19:46 PM, Sunday, October 23, 2005 Message: Cleaning up Scaffold class. [1167] Author: phpnut Date: 5:26:27 PM, Sunday, October 23, 2005 Message: Changes are added to remove the $this->models array that would hold the instance of the models. Now they are available as $this->ModelName; This should be CamelCased. Added check in the Scaffold to return forms when accessing the actions update, create without a form being submitted. [1166] Author: phpnut Date: 3:53:08 PM, Sunday, October 23, 2005 Message: Making change to allow setting the name of a class camel cased to fix issues with PHP 4. In both the model and the controllers: Model: var $name = 'ModelName'; Controller: var $name = 'ControllerName'; ControllerName not ControllerNameController. [1165] Author: phpnut Date: 1:45:17 PM, Sunday, October 23, 2005 Message: Fix added for problems with key name that was added to the class registry when underscored git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1179 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-24 01:56:20 +00:00
* When methods are now present in a controller
* scaffoldView is used to call default Scaffold methods if:
* <code>
* var $scaffold;
* </code>
* is placed in the controller's class definition.
*
* @param string $url
* @param string $controller_class
* @param array $params
* @since Cake v 0.10.0.172
* @access private
*/
function __scaffold($params) {
$db = &ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
if (isset($db)) {
if(empty($this->scaffoldActions)) {
$this->scaffoldActions = array('index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete');
}
if (in_array($params['action'], $this->scaffoldActions)) {
switch($params['action']) {
case 'index':
$this->__scaffoldIndex($params);
break;
case 'view':
$this->__scaffoldView($params);
break;
case 'list':
$this->__scaffoldIndex($params);
break;
case 'add':
$this->__scaffoldSave($params, 'add');
break;
case 'edit':
$this->__scaffoldSave($params, 'edit');
break;
case 'create':
$this->__scaffoldSave($params, 'add');
break;
case 'update':
$this->__scaffoldSave($params, 'edit');
break;
case 'delete':
$this->__scaffoldDelete($params);
break;
}
} else {
return $this->cakeError('missingAction', array(array('className' => $this->controller->name . "Controller",
'base' => $this->controller->base,
'action' => $this->action,
'webroot' => $this->controller->webroot)));
}
} else {
return $this->cakeError('missingDatabase', array(array('webroot' => $this->controller->webroot)));
}
}
/**
* Returns scaffold view filename of given action's template file (.ctp) as a string.
*
* @param string $action Controller action to find template filename for
* @return string Template filename
* @access private
*/
function __getViewFileName($action) {
$action = Inflector::underscore($action);
$scaffoldAction = 'scaffold.'.$action;
$paths = Configure::getInstance();
if (!is_null($this->webservices)) {
$type = strtolower($this->webservices) . DS;
} else {
$type = null;
}
if (!is_null($this->plugin)) {
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
return APP . 'views' . DS . 'plugins' . DS . 'scaffold'. DS . $this->subDir . $type . $action . $this->ext;
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext;
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext)) {
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . $this->ext;
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . 'scaffold'. DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml')) {
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $scaffoldAction . '.thtml';
}
}
foreach($paths->viewPaths as $path) {
if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext;
} elseif (file_exists($path . $this->viewPath . DS . 'scaffold' . DS . $this->subDir . $type . $scaffoldAction . $this->ext)) {
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . $this->ext;
} elseif (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
return $path . $this->viewPath . DS . $this->subDir . $type . $action . '.thtml';
} elseif (file_exists($path . $this->viewPath . DS . 'scaffold' . DS . $this->subDir . $type . $scaffoldAction . '.thtml')) {
return $path . $this->viewPath . DS . $this->subDir . $type . $scaffoldAction . '.thtml';
}
}
return LIBS . 'view' . DS . 'templates' . DS . 'scaffolds' . DS . $action . '.thtml';
}
}
?>