Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 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
 
21
App::uses('View', 'View');
22
 
23
/**
24
 * ScaffoldView provides specific view file loading features for scaffolded views.
25
 *
26
 * @package       Cake.View
27
 */
28
class ScaffoldView extends View {
29
 
30
/**
31
 * Override _getViewFileName Appends special scaffolding views in.
32
 *
33
 * @param string $name name of the view file to get.
34
 * @return string action
35
 * @throws MissingViewException
36
 */
37
	protected function _getViewFileName($name = null) {
38
		if ($name === null) {
39
			$name = $this->action;
40
		}
41
		$name = Inflector::underscore($name);
42
		$prefixes = Configure::read('Routing.prefixes');
43
 
44
		if (!empty($prefixes)) {
45
			foreach ($prefixes as $prefix) {
46
				if (strpos($name, $prefix . '_') !== false) {
47
					$name = substr($name, strlen($prefix) + 1);
48
					break;
49
				}
50
			}
51
		}
52
 
53
		if ($name === 'add' || $name === 'edit') {
54
			$name = 'form';
55
		}
56
 
57
		$scaffoldAction = 'scaffold.' . $name;
58
 
59
		if ($this->subDir !== null) {
60
			$subDir = strtolower($this->subDir) . DS;
61
		} else {
62
			$subDir = null;
63
		}
64
 
65
		$names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
66
		$names[] = 'Scaffolds' . DS . $subDir . $name;
67
 
68
		$paths = $this->_paths($this->plugin);
69
		$exts = array($this->ext);
70
		if ($this->ext !== '.ctp') {
71
			$exts[] = '.ctp';
72
		}
73
		foreach ($exts as $ext) {
74
			foreach ($paths as $path) {
75
				foreach ($names as $name) {
76
					if (file_exists($path . $name . $ext)) {
77
						return $path . $name . $ext;
78
					}
79
				}
80
			}
81
		}
82
 
83
		if ($name === 'Scaffolds' . DS . $subDir . 'error') {
84
			return CAKE . 'View' . DS . 'Errors' . DS . 'scaffold_error.ctp';
85
		}
86
 
87
		throw new MissingViewException($paths[0] . $name . $this->ext);
88
	}
89
 
90
}