mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-16 11:58:25 +00:00
7c7a2151ab
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@737 3807eeeb-6ff5-0310-8944-8be069107fe0
149 lines
4.8 KiB
Text
149 lines
4.8 KiB
Text
<?php
|
|
$modelName = Inflector::singularize($this->name);
|
|
$registry = ClassRegistry::getInstance();
|
|
|
|
?>
|
|
<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 ];
|
|
|
|
if( !empty($data[$modelName][$field]))
|
|
{
|
|
echo "<dd>".$html->linkTo($displayText, '/'.Inflector::underscore($value['controller']).'/show/'.$data[$modelName][ $field ] )."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// this is just a plain old field.
|
|
if( !empty($data[$modelName][$field]))
|
|
{
|
|
echo "<dd>".$data[$modelName][$field]."</dd>";
|
|
}
|
|
else
|
|
{
|
|
echo "<dd> </dd>";
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
|
|
</dl>
|
|
<ul class='actions'>
|
|
<?php
|
|
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>";
|
|
|
|
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>
|
|
|
|
<!--hasOne relationships -->
|
|
<?php
|
|
$objModel = $registry->getObject($modelName);
|
|
|
|
foreach ($objModel->_oneToOne as $relation)
|
|
{
|
|
list($table, $field, $value) = $relation;
|
|
$otherModelName = Inflector::singularize($table);
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($otherModelName)."</H2><br/><br/>";
|
|
echo "<dl>";
|
|
if( isset($data[$otherModelName]) && is_array($data[$otherModelName]) )
|
|
{
|
|
foreach( $data[$otherModelName] as $field=>$value )
|
|
{
|
|
echo "<dt>".Inflector::humanize($field)."</dt>";
|
|
if( !empty($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></div>";
|
|
}
|
|
?>
|
|
|
|
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
|
|
<?php
|
|
$relations = array();
|
|
foreach( $objModel->_oneToMany as $relation )
|
|
{
|
|
$relations[] = $relation;
|
|
} // end loop through onetomany relations.
|
|
|
|
foreach( $objModel->_manyToMany as $relation )
|
|
{
|
|
$relations[] = $relation;
|
|
} // end loop through manytomany relations.
|
|
|
|
foreach( $relations as $relation )
|
|
{
|
|
list($table, $field, $value) = $relation;
|
|
$count = 0;
|
|
$otherModelName = Inflector::singularize($table);
|
|
|
|
echo "<div class='related'><H2>Related ".Inflector::humanize($table)."</H2><br/><br/>";
|
|
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">
|
|
<?php
|
|
// add a link to create a new relation.
|
|
|
|
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>";
|
|
?>
|
|
</ul></div>
|
|
|
|
<?php } // end loop through relations
|
|
?>
|