2005-10-09 01:56:21 +00:00
<?php
/* SVN FILE: $Id$ */
/**
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
2006-05-26 05:29:17 +00:00
* Copyright (c) 2006, Cake Software Foundation, Inc.
* 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-05-26 05:29:17 +00:00
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake
* @subpackage cake.cake.libs.view.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-10-09 01:56:21 +00:00
*/
?>
2005-07-21 04:02:32 +00:00
<?php
2006-11-26 06:15:30 +00:00
$modelObj =& ClassRegistry::getObject($modelKey);
if(!empty($modelObj->alias)) {
$alias = array_combine(array_keys($modelObj->alias), array_keys($modelObj->alias));
2006-11-25 18:23:53 +00:00
}?>
2006-11-26 06:15:30 +00:00
<h1>View <?php echo $humanSingularName?>
2006-01-25 22:40:17 +00:00
</h1>
2005-08-21 06:49:02 +00:00
<dl>
2006-01-25 22:40:17 +00:00
<?php
2006-11-25 18:23:53 +00:00
foreach($fieldNames as $field => $value) {
2006-11-27 01:04:19 +00:00
echo "<dt>".$value['label']."</dt>";
2006-11-25 18:23:53 +00:00
if(isset($value['foreignKey'])) {
2006-11-26 06:15:30 +00:00
$otherControllerName = $value['controller'];
$otherControllerPath = Inflector::underscore($value['controller']);
$otherModelObj =& ClassRegistry::getObject($value['modelKey']);
$othereDisplayField = $otherModelObj->getDisplayField();
$displayText = $data[$alias[$value['model']]][$othereDisplayField];
2006-11-27 01:04:19 +00:00
if(!empty($data[$modelClass][$field]) && (!empty($displayText))) {
2006-11-26 06:15:30 +00:00
echo "<dd>".$html->link($displayText, $path . $otherControllerPath.'/view/'
.$data[$modelClass][$field] )."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2006-05-26 05:29:17 +00:00
echo "<dd> </dd>";
}
2006-11-25 18:23:53 +00:00
} else {
2006-11-26 06:15:30 +00:00
if( !empty($data[$modelClass][$field])) {
echo "<dd>".$data[$modelClass][$field]."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2006-05-26 05:29:17 +00:00
echo "<dd> </dd>";
}
}
2006-11-25 18:23:53 +00:00
}?>
2005-08-21 06:49:02 +00:00
</dl>
<ul class='actions'>
2005-07-21 04:02:32 +00:00
<?php
2006-11-26 06:15:30 +00:00
echo "<li>".$html->link('Edit '.$humanSingularName, $path . $viewPath.'/edit/'.$data[$modelClass][$modelObj->primaryKey])."</li>";
echo "<li>".$html->link('Delete '.$humanSingularName, $path . $viewPath.'/delete/'.$data[$modelClass][$modelObj->primaryKey], null, 'Are you sure you want to delete id '.$data[$modelClass][$modelObj->primaryKey].' ?')."</li>";
2006-11-27 01:04:19 +00:00
echo "<li>".$html->link('List '.$humanPluralName, $path . $viewPath.'/index')."</li>";
2006-11-26 06:15:30 +00:00
echo "<li>".$html->link('New '.$humanSingularName, $path . $viewPath.'/add')."</li>";
2006-01-12 02:10:47 +00:00
2006-11-25 18:23:53 +00:00
foreach( $fieldNames as $field => $value ) {
if( isset( $value['foreignKey'] ) ) {
2006-11-26 06:15:30 +00:00
echo "<li>".$html->link( "List ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/index/")."</li>";
2006-11-27 01:04:19 +00:00
echo "<li>".$html->link( "Add ".Inflector::humanize($value['controller']), $path . $value['controller'] ."/add/")."</li>";
2006-05-26 05:29:17 +00:00
}
2006-11-25 18:23:53 +00:00
}?>
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-11-26 06:15:30 +00:00
foreach ($modelObj->hasOne as $associationNameName => $relation) {
$otherModelKey = Inflector::underscore($relation['className']);
$otherModelObj =& ClassRegistry::getObject($otherModelKey);
$otherControllerPath = Inflector::pluralize($otherModelKey);
2006-05-26 05:29:17 +00:00
$new = true;
2006-11-26 06:15:30 +00:00
echo "<div class='related'><H2>Related ".Inflector::humanize($associationNameName)."</H2>";
2006-05-26 05:29:17 +00:00
echo "<dl>";
2006-11-26 06:15:30 +00:00
if(isset($data[$associationNameName]) && is_array($data[$associationNameName])) {
foreach($data[$associationNameName] as $field => $value) {
2006-11-25 18:23:53 +00:00
if(isset($value)) {
2006-05-26 05:29:17 +00:00
echo "<dt>".Inflector::humanize($field)."</dt>";
2006-11-25 18:23:53 +00:00
if(!empty($value)) {
2006-05-26 05:29:17 +00:00
echo "<dd>".$value."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2006-05-26 05:29:17 +00:00
echo "<dd> </dd>";
}
$new = null;
}
}
echo "</dl>";
2006-11-25 18:23:53 +00:00
if($new == null) {
2006-11-26 06:15:30 +00:00
echo "<ul class='actions'><li>".$html->link('Edit '.Inflector::humanize($associationNameName), $path . $otherControllerPath."/edit/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
2006-11-25 18:23:53 +00:00
} else {
2006-11-26 06:15:30 +00:00
echo "<ul class='actions'><li>".$html->link('New '.Inflector::humanize($associationNameName), $path . $otherControllerPath."/add/{$data[$associationNameName][$otherModelObj->primaryKey]}")."</li></ul></div>";
2006-05-26 05:29:17 +00:00
}
}
2006-01-25 22:40:17 +00:00
}
2005-08-21 20:01:32 +00:00
?>
<!-- HAS MANY AND HASANDBELONGSTOMANY -->
<?php
2006-11-26 06:15:30 +00:00
$relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany);
foreach($relations as $associationName => $relation) {
$otherModelKey = Inflector::underscore($relation['className']);
$otherModelObj = &ClassRegistry::getObject($otherModelKey);
$otherControllerPath = Inflector::pluralize($otherModelKey);
$otherModelName = $relation['className'];
2005-08-21 20:01:32 +00:00
2006-11-26 06:15:30 +00:00
echo "<div class='related'><h2>Related ".Inflector::humanize($otherControllerPath)."</h2>";
if(isset($data[$associationName][0]) && is_array($data[$associationName])) {?>
2006-05-26 05:29:17 +00:00
<table class="inav" cellspacing="0">
<tr>
2006-01-25 22:40:17 +00:00
<?php
2006-05-26 05:29:17 +00:00
$bFound = false;
2006-11-26 06:15:30 +00:00
foreach($data[$associationName][0] as $column => $value) {
if(false !== strpos($column, "_id")) {
$column = substr($column, 0, strpos($column, "_id" ));
}
2006-05-26 05:29:17 +00:00
echo "<th>".Inflector::humanize($column)."</th>";
2006-11-25 18:23:53 +00:00
}?>
2006-05-26 05:29:17 +00:00
<th>Actions</th>
</tr>
2005-08-21 06:49:02 +00:00
<?php
2006-11-26 06:15:30 +00:00
foreach($data[$associationName] as $row) {
2006-05-26 05:29:17 +00:00
echo "<tr>";
2006-11-26 06:15:30 +00:00
foreach($row as $column => $value) {
2006-05-26 05:29:17 +00:00
echo "<td>".$value."</td>";
}
2006-11-26 06:15:30 +00:00
if (isset($otherModelObj->{$associationName})) {?>
<td class="listactions"><?php echo $html->link('View', $path . $otherControllerPath .
"/view/{$row[$otherModelObj->primaryKey]}/")?>
<?php echo $html->link('Edit', $path . $otherControllerPath .
"/edit/{$row[$otherModelObj->primaryKey]}/")?>
<?php echo $html->link('Delete', $path . $otherControllerPath .
"/delete/{$row[$otherModelObj->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$otherModelObj->primaryKey].' ?')?>
2006-05-26 05:29:17 +00:00
</td>
2006-01-16 21:34:46 +00:00
<?php
2006-11-25 18:23:53 +00:00
} else {?>
2006-11-26 06:15:30 +00:00
<td class="listactions"><?php echo $html->link('View', $path . $otherControllerPath .
"/view/{$row[$otherModelObj->primaryKey]}/")?>
<?php echo $html->link('Edit', $path . $otherControllerPath .
"/edit/{$row[$otherModelObj->primaryKey]}/")?>
<?php echo $html->link('Delete', $path . $otherControllerPath .
"/delete/{$row[$otherModelObj->primaryKey]}/", null, 'Are you sure you want to delete id '.$row[$otherModelObj->primaryKey].' ?')?>
2006-05-26 05:29:17 +00:00
</td>
2005-08-21 06:49:02 +00:00
<?php
2006-05-26 05:29:17 +00:00
}
echo "</tr>";
}
2006-11-25 18:23:53 +00:00
}?>
2006-01-25 22:40:17 +00:00
</table>
2005-08-21 06:49:02 +00:00
<ul class="actions">
2006-11-26 06:15:30 +00:00
<?php echo "<li>".$html->link('New '.Inflector::humanize($associationName), $path . $otherControllerPath ."/add/")."</li>";?>
2005-08-21 20:01:32 +00:00
</ul></div>
2006-11-25 18:23:53 +00:00
<?php }?>