1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: App::uses('View', 'View');
24:
25: 26: 27: 28: 29:
30: class ScaffoldView extends View {
31:
32: 33: 34: 35: 36: 37: 38:
39: protected function _getViewFileName($name = null) {
40: if ($name === null) {
41: $name = $this->action;
42: }
43: $name = Inflector::underscore($name);
44: $prefixes = Configure::read('Routing.prefixes');
45:
46: if (!empty($prefixes)) {
47: foreach ($prefixes as $prefix) {
48: if (strpos($name, $prefix . '_') !== false) {
49: $name = substr($name, strlen($prefix) + 1);
50: break;
51: }
52: }
53: }
54:
55: if ($name === 'add' || $name === 'edit') {
56: $name = 'form';
57: }
58:
59: $scaffoldAction = 'scaffold.' . $name;
60:
61: if ($this->subDir !== null) {
62: $subDir = strtolower($this->subDir) . DS;
63: } else {
64: $subDir = null;
65: }
66:
67: $names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
68: $names[] = 'Scaffolds' . DS . $subDir . $name;
69:
70: $paths = $this->_paths($this->plugin);
71: $exts = array($this->ext);
72: if ($this->ext !== '.ctp') {
73: $exts[] = '.ctp';
74: }
75: foreach ($exts as $ext) {
76: foreach ($paths as $path) {
77: foreach ($names as $name) {
78: if (file_exists($path . $name . $ext)) {
79: return $path . $name . $ext;
80: }
81: }
82: }
83: }
84:
85: if ($name === 'Scaffolds' . DS . $subDir . 'error') {
86: return CAKE . 'View' . DS . 'Errors' . DS . 'scaffold_error.ctp';
87: }
88:
89: throw new MissingViewException($paths[0] . $name . $this->ext);
90: }
91:
92: }
93: