Subversion-Projekte lars-tiefland.cakephp

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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