mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 23:49:55 +00:00
1.2: continue refactor of view files
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3969 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
99f50e78c3
commit
4320acdb96
1 changed files with 42 additions and 34 deletions
|
@ -205,11 +205,11 @@ class View extends Object {
|
||||||
var $loaded = array();
|
var $loaded = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File extension. Defaults to Cake's conventional ".thtml".
|
* File extension. Defaults to Cake's template ".ctp".
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $ext = '.thtml';
|
var $ext = '.ctp';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub-directory for this view file.
|
* Sub-directory for this view file.
|
||||||
|
@ -273,7 +273,7 @@ class View extends Object {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders view for given action and layout. If $file is given, that is used
|
* Renders view for given action and layout. If $file is given, that is used
|
||||||
* for a view filename (e.g. customFunkyView.thtml).
|
* for a view filename (e.g. customFunkyView.ctp).
|
||||||
*
|
*
|
||||||
* @param string $action Name of action to render for
|
* @param string $action Name of action to render for
|
||||||
* @param string $layout Layout to use
|
* @param string $layout Layout to use
|
||||||
|
@ -313,7 +313,7 @@ class View extends Object {
|
||||||
|
|
||||||
if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) {
|
if (file_exists(VIEWS . $viewDir . DS . $errorAction . $this->ext)) {
|
||||||
$missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext;
|
$missingViewFileName = VIEWS . $viewDir . DS . $errorAction . $this->ext;
|
||||||
} elseif($missingViewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $viewDir . DS . $errorAction . '.thtml')) {
|
} elseif($missingViewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $viewDir . DS . $errorAction . '.ctp')) {
|
||||||
} else {
|
} else {
|
||||||
$missingViewFileName = false;
|
$missingViewFileName = false;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ class View extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($viewFileName && !$this->hasRendered) {
|
if ($viewFileName && !$this->hasRendered) {
|
||||||
if (substr($viewFileName, -5) === 'thtml') {
|
if (substr($viewFileName, -4) === 'ctp' || substr($viewFileName, -5) === 'thtml') {
|
||||||
$out = View::_render($viewFileName, $this->_viewVars);
|
$out = View::_render($viewFileName, $this->_viewVars);
|
||||||
} else {
|
} else {
|
||||||
$out = $this->_render($viewFileName, $this->_viewVars);
|
$out = $this->_render($viewFileName, $this->_viewVars);
|
||||||
|
@ -399,6 +399,9 @@ class View extends Object {
|
||||||
if (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext)) {
|
if (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext)) {
|
||||||
$elementFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext;
|
$elementFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext;
|
||||||
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||||
|
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . '.thtml')) {
|
||||||
|
$elementFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . '.thtml';
|
||||||
|
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +410,9 @@ class View extends Object {
|
||||||
if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||||
$elementFileName = $path . 'elements' . DS . $name . $this->ext;
|
$elementFileName = $path . 'elements' . DS . $name . $this->ext;
|
||||||
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||||
|
} elseif (file_exists($path . 'elements' . DS . $name . '.thtml')) {
|
||||||
|
$elementFileName = $path . 'elements' . DS . $name . '.thtml';
|
||||||
|
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "(Error rendering Element: {$name})";
|
return "(Error rendering Element: {$name})";
|
||||||
|
@ -426,7 +432,7 @@ class View extends Object {
|
||||||
$layout_fn = $this->_getLayoutFileName();
|
$layout_fn = $this->_getLayoutFileName();
|
||||||
|
|
||||||
if (DEBUG > 2 && $this->controller != null) {
|
if (DEBUG > 2 && $this->controller != null) {
|
||||||
$debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.thtml', array('controller' => $this->controller), false);
|
$debug = View::_render(LIBS . 'view' . DS . 'templates' . DS . 'elements' . DS . 'dump.ctp', array('controller' => $this->controller), false);
|
||||||
} else {
|
} else {
|
||||||
$debug = '';
|
$debug = '';
|
||||||
}
|
}
|
||||||
|
@ -454,7 +460,7 @@ class View extends Object {
|
||||||
$data_for_layout = array_merge($data_for_layout, $this->loaded);
|
$data_for_layout = array_merge($data_for_layout, $this->loaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($layout_fn, -5) === 'thtml') {
|
if (substr($layout_fn, -4) === 'ctp' || substr($layout_fn, -5) === 'thtml') {
|
||||||
$out = View::_render($layout_fn, $data_for_layout, $loadHelpers, true);
|
$out = View::_render($layout_fn, $data_for_layout, $loadHelpers, true);
|
||||||
} else {
|
} else {
|
||||||
$out = $this->_render($layout_fn, $data_for_layout, $loadHelpers);
|
$out = $this->_render($layout_fn, $data_for_layout, $loadHelpers);
|
||||||
|
@ -569,8 +575,8 @@ class View extends Object {
|
||||||
function error($code, $name, $message) {
|
function error($code, $name, $message) {
|
||||||
header ("HTTP/1.0 {$code} {$name}");
|
header ("HTTP/1.0 {$code} {$name}");
|
||||||
print ($this->_render(VIEWS . 'layouts/error.thtml', array('code' => $code,
|
print ($this->_render(VIEWS . 'layouts/error.thtml', array('code' => $code,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'message' => $message)));
|
'message' => $message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -578,7 +584,7 @@ class View extends Object {
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns filename of given action's template file (.thtml) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.thtml views.
|
* Returns filename of given action's template file (.ctp) as a string. CamelCased action names will be under_scored! This means that you can have LongActionNames that refer to long_action_names.ctp views.
|
||||||
*
|
*
|
||||||
* @param string $action Controller action to find template filename for
|
* @param string $action Controller action to find template filename for
|
||||||
* @return string Template filename
|
* @return string Template filename
|
||||||
|
@ -609,14 +615,15 @@ class View extends Object {
|
||||||
$viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
|
$viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
|
||||||
|
|
||||||
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext)) {
|
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext)) {
|
||||||
$viewFileName = APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext;
|
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . $this->ext;
|
||||||
return $viewFileName;
|
|
||||||
|
|
||||||
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext)) {
|
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext)) {
|
||||||
$viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
|
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
|
||||||
return $viewFileName;
|
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . '.thtml')) {
|
||||||
|
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . $this->subDir . $type . $action . '.thtml';
|
||||||
|
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . '.thtml')) {
|
||||||
|
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . '.thtml';
|
||||||
} else {
|
} else {
|
||||||
|
$viewFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . $this->viewPath . DS . $action . $this->ext;
|
||||||
return $this->cakeError('missingView', array(array(
|
return $this->cakeError('missingView', array(array(
|
||||||
'className' => $this->name,
|
'className' => $this->name,
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
|
@ -627,13 +634,14 @@ class View extends Object {
|
||||||
|
|
||||||
foreach($paths->viewPaths as $path) {
|
foreach($paths->viewPaths as $path) {
|
||||||
if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext)) {
|
if (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext)) {
|
||||||
$viewFileName = $path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;
|
return $path . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;
|
||||||
return $viewFileName;
|
} elseif (file_exists($path . $this->viewPath . DS . $this->subDir . $type . $action . '.thtml')) {
|
||||||
|
return $path . $this->viewPath . DS . $this->subDir . $type . $action . '.thtml';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.thtml')) {
|
if ($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'errors' . DS . $type . $action . '.ctp')) {
|
||||||
} elseif($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.thtml')) {
|
} elseif($viewFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . $this->viewPath . DS . $type . $action . '.ctp')) {
|
||||||
} else {
|
} else {
|
||||||
$viewFileName = VIEWS . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;
|
$viewFileName = VIEWS . $this->viewPath . DS . $this->subDir . $type . $action . $this->ext;
|
||||||
}
|
}
|
||||||
|
@ -644,7 +652,7 @@ class View extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns layout filename for this template as a string.
|
* Returns layout filename for this template as a string.
|
||||||
*
|
*
|
||||||
* @return string Filename for layout file (.thtml).
|
* @return string Filename for layout file (.ctp).
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function _getLayoutFileName() {
|
function _getLayoutFileName() {
|
||||||
|
@ -655,18 +663,18 @@ class View extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($this->layoutPath)){
|
if(!is_null($this->layoutPath)){
|
||||||
$this->layoutPath = $this->layoutPath . DS;
|
$type = $this->layoutPath . DS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_null($this->plugin)) {
|
if (!is_null($this->plugin)) {
|
||||||
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $action . $this->ext)) {
|
if (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext)) {
|
||||||
$layoutFileName = APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $action . $this->ext;
|
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext;
|
||||||
return $layoutFileName;
|
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext)) {
|
||||||
|
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . $this->ext;
|
||||||
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext)) {
|
} elseif (file_exists(APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . '.thtml')) {
|
||||||
$layoutFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext;
|
return APP . 'views' . DS . 'plugins' . DS . $this->plugin . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . '.thtml';
|
||||||
return $layoutFileName;
|
} elseif (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . '.thtml')) {
|
||||||
|
return APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->subDir . $type . $this->layout . '.thtml';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -674,13 +682,13 @@ class View extends Object {
|
||||||
|
|
||||||
foreach($paths->viewPaths as $path) {
|
foreach($paths->viewPaths as $path) {
|
||||||
if (file_exists($path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . $this->ext)) {
|
if (file_exists($path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . $this->ext)) {
|
||||||
$layoutFileName = $path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . $this->ext;
|
return $path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . $this->ext;
|
||||||
return $layoutFileName;
|
} elseif (file_exists($path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . '.thtml')) {
|
||||||
|
return $path . 'layouts' . DS . $this->subDir . $this->layoutPath . $type . $this->layout . '.thtml';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.ctp')) {
|
||||||
if($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.thtml')) {
|
|
||||||
} else {
|
} else {
|
||||||
$layoutFileName = LAYOUTS . $type . $this->layout . $this->ext;
|
$layoutFileName = LAYOUTS . $type . $this->layout . $this->ext;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue