2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
$modelName = Inflector::singularize($this->name);
|
|
|
|
$registry = ClassRegistry::getInstance();
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
?>
|
|
|
|
<dl>
|
|
|
|
<?php foreach( $fieldNames as $field=>$value ) {
|
|
|
|
echo "<dt>".$value['prompt']."</dt>";
|
|
|
|
if( isset( $value['foreignKey'] ) ) {
|
|
|
|
$otherModelObject = $registry->getObject($value['model']);
|
|
|
|
$displayField = $otherModelObject->getDisplayField();
|
|
|
|
$displayText = $data[$value['model']][ $displayField ];
|
|
|
|
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelName][ $field ] )."</dd>";
|
|
|
|
} else {
|
|
|
|
// this is just a plain old field.
|
|
|
|
if( isset($data[$modelName][$field]) )
|
|
|
|
{
|
|
|
|
echo "<dd>".$data[$modelName][$field]."</dd>";
|
|
|
|
} else {
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</dl>
|
|
|
|
<ul class='actions'>
|
2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
echo "<li>".$html->linkTo('Edit '.Inflector::humanize($modelName), '/'.$this->viewPath.'/edit/'.$data[$modelName]['id'])."</li>";
|
|
|
|
echo "<li>".$html->linkTo('Delete '.Inflector::humanize($modelName), '/'.$this->viewPath.'/destroy/'.$data[$modelName]['id'])."</li>";
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
foreach( $fieldNames as $field=>$value ) {
|
|
|
|
if( isset( $value['foreignKey'] ) )
|
|
|
|
{
|
|
|
|
echo "<li>".$html->linkTo( "View ".Inflector::humanize($value['controller']), "/".Inflector::underscore($value['controller'])."/show/".$data[Inflector::singularize($params['controller'])][$field] )."</li>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</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 06:49:02 +00:00
|
|
|
$objModel = $registry->getObject($modelName);
|
2005-08-21 20:01:32 +00:00
|
|
|
|
|
|
|
foreach ($objModel->_oneToOne as $relation)
|
|
|
|
{
|
|
|
|
list($table, $field, $value) = $relation;
|
|
|
|
$otherModelName = Inflector::singularize($table);
|
|
|
|
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($otherModelName)."</H2>";
|
|
|
|
echo "<dl>";
|
|
|
|
if( isset($data[$otherModelName]) && is_array($data[$otherModelName]) )
|
|
|
|
{
|
|
|
|
foreach( $data[$otherModelName] as $field=>$value )
|
|
|
|
{
|
|
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
|
|
|
if( isset($value) )
|
|
|
|
{
|
|
|
|
echo "<dd>".$value."</dd>";
|
|
|
|
} else {
|
|
|
|
echo "<dd> </dd>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
echo "</dl>";
|
|
|
|
echo "<ul class='actions'><li>".$html->linkTo('Edit '.Inflector::humanize($otherModelName),"/".Inflector::underscore($table)."/edit/{$data[$otherModelName]['id']}")."</li></ul>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
|
|
<?php
|
|
|
|
$relations = array();
|
2005-08-21 06:49:02 +00:00
|
|
|
foreach( $objModel->_oneToMany as $relation )
|
|
|
|
{
|
2005-08-21 20:01:32 +00:00
|
|
|
$relations[] = $relation;
|
|
|
|
} // end loop through onetomany relations.
|
|
|
|
|
|
|
|
foreach( $objModel->_manyToMany as $relation )
|
|
|
|
{
|
|
|
|
$relations[] = $relation;
|
|
|
|
} // end loop through manytomany relations.
|
|
|
|
|
|
|
|
foreach( $relations as $relation )
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
list($table, $field, $value) = $relation;
|
2005-08-21 20:01:32 +00:00
|
|
|
$count = 0;
|
2005-08-21 06:49:02 +00:00
|
|
|
$otherModelName = Inflector::singularize($table);
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($table)."</H2>";
|
|
|
|
if( isset($data[$table]) && is_array($data[$table]) )
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
|
|
|
|
<table class="inav" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<?php // Loop through and create the header row.
|
|
|
|
// find a row that matches this title.
|
|
|
|
$bFound = false;
|
|
|
|
foreach( $data[$table][0] as $column=>$value ) {
|
|
|
|
echo "<th>".Inflector::humanize($column)."</th>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<th>Actions</th>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
// now find all matching rows
|
|
|
|
foreach( $data[$table] as $row )
|
|
|
|
{
|
|
|
|
echo "<tr>";
|
|
|
|
foreach( $row as $column=>$value )
|
|
|
|
{
|
|
|
|
echo "<td>".$value."</td>";
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
<td class="listactions"><?php echo $html->linkTo('View',"/".Inflector::underscore($table)."/show/{$row['id']}/")?>
|
|
|
|
<?php echo $html->linkTo('Edit',"/".Inflector::underscore($table)."/edit/{$row['id']}/")?>
|
|
|
|
<?php echo $html->linkTo('Delete',"/".Inflector::underscore($table)."/destroy/{$row['id']}/")?>
|
|
|
|
</td>
|
|
|
|
<?php
|
|
|
|
echo "</tr>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</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
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
echo "<li>".$html->linkTo('New '.Inflector::humanize($otherModelName),"/".Inflector::underscore($table)."/new/")."</li>";
|
|
|
|
// echo "<li>".$html->linkTo( "View ".Inflector::humanize($table), "/".Inflector::underscore($table)."/list/".$modelName."/".$data[$modelName]['id'])."</li>";
|
2005-07-21 04:02:32 +00:00
|
|
|
?>
|
2005-08-21 20:01:32 +00:00
|
|
|
</ul></div>
|
|
|
|
|
|
|
|
<?php } // end loop through relations
|
|
|
|
?>
|