2010-11-13 03:53:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Scaffold.
|
|
|
|
*
|
|
|
|
* Automatic forms and actions generation for rapid web application development.
|
|
|
|
*
|
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2013-02-08 11:59:49 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-11-13 03:53:40 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2010-11-13 03:53:40 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2013-02-08 11:59:49 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-11-13 03:53:40 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.View
|
2010-11-13 03:53:40 +00:00
|
|
|
* @since Cake v 0.10.0.1076
|
2013-05-30 22:11:14 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
2010-11-13 03:53:40 +00:00
|
|
|
*/
|
2011-12-08 15:35:02 +00:00
|
|
|
|
2013-06-22 16:35:31 +00:00
|
|
|
App::uses('View', 'View');
|
2010-11-13 03:53:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ScaffoldView provides specific view file loading features for scaffolded views.
|
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.View
|
2010-11-13 03:53:40 +00:00
|
|
|
*/
|
2013-06-22 16:35:31 +00:00
|
|
|
class ScaffoldView extends View {
|
2010-11-13 03:53:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Override _getViewFileName Appends special scaffolding views in.
|
|
|
|
*
|
|
|
|
* @param string $name name of the view file to get.
|
|
|
|
* @return string action
|
2011-07-31 20:55:52 +00:00
|
|
|
* @throws MissingViewException
|
2010-11-13 03:53:40 +00:00
|
|
|
*/
|
|
|
|
protected function _getViewFileName($name = null) {
|
|
|
|
if ($name === null) {
|
|
|
|
$name = $this->action;
|
|
|
|
}
|
|
|
|
$name = Inflector::underscore($name);
|
|
|
|
$prefixes = Configure::read('Routing.prefixes');
|
|
|
|
|
|
|
|
if (!empty($prefixes)) {
|
|
|
|
foreach ($prefixes as $prefix) {
|
|
|
|
if (strpos($name, $prefix . '_') !== false) {
|
|
|
|
$name = substr($name, strlen($prefix) + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-12 02:38:08 +00:00
|
|
|
if ($name === 'add' || $name === 'edit') {
|
2010-12-12 18:18:28 +00:00
|
|
|
$name = 'form';
|
2010-11-13 03:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$scaffoldAction = 'scaffold.' . $name;
|
|
|
|
|
2013-08-16 18:12:49 +00:00
|
|
|
if ($this->subDir !== null) {
|
2010-11-13 03:53:40 +00:00
|
|
|
$subDir = strtolower($this->subDir) . DS;
|
|
|
|
} else {
|
|
|
|
$subDir = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
|
2011-05-16 21:50:42 +00:00
|
|
|
$names[] = 'Scaffolds' . DS . $subDir . $name;
|
2010-11-13 03:53:40 +00:00
|
|
|
|
|
|
|
$paths = $this->_paths($this->plugin);
|
|
|
|
$exts = array($this->ext);
|
|
|
|
if ($this->ext !== '.ctp') {
|
2013-01-02 22:47:27 +00:00
|
|
|
$exts[] = '.ctp';
|
2010-11-13 03:53:40 +00:00
|
|
|
}
|
|
|
|
foreach ($exts as $ext) {
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
foreach ($names as $name) {
|
|
|
|
if (file_exists($path . $name . $ext)) {
|
|
|
|
return $path . $name . $ext;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-16 21:50:42 +00:00
|
|
|
if ($name === 'Scaffolds' . DS . $subDir . 'error') {
|
2011-05-15 17:41:34 +00:00
|
|
|
return CAKE . 'View' . DS . 'Errors' . DS . 'scaffold_error.ctp';
|
2010-11-13 03:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new MissingViewException($paths[0] . $name . $this->ext);
|
|
|
|
}
|
2012-03-03 22:10:12 +00:00
|
|
|
|
2010-11-13 03:53:40 +00:00
|
|
|
}
|