| 1 |
lars |
1 |
<?php
|
|
|
2 |
/* SVN FILE: $Id: view.ctp 7945 2008-12-19 02:16:01Z gwoo $ */
|
|
|
3 |
/**
|
|
|
4 |
*
|
|
|
5 |
* PHP versions 4 and 5
|
|
|
6 |
*
|
|
|
7 |
* CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
|
|
|
8 |
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
|
|
9 |
*
|
|
|
10 |
* Licensed under The MIT License
|
|
|
11 |
* Redistributions of files must retain the above copyright notice.
|
|
|
12 |
*
|
|
|
13 |
* @filesource
|
|
|
14 |
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
|
|
15 |
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
|
|
|
16 |
* @package cake
|
|
|
17 |
* @subpackage cake.cake.libs.view.templates.scaffolds
|
|
|
18 |
* @since CakePHP(tm) v 0.10.0.1076
|
|
|
19 |
* @version $Revision: 7945 $
|
|
|
20 |
* @modifiedby $LastChangedBy: gwoo $
|
|
|
21 |
* @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
|
|
|
22 |
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
23 |
*/
|
|
|
24 |
?>
|
|
|
25 |
<div class="<?php echo $pluralVar;?> view">
|
|
|
26 |
<h2><?php echo sprintf(__("View %s", true), $singularHumanName);?></h2>
|
|
|
27 |
<dl>
|
|
|
28 |
<?php
|
|
|
29 |
$i = 0;
|
|
|
30 |
foreach ($scaffoldFields as $_field) {
|
|
|
31 |
$class = null;
|
|
|
32 |
if ($i++ % 2 == 0) {
|
|
|
33 |
$class = ' class="altrow"';
|
|
|
34 |
}
|
|
|
35 |
$isKey = false;
|
|
|
36 |
if (!empty($associations['belongsTo'])) {
|
|
|
37 |
foreach ($associations['belongsTo'] as $_alias => $_details) {
|
|
|
38 |
if ($_field === $_details['foreignKey']) {
|
|
|
39 |
$isKey = true;
|
|
|
40 |
echo "\t\t<dt{$class}>".Inflector::humanize($_alias)."</dt>\n";
|
|
|
41 |
echo "\t\t<dd{$class}>\n\t\t\t" . $html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller'=> $_details['controller'], 'action'=>'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . "\n\t\t </dd>\n";
|
|
|
42 |
break;
|
|
|
43 |
}
|
|
|
44 |
}
|
|
|
45 |
}
|
|
|
46 |
if ($isKey !== true) {
|
|
|
47 |
echo "\t\t<dt{$class}>".Inflector::humanize($_field)."</dt>\n";
|
|
|
48 |
echo "\t\t<dd{$class}>\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n \t\t</dd>\n";
|
|
|
49 |
}
|
|
|
50 |
}
|
|
|
51 |
?>
|
|
|
52 |
</dl>
|
|
|
53 |
</div>
|
|
|
54 |
<div class="actions">
|
|
|
55 |
<ul>
|
|
|
56 |
<?php
|
|
|
57 |
echo "\t\t<li>" .$html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action'=>'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n";
|
|
|
58 |
echo "\t\t<li>" .$html->link(sprintf(__('Delete %s', true), $singularHumanName), array('action'=>'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete', true).' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). " </li>\n";
|
|
|
59 |
echo "\t\t<li>" .$html->link(sprintf(__('List %s', true), $pluralHumanName), array('action'=>'index')). " </li>\n";
|
|
|
60 |
echo "\t\t<li>" .$html->link(sprintf(__('New %s', true), $singularHumanName), array('action'=>'add')). " </li>\n";
|
|
|
61 |
|
|
|
62 |
$done = array();
|
|
|
63 |
foreach ($associations as $_type => $_data) {
|
|
|
64 |
foreach ($_data as $_alias => $_details) {
|
|
|
65 |
if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
|
|
|
66 |
echo "\t\t<li>".$html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller'=> $_details['controller'], 'action'=>'index'))."</li>\n";
|
|
|
67 |
echo "\t\t<li>".$html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'))."</li>\n";
|
|
|
68 |
$done[] = $_details['controller'];
|
|
|
69 |
}
|
|
|
70 |
}
|
|
|
71 |
}
|
|
|
72 |
?>
|
|
|
73 |
</ul>
|
|
|
74 |
</div>
|
|
|
75 |
<?php
|
|
|
76 |
if (!empty($associations['hasOne'])) :
|
|
|
77 |
foreach ($associations['hasOne'] as $_alias => $_details): ?>
|
|
|
78 |
<div class="related">
|
|
|
79 |
<h3><?php echo sprintf(__("Related %s", true), Inflector::humanize($_details['controller']));?></h3>
|
|
|
80 |
<?php if (!empty(${$singularVar}[$_alias])):?>
|
|
|
81 |
<dl>
|
|
|
82 |
<?php
|
|
|
83 |
$i = 0;
|
|
|
84 |
$otherFields = array_keys(${$singularVar}[$_alias]);
|
|
|
85 |
foreach ($otherFields as $_field) {
|
|
|
86 |
$class = null;
|
|
|
87 |
if ($i++ % 2 == 0) {
|
|
|
88 |
$class = ' class="altrow"';
|
|
|
89 |
}
|
|
|
90 |
echo "\t\t<dt{$class}>".Inflector::humanize($_field)."</dt>\n";
|
|
|
91 |
echo "\t\t<dd{$class}>\n\t" .${$singularVar}[$_alias][$_field] ."\n </dd>\n";
|
|
|
92 |
}
|
|
|
93 |
?>
|
|
|
94 |
</dl>
|
|
|
95 |
<?php endif; ?>
|
|
|
96 |
<div class="actions">
|
|
|
97 |
<ul>
|
|
|
98 |
<li><?php echo $html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?>
|
|
|
99 |
</ul>
|
|
|
100 |
</div>
|
|
|
101 |
</div>
|
|
|
102 |
<?php
|
|
|
103 |
endforeach;
|
|
|
104 |
endif;
|
|
|
105 |
|
|
|
106 |
if (empty($associations['hasMany'])) {
|
|
|
107 |
$associations['hasMany'] = array();
|
|
|
108 |
}
|
|
|
109 |
if (empty($associations['hasAndBelongsToMany'])) {
|
|
|
110 |
$associations['hasAndBelongsToMany'] = array();
|
|
|
111 |
}
|
|
|
112 |
$relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
|
|
|
113 |
$i = 0;
|
|
|
114 |
foreach ($relations as $_alias => $_details):
|
|
|
115 |
$otherSingularVar = Inflector::variable($_alias);
|
|
|
116 |
?>
|
|
|
117 |
<div class="related">
|
|
|
118 |
<h3><?php echo sprintf(__("Related %s", true), Inflector::humanize($_details['controller']));?></h3>
|
|
|
119 |
<?php if (!empty(${$singularVar}[$_alias])):?>
|
|
|
120 |
<table cellpadding="0" cellspacing="0">
|
|
|
121 |
<tr>
|
|
|
122 |
<?php
|
|
|
123 |
$otherFields = array_keys(${$singularVar}[$_alias][0]);
|
|
|
124 |
foreach ($otherFields as $_field) {
|
|
|
125 |
echo "\t\t<th>".Inflector::humanize($_field)."</th>\n";
|
|
|
126 |
}
|
|
|
127 |
?>
|
|
|
128 |
<th class="actions">Actions</th>
|
|
|
129 |
</tr>
|
|
|
130 |
<?php
|
|
|
131 |
$i = 0;
|
|
|
132 |
foreach (${$singularVar}[$_alias] as ${$otherSingularVar}):
|
|
|
133 |
$class = null;
|
|
|
134 |
if ($i++ % 2 == 0) {
|
|
|
135 |
$class = ' class="altrow"';
|
|
|
136 |
}
|
|
|
137 |
echo "\t\t<tr{$class}>\n";
|
|
|
138 |
|
|
|
139 |
foreach ($otherFields as $_field) {
|
|
|
140 |
echo "\t\t\t<td>".${$otherSingularVar}[$_field]."</td>\n";
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
echo "\t\t\t<td class=\"actions\">\n";
|
|
|
144 |
echo "\t\t\t\t" . $html->link(__('View', true), array('controller'=> $_details['controller'], 'action'=>'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
|
|
145 |
echo "\t\t\t\t" . $html->link(__('Edit', true), array('controller'=> $_details['controller'], 'action'=>'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n";
|
|
|
146 |
echo "\t\t\t\t" . $html->link(__('Delete', true), array('controller'=> $_details['controller'], 'action'=>'delete', ${$otherSingularVar}[$_details['primaryKey']]), null, __('Are you sure you want to delete', true).' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'). "\n";
|
|
|
147 |
echo "\t\t\t</td>\n";
|
|
|
148 |
echo "\t\t</tr>\n";
|
|
|
149 |
endforeach;
|
|
|
150 |
?>
|
|
|
151 |
</table>
|
|
|
152 |
<?php endif; ?>
|
|
|
153 |
<div class="actions">
|
|
|
154 |
<ul>
|
|
|
155 |
<li><?php echo $html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller'=> $_details['controller'], 'action'=>'add'));?> </li>
|
|
|
156 |
</ul>
|
|
|
157 |
</div>
|
|
|
158 |
</div>
|
|
|
159 |
<?php endforeach;?>
|