view.ctp 6.2 KB

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