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