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

837 lines
26 KiB
PHP
Raw Normal View History

<?php
/* SVN FILE: $Id$ */
/**
* Base controller class.
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
* @subpackage cake.cake.libs.controller
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Include files
*/
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
uses(DS.'controller'.DS.'component',DS.'model'.DS.'model', 'inflector', 'folder', DS.'view'.DS.'view');
/**
* Controller
*
* Application controller (controllers are where you put all the actual code)
* Provides basic functionality, such as rendering views (aka displaying templates).
* Automatically selects model name from on singularized object class name
* and creates the model object if proper class exists.
*
* @package cake
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
* @subpackage cake.cake.libs.controller
* @since CakePHP v 0.2.9
*
*/
class Controller extends Object
{
/**
* Name of the controller.
*
* @var unknown_type
* @access public
*/
var $name = null;
/**
* Stores the current URL (for links etc.)
*
* @var string Current URL
*/
var $here = null;
/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $parent = null;
/**
* Action to be performed.
*
* @var string
* @access public
*/
var $action = null;
/**
* An array of names of models the particular controller wants to use.
*
* @var mixed A single name as a string or a list of names as an array.
* @access protected
*/
var $uses = false;
/**
* An array of names of built-in helpers to include.
*
* @var mixed A single name as a string or a list of names as an array.
* @access protected
*/
var $helpers = array('html');
/**
* Enter description here...
*
* @var unknown_type
*/
var $viewPath;
/**
* Variables for the view
*
* @var array
* @access private
*/
var $_viewVars = array();
/**
* Web page title
*
* @var boolean
* @access private
*/
var $pageTitle = false;
/**
* An array of model objects.
*
* @var array Array of model objects.
* @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 $modelNames = array();
/**
* Enter description here...
*
* @var unknown_type
* @access public
*/
var $base = null;
/**
* Layout file to use (see /app/views/layouts/default.thtml)
*
* @var string
* @access public
*/
var $layout = 'default';
/**
* Automatically render the view (the dispatcher checks for this variable before running render())
*
* @var boolean
* @access public
*/
var $autoRender = true;
/**
* Enter description here...
*
* @var boolean
* @access public
*/
var $autoLayout = true;
/**
* Database configuration to use (see /config/database.php)
*
* @var string
* @access public
*/
var $useDbConfig = 'default';
/**
* Enter description here...
*
* @var string
* @access public
*/
var $beforeFilter = null;
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
/**
* Enter description here...
*
* @var unknown_type
*/
var $components = array();
/**
* Constructor.
*
*/
function __construct ()
{
[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
if($this->name === 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
$r = null;
if (!preg_match('/(.*)Controller/i', get_class($this), $r))
{
die("Controller::__construct() : Can't get or parse my own class name, exiting.");
}
$this->name = $r[1];
}
[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
$this->viewPath = Inflector::underscore($this->name);
parent::__construct();
}
/**
* Enter description here...
*
*/
function constructClasses(){
Merging [920] [922] [929] [920] Small bugfix for after condition in AjaxHelper::remoteFunction [922] Fixed Ticket #224 Added patch from Ticket #221 Added patch from Ticket #222 Renamed renderMethod() to requestAction() the name fits better since we are really requesting another objects response. Added a default setting to turn of autoRender for the class you are requesting the action from, this will allow you to request an action and use the return how you like, instead of letting the object output the content directly to the browser if it would normally do so. [929] Adding fix for Itcket #225. Moved code for beforeFilters to first section of Controller::constructClasses(). Removed current implementaion of beforeFilters. This will be changed to pass a reference of the object to the filters through a core filters class. The core filter class will then load the filters and perform all request on the object in the order the filters are arranged in var $beforeFilters, each beforeFilter needs to be a class that the core filter class will create an instance of. If one of the filters fails, it will return the object, untouched and not try to process other filters, an failed var will be set on the controller. This will be done before data base is initialized for the current object that is being filtered. Modifed the requestAction() changes are noted below Using inside of a controller. Default $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); Using a helper object to make request inside of a view: Default $helpername->requestAction('/controller/action/argument/'); Request Object to render output directly $helpername->requestAction('/controller/action/argument/', a('render')); Using the View object "$this" in a view to make request: $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); git-svn-id: https://svn.cakephp.org/repo/trunk/cake@930 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-09-21 05:48:09 +00:00
Merging from sandboxes [1079] Merged [1005] committed by nate but not added to core prior to release. Merged [1078] prior to modifying all developers sandboxes. [1081] adding view and template directories [1082] adding base files for view generator [1083] correcting all package and sub package tags for in doc blocks. Making sure every file in the core has doc block in them [1084] renaming working copy of latest release [1093] Added fix for associations using underscores if var $useTable is set in the associated models. This closes ticket #11. [1094] Fix for Ticket #24. The problem was tracked to a variable in View::_render(); $loadedHelpers was being assigned a reference when it when it should not have been. [1096] Initial work on controller components needs testing. Also added a work around for the basics.php uses(). Using the define DS where the files from the original version are now located in deeper libs directories. [1097] committing a few typos in the code I added [1098] reformatting code in component.php [1104] changed the test route and corrected a regex in inflector. [1111] removing the contructor from dispatcher, it is not needed [1112] Changes made for errors when a file is not present in webroot. Fixed the regex used in Router::parse(). Change the error layout template. [1113] Changes to Folder class to allow setting the permissions mode when constructing. This class needs to be refactored and move everything that is in the contructor out. The constructor should set the vars for use in other Folder::"methods"(). Will work on this at a later time. git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1114 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-09 01:56:21 +00:00
if (!empty($this->components))
{
$component =& new Component($this);
}
Merging [920] [922] [929] [920] Small bugfix for after condition in AjaxHelper::remoteFunction [922] Fixed Ticket #224 Added patch from Ticket #221 Added patch from Ticket #222 Renamed renderMethod() to requestAction() the name fits better since we are really requesting another objects response. Added a default setting to turn of autoRender for the class you are requesting the action from, this will allow you to request an action and use the return how you like, instead of letting the object output the content directly to the browser if it would normally do so. [929] Adding fix for Itcket #225. Moved code for beforeFilters to first section of Controller::constructClasses(). Removed current implementaion of beforeFilters. This will be changed to pass a reference of the object to the filters through a core filters class. The core filter class will then load the filters and perform all request on the object in the order the filters are arranged in var $beforeFilters, each beforeFilter needs to be a class that the core filter class will create an instance of. If one of the filters fails, it will return the object, untouched and not try to process other filters, an failed var will be set on the controller. This will be done before data base is initialized for the current object that is being filtered. Modifed the requestAction() changes are noted below Using inside of a controller. Default $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); Using a helper object to make request inside of a view: Default $helpername->requestAction('/controller/action/argument/'); Request Object to render output directly $helpername->requestAction('/controller/action/argument/', a('render')); Using the View object "$this" in a view to make request: $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); git-svn-id: https://svn.cakephp.org/repo/trunk/cake@930 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-09-21 05:48:09 +00:00
if (!empty($this->beforeFilter))
{
if(is_array($this->beforeFilter))
{
foreach($this->beforeFilter as $filter)
{
if(is_callable(array($this,$filter)))
{
$this->$filter();
}
Merging [920] [922] [929] [920] Small bugfix for after condition in AjaxHelper::remoteFunction [922] Fixed Ticket #224 Added patch from Ticket #221 Added patch from Ticket #222 Renamed renderMethod() to requestAction() the name fits better since we are really requesting another objects response. Added a default setting to turn of autoRender for the class you are requesting the action from, this will allow you to request an action and use the return how you like, instead of letting the object output the content directly to the browser if it would normally do so. [929] Adding fix for Itcket #225. Moved code for beforeFilters to first section of Controller::constructClasses(). Removed current implementaion of beforeFilters. This will be changed to pass a reference of the object to the filters through a core filters class. The core filter class will then load the filters and perform all request on the object in the order the filters are arranged in var $beforeFilters, each beforeFilter needs to be a class that the core filter class will create an instance of. If one of the filters fails, it will return the object, untouched and not try to process other filters, an failed var will be set on the controller. This will be done before data base is initialized for the current object that is being filtered. Modifed the requestAction() changes are noted below Using inside of a controller. Default $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); Using a helper object to make request inside of a view: Default $helpername->requestAction('/controller/action/argument/'); Request Object to render output directly $helpername->requestAction('/controller/action/argument/', a('render')); Using the View object "$this" in a view to make request: $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); git-svn-id: https://svn.cakephp.org/repo/trunk/cake@930 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-09-21 05:48:09 +00:00
}
}
else
{
if(is_callable(array($this,$this->beforeFilter)))
{
$this->{$this->beforeFilter}();
}
Merging [920] [922] [929] [920] Small bugfix for after condition in AjaxHelper::remoteFunction [922] Fixed Ticket #224 Added patch from Ticket #221 Added patch from Ticket #222 Renamed renderMethod() to requestAction() the name fits better since we are really requesting another objects response. Added a default setting to turn of autoRender for the class you are requesting the action from, this will allow you to request an action and use the return how you like, instead of letting the object output the content directly to the browser if it would normally do so. [929] Adding fix for Itcket #225. Moved code for beforeFilters to first section of Controller::constructClasses(). Removed current implementaion of beforeFilters. This will be changed to pass a reference of the object to the filters through a core filters class. The core filter class will then load the filters and perform all request on the object in the order the filters are arranged in var $beforeFilters, each beforeFilter needs to be a class that the core filter class will create an instance of. If one of the filters fails, it will return the object, untouched and not try to process other filters, an failed var will be set on the controller. This will be done before data base is initialized for the current object that is being filtered. Modifed the requestAction() changes are noted below Using inside of a controller. Default $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); Using a helper object to make request inside of a view: Default $helpername->requestAction('/controller/action/argument/'); Request Object to render output directly $helpername->requestAction('/controller/action/argument/', a('render')); Using the View object "$this" in a view to make request: $this->requestAction('/controller/action/argument/'); Request Object to render output directly $this->requestAction('/controller/action/argument/', a('render')); git-svn-id: https://svn.cakephp.org/repo/trunk/cake@930 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-09-21 05:48:09 +00:00
}
}
if(empty($this->params['pass']))
{
$id = false;
}
else
{
$id = $this->params['pass'];
}
$dboFactory = DboFactory::getInstance($this->useDbConfig);
$this->db =& $dboFactory;
$modelClass = Inflector::singularize($this->name);
$modelKey = strtolower(Inflector::underscore($modelClass));
if (class_exists($modelClass) && ($this->uses === false))
{
[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
$this->{$modelClass} =& new $modelClass($id);
$this->modelNames[] = $modelClass;
}
elseif ($this->uses)
{
if (!$this->db)
{
die("Controller::__construct() : ".$this->name." controller needs database access, exiting.");
}
$uses = is_array($this->uses)? $this->uses: array($this->uses);
foreach ($uses as $modelName)
{
$modelClass = ucfirst(strtolower($modelName));
$modelKey = strtolower(Inflector::underscore($modelClass));
if (class_exists($modelClass))
{
[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
$this->{$modelClass} =& new $modelClass($id);
$this->modelNames[] = $modelClass;
}
else
{
die("Controller::__construct() : ".ucfirst($this->name)." requires missing model {$modelClass}, exiting.");
}
}
}
}
/**
* Redirects to given $url, after turning off $this->autoRender.
*
* @param unknown_type $url
*/
function redirect ($url)
{
$this->autoRender = false;
header ('Location: '.$this->base.$url);
}
/**
* Saves a variable to use inside a template.
*
* @param mixed $one A string or an array of data.
* @param string $two Value in case $one is a string (which then works as the key), otherwise unused.
* @return unknown
*/
function set($one, $two=null)
{
return $this->_setArray(is_array($one)? $one: array($one=>$two));
}
/**
* Enter description here...
*
* @param unknown_type $action
*/
function setAction ($action)
{
$this->action = $action;
$args = func_get_args();
call_user_func_array(array(&$this, $action), $args);
}
/**
* Returns number of errors in a submitted FORM.
*
* @return int Number of errors
*/
function validate ()
{
$args = func_get_args();
$errors = call_user_func_array(array(&$this, 'validateErrors'), $args);
return count($errors);
}
/**
* Validates a FORM according to the rules set up in the Model.
*
* @return int Number of errors
*/
function validateErrors ()
{
$objects = func_get_args();
if (!count($objects)) return false;
$errors = array();
foreach ($objects as $object)
{
$errors = array_merge($errors, $object->invalidFields($object->data));
}
return $this->validationErrors = (count($errors)? $errors: false);
}
/**
* Gets an instance of the view object & prepares it for rendering the output, then
* asks the view to actualy do the job.
*
* @param unknown_type $action
* @param unknown_type $layout
* @param unknown_type $file
* @return unknown
*/
function render($action=null, $layout=null, $file=null)
{
$view =& new View($this);
[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
if(!empty($this->modelNames))
{
[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
foreach ($this->modelNames as $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
$key = Inflector::underscore($model);
if(!empty($this->{$model}->validationErrors))
{
[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
$view->validationErrors[$key] =& $this->{$model}->validationErrors;
}
}
}
return $view->render($action, $layout, $file);
}
/**
* Renders the Missing Controller web page.
*
*/
function missingController()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Controller';
$this->render('../errors/missingController');
exit();
}
/**
* Renders the Missing Action web page.
*
*/
function missingAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Method in Controller';
$this->render('../errors/missingAction');
exit();
}
/**
* Renders the Private Action web page.
*
*/
function privateAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Trying to access private method in class';
$this->render('../errors/privateAction');
exit();
}
/**
* Renders the Missing Database web page.
*
*/
function missingDatabase()
{
$this->autoLayout = true;
$this->pageTitle = 'Scaffold Missing Database Connection';
$this->render('../errors/missingScaffolddb');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingTable($tableName)
{
$this->autoLayout = true;
$this->missingTableName = $tableName;
$this->pageTitle = 'Missing Database Table';
$this->render('../errors/missingTable');
exit();
}
/**
* Renders the Missing Helper file web page.
*
*/
function missingHelperFile($file)
{
$this->missingHelperFile = $file;
$this->missingHelperClass = Inflector::camelize($file) . "Helper";
$this->pageTitle = 'Missing Helper File';
$this->render('../errors/missingHelperFile');
exit();
}
/**
* Renders the Missing Helper class web page.
*
*/
function missingHelperClass($class)
{
$this->missingHelperClass = Inflector::camelize($class) . "Helper";
$this->missingHelperFile = Inflector::underscore($class);
$this->pageTitle = 'Missing Helper Class';
$this->render('../errors/missingHelperClass');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingConnection()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Database Connection';
$this->render('../errors/missingDatabase');
exit();
}
// /**
// * Displays an error page to the user. Uses layouts/error.html to render the page.
// *
// * @param int $code Error code (for instance: 404)
// * @param string $name Name of the error (for instance: Not Found)
// * @param string $message Error message
// */
// function error ($code, $name, $message)
// {
// header ("HTTP/1.0 {$code} {$name}");
// print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
// }
/**
* Sets data for this view. Will set title if the key "title" is in given $data array.
*
* @param array $data Array of
* @access private
*/
function _setArray($data)
{
foreach ($data as $name => $value)
{
if ($name == 'title')
$this->_setTitle($value);
else
$this->_viewVars[$name] = $value;
}
}
/**
* Set the title element of the page.
*
* @param string $pageTitle Text for the title
* @access private
*/
function _setTitle($pageTitle)
{
$this->pageTitle = $pageTitle;
}
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url Relative URL to redirect to after the time expires
* @param int $time Time to show the message
*/
function flash($message, $url, $pause=1)
{
$this->autoRender = false;
$this->autoLayout = false;
$this->set('url', $this->base.$url);
$this->set('message', $message);
$this->set('pause', $pause);
$this->set('page_title', $message);
if(file_exists(VIEWS.'layouts'.DS.'flash.thtml'))
{
$flash = VIEWS.'layouts'.DS.'flash.thtml';
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml'))
{
$flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml';
}
$this->render(null,false,$flash);
}
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url URL to redirect to after the time expires
* @param int $time Time to show the message
*
* @param unknown_type $message
* @param unknown_type $url
* @param unknown_type $time
*/
function flashOut($message, $url, $time=1)
{
$this->autoRender = false;
$this->autoLayout = false;
$this->set('url', $url);
$this->set('message', $message);
$this->set('time', $time);
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
}
/**
* This function creates a $fieldNames array for the view to use.
* @todo Map more database field types to html form fields.
* @todo View the database field types from all the supported databases.
*
*/
function generateFieldNames( $data = null, $doCreateOptions = true )
{
// Initialize the list array
$fieldNames = array();
// figure out what model and table we are working with
[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
$model = Inflector::singularize($this->name);
$modelKey = Inflector::underscore($model);
$table = $this->{$model}->table;
[1159] Author: phpnut Date: 1:39:26 PM, Saturday, October 22, 2005 Message: Just about done with refactoring the model class. This should be tested to make sure all changes are working as expected. [1158] Author: phpnut Date: 5:34:41 AM, Saturday, October 22, 2005 Message: More work on associations. Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany [1157] Author: phpnut Date: 3:39:13 AM, Saturday, October 22, 2005 Message: More cleanup in Model class. [1156] Author: phpnut Date: 2:43:38 AM, Saturday, October 22, 2005 Message: Removing duplicate code the the associations. Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code. [1155] Author: phpnut Date: 1:52:47 AM, Saturday, October 22, 2005 Message: More cleaning up of the model class [1154] Author: phpnut Date: 1:40:34 AM, Saturday, October 22, 2005 Message: Cleaning up code layout [1153] Author: phpnut Date: 1:32:05 AM, Saturday, October 22, 2005 Message: removing temp variables and extra calls to Inflector::underscore(); [1152] Author: phpnut Date: 1:22:58 AM, Saturday, October 22, 2005 Message: More work on associations. Removing code that is no longer needed. [1151] Author: phpnut Date: 12:02:43 AM, Saturday, October 22, 2005 Message: more work on associations [1150] Author: phpnut Date: 6:25:45 PM, Friday, October 21, 2005 Message: more refactoring of associations [1149] Author: phpnut Date: 6:04:18 PM, Friday, October 21, 2005 Message: refactoring model and adding more association code [1145] Author: phpnut Date: 2:43:05 PM, Thursday, October 20, 2005 Message: more refactoring on associations [1143] Author: phpnut Date: 1:44:42 PM, Thursday, October 20, 2005 Message: Refactoring associations code. Starting work allowing full use of associations array settings git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
// get all of the column names.
$classRegistry =& ClassRegistry::getInstance();
[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
$objRegistryModel = $classRegistry->getObject($modelKey);
[1159] Author: phpnut Date: 1:39:26 PM, Saturday, October 22, 2005 Message: Just about done with refactoring the model class. This should be tested to make sure all changes are working as expected. [1158] Author: phpnut Date: 5:34:41 AM, Saturday, October 22, 2005 Message: More work on associations. Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany [1157] Author: phpnut Date: 3:39:13 AM, Saturday, October 22, 2005 Message: More cleanup in Model class. [1156] Author: phpnut Date: 2:43:38 AM, Saturday, October 22, 2005 Message: Removing duplicate code the the associations. Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code. [1155] Author: phpnut Date: 1:52:47 AM, Saturday, October 22, 2005 Message: More cleaning up of the model class [1154] Author: phpnut Date: 1:40:34 AM, Saturday, October 22, 2005 Message: Cleaning up code layout [1153] Author: phpnut Date: 1:32:05 AM, Saturday, October 22, 2005 Message: removing temp variables and extra calls to Inflector::underscore(); [1152] Author: phpnut Date: 1:22:58 AM, Saturday, October 22, 2005 Message: More work on associations. Removing code that is no longer needed. [1151] Author: phpnut Date: 12:02:43 AM, Saturday, October 22, 2005 Message: more work on associations [1150] Author: phpnut Date: 6:25:45 PM, Friday, October 21, 2005 Message: more refactoring of associations [1149] Author: phpnut Date: 6:04:18 PM, Friday, October 21, 2005 Message: refactoring model and adding more association code [1145] Author: phpnut Date: 2:43:05 PM, Thursday, October 20, 2005 Message: more refactoring on associations [1143] Author: phpnut Date: 1:44:42 PM, Thursday, October 20, 2005 Message: Refactoring associations code. Starting work allowing full use of associations array settings git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
foreach ($objRegistryModel->_tableInfo as $tables)
{
foreach ($tables as $tabl)
{
// set up the prompt
if( $objRegistryModel->isForeignKey($tabl['name']) )
{
$niceName = substr( $tabl['name'], 0, strpos( $tabl['name'], "_id" ) );
$fieldNames[ $tabl['name'] ]['prompt'] = Inflector::humanize($niceName);
// this is a foreign key, also set up the other controller
[1159] Author: phpnut Date: 1:39:26 PM, Saturday, October 22, 2005 Message: Just about done with refactoring the model class. This should be tested to make sure all changes are working as expected. [1158] Author: phpnut Date: 5:34:41 AM, Saturday, October 22, 2005 Message: More work on associations. Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany [1157] Author: phpnut Date: 3:39:13 AM, Saturday, October 22, 2005 Message: More cleanup in Model class. [1156] Author: phpnut Date: 2:43:38 AM, Saturday, October 22, 2005 Message: Removing duplicate code the the associations. Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code. [1155] Author: phpnut Date: 1:52:47 AM, Saturday, October 22, 2005 Message: More cleaning up of the model class [1154] Author: phpnut Date: 1:40:34 AM, Saturday, October 22, 2005 Message: Cleaning up code layout [1153] Author: phpnut Date: 1:32:05 AM, Saturday, October 22, 2005 Message: removing temp variables and extra calls to Inflector::underscore(); [1152] Author: phpnut Date: 1:22:58 AM, Saturday, October 22, 2005 Message: More work on associations. Removing code that is no longer needed. [1151] Author: phpnut Date: 12:02:43 AM, Saturday, October 22, 2005 Message: more work on associations [1150] Author: phpnut Date: 6:25:45 PM, Friday, October 21, 2005 Message: more refactoring of associations [1149] Author: phpnut Date: 6:04:18 PM, Friday, October 21, 2005 Message: refactoring model and adding more association code [1145] Author: phpnut Date: 2:43:05 PM, Thursday, October 20, 2005 Message: more refactoring on associations [1143] Author: phpnut Date: 1:44:42 PM, Thursday, October 20, 2005 Message: Refactoring associations code. Starting work allowing full use of associations array settings git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
$fieldNames[ $tabl['name'] ]['table'] = Inflector::pluralize($niceName);
[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
$fieldNames[ $tabl['name'] ]['model'] = $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']];
$fieldNames[ $tabl['name'] ]['controller'] = Inflector::pluralize($this->{$model}->tableToModel[Inflector::pluralize($niceName)]);
$fieldNames[ $tabl['name'] ]['foreignKey'] = true;
}
else if( 'created' != $tabl['name'] && 'updated' != $tabl['name'] )
{
$fieldNames[$tabl['name']]['prompt'] = Inflector::humanize($tabl['name']);
}
else if( 'created' == $tabl['name'] )
{
$fieldNames[$tabl['name']]['prompt'] = 'Created';
}
else if( 'updated' == $tabl['name'] )
{
$fieldNames[$tabl['name']]['prompt'] = 'Modified';
}
// Now, set up some other attributes that will be useful for auto generating a form.
//tagName is in the format table/field "post/title"
[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
$fieldNames[ $tabl['name']]['tagName'] = $modelKey.'/'.$tabl['name'];
// Now, find out if this is a required field.
//$validationFields = $classRegistry->getObject($table)->validate;
$validationFields = $objRegistryModel->validate;
if( isset( $validationFields[ $tabl['name'] ] ) )
{
// Now, we know that this field has some validation set.
// find out if it is a required field.
if( VALID_NOT_EMPTY == $validationFields[ $tabl['name'] ] )
{
// this is a required field.
$fieldNames[$tabl['name']]['required'] = true;
$fieldNames[$tabl['name']]['errorMsg'] = "Required Field";
}
}
// now, determine what the input type should be for this database field.
$lParenPos = strpos( $tabl['type'], '(');
$rParenPos = strpos( $tabl['type'], ')');
if( false != $lParenPos )
{
$type = substr($tabl['type'], 0, $lParenPos );
$fieldLength = substr( $tabl['type'], $lParenPos+1, $rParenPos - $lParenPos -1 );
}
else
{
$type = $tabl['type'];
}
switch( $type )
{
case "text":
{
$fieldNames[ $tabl['name']]['type'] = 'area';
//$fieldNames[ $tabl['name']]['size'] = $fieldLength;
}
break;
case "varchar":
{
if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
{
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
// get the list of options from the other model.
$registry =& ClassRegistry::getInstance();
[1159] Author: phpnut Date: 1:39:26 PM, Saturday, October 22, 2005 Message: Just about done with refactoring the model class. This should be tested to make sure all changes are working as expected. [1158] Author: phpnut Date: 5:34:41 AM, Saturday, October 22, 2005 Message: More work on associations. Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany [1157] Author: phpnut Date: 3:39:13 AM, Saturday, October 22, 2005 Message: More cleanup in Model class. [1156] Author: phpnut Date: 2:43:38 AM, Saturday, October 22, 2005 Message: Removing duplicate code the the associations. Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code. [1155] Author: phpnut Date: 1:52:47 AM, Saturday, October 22, 2005 Message: More cleaning up of the model class [1154] Author: phpnut Date: 1:40:34 AM, Saturday, October 22, 2005 Message: Cleaning up code layout [1153] Author: phpnut Date: 1:32:05 AM, Saturday, October 22, 2005 Message: removing temp variables and extra calls to Inflector::underscore(); [1152] Author: phpnut Date: 1:22:58 AM, Saturday, October 22, 2005 Message: More work on associations. Removing code that is no longer needed. [1151] Author: phpnut Date: 12:02:43 AM, Saturday, October 22, 2005 Message: more work on associations [1150] Author: phpnut Date: 6:25:45 PM, Friday, October 21, 2005 Message: more refactoring of associations [1149] Author: phpnut Date: 6:04:18 PM, Friday, October 21, 2005 Message: refactoring model and adding more association code [1145] Author: phpnut Date: 2:43:05 PM, Thursday, October 20, 2005 Message: more refactoring on associations [1143] Author: phpnut Date: 1:44:42 PM, Thursday, October 20, 2005 Message: Refactoring associations code. Starting work allowing full use of associations array settings git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
$otherModel =& $registry->getObject($fieldNames[ $tabl['name']]['model']);
if( is_object($otherModel) )
{
if( $doCreateOptions )
{
$otherDisplayField = $otherModel->getDisplayField();
foreach( $otherModel->findAll() as $pass )
{
foreach( $pass as $key=>$value )
{
if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
}
}
}
}
$fieldNames[ $tabl['name']]['selected'] = $data[$table][$tabl['name']];
}
}
else
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
}
break;
case "tinyint":
{
if( $fieldLength > 1 )
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
else
{
$fieldNames[ $tabl['name']]['type'] = 'checkbox';
}
}
break;
case "int":
case "smallint":
case "mediumint":
case "bigint":
case "decimal":
case "float":
case "double":
{
//BUGBUG: Need a better way to determine if this field is an auto increment foreign key.
// If it is a number, and it is a foreign key, we'll make a HUGE assumption that it is an auto increment field.
// for foreign key autonumber fields, we'll set the type to 'key' so that it does not display in the input form.
if( 0 == strncmp($tabl['name'], 'id', 2) )
{
$fieldNames[ $tabl['name']]['type'] = 'hidden';
}
else if( isset( $fieldNames[ $tabl['name']]['foreignKey'] ) )
{
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
// get the list of options from the other model.
$registry =& ClassRegistry::getInstance();
[1159] Author: phpnut Date: 1:39:26 PM, Saturday, October 22, 2005 Message: Just about done with refactoring the model class. This should be tested to make sure all changes are working as expected. [1158] Author: phpnut Date: 5:34:41 AM, Saturday, October 22, 2005 Message: More work on associations. Adding fields setting, order by and conditions to hasMany and hasAndBelongsToMany [1157] Author: phpnut Date: 3:39:13 AM, Saturday, October 22, 2005 Message: More cleanup in Model class. [1156] Author: phpnut Date: 2:43:38 AM, Saturday, October 22, 2005 Message: Removing duplicate code the the associations. Added Model::_associationSwitch(); to move all association settings to one location and remove duplicate code. [1155] Author: phpnut Date: 1:52:47 AM, Saturday, October 22, 2005 Message: More cleaning up of the model class [1154] Author: phpnut Date: 1:40:34 AM, Saturday, October 22, 2005 Message: Cleaning up code layout [1153] Author: phpnut Date: 1:32:05 AM, Saturday, October 22, 2005 Message: removing temp variables and extra calls to Inflector::underscore(); [1152] Author: phpnut Date: 1:22:58 AM, Saturday, October 22, 2005 Message: More work on associations. Removing code that is no longer needed. [1151] Author: phpnut Date: 12:02:43 AM, Saturday, October 22, 2005 Message: more work on associations [1150] Author: phpnut Date: 6:25:45 PM, Friday, October 21, 2005 Message: more refactoring of associations [1149] Author: phpnut Date: 6:04:18 PM, Friday, October 21, 2005 Message: refactoring model and adding more association code [1145] Author: phpnut Date: 2:43:05 PM, Thursday, October 20, 2005 Message: more refactoring on associations [1143] Author: phpnut Date: 1:44:42 PM, Thursday, October 20, 2005 Message: Refactoring associations code. Starting work allowing full use of associations array settings git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1160 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-22 19:31:38 +00:00
$otherModel =& $registry->getObject($fieldNames[ $tabl['name']]['model']);
if( is_object($otherModel) )
{
if( $doCreateOptions )
{
$otherDisplayField = $otherModel->getDisplayField();
foreach( $otherModel->findAll() as $pass )
{
foreach( $pass as $key=>$value )
{
if( $key == $fieldNames[ $tabl['name']]['model'] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
}
}
}
}
[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
$fieldNames[ $tabl['name']]['selected'] = $data[$modelKey][$tabl['name']];
}
}
else
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
}
break;
case "enum":
{
// for enums, the $fieldLength variable is actually the list of enums.
$fieldNames[ $tabl['name']]['type'] = 'select';
// This is a foreign key select dropdown box. now, we have to add the options.
$fieldNames[ $tabl['name']]['options'] = array();
$enumValues = split(',', $fieldLength );
foreach ($enumValues as $enum )
{
$enum = trim( $enum, "'" );
$fieldNames[$tabl['name']]['options'][$enum] = $enum;
}
$fieldNames[ $tabl['name']]['selected'] = $data[$table][$tabl['name']];
}
break;
case "date":
case "datetime":
{
if( 0 != strncmp( "created", $tabl['name'], 6 ) && 0 != strncmp("modified",$tabl['name'], 8) )
$fieldNames[ $tabl['name']]['type'] = $type;
}
break;
default:
//sorry, this database field type is not yet set up.
break;
} // end switch
}
// now, add any necessary hasAndBelongsToMany list boxes
// loop through the many to many relations to make a list box.
foreach( $objRegistryModel->_manyToMany as $relation )
{
list($tableName) = $relation;
$otherModelName = Inflector::singularize($tableName);
$otherModel = new $otherModelName();
if( $doCreateOptions )
{
$otherDisplayField = $otherModel->getDisplayField();
$fieldNames[$tableName]['model'] = $tableName;
$fieldNames[$tableName]['prompt'] = "Related ".Inflector::humanize($tableName);
$fieldNames[$tableName]['type'] = "selectMultiple";
$fieldNames[$tableName]['tagName'] = $otherModelName.'/'.$tableName;
foreach( $otherModel->findAll() as $pass )
{
foreach( $pass as $key=>$value )
{
if( $key == $otherModelName && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[$tableName]['options'][$value['id']] = $value[$otherDisplayField];
}
}
}
if( isset( $data[$tableName] ) )
{
foreach( $data[$tableName] as $row )
{
$fieldNames[$tableName]['selected'][$row['id']] = $row['id'];
}
}
}
} // end loop through manytomany relations.
}
return $fieldNames;
}
}
?>