2005-10-09 01:56:21 +00:00
<?php
/* SVN FILE: $Id$ */
/**
*
* PHP versions 4 and 5
*
2007-02-02 10:39:45 +00:00
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
2006-05-26 05:29:17 +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
2007-02-02 10:39:45 +00:00
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
2006-05-26 05:29:17 +00:00
* @package cake
* @subpackage cake.cake.libs.view.templates.scaffolds
2007-02-02 10:39:45 +00:00
* @since CakePHP(tm) v 0.10.0.1076
2006-05-26 05:29:17 +00:00
* @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);
2007-01-10 22:53:52 +00:00
?>
<h2><?php echo sprintf(__("View %s", true), $humanSingularName)?></h2>
2005-08-21 06:49:02 +00:00
<dl>
2006-01-25 22:40:17 +00:00
<?php
2007-01-10 22:53:52 +00:00
$i = 0;
2006-11-25 18:23:53 +00:00
foreach($fieldNames as $field => $value) {
2007-01-10 22:53:52 +00:00
if($i++ % 2 == 0) {
$class = 'class="altrow"';
} else {
$class = null;
}
echo "<dt {$class}>".$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))) {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}>".$html->link($displayText, $path . $otherControllerPath.'/view/'
2006-11-26 06:15:30 +00:00
.$data[$modelClass][$field] )."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}> </dd>";
2006-05-26 05:29:17 +00:00
}
2006-11-25 18:23:53 +00:00
} else {
2006-11-26 06:15:30 +00:00
if( !empty($data[$modelClass][$field])) {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}>".$data[$modelClass][$field]."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}> </dd>";
2006-05-26 05:29:17 +00:00
}
}
2006-11-25 18:23:53 +00:00
}?>
2005-08-21 06:49:02 +00:00
</dl>
2007-01-10 22:53:52 +00:00
<div class='actions'>
<ul>
2005-07-21 04:02:32 +00:00
<?php
2006-12-23 09:09:06 +00:00
echo '<li>' . $html->link(sprintf(__("Edit %s", true), $humanSingularName), array('action' => 'edit', $data[$modelClass][$modelObj->primaryKey])) . '</li>';
echo '<li>' . $html->link(sprintf(__("Delete %s", true), $humanSingularName), array('action' => 'delete', $data[$modelClass][$modelObj->primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $data[$modelClass][$modelObj->primaryKey])) . '</li>';
echo '<li>' . $html->link(sprintf(__("List %s", true), $humanPluralName), array('action' => 'index')) . '</li>';
echo '<li>' . $html->link(sprintf(__("New %s", true), $humanSingularName), array('action' => 'add')) . '</li>';
2006-01-12 02:10:47 +00:00
2006-12-20 21:41:42 +00:00
foreach($fieldNames as $field => $value) {
if(isset($value['foreignKey'])) {
2006-12-28 05:22:41 +00:00
echo "<li>".$html->link(sprintf(__("List %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action' => 'index')) . '</li>';
2007-01-10 22:53:52 +00:00
echo "<li>".$html->link(sprintf(__("Add %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action'=>'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>
2007-01-10 22:53:52 +00:00
</div>
2005-08-21 20:01:32 +00:00
<!--hasOne relationships -->
2005-07-21 04:02:32 +00:00
<?php
2007-01-10 22:53:52 +00:00
$j = 0;
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;
2007-01-10 22:53:52 +00:00
if($j++ % 2 == 0) {
$class = 'class="altrow"';
} else {
$class = null;
}
echo "<div class=\"related\">";
echo "<h3>".sprintf(__("Related %s", true), Inflector::humanize($associationNameName))."</h3>";
if(!empty($data[$associationNameName])) {
echo "<dl>";
2006-11-26 06:15:30 +00:00
foreach($data[$associationNameName] as $field => $value) {
2006-11-25 18:23:53 +00:00
if(isset($value)) {
2007-01-10 22:53:52 +00:00
echo "<dt {$class}>".Inflector::humanize($field)."</dt>";
2006-11-25 18:23:53 +00:00
if(!empty($value)) {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}>".$value."</dd>";
2006-11-25 18:23:53 +00:00
} else {
2007-01-10 22:53:52 +00:00
echo "<dd {$class}> </dd>";
2006-05-26 05:29:17 +00:00
}
$new = null;
}
}
echo "</dl>";
2007-01-10 22:53:52 +00:00
}
echo "<div class=\"actions\">";
echo "<ul>";
2006-11-25 18:23:53 +00:00
if($new == null) {
2007-01-10 22:53:52 +00:00
echo "<li>".$html->link(sprintf(__("Edit %s", true), Inflector::humanize($associationNameName)), array('controller'=> $otherControllerPath, 'action'=>'edit', $data[$associationNameName][$otherModelObj->primaryKey]))."</li>";
2006-11-25 18:23:53 +00:00
} else {
2007-01-10 22:53:52 +00:00
echo "<li>".$html->link(sprintf(__("New %s", true), Inflector::humanize($associationNameName)), array('controller'=> $otherControllerPath, 'action'=>'add'))."</li>";
2006-05-26 05:29:17 +00:00
}
2007-01-10 22:53:52 +00:00
echo "</ul>";
echo "</div>";
echo "</div>";
2006-01-25 22:40:17 +00:00
}
2005-08-21 20:01:32 +00:00
?>
2007-01-10 22:53:52 +00:00
<!--hasMany and hasAndBelongsToMany relationships -->
2005-08-21 20:01:32 +00:00
<?php
2006-11-26 06:15:30 +00:00
$relations = array_merge($modelObj->hasMany, $modelObj->hasAndBelongsToMany);
foreach($relations as $associationName => $relation) {
2006-12-23 09:09:06 +00:00
2006-11-26 06:15:30 +00:00
$otherModelKey = Inflector::underscore($relation['className']);
$otherModelObj = &ClassRegistry::getObject($otherModelKey);
$otherControllerPath = Inflector::pluralize($otherModelKey);
2006-12-23 09:09:06 +00:00
2006-11-26 06:15:30 +00:00
$otherModelName = $relation['className'];
2005-08-21 20:01:32 +00:00
2007-01-10 22:53:52 +00:00
echo "<div class=\"related\">";
echo "<h3>".sprintf(__("Related %s", true), Inflector::humanize($otherControllerPath))."</h3>";
2006-11-26 06:15:30 +00:00
if(isset($data[$associationName][0]) && is_array($data[$associationName])) {?>
2007-01-10 22:53:52 +00:00
<table cellspacing="0">
2006-05-26 05:29:17 +00:00
<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-12-23 09:09:06 +00:00
}
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>";
}
2007-01-10 22:53:52 +00:00
?>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> $otherControllerPath, 'action'=>'view', $row[$otherModelObj->primaryKey]))?>
<?php echo $html->link(__('Edit', true), array('controller'=> $otherControllerPath, 'action'=>'edit', $row[$otherModelObj->primaryKey]))?>
<?php echo $html->link(__('Delete', true), array('controller'=> $otherControllerPath, 'action'=>'delete', $row[$otherModelObj->primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $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>";
}
2007-01-10 22:53:52 +00:00
?>
</table>
<?php
2006-11-25 18:23:53 +00:00
}?>
2007-01-10 22:53:52 +00:00
<div class="actions">
<ul>
<?php echo "<li>".$html->link(__('New ', true).Inflector::humanize($associationName), array('controller'=> $otherControllerPath, 'action'=>'add')) . '</li>'; ?>
</ul>
</div>
</div>
2006-11-25 18:23:53 +00:00
<?php }?>