index.ctp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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; ?> index">
  20. <h2><?php echo $pluralHumanName; ?></h2>
  21. <table cellpadding="0" cellspacing="0">
  22. <tr>
  23. <?php foreach ($scaffoldFields as $_field): ?>
  24. <th><?php echo $this->Paginator->sort($_field); ?></th>
  25. <?php endforeach; ?>
  26. <th><?php echo __d('cake', 'Actions'); ?></th>
  27. </tr>
  28. <?php
  29. foreach (${$pluralVar} as ${$singularVar}):
  30. echo '<tr>';
  31. foreach ($scaffoldFields as $_field) {
  32. $isKey = false;
  33. if (!empty($associations['belongsTo'])) {
  34. foreach ($associations['belongsTo'] as $_alias => $_details) {
  35. if ($_field === $_details['foreignKey']) {
  36. $isKey = true;
  37. echo '<td>' . $this->Html->link(${$singularVar}[$_alias][$_details['displayField']], array('controller' => $_details['controller'], 'action' => 'view', ${$singularVar}[$_alias][$_details['primaryKey']])) . '</td>';
  38. break;
  39. }
  40. }
  41. }
  42. if ($isKey !== true) {
  43. echo '<td>' . h(${$singularVar}[$modelClass][$_field]) . '</td>';
  44. }
  45. }
  46. echo '<td class="actions">';
  47. echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey]));
  48. echo ' ' . $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey]));
  49. echo ' ' . $this->Form->postLink(
  50. __d('cake', 'Delete'),
  51. array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]),
  52. null,
  53. __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey]
  54. );
  55. echo '</td>';
  56. echo '</tr>';
  57. endforeach;
  58. ?>
  59. </table>
  60. <p><?php
  61. echo $this->Paginator->counter(array(
  62. 'format' => __d('cake', 'Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
  63. ));
  64. ?></p>
  65. <div class="paging">
  66. <?php
  67. echo $this->Paginator->prev('< ' . __d('cake', 'previous'), array(), null, array('class' => 'prev disabled'));
  68. echo $this->Paginator->numbers(array('separator' => ''));
  69. echo $this->Paginator->next(__d('cake', 'next') .' >', array(), null, array('class' => 'next disabled'));
  70. ?>
  71. </div>
  72. </div>
  73. <div class="actions">
  74. <h3><?php echo __d('cake', 'Actions'); ?></h3>
  75. <ul>
  76. <li><?php echo $this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')); ?></li>
  77. <?php
  78. $done = array();
  79. foreach ($associations as $_type => $_data) {
  80. foreach ($_data as $_alias => $_details) {
  81. if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) {
  82. echo '<li>';
  83. echo $this->Html->link(
  84. __d('cake', 'List %s', Inflector::humanize($_details['controller'])),
  85. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'index')
  86. );
  87. echo '</li>';
  88. echo '<li>';
  89. echo $this->Html->link(
  90. __d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))),
  91. array('plugin' => $_details['plugin'], 'controller' => $_details['controller'], 'action' => 'add')
  92. );
  93. echo '</li>';
  94. $done[] = $_details['controller'];
  95. }
  96. }
  97. }
  98. ?>
  99. </ul>
  100. </div>