Mercurial > hg > Members > shoshi > webvirt
comparison cake/libs/view/scaffolds/view.ctp @ 0:261e66bd5a0c
hg init
author | Shoshi TAMAKI <shoshi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 24 Jul 2011 21:08:31 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:261e66bd5a0c |
---|---|
1 <?php | |
2 /** | |
3 * | |
4 * PHP versions 4 and 5 | |
5 * | |
6 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | |
7 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
8 * | |
9 * Licensed under The MIT License | |
10 * Redistributions of files must retain the above copyright notice. | |
11 * | |
12 * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) | |
13 * @link http://cakephp.org CakePHP(tm) Project | |
14 * @package cake | |
15 * @subpackage cake.cake.libs.view.templates.scaffolds | |
16 * @since CakePHP(tm) v 0.10.0.1076 | |
17 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) | |
18 */ | |
19 ?> | |
20 <div class="<?php echo $pluralVar;?> view"> | |
21 <h2><?php printf(__("View %s", true), $singularHumanName); ?></h2> | |
22 <dl> | |
23 <?php | |
24 $i = 0; | |
25 foreach ($scaffoldFields as $_field) { | |
26 $class = null; | |
27 if ($i++ % 2 == 0) { | |
28 $class = ' class="altrow"'; | |
29 } | |
30 $isKey = false; | |
31 if (!empty($associations['belongsTo'])) { | |
32 foreach ($associations['belongsTo'] as $_alias => $_details) { | |
33 if ($_field === $_details['foreignKey']) { | |
34 $isKey = true; | |
35 echo "\t\t<dt{$class}>" . Inflector::humanize($_alias) . "</dt>\n"; | |
36 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 </dd>\n"; | |
37 break; | |
38 } | |
39 } | |
40 } | |
41 if ($isKey !== true) { | |
42 echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n"; | |
43 echo "\t\t<dd{$class}>\n\t\t\t{${$singularVar}[$modelClass][$_field]}\n \t\t</dd>\n"; | |
44 } | |
45 } | |
46 ?> | |
47 </dl> | |
48 </div> | |
49 <div class="actions"> | |
50 <h3><?php __('Actions'); ?></h3> | |
51 <ul> | |
52 <?php | |
53 echo "\t\t<li>" .$this->Html->link(sprintf(__('Edit %s', true), $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " </li>\n"; | |
54 echo "\t\t<li>" .$this->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"; | |
55 echo "\t\t<li>" .$this->Html->link(sprintf(__('List %s', true), $pluralHumanName), array('action' => 'index')). " </li>\n"; | |
56 echo "\t\t<li>" .$this->Html->link(sprintf(__('New %s', true), $singularHumanName), array('action' => 'add')). " </li>\n"; | |
57 | |
58 $done = array(); | |
59 foreach ($associations as $_type => $_data) { | |
60 foreach ($_data as $_alias => $_details) { | |
61 if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { | |
62 echo "\t\t<li>" . $this->Html->link(sprintf(__('List %s', true), Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "</li>\n"; | |
63 echo "\t\t<li>" . $this->Html->link(sprintf(__('New %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "</li>\n"; | |
64 $done[] = $_details['controller']; | |
65 } | |
66 } | |
67 } | |
68 ?> | |
69 </ul> | |
70 </div> | |
71 <?php | |
72 if (!empty($associations['hasOne'])) : | |
73 foreach ($associations['hasOne'] as $_alias => $_details): ?> | |
74 <div class="related"> | |
75 <h3><?php printf(__("Related %s", true), Inflector::humanize($_details['controller'])); ?></h3> | |
76 <?php if (!empty(${$singularVar}[$_alias])):?> | |
77 <dl> | |
78 <?php | |
79 $i = 0; | |
80 $otherFields = array_keys(${$singularVar}[$_alias]); | |
81 foreach ($otherFields as $_field) { | |
82 $class = null; | |
83 if ($i++ % 2 == 0) { | |
84 $class = ' class="altrow"'; | |
85 } | |
86 echo "\t\t<dt{$class}>" . Inflector::humanize($_field) . "</dt>\n"; | |
87 echo "\t\t<dd{$class}>\n\t" . ${$singularVar}[$_alias][$_field] . "\n </dd>\n"; | |
88 } | |
89 ?> | |
90 </dl> | |
91 <?php endif; ?> | |
92 <div class="actions"> | |
93 <ul> | |
94 <li><?php echo $this->Html->link(sprintf(__('Edit %s', true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']]))."</li>\n";?> | |
95 </ul> | |
96 </div> | |
97 </div> | |
98 <?php | |
99 endforeach; | |
100 endif; | |
101 | |
102 if (empty($associations['hasMany'])) { | |
103 $associations['hasMany'] = array(); | |
104 } | |
105 if (empty($associations['hasAndBelongsToMany'])) { | |
106 $associations['hasAndBelongsToMany'] = array(); | |
107 } | |
108 $relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']); | |
109 $i = 0; | |
110 foreach ($relations as $_alias => $_details): | |
111 $otherSingularVar = Inflector::variable($_alias); | |
112 ?> | |
113 <div class="related"> | |
114 <h3><?php printf(__("Related %s", true), Inflector::humanize($_details['controller'])); ?></h3> | |
115 <?php if (!empty(${$singularVar}[$_alias])):?> | |
116 <table cellpadding="0" cellspacing="0"> | |
117 <tr> | |
118 <?php | |
119 $otherFields = array_keys(${$singularVar}[$_alias][0]); | |
120 if (isset($_details['with'])) { | |
121 $index = array_search($_details['with'], $otherFields); | |
122 unset($otherFields[$index]); | |
123 } | |
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" . $this->Html->link(__('View', true), array('controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; | |
145 echo "\t\t\t\t" . $this->Html->link(__('Edit', true), array('controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])). "\n"; | |
146 echo "\t\t\t\t" . $this->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 $this->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;?> |