Base for a static organization website

ScaffoldView.php 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Scaffold.
  4. *
  5. * Automatic forms and actions generation for rapid web application development.
  6. *
  7. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  8. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. *
  10. * Licensed under The MIT License
  11. * For full copyright and license information, please see the LICENSE.txt
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  15. * @link http://cakephp.org CakePHP(tm) Project
  16. * @package Cake.View
  17. * @since Cake v 0.10.0.1076
  18. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  19. */
  20. App::uses('View', 'View');
  21. /**
  22. * ScaffoldView provides specific view file loading features for scaffolded views.
  23. *
  24. * @package Cake.View
  25. * @deprecated 3.0.0 Dynamic scaffolding will be removed and replaced in 3.0
  26. */
  27. class ScaffoldView extends View {
  28. /**
  29. * Override _getViewFileName Appends special scaffolding views in.
  30. *
  31. * @param string $name name of the view file to get.
  32. * @return string action
  33. * @throws MissingViewException
  34. */
  35. protected function _getViewFileName($name = null) {
  36. if ($name === null) {
  37. $name = $this->action;
  38. }
  39. $name = Inflector::underscore($name);
  40. $prefixes = Configure::read('Routing.prefixes');
  41. if (!empty($prefixes)) {
  42. foreach ($prefixes as $prefix) {
  43. if (strpos($name, $prefix . '_') !== false) {
  44. $name = substr($name, strlen($prefix) + 1);
  45. break;
  46. }
  47. }
  48. }
  49. if ($name === 'add' || $name === 'edit') {
  50. $name = 'form';
  51. }
  52. $scaffoldAction = 'scaffold.' . $name;
  53. if ($this->subDir !== null) {
  54. $subDir = strtolower($this->subDir) . DS;
  55. } else {
  56. $subDir = null;
  57. }
  58. $names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
  59. $names[] = 'Scaffolds' . DS . $subDir . $name;
  60. $paths = $this->_paths($this->plugin);
  61. $exts = array($this->ext);
  62. if ($this->ext !== '.ctp') {
  63. $exts[] = '.ctp';
  64. }
  65. foreach ($exts as $ext) {
  66. foreach ($paths as $path) {
  67. foreach ($names as $name) {
  68. if (file_exists($path . $name . $ext)) {
  69. return $path . $name . $ext;
  70. }
  71. }
  72. }
  73. }
  74. if ($name === 'Scaffolds' . DS . $subDir . 'error') {
  75. return CAKE . 'View' . DS . 'Errors' . DS . 'scaffold_error.ctp';
  76. }
  77. throw new MissingViewException($paths[0] . $name . $this->ext);
  78. }
  79. }