2005-10-09 01:56:21 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base controller class.
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
2005-12-23 21:57:26 +00:00
|
|
|
* Copyright (c) 2005, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-10-09 01:56:21 +00:00
|
|
|
*
|
|
|
|
* @filesource
|
2005-12-23 21:57:26 +00:00
|
|
|
* @copyright Copyright (c) 2005, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2005-10-09 01:56:21 +00:00
|
|
|
* @package cake
|
|
|
|
* @subpackage cake.cake.libs.controller.templates.scaffolds
|
|
|
|
* @since CakePHP v 0.10.0.1076
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
?>
|
|
|
|
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
$modelName = Inflector::singularize($this->name);
|
2005-09-17 02:22:07 +00:00
|
|
|
$modelKey = Inflector::underscore($modelName);
|
[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
|
|
|
$registry =& ClassRegistry::getInstance();
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$objModel = $registry->getObject($modelKey);
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
2005-10-24 07:51:09 +00:00
|
|
|
<h1>Show <?php echo Inflector::humanize($modelName)?></h1>
|
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
<dl>
|
[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
|
|
|
<?php foreach($fieldNames as $field => $value)
|
2005-08-28 16:33:50 +00:00
|
|
|
{
|
[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
|
|
|
echo "<dt>".$value['prompt']."</dt>";
|
|
|
|
if(isset($value['foreignKey']))
|
2005-08-28 16:33:50 +00:00
|
|
|
{
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
$alias = array_search($value['table'],$objModel->alias);
|
[1210]
Author: phpnut
Date: 4:44:45 AM, Wednesday, October 26, 2005
Message:
AJAX is now available as a by default in the $html variable in the templates.
You access it like this:
$html->Ajax->xxx();
Updated default templates.
[1208]
Author: phpnut
Date: 6:49:26 PM, Tuesday, October 25, 2005
Message:
Adding fix in Controller::generateFieldNames();
[1203]
Author: phpnut
Date: 10:40:28 AM, Tuesday, October 25, 2005
Message:
Changes made to core templates and css.
Fixed added for Ticket #60
[1202]
Author: phpnut
Date: 2:30:58 AM, Tuesday, October 25, 2005
Message:
Fix for cake error templates
Fixed a key for tables that are underscored in scaffolded code.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1211 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-10-26 10:55:44 +00:00
|
|
|
$otherModelObject = $registry->getObject(Inflector::underscore($objModel->tableToModel[$value['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
|
|
|
$displayField = $otherModelObject->getDisplayField();
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
$displayText = $data[$alias][$displayField];
|
2005-12-23 21:57:26 +00:00
|
|
|
|
[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
|
|
|
if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]))
|
|
|
|
{
|
|
|
|
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'
|
|
|
|
.$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
2005-08-28 16:33:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
[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
|
|
|
// this is just a plain old field.
|
|
|
|
if( !empty($data[$objModel->tableToModel[$objModel->table]][$field]))
|
|
|
|
{
|
|
|
|
echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
2005-08-28 16:33:50 +00:00
|
|
|
}
|
2005-12-23 21:57:26 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
</dl>
|
|
|
|
<ul class='actions'>
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-12-23 21:57:26 +00:00
|
|
|
echo "<li>".$html->linkTo('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
|
|
|
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/destroy/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
[1285]
Author: phpnut
Date: 10:09:03 PM, Monday, October 31, 2005
Message:
Removed references in the Session class
[1283]
Author: phpnut
Date: 8:47:37 PM, Monday, October 31, 2005
Message:
Added fix to the Controller::constructClassess().
The database should have an instance available if a component will use it.
[1282]
Author: phpnut
Date: 8:36:07 PM, Monday, October 31, 2005
Message:
Updated the Model association methods to correct and error I introduced when reactoring last week.
Added a return from each of the settings in Security::inactiveMins(); This class is not fully implemented.
Updated scaffold and dipatcher with changes to the session class.
Fixed problem with session not working properly.
Added a regenrate id for sessions.
When CAKE_SECURITY is set to high this will regenrate a new session key on each request.
The old session file will be removed from the file system. This is a added security measure.
[1270]
Author: phpnut
Date: 1:55:28 PM, Sunday, October 30, 2005
Message:
Updated Session class to regenrate a new session key on each request when security level set to high.
Updated doc comments in some classes
[1269]
Author: phpnut
Date: 9:49:43 AM, Sunday, October 30, 2005
Message:
Added a fix for Ticket #105
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1286 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-01 04:20:28 +00:00
|
|
|
echo "<li>".$html->linkTo('List '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/index')."</li>";
|
2005-10-28 08:25:31 +00:00
|
|
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
|
2005-12-23 21:57:26 +00:00
|
|
|
foreach( $fieldNames as $field => $value ) {
|
2005-08-21 06:49:02 +00:00
|
|
|
if( isset( $value['foreignKey'] ) )
|
|
|
|
{
|
2005-12-23 21:57:26 +00:00
|
|
|
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[$alias][$otherModelObject->primaryKey] )."</li>";
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</ul>
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 20:01:32 +00:00
|
|
|
<!--hasOne relationships -->
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 20:01:32 +00:00
|
|
|
foreach ($objModel->_oneToOne as $relation)
|
|
|
|
{
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
list($association, $model, $value) = $relation;
|
2005-10-24 07:51:09 +00:00
|
|
|
$otherModelName = $objModel->tableToModel[$model];
|
|
|
|
$controller = Inflector::pluralize($model);
|
2005-12-23 21:57:26 +00:00
|
|
|
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
|
2005-08-21 20:01:32 +00:00
|
|
|
echo "<dl>";
|
2005-12-23 21:57:26 +00:00
|
|
|
if( isset($data[$association]) && is_array($data[$association]) )
|
2005-08-21 20:01:32 +00:00
|
|
|
{
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
foreach( $data[$association] as $field=>$value )
|
2005-08-21 20:01:32 +00:00
|
|
|
{
|
|
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
2005-08-28 16:33:50 +00:00
|
|
|
if( !empty($value) )
|
2005-08-21 20:01:32 +00:00
|
|
|
{
|
|
|
|
echo "<dd>".$value."</dd>";
|
|
|
|
} else {
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
2005-12-23 21:57:26 +00:00
|
|
|
}
|
|
|
|
|
2005-08-21 20:01:32 +00:00
|
|
|
}
|
|
|
|
echo "</dl>";
|
2005-12-23 21:57:26 +00:00
|
|
|
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/edit/{$data[$association][$otherModelObject->primaryKey]}")."</li></ul></div>";
|
2005-08-21 20:01:32 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
|
|
<?php
|
|
|
|
$relations = array();
|
2005-12-23 21:57:26 +00:00
|
|
|
foreach( $objModel->_oneToMany as $relation )
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
2005-08-21 20:01:32 +00:00
|
|
|
$relations[] = $relation;
|
|
|
|
} // end loop through onetomany relations.
|
|
|
|
|
2005-12-23 21:57:26 +00:00
|
|
|
foreach( $objModel->_manyToMany as $relation )
|
2005-08-21 20:01:32 +00:00
|
|
|
{
|
|
|
|
$relations[] = $relation;
|
|
|
|
} // end loop through manytomany relations.
|
|
|
|
|
|
|
|
foreach( $relations as $relation )
|
|
|
|
{
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
list($association, $model, $value) = $relation;
|
2005-08-21 20:01:32 +00:00
|
|
|
$count = 0;
|
[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
|
|
|
$otherModelName = Inflector::singularize($model);
|
|
|
|
$controller = Inflector::pluralize($model);
|
2005-07-21 04:02:32 +00:00
|
|
|
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>";
|
2005-12-23 21:57:26 +00:00
|
|
|
if( isset($data[$association]) && is_array($data[$association]) )
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
?>
|
2005-12-23 21:57:26 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
<table class="inav" cellspacing="0">
|
2005-12-23 21:57:26 +00:00
|
|
|
<tr>
|
2005-08-21 06:49:02 +00:00
|
|
|
<?php // Loop through and create the header row.
|
|
|
|
// find a row that matches this title.
|
|
|
|
$bFound = false;
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
foreach( $data[$association][0] as $column=>$value ) {
|
2005-08-21 06:49:02 +00:00
|
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<th>Actions</th>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
// now find all matching rows
|
2005-12-23 21:57:26 +00:00
|
|
|
foreach( $data[$association] as $row )
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
echo "<tr>";
|
2005-12-23 21:57:26 +00:00
|
|
|
foreach( $row as $column=>$value )
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
echo "<td>".$value."</td>";
|
|
|
|
}
|
|
|
|
?>
|
2005-12-23 21:57:26 +00:00
|
|
|
<td class="listactions"><?php echo $html->linkTo('View',"/".Inflector::underscore($controller)."/show/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->linkTo('Edit',"/".Inflector::underscore($controller)."/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->linkTo('Delete',"/".Inflector::underscore($controller)."/destroy/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
2005-08-21 06:49:02 +00:00
|
|
|
</td>
|
|
|
|
<?php
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
2005-12-23 21:57:26 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
</table>
|
|
|
|
<ul class="actions">
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
// add a link to create a new relation.
|
2005-07-21 04:02:32 +00:00
|
|
|
|
[1335]
Author: phpnut
Date: 2:11:57 PM, Saturday, November 05, 2005
Message:
Fixing Controller::generateFieldNames() to work with changes to Model
[1334]
Author: phpnut
Date: 1:18:02 PM, Saturday, November 05, 2005
Message:
More work on changes made in the model to allow association names to be used as an alias.
These changes are being made to update scaffold to work with changes in [1330].
Added var $alias that holds an array with the key value pair of the table name and the association name.
[1330]
Author: phpnut
Date: 10:25:16 PM, Friday, November 04, 2005
Message:
Adding fix for Ticket #127. The query returns properly now but, this breaks scaffold which I will be fixing soon.
Also the save methods for the model have not been tested but I am sure these need to be corrected also.
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1336 3807eeeb-6ff5-0310-8944-8be069107fe0
2005-11-05 20:35:43 +00:00
|
|
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/add/")."</li>";
|
2005-07-21 04:02:32 +00:00
|
|
|
?>
|
2005-08-21 20:01:32 +00:00
|
|
|
</ul></div>
|
|
|
|
|
|
|
|
<?php } // end loop through relations
|
2005-09-17 02:22:07 +00:00
|
|
|
?>
|