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/>
|
2006-01-20 07:46:14 +00:00
|
|
|
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2006-01-06 04:46:42 +00:00
|
|
|
*
|
2005-12-23 21:57:26 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
2005-10-09 01:56:21 +00:00
|
|
|
*
|
|
|
|
* @filesource
|
2006-01-20 07:46:14 +00:00
|
|
|
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
2005-12-23 21:57:26 +00:00
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2005-10-09 01:56:21 +00:00
|
|
|
* @package cake
|
2006-02-25 19:20:18 +00:00
|
|
|
* @subpackage cake.cake.libs.view.templates.scaffolds
|
2005-10-09 01:56:21 +00:00
|
|
|
* @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
|
2006-03-15 20:45:59 +00:00
|
|
|
$modelName = ucwords(Inflector::singularize($this->name));
|
2006-01-25 22:40:17 +00:00
|
|
|
$modelKey = Inflector::underscore($modelName);
|
|
|
|
$objModel =& ClassRegistry::getObject($modelKey);
|
|
|
|
if(!empty($objModel->alias))
|
|
|
|
{
|
|
|
|
foreach ($objModel->alias as $key => $value)
|
|
|
|
{
|
|
|
|
$alias[] = $key;
|
|
|
|
}
|
|
|
|
$count = 0;
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
2006-01-25 22:40:17 +00:00
|
|
|
<h1>Show
|
|
|
|
<?php echo Inflector::humanize($modelName)?>
|
|
|
|
</h1>
|
2005-10-24 07:51:09 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
<dl>
|
2006-01-25 22:40:17 +00:00
|
|
|
<?php
|
|
|
|
foreach($fieldNames as $field => $value)
|
|
|
|
{
|
|
|
|
echo "<dt>".$value['prompt']."</dt>";
|
|
|
|
if(isset($value['foreignKey']))
|
|
|
|
{
|
|
|
|
$otherModelObject =& ClassRegistry::getObject(Inflector::underscore($objModel->tableToModel[$value['table']]));
|
|
|
|
$displayField = $otherModelObject->getDisplayField();
|
|
|
|
$displayText = $data[$alias[$count]][$displayField];
|
2005-12-23 21:57:26 +00:00
|
|
|
|
2006-01-25 22:40:17 +00:00
|
|
|
if(!empty($data[$objModel->tableToModel[$objModel->table]][$field]) && (isset($displayText)))
|
|
|
|
{
|
|
|
|
echo "<dd>".$html->link($displayText, '/'.Inflector::underscore($value['controller']).'/show/'
|
2006-02-18 23:42:21 +00:00
|
|
|
.$data[$objModel->tableToModel[$objModel->table]][$field] )."</dd>";
|
2006-01-25 22:40:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !empty($data[$objModel->tableToModel[$objModel->table]][$field]))
|
|
|
|
{
|
|
|
|
echo "<dd>".$data[$objModel->tableToModel[$objModel->table]][$field]."</dd>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
</dl>
|
|
|
|
<ul class='actions'>
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2006-01-25 22:40:17 +00:00
|
|
|
echo "<li>".$html->link('Edit '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/edit/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
2006-02-23 11:40:52 +00:00
|
|
|
echo "<li>".$html->link('Delete '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/delete/'.$data[$objModel->tableToModel[$objModel->table]][$this->controller->{$modelName}->primaryKey])."</li>";
|
2006-01-25 22:40:17 +00:00
|
|
|
echo "<li>".$html->link('List '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/index')."</li>";
|
|
|
|
echo "<li>".$html->link('New '.Inflector::humanize($objModel->name), '/'.$this->viewPath.'/add')."</li>";
|
2006-01-12 02:10:47 +00:00
|
|
|
|
2006-01-25 22:40:17 +00:00
|
|
|
foreach( $fieldNames as $field => $value )
|
|
|
|
{
|
|
|
|
if( isset( $value['foreignKey'] ) )
|
|
|
|
{
|
|
|
|
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/index/")."</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
|
2006-01-25 22:40:17 +00:00
|
|
|
foreach ($objModel->hasOne as $association => $relation)
|
|
|
|
{
|
|
|
|
$model = $relation['className'];
|
|
|
|
$otherModelName = $objModel->tableToModel[$objModel->{$model}->table];
|
|
|
|
$controller = Inflector::pluralize($model);
|
|
|
|
$new = true;
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($association)."</H2>";
|
|
|
|
echo "<dl>";
|
|
|
|
if(isset($data[$association]) && is_array($data[$association]))
|
|
|
|
{
|
|
|
|
foreach($data[$association] as $field => $value)
|
|
|
|
{
|
|
|
|
if(isset($value))
|
|
|
|
{
|
|
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
|
|
|
if(!empty($value))
|
|
|
|
{
|
|
|
|
echo "<dd>".$value."</dd>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
|
|
|
$new = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo "</dl>";
|
|
|
|
if($new == null)
|
|
|
|
{
|
|
|
|
echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/edit/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($association),"/".Inflector::underscore($controller)."/add/{$data[$association][$objModel->{$model}->primaryKey]}")."</li></ul></div>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 20:01:32 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
|
|
<?php
|
2006-01-25 22:40:17 +00:00
|
|
|
$relations = array_merge($objModel->hasMany, $objModel->hasAndBelongsToMany);
|
|
|
|
foreach($relations as $association => $relation)
|
|
|
|
{
|
|
|
|
$model = $relation['className'];
|
|
|
|
$count = 0;
|
|
|
|
$otherModelName = Inflector::singularize($model);
|
|
|
|
$controller = Inflector::pluralize($model);
|
2005-08-21 20:01:32 +00:00
|
|
|
|
2006-01-25 22:40:17 +00:00
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize(Inflector::pluralize($association))."</H2>";
|
|
|
|
if(isset($data[$association]) && is_array($data[$association]))
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
2006-01-25 22:40:17 +00:00
|
|
|
<table class="inav" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<?php
|
|
|
|
$bFound = false;
|
|
|
|
foreach($data[$association][0] as $column=>$value)
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
2006-01-25 22:40:17 +00:00
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
2006-01-25 22:40:17 +00:00
|
|
|
<th>Actions</th>
|
|
|
|
</tr>
|
2005-08-21 06:49:02 +00:00
|
|
|
<?php
|
2006-01-25 22:40:17 +00:00
|
|
|
foreach($data[$association] as $row)
|
|
|
|
{
|
|
|
|
echo "<tr>";
|
|
|
|
foreach($row as $column=>$value)
|
|
|
|
{
|
|
|
|
echo "<td>".$value."</td>";
|
|
|
|
}
|
|
|
|
if (isset($this->controller->{$modelName}->{$association}))
|
2005-08-21 06:49:02 +00:00
|
|
|
{
|
|
|
|
?>
|
2006-01-25 22:40:17 +00:00
|
|
|
<td class="listactions"><?php echo $html->link('View',"/".Inflector::underscore($controller).
|
|
|
|
"/show/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->link('Edit',"/".Inflector::underscore($controller).
|
|
|
|
"/edit/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->link('Delete',"/".Inflector::underscore($controller).
|
2006-02-23 11:40:52 +00:00
|
|
|
"/delete/{$row[$this->controller->{$modelName}->{$association}->primaryKey]}/")?>
|
2006-02-18 23:42:21 +00:00
|
|
|
</td>
|
2006-01-16 21:34:46 +00:00
|
|
|
<?php
|
2006-01-25 22:40:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<td class="listactions"><?php echo $html->link('View',"/".Inflector::underscore($controller).
|
|
|
|
"/show/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->link('Edit',"/".Inflector::underscore($controller).
|
|
|
|
"/edit/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
|
|
|
<?php echo $html->link('Delete',"/".Inflector::underscore($controller).
|
2006-02-23 11:40:52 +00:00
|
|
|
"/delete/{$row[$this->controller->{$modelName}->primaryKey]}/")?>
|
2006-01-25 22:40:17 +00:00
|
|
|
</td>
|
2005-08-21 06:49:02 +00:00
|
|
|
<?php
|
|
|
|
}
|
2006-01-25 22:40:17 +00:00
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
2006-01-25 22:40:17 +00:00
|
|
|
</table>
|
2005-08-21 06:49:02 +00:00
|
|
|
<ul class="actions">
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2006-01-25 22:40:17 +00:00
|
|
|
echo "<li>".$html->link('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>
|
2006-01-25 22:40:17 +00:00
|
|
|
<?php
|
|
|
|
}
|
2005-09-17 02:22:07 +00:00
|
|
|
?>
|