cakephp2-php8/lib/Cake/View/scaffolds/view.ctp

158 lines
6.2 KiB
Text
Raw Normal View History

<?php
/**
*
2010-10-03 16:38:58 +00:00
* PHP 5
*
2009-11-06 06:46:59 +00:00
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
2010-01-26 19:18:20 +00:00
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
2010-01-26 19:18:20 +00:00
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
2009-11-06 06:00:11 +00:00
* @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.view.templates.scaffolds
* @since CakePHP(tm) v 0.10.0.1076
2009-11-06 06:51:51 +00:00
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
?>
<div class="<?php echo $pluralVar;?> view">
2011-03-12 19:02:56 +00:00
<h2><?php echo __d('cake', 'View %s', $singularHumanName); ?></h2>
<dl>
<?php
$i = 0;
foreach ($scaffoldFields as $_field) {
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
$isKey = false;
if (!empty($associations['belongsTo'])) {
foreach ($associations['belongsTo'] as $_alias => $_details) {
if ($_field === $_details['foreignKey']) {
$isKey = true;
echo "\t\t<dt{$class}>" . Inflector::humanize($_alias) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t\t\t" . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t&nbsp;</dd>\n";
break;
}
}
}
if ($isKey !== true) {
echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n";
echo "\t\t<dd{$class}>" . h(${$singularVar}[$modelClass][$_field]) . "&nbsp;</dd>\n";
}
}
?>
</dl>
</div>
<div class="actions">
2011-03-12 19:02:56 +00:00
<h3><?php echo __d('cake', 'Actions'); ?></h3>
<ul>
<?php
2011-03-12 19:02:56 +00:00
echo "\t\t<li>" .$this->Html->link(__d('cake', 'Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'List %s', $pluralHumanName), array('action' => 'index')). " </li>\n";
echo "\t\t<li>" .$this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')). " </li>\n";
$done = array();
foreach ($associations as $_type => $_data) {
foreach ($_data as $_alias => $_details) {
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
2011-03-12 19:02:56 +00:00
echo "\t\t<li>" . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n";
echo "\t\t<li>" . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n";
$done[] = $_details['controller'];
}
}
}
?>
</ul>
</div>
<?php
if (!empty($associations['hasOne'])) :
foreach ($associations['hasOne'] as $_alias => $_details): ?>
<div class="related">
2011-03-12 19:02:56 +00:00
<h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?>
<dl>
<?php
$i = 0;
$otherFields = array_keys(${$singularVar}[$_alias]);
foreach ($otherFields as $_field) {
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n";
echo "\t\t<dd{$class}>\n\t" . ${$singularVar}[$_alias][$_field] . "\n&nbsp;</dd>\n";
}
?>
</dl>
<?php endif; ?>
<div class="actions">
<ul>
2011-03-12 19:02:56 +00:00
<li><?php echo $this->Html->link(__d('cake', 'Edit %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
</ul>
</div>
</div>
<?php
endforeach;
endif;
if (empty($associations['hasMany'])) {
$associations['hasMany'] = array();
}
if (empty($associations['hasAndBelongsToMany'])) {
$associations['hasAndBelongsToMany'] = array();
}
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
$i = 0;
foreach ($relations as $_alias => $_details):
$otherSingularVar = Inflector::variable($_alias);
?>
<div class="related">
2011-03-12 19:02:56 +00:00
<h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3>
<?php if (!empty(${$singularVar}[$_alias])):?>
<table cellpadding="0" cellspacing="0">
<tr>
<?php
$otherFields = array_keys(${$singularVar}[$_alias][0]);
if (isset($_details['with'])) {
$index = array_search($_details['with'], $otherFields);
unset($otherFields[$index]);
}
foreach ($otherFields as $_field) {
echo "\t\t<th>" . Inflector::humanize($_field) . "</th>\n";
}
?>
<th class="actions">Actions</th>
</tr>
<?php
$i = 0;
foreach (${$singularVar}[$_alias] as ${$otherSingularVar}):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
echo "\t\t<tr{$class}>\n";
foreach ($otherFields as $_field) {
echo "\t\t\t<td>" . ${$otherSingularVar}[$_field] . "</td>\n";
}
echo "\t\t\t<td class=\"actions\">\n";
2011-03-12 19:02:56 +00:00
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'View'), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'Edit'), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
echo "\t\t\t\t" . $this->Html->link(__d('cake', 'Delete'), array('controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __d('cake', 'Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
echo "\t\t\t</td>\n";
echo "\t\t</tr>\n";
endforeach;
?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
2011-03-12 19:02:56 +00:00
<li><?php echo $this->Html->link(__d('cake', "New %s", Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul>
</div>
</div>
<?php endforeach;?>