- bugfix output filter should not run on individually cached subtemplates

- add unloadFilter() method
This commit is contained in:
uwe.tews@googlemail.com
2011-10-04 17:50:39 +00:00
parent 4cb1e143cc
commit eb9714cf0e
2 changed files with 24 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
04.10.2011 04.10.2011
- bugfix assign() in plugins called in subtemplates did change value also in parent template - bugfix assign() in plugins called in subtemplates did change value also in parent template
- bugfix of problem introduced with r4342 on math plugin - bugfix of problem introduced with r4342 on math plugin
- bugfix output filter should not run on individually cached subtemplates
- add unloadFilter() method
===== Smarty-3.1.2 ===== ===== Smarty-3.1.2 =====
03.10.2011 03.10.2011

View File

@@ -230,7 +230,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
$output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); $output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]);
} }
} }
if (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output'])) { if (!$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
$output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
} }
// rendering (must be done before writing cache file because of {function} nocache handling) // rendering (must be done before writing cache file because of {function} nocache handling)
@@ -651,13 +651,32 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
$_plugin = array($_plugin, 'execute'); $_plugin = array($_plugin, 'execute');
} }
if (is_callable($_plugin)) { if (is_callable($_plugin)) {
return $this->smarty->registered_filters[$type][$_filter_name] = $_plugin; $this->smarty->registered_filters[$type][$_filter_name] = $_plugin;
return true;
} }
} }
throw new SmartyException("{$type}filter \"{$name}\" not callable"); throw new SmartyException("{$type}filter \"{$name}\" not callable");
return false; return false;
} }
/**
* unload a filter of specified type and name
*
* @param string $type filter type
* @param string $name filter name
* @return bool
*/
public function unloadFilter($type, $name)
{
$_filter_name = "smarty_{$type}filter_{$name}";
if (isset($this->smarty->registered_filters[$type][$_filter_name])) {
unset ($this->smarty->registered_filters[$type][$_filter_name]);
return true;
} else {
return false;
}
}
/** /**
* preg_replace callback to convert camelcase getter/setter to underscore property names * preg_replace callback to convert camelcase getter/setter to underscore property names
* *
@@ -679,7 +698,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data {
static $_prefixes = array('set' => true, 'get' => true); static $_prefixes = array('set' => true, 'get' => true);
static $_resolved_property_name = array(); static $_resolved_property_name = array();
static $_resolved_property_source = array(); static $_resolved_property_source = array();
// method of Smarty object? // method of Smarty object?
if (method_exists($this->smarty, $name)) { if (method_exists($this->smarty, $name)) {
return call_user_func_array(array($this->smarty, $name), $args); return call_user_func_array(array($this->smarty, $name), $args);