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
*/
?>
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-05-15 05:38:56 +00:00
echo "<dd {$class}>"
.$html->link($displayText,
array('controller'=> $otherControllerPath, 'action'=>'view',
$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-05-10 16:19:23 +00:00
<div class="nav">
<ul>
<?php
2007-05-15 05:38:56 +00:00
echo '<li>' . $html->link(sprintf(__("Edit %s", true), $humanSingularName), array('action' => 'edit', $data[$modelClass][$primaryKey])) . '</li>';
echo '<li>' . $html->link(sprintf(__("Delete %s", true), $humanSingularName), array('action' => 'delete', $data[$modelClass][$primaryKey]), null, sprintf(__("Are you sure you want to delete id %s?", true), $data[$modelClass][$primaryKey])) . '</li>';
2007-05-10 16:19:23 +00:00
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
2007-05-10 16:19:23 +00:00
foreach($fieldNames as $field => $value) {
if(isset($value['foreignKey']) && $value['modelKey'] != $modelKey) {
echo "<li>".$html->link(sprintf(__("List %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action' => 'index')) . '</li>';
echo "<li>".$html->link(sprintf(__("Add %s", true), Inflector::humanize($value['controller'])), array('controller' => $value['controller'], 'action'=>'add'))."</li>";
}
}?>
</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;
2007-05-15 05:38:56 +00:00
foreach ($hasOne as $associationName => $relation) {
2006-11-26 06:15:30 +00:00
$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\">";
2007-05-10 16:19:23 +00:00
echo "<h3>".sprintf(__("Related %s", true), Inflector::humanize($associationName))."</h3>";
if(!empty($data[$associationName])) {
2007-01-10 22:53:52 +00:00
echo "<dl>";
2007-05-10 16:19:23 +00:00
foreach($data[$associationName] 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-05-10 16:19:23 +00:00
echo "<li>".$html->link(sprintf(__("Edit %s", true), Inflector::humanize($associationName)), array('controller'=> $otherControllerPath, 'action'=>'edit', $data[$associationName][$otherModelObj->primaryKey]))."</li>";
2006-11-25 18:23:53 +00:00
} else {
2007-05-10 16:19:23 +00:00
echo "<li>".$html->link(sprintf(__("New %s", true), Inflector::humanize($associationName)), 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
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
2007-05-15 05:38:56 +00:00
?>
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>
2007-05-10 16:19:23 +00:00
<?php echo "<li>".$html->link(__('New ', true).Inflector::humanize($otherModelKey), array('controller'=> $otherControllerPath, 'action'=>'add')) . '</li>'; ?>
2007-01-10 22:53:52 +00:00
</ul>
</div>
</div>
2006-11-25 18:23:53 +00:00
<?php }?>