Make it possible to unregister pre/postfilter plugins.

This commit is contained in:
andrei
2002-04-05 17:16:52 +00:00
parent 360fbad56a
commit ba8a7a6115
5 changed files with 27 additions and 7 deletions

4
NEWS
View File

@@ -1,4 +1,6 @@
- added htmlall attribute to escape (Monte)
- added ability to unregister pre/postfilters plugins at
runtime. (Andrei)
- added 'htmlall' attribute to escape modifier. (Monte)
- added template_exists() API function. (Andrei)
- fixed a problem with using dynamic values for 'file'
attribute of {include_php} tag. (Andrei)

View File

@@ -370,7 +370,10 @@ class Smarty
\*======================================================================*/
function unregister_prefilter($function)
{
if (isset($this->_plugins['prefilter'][$function]))
unset($this->_plugins['prefilter'][$function]);
else
$this->_plugins['prefilter'][$function] = false;
}
/*======================================================================*\
@@ -390,7 +393,10 @@ class Smarty
\*======================================================================*/
function unregister_postfilter($function)
{
if (isset($this->_plugins['postfilter'][$function]))
unset($this->_plugins['postfilter'][$function]);
else
$this->_plugins['postfilter'][$function] = false;
}
/*======================================================================*\

View File

@@ -80,6 +80,7 @@ class Smarty_Compiler extends Smarty {
// run template source through prefilter functions
if (count($this->_plugins['prefilter']) > 0) {
foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
if ($prefilter === false) continue;
if ($prefilter[3] || function_exists($prefilter[0])) {
$template_source = $prefilter[0]($template_source, $this);
$this->_plugins['prefilter'][$filter_name][3] = true;
@@ -176,6 +177,7 @@ class Smarty_Compiler extends Smarty {
// run compiled template through postfilter functions
if (count($this->_plugins['postfilter']) > 0) {
foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
if ($postfilter === false) continue;
if ($postfilter[3] || function_exists($postfilter[0])) {
$template_compiled = $postfilter[0]($template_compiled, $this);
$this->_plugins['postfilter'][$filter_name][3] = true;
@@ -1366,7 +1368,8 @@ class Smarty_Compiler extends Smarty {
$parts[2] != 'php' ||
($parts[0] != 'prefilter' &&
$parts[0] != 'postfilter') ||
isset($this->_plugins[$parts[0]][$parts[1]]))
(isset($this->_plugins[$parts[0]][$parts[1]]) &&
$this->_plugins[$parts[0]][$parts[1]] === false))
continue;
$plugin_file = $plugins_dir . '/' . $entry;

View File

@@ -370,7 +370,10 @@ class Smarty
\*======================================================================*/
function unregister_prefilter($function)
{
if (isset($this->_plugins['prefilter'][$function]))
unset($this->_plugins['prefilter'][$function]);
else
$this->_plugins['prefilter'][$function] = false;
}
/*======================================================================*\
@@ -390,7 +393,10 @@ class Smarty
\*======================================================================*/
function unregister_postfilter($function)
{
if (isset($this->_plugins['postfilter'][$function]))
unset($this->_plugins['postfilter'][$function]);
else
$this->_plugins['postfilter'][$function] = false;
}
/*======================================================================*\

View File

@@ -80,6 +80,7 @@ class Smarty_Compiler extends Smarty {
// run template source through prefilter functions
if (count($this->_plugins['prefilter']) > 0) {
foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) {
if ($prefilter === false) continue;
if ($prefilter[3] || function_exists($prefilter[0])) {
$template_source = $prefilter[0]($template_source, $this);
$this->_plugins['prefilter'][$filter_name][3] = true;
@@ -176,6 +177,7 @@ class Smarty_Compiler extends Smarty {
// run compiled template through postfilter functions
if (count($this->_plugins['postfilter']) > 0) {
foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) {
if ($postfilter === false) continue;
if ($postfilter[3] || function_exists($postfilter[0])) {
$template_compiled = $postfilter[0]($template_compiled, $this);
$this->_plugins['postfilter'][$filter_name][3] = true;
@@ -1366,7 +1368,8 @@ class Smarty_Compiler extends Smarty {
$parts[2] != 'php' ||
($parts[0] != 'prefilter' &&
$parts[0] != 'postfilter') ||
isset($this->_plugins[$parts[0]][$parts[1]]))
(isset($this->_plugins[$parts[0]][$parts[1]]) &&
$this->_plugins[$parts[0]][$parts[1]] === false))
continue;
$plugin_file = $plugins_dir . '/' . $entry;