- code cleanup

This commit is contained in:
uwe.tews@googlemail.com
2010-11-13 17:48:30 +00:00
parent 7dc5c0a09d
commit 5d278ce5ad
4 changed files with 14 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
13/11/2010
- bugfix overloading problem when $smarty->fetch()/display() have been used in plugins
(introduced with 3.0.2)
- code cleanup
===== Smarty 3.0.3 =====

View File

@@ -564,19 +564,15 @@ class Smarty extends Smarty_Internal_Data {
if (!isset($type)) {
$type = $this->caching_type;
}
// already loaded?
if (isset($this->cache_resource_objects[$type])) {
return $this->cache_resource_objects[$type];
}
if (in_array($type, $this->cache_resource_types)) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
return new $cache_resource_class($this);
}
else {
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if (Smarty_Internal_Plugin_Loader::loadPlugin($cache_resource_class, $this->plugins_dir)) {
return $this->cache_resource_objects[$type] = new $cache_resource_class($this);
if ($this->loadPlugin($cache_resource_class)) {
return new $cache_resource_class($this);
}
else {
throw new SmartyException("Unable to load cache resource '{$type}'");

View File

@@ -93,7 +93,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
$rdelim = $smarty->right_delimiter;
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
$_template = new Smarty_Template ($smarty->debug_tpl, $smarty);
$_template = new Smarty_Internal_Template ($smarty->debug_tpl, $smarty);
$_template->caching = false;
$_template->force_compile = false;
$_template->disableSecurity();

View File

@@ -95,7 +95,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
// Template resource
$this->template_resource = $template_resource;
// copy block data of template inheritance
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
if ($this->parent instanceof Smarty_Internal_Template) {
$this->block_data = $this->parent->block_data;
}
@@ -455,7 +455,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) {
$this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(),$this->resource_type);
}
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
if ($this->parent instanceof Smarty_Internal_Template) {
$this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
foreach($this->required_plugins as $code => $tmp1) {
foreach($tmp1 as $name => $tmp) {
@@ -859,7 +859,10 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($template == null) {
return $this->smarty->fetch($this);
} else {
return $this->smarty->fetch($template, $cache_id, $compile_id, $parent, $display);
if (!isset($parent)) {
$parent = $this;
}
return $this->smarty->fetch($template, $cache_id, $compile_id, $parent, $display);
}
}
@@ -872,6 +875,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($template == null) {
return $this->smarty->display($this);
} else {
if (!isset($parent)) {
$parent = $this;
}
return $this->smarty->display($template, $cache_id, $compile_id, $parent);
}
@@ -953,10 +959,4 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
}
}
/**
* wrapper for template class
*/
class Smarty_Template extends Smarty_Internal_Template {
}
?>