comparison cake/console/templates/default/views/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.console.libs.templates.views
16 * @since CakePHP(tm) v 1.2.0.5234
17 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
18 */
19 ?>
20 <div class="<?php echo $pluralVar;?> view">
21 <h2><?php echo "<?php __('{$singularHumanName}');?>";?></h2>
22 <dl><?php echo "<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
23 <?php
24 foreach ($fields as $field) {
25 $isKey = false;
26 if (!empty($associations['belongsTo'])) {
27 foreach ($associations['belongsTo'] as $alias => $details) {
28 if ($field === $details['foreignKey']) {
29 $isKey = true;
30 echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize(Inflector::underscore($alias)) . "'); ?></dt>\n";
31 echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \$this->Html->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
32 break;
33 }
34 }
35 }
36 if ($isKey !== true) {
37 echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "'); ?></dt>\n";
38 echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t\t\t<?php echo \${$singularVar}['{$modelClass}']['{$field}']; ?>\n\t\t\t&nbsp;\n\t\t</dd>\n";
39 }
40 }
41 ?>
42 </dl>
43 </div>
44 <div class="actions">
45 <h3><?php echo "<?php __('Actions'); ?>"; ?></h3>
46 <ul>
47 <?php
48 echo "\t\t<li><?php echo \$this->Html->link(__('Edit " . $singularHumanName ."', true), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
49 echo "\t\t<li><?php echo \$this->Html->link(__('Delete " . $singularHumanName . "', true), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> </li>\n";
50 echo "\t\t<li><?php echo \$this->Html->link(__('List " . $pluralHumanName . "', true), array('action' => 'index')); ?> </li>\n";
51 echo "\t\t<li><?php echo \$this->Html->link(__('New " . $singularHumanName . "', true), array('action' => 'add')); ?> </li>\n";
52
53 $done = array();
54 foreach ($associations as $type => $data) {
55 foreach ($data as $alias => $details) {
56 if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) {
57 echo "\t\t<li><?php echo \$this->Html->link(__('List " . Inflector::humanize($details['controller']) . "', true), array('controller' => '{$details['controller']}', 'action' => 'index')); ?> </li>\n";
58 echo "\t\t<li><?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add')); ?> </li>\n";
59 $done[] = $details['controller'];
60 }
61 }
62 }
63 ?>
64 </ul>
65 </div>
66 <?php
67 if (!empty($associations['hasOne'])) :
68 foreach ($associations['hasOne'] as $alias => $details): ?>
69 <div class="related">
70 <h3><?php echo "<?php __('Related " . Inflector::humanize($details['controller']) . "');?>";?></h3>
71 <?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
72 <dl><?php echo "\t<?php \$i = 0; \$class = ' class=\"altrow\"';?>\n";?>
73 <?php
74 foreach ($details['fields'] as $field) {
75 echo "\t\t<dt<?php if (\$i % 2 == 0) echo \$class;?>><?php __('" . Inflector::humanize($field) . "');?></dt>\n";
76 echo "\t\t<dd<?php if (\$i++ % 2 == 0) echo \$class;?>>\n\t<?php echo \${$singularVar}['{$alias}']['{$field}'];?>\n&nbsp;</dd>\n";
77 }
78 ?>
79 </dl>
80 <?php echo "<?php endif; ?>\n";?>
81 <div class="actions">
82 <ul>
83 <li><?php echo "<?php echo \$this->Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?></li>\n";?>
84 </ul>
85 </div>
86 </div>
87 <?php
88 endforeach;
89 endif;
90 if (empty($associations['hasMany'])) {
91 $associations['hasMany'] = array();
92 }
93 if (empty($associations['hasAndBelongsToMany'])) {
94 $associations['hasAndBelongsToMany'] = array();
95 }
96 $relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
97 $i = 0;
98 foreach ($relations as $alias => $details):
99 $otherSingularVar = Inflector::variable($alias);
100 $otherPluralHumanName = Inflector::humanize($details['controller']);
101 ?>
102 <div class="related">
103 <h3><?php echo "<?php __('Related " . $otherPluralHumanName . "');?>";?></h3>
104 <?php echo "<?php if (!empty(\${$singularVar}['{$alias}'])):?>\n";?>
105 <table cellpadding = "0" cellspacing = "0">
106 <tr>
107 <?php
108 foreach ($details['fields'] as $field) {
109 echo "\t\t<th><?php __('" . Inflector::humanize($field) . "'); ?></th>\n";
110 }
111 ?>
112 <th class="actions"><?php echo "<?php __('Actions');?>";?></th>
113 </tr>
114 <?php
115 echo "\t<?php
116 \$i = 0;
117 foreach (\${$singularVar}['{$alias}'] as \${$otherSingularVar}):
118 \$class = null;
119 if (\$i++ % 2 == 0) {
120 \$class = ' class=\"altrow\"';
121 }
122 ?>\n";
123 echo "\t\t<tr<?php echo \$class;?>>\n";
124
125 foreach ($details['fields'] as $field) {
126 echo "\t\t\t<td><?php echo \${$otherSingularVar}['{$field}'];?></td>\n";
127 }
128
129 echo "\t\t\t<td class=\"actions\">\n";
130 echo "\t\t\t\t<?php echo \$this->Html->link(__('View', true), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
131 echo "\t\t\t\t<?php echo \$this->Html->link(__('Edit', true), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
132 echo "\t\t\t\t<?php echo \$this->Html->link(__('Delete', true), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, sprintf(__('Are you sure you want to delete # %s?', true), \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n";
133 echo "\t\t\t</td>\n";
134 echo "\t\t</tr>\n";
135
136 echo "\t<?php endforeach; ?>\n";
137 ?>
138 </table>
139 <?php echo "<?php endif; ?>\n\n";?>
140 <div class="actions">
141 <ul>
142 <li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
143 </ul>
144 </div>
145 </div>
146 <?php endforeach;?>