2005-07-21 04:02:32 +00:00
|
|
|
<?php
|
2005-08-21 06:49:02 +00:00
|
|
|
$model = Inflector::pluralize($this->name);
|
2005-09-17 02:22:07 +00:00
|
|
|
//$table = Inflector::underscore(get_class($this->models[strtolower(Inflector::singularize(Inflector::underscore($this->name)))]));
|
|
|
|
|
|
|
|
$modelKey = Inflector::underscore(Inflector::singularize($this->name));
|
2005-08-21 06:49:02 +00:00
|
|
|
$humanName = Inflector::humanize($this->name);
|
|
|
|
$humanSingularName = Inflector::singularize( $humanName );
|
|
|
|
// var_dump( $data );
|
2005-07-21 04:02:32 +00:00
|
|
|
?>
|
2005-08-21 06:49:02 +00:00
|
|
|
<table class="inav" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<?php foreach ( $fieldNames as $fieldName ) { ?>
|
|
|
|
<th><?php echo $fieldName['prompt'];?></th>
|
|
|
|
<?php } ?>
|
|
|
|
<th>Actions</th>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
$iRowIndex = 0;
|
|
|
|
|
|
|
|
if( is_array( $data ) )
|
|
|
|
{
|
|
|
|
foreach ( $data as $row ) {
|
|
|
|
if( $iRowIndex++ % 2 == 0 )
|
|
|
|
{
|
|
|
|
echo "<tr>";
|
|
|
|
} else {
|
|
|
|
echo "<tr class='altRow'>";
|
|
|
|
}
|
|
|
|
foreach( $fieldNames as $field=>$value ) { ?>
|
|
|
|
<td>
|
|
|
|
<?php
|
2005-08-25 16:40:50 +00:00
|
|
|
if( isset($value['foreignKey']) )
|
|
|
|
{
|
2005-08-21 06:49:02 +00:00
|
|
|
|
|
|
|
// this is a foreign key, figure out what the display field should be for this model.
|
|
|
|
$otherModelName = $value['model'];
|
|
|
|
$otherControllerName = $value['controller'];
|
|
|
|
|
|
|
|
$registry = ClassRegistry::getInstance();
|
|
|
|
$otherModelObject = $registry->getObject( $otherModelName );
|
|
|
|
if( is_object($otherModelObject) )
|
|
|
|
{
|
|
|
|
$displayText = $row[$otherModelName][ $otherModelObject->getDisplayField() ];
|
|
|
|
} else{
|
2005-09-17 02:22:07 +00:00
|
|
|
$displayText = $row[$modelKey][$field];
|
2005-08-21 06:49:02 +00:00
|
|
|
}
|
2005-09-17 02:22:07 +00:00
|
|
|
echo $html->linkTo( $displayText, "/".Inflector::underscore($otherControllerName)."/show/".$row[$modelKey][$field] );
|
2005-08-21 06:49:02 +00:00
|
|
|
|
|
|
|
} else {
|
2005-09-17 02:22:07 +00:00
|
|
|
echo $row[$modelKey][$field];
|
2005-08-21 06:49:02 +00:00
|
|
|
} ?>
|
|
|
|
</td>
|
|
|
|
<?php } // end for each $fieldNames as $field=>value ?>
|
2005-09-17 02:22:07 +00:00
|
|
|
<td class="listactions"><?php echo $html->linkTo('View',"/".$this->viewPath."/show/{$row[$modelKey]['id']}/")?>
|
|
|
|
<?php echo $html->linkTo('Edit',"/".$this->viewPath."/edit/{$row[$modelKey]['id']}/")?>
|
|
|
|
<?php echo $html->linkTo('Delete',"/".$this->viewPath."/destroy/{$row[$modelKey]['id']}/")?>
|
2005-08-21 06:49:02 +00:00
|
|
|
</td>
|
2005-07-21 04:02:32 +00:00
|
|
|
|
2005-08-21 06:49:02 +00:00
|
|
|
</tr>
|
|
|
|
<?php } // end for each data as row
|
|
|
|
} // end if( $data )?>
|
|
|
|
|
|
|
|
|
|
|
|
</table>
|
|
|
|
<ul class="actions">
|
|
|
|
<li><?php echo $html->linkTo('New '.$humanSingularName, '/'.$this->viewPath.'/new'); ?></li>
|
|
|
|
</ul>
|
2005-07-21 04:02:32 +00:00
|
|
|
|
|
|
|
|