index.ctp 3.8 KB

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