view.ctp 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?php
  2. /**
  3. *
  4. * PHP 5
  5. *
  6. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  7. * Copyright 2005-2012, 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-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP(tm) Project
  14. * @package Cake.View.Scaffolds
  15. * @since CakePHP(tm) v 0.10.0.1076
  16. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  17. */
  18. ?>
  19. <div class="<?php echo $pluralVar; ?> view">
  20. <h2><?php echo __d('cake', 'View %s', $singularHumanName); ?></h2>
  21. <dl>
  22. <?php
  23. $i = 0;
  24. foreach ($scaffoldFields 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>" . Inflector::humanize($_alias) . "</dt>\n";
  31. echo "\t\t<dd>\n\t\t\t";
  32. echo $this->Html->link(
  33. ${$singularVar}[$_alias][$_details['displayField']],
  34. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])
  35. );
  36. echo "\n\t\t&nbsp;</dd>\n";
  37. break;
  38. }
  39. }
  40. }
  41. if ($isKey !== true) {
  42. echo "\t\t<dt>" . Inflector::humanize($_field) . "</dt>\n";
  43. echo "\t\t<dd>" . h(${$singularVar}[$modelClass][$_field]) . "&nbsp;</dd>\n";
  44. }
  45. }
  46. ?>
  47. </dl>
  48. </div>
  49. <div class="actions">
  50. <h3><?php echo __d('cake', 'Actions'); ?></h3>
  51. <ul>
  52. <?php
  53. echo "\t\t<li>";
  54. echo $this->Html->link(__d('cake', 'Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey]));
  55. echo " </li>\n";
  56. echo "\t\t<li>";
  57. echo $this->Form->postLink(__d('cake', 'Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?');
  58. echo " </li>\n";
  59. echo "\t\t<li>";
  60. echo $this->Html->link(__d('cake', 'List %s', $pluralHumanName), array('action' => 'index'));
  61. echo " </li>\n";
  62. echo "\t\t<li>";
  63. echo $this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add'));
  64. echo " </li>\n";
  65. $done = array();
  66. foreach ($associations as $_type => $_data) {
  67. foreach ($_data as $_alias => $_details) {
  68. if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
  69. echo "\t\t<li>";
  70. echo $this->Html->link(
  71. __d('cake', 'List %s', Inflector::humanize($_details['controller'])),
  72. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'index')
  73. );
  74. echo "</li>\n";
  75. echo "\t\t<li>";
  76. echo $this->Html->link(
  77. __d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))),
  78. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'add')
  79. );
  80. echo "</li>\n";
  81. $done[] = $_details['controller'];
  82. }
  83. }
  84. }
  85. ?>
  86. </ul>
  87. </div>
  88. <?php
  89. if (!empty($associations['hasOne'])) :
  90. foreach ($associations['hasOne'] as $_alias => $_details): ?>
  91. <div class="related">
  92. <h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3>
  93. <?php if (!empty(${$singularVar}[$_alias])): ?>
  94. <dl>
  95. <?php
  96. $i = 0;
  97. $otherFields = array_keys(${$singularVar}[$_alias]);
  98. foreach ($otherFields as $_field) {
  99. echo "\t\t<dt>" . Inflector::humanize($_field) . "</dt>\n";
  100. echo "\t\t<dd>\n\t" . ${$singularVar}[$_alias][$_field] . "\n&nbsp;</dd>\n";
  101. }
  102. ?>
  103. </dl>
  104. <?php endif; ?>
  105. <div class="actions">
  106. <ul>
  107. <li><?php
  108. echo $this->Html->link(
  109. __d('cake', 'Edit %s', Inflector::humanize(Inflector::underscore($_alias))),
  110. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'edit', ${$singularVar}[$_alias][$_details['primaryKey']])
  111. );
  112. echo "</li>\n";
  113. ?>
  114. </ul>
  115. </div>
  116. </div>
  117. <?php
  118. endforeach;
  119. endif;
  120. if (empty($associations['hasMany'])) {
  121. $associations['hasMany'] = array();
  122. }
  123. if (empty($associations['hasAndBelongsToMany'])) {
  124. $associations['hasAndBelongsToMany'] = array();
  125. }
  126. $relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']);
  127. $i = 0;
  128. foreach ($relations as $_alias => $_details):
  129. $otherSingularVar = Inflector::variable($_alias);
  130. ?>
  131. <div class="related">
  132. <h3><?php echo __d('cake', "Related %s", Inflector::humanize($_details['controller'])); ?></h3>
  133. <?php if (!empty(${$singularVar}[$_alias])): ?>
  134. <table cellpadding="0" cellspacing="0">
  135. <tr>
  136. <?php
  137. $otherFields = array_keys(${$singularVar}[$_alias][0]);
  138. if (isset($_details['with'])) {
  139. $index = array_search($_details['with'], $otherFields);
  140. unset($otherFields[$index]);
  141. }
  142. foreach ($otherFields as $_field) {
  143. echo "\t\t<th>" . Inflector::humanize($_field) . "</th>\n";
  144. }
  145. ?>
  146. <th class="actions">Actions</th>
  147. </tr>
  148. <?php
  149. $i = 0;
  150. foreach (${$singularVar}[$_alias] as ${$otherSingularVar}):
  151. echo "\t\t<tr>\n";
  152. foreach ($otherFields as $_field) {
  153. echo "\t\t\t<td>" . ${$otherSingularVar}[$_field] . "</td>\n";
  154. }
  155. echo "\t\t\t<td class=\"actions\">\n";
  156. echo "\t\t\t\t";
  157. echo $this->Html->link(
  158. __d('cake', 'View'),
  159. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'view', ${$otherSingularVar}[$_details['primaryKey']])
  160. );
  161. echo "\n";
  162. echo "\t\t\t\t";
  163. echo $this->Html->link(
  164. __d('cake', 'Edit'),
  165. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'edit', ${$otherSingularVar}[$_details['primaryKey']])
  166. );
  167. echo "\n";
  168. echo "\t\t\t\t";
  169. echo $this->Form->postLink(
  170. __d('cake', 'Delete'),
  171. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'delete', ${$otherSingularVar}[$_details['primaryKey']]),
  172. null,
  173. __d('cake', 'Are you sure you want to delete', true) .' #' . ${$otherSingularVar}[$_details['primaryKey']] . '?'
  174. );
  175. echo "\n";
  176. echo "\t\t\t</td>\n";
  177. echo "\t\t</tr>\n";
  178. endforeach;
  179. ?>
  180. </table>
  181. <?php endif; ?>
  182. <div class="actions">
  183. <ul>
  184. <li><?php echo $this->Html->link(
  185. __d('cake', "New %s", Inflector::humanize(Inflector::underscore($_alias))),
  186. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'add')
  187. ); ?> </li>
  188. </ul>
  189. </div>
  190. </div>
  191. <?php endforeach; ?>