mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for #1544.
Adds additional path searches for elements and layouts git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3786 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e72eba2f82
commit
d6b2545628
1 changed files with 27 additions and 26 deletions
|
@ -111,7 +111,7 @@ class View extends Object {
|
|||
*
|
||||
* @var string Path to Layout
|
||||
*/
|
||||
var $layoutPath = '';
|
||||
var $layoutPath = null;
|
||||
|
||||
/**
|
||||
* Variables for the view
|
||||
|
@ -390,24 +390,27 @@ class View extends Object {
|
|||
* @return string Rendered output
|
||||
*/
|
||||
function renderElement($name, $params = array()) {
|
||||
$fn = ELEMENTS . $name . $this->ext;
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
|
||||
if(isset($params['plugin'])) {
|
||||
$this->plugin = $params['plugin'];
|
||||
}
|
||||
|
||||
if (!is_null($this->plugin)) {
|
||||
if (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext)) {
|
||||
$fn = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext;
|
||||
$params = array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
||||
$elementFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'elements' . DS . $name . $this->ext;
|
||||
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists($fn)) {
|
||||
return "(Error rendering {$name})";
|
||||
$paths = Configure::getInstance();
|
||||
foreach($paths->viewPaths as $path) {
|
||||
if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
||||
$elementFileName = $path . 'elements' . DS . $name . $this->ext;
|
||||
return $this->_render($elementFileName, array_merge($this->_viewVars, $params), false);
|
||||
}
|
||||
|
||||
$params=array_merge_recursive($params, $this->loaded);
|
||||
return $this->_render($fn, array_merge($this->_viewVars, $params), false);
|
||||
}
|
||||
return "(Error rendering Element: {$name})";
|
||||
}
|
||||
|
||||
function element($name) {
|
||||
|
@ -631,32 +634,30 @@ class View extends Object {
|
|||
$type = null;
|
||||
}
|
||||
|
||||
if(!is_null($this->layoutPath)){
|
||||
$this->layoutPath = $this->layoutPath . DS;
|
||||
}
|
||||
|
||||
if (isset($this->plugin) && !is_null($this->plugin)) {
|
||||
if (file_exists(APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext)) {
|
||||
$layoutFileName = APP . 'plugins' . DS . $this->plugin . DS . 'views' . DS . 'layouts' . DS . $this->layout . $this->ext;
|
||||
return $layoutFileName;
|
||||
}
|
||||
}
|
||||
$paths = Configure::getInstance();
|
||||
|
||||
if (!empty($this->layoutPath)) {
|
||||
$path = $this->layoutPath . DS;
|
||||
if (file_exists(LAYOUTS . $this->subDir . $this->layoutPath . $type . "{$this->layout}{$this->ext}")) {
|
||||
$layoutFileName = LAYOUTS . $this->subDir . $path . $type . "{$this->layout}{$this->ext}";
|
||||
} elseif (file_exists(LAYOUTS . $this->subDir . $path . $type . "default{$this->ext}")) {
|
||||
$layoutFileName = LAYOUTS . $this->subDir . $path . $type . "default{$this->ext}";
|
||||
} elseif ($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $path . "default{$this->ext}")) {
|
||||
} else {
|
||||
$layoutFileName = LAYOUTS . $this->subDir . $path . $type . "default{$this->ext}";
|
||||
}
|
||||
} else {
|
||||
if (file_exists(LAYOUTS . $this->subDir . $type . "{$this->layout}$this->ext")) {
|
||||
$layoutFileName = LAYOUTS . $this->subDir . $type . "{$this->layout}$this->ext";
|
||||
} elseif($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . "{$this->layout}.thtml")) {
|
||||
} else {
|
||||
$layoutFileName = LAYOUTS . $type . "{$this->layout}$this->ext";
|
||||
foreach($paths->viewPaths as $path) {
|
||||
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 $layoutFileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($layoutFileName = fileExistsInPath(LIBS . 'view' . DS . 'templates' . DS . 'layouts' . DS . $type . $this->layout . '.thtml')) {
|
||||
} else {
|
||||
$layoutFileName = LAYOUTS . $type . $this->layout . $this->ext;
|
||||
}
|
||||
return $layoutFileName;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue