2010-11-12 22:53:40 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Scaffold.
|
|
|
|
*
|
|
|
|
* Automatic forms and actions generation for rapid web application development.
|
|
|
|
*
|
2017-06-10 23:33:55 +02:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
2017-06-11 00:10:52 +02:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2010-11-12 22:53:40 -05:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 21:22:51 +09:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2010-11-12 22:53:40 -05:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-11 00:10:52 +02:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 23:33:55 +02:00
|
|
|
* @link https://cakephp.org CakePHP(tm) Project
|
2011-07-26 01:46:14 -04:30
|
|
|
* @package Cake.View
|
2010-11-12 22:53:40 -05:00
|
|
|
* @since Cake v 0.10.0.1076
|
2017-06-11 00:23:14 +02:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2010-11-12 22:53:40 -05:00
|
|
|
*/
|
2011-12-08 07:35:02 -08:00
|
|
|
|
2013-06-22 22:05:31 +05:30
|
|
|
App::uses('View', 'View');
|
2010-11-12 22:53:40 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ScaffoldView provides specific view file loading features for scaffolded views.
|
|
|
|
*
|
2013-12-20 14:16:44 -05:00
|
|
|
* @package Cake.View
|
2014-09-02 17:03:22 +02:00
|
|
|
* @deprecated 3.0.0 Dynamic scaffolding will be removed and replaced in 3.0
|
2010-11-12 22:53:40 -05:00
|
|
|
*/
|
2013-06-22 22:05:31 +05:30
|
|
|
class ScaffoldView extends View {
|
2010-11-12 22:53:40 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Override _getViewFileName Appends special scaffolding views in.
|
|
|
|
*
|
|
|
|
* @param string $name name of the view file to get.
|
|
|
|
* @return string action
|
2011-07-31 16:55:52 -04:00
|
|
|
* @throws MissingViewException
|
2010-11-12 22:53:40 -05: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 03:38:08 +01:00
|
|
|
if ($name === 'add' || $name === 'edit') {
|
2010-12-12 13:18:28 -05:00
|
|
|
$name = 'form';
|
2010-11-12 22:53:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
$scaffoldAction = 'scaffold.' . $name;
|
|
|
|
|
2013-08-16 20:12:49 +02:00
|
|
|
if ($this->subDir !== null) {
|
2010-11-12 22:53:40 -05:00
|
|
|
$subDir = strtolower($this->subDir) . DS;
|
|
|
|
} else {
|
|
|
|
$subDir = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$names[] = $this->viewPath . DS . $subDir . $scaffoldAction;
|
2011-05-16 23:50:42 +02:00
|
|
|
$names[] = 'Scaffolds' . DS . $subDir . $name;
|
2010-11-12 22:53:40 -05:00
|
|
|
|
|
|
|
$paths = $this->_paths($this->plugin);
|
|
|
|
$exts = array($this->ext);
|
|
|
|
if ($this->ext !== '.ctp') {
|
2013-01-02 23:47:27 +01:00
|
|
|
$exts[] = '.ctp';
|
2010-11-12 22:53:40 -05: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 23:50:42 +02:00
|
|
|
if ($name === 'Scaffolds' . DS . $subDir . 'error') {
|
2011-05-15 19:41:34 +02:00
|
|
|
return CAKE . 'View' . DS . 'Errors' . DS . 'scaffold_error.ctp';
|
2010-11-12 22:53:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
throw new MissingViewException($paths[0] . $name . $this->ext);
|
|
|
|
}
|
2012-03-03 17:10:12 -05:00
|
|
|
|
2010-11-12 22:53:40 -05:00
|
|
|
}
|