aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-06-30 05:34:55 +0000
committerrvelices <rv-github@modusoptimus.com>2013-06-30 05:34:55 +0000
commit3c3c3aacc96cf90523ed865e223b444137a5b81c (patch)
tree9e9a49a54697faf85771f8bd958644e29c5db656 /include
parent84f6ee73d8c53313b8fdc9193d3e091fd6d345e4 (diff)
replace the language_prefilter with a postfilter (now that smarty has modifiercompiler feature, there is no need for prefilter)
git-svn-id: http://piwigo.org/svn/trunk@23688 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/template.class.php23
1 files changed, 10 insertions, 13 deletions
diff --git a/include/template.class.php b/include/template.class.php
index e4a731aef..6b253120a 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -107,7 +107,7 @@ class Template {
$this->smarty->registerFilter('pre', array('Template', 'prefilter_white_space') );
if ( $conf['compiled_template_cache_language'] )
{
- $this->smarty->registerFilter('pre', array('Template', 'prefilter_language') );
+ $this->smarty->registerFilter('post', array('Template', 'postfilter_language') );
}
$this->smarty->setTemplateDir(array());
@@ -528,13 +528,13 @@ class Template {
}
else
{
- $ret .= '('.$params[0].')>1';
+ $ret .= '($tmp=('.$params[0].'))>1';
}
$ret .= '?';
$ret .= self::modcompiler_translate( array($params[2]) );
$ret .= ':';
$ret .= self::modcompiler_translate( array($params[1]) );
- $ret .= ','.$params[0];
+ $ret .= ',$tmp';
$ret .= ')';
return $ret;
}
@@ -843,18 +843,15 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
}
/**
- * Smarty prefilter to allow caching (whenever possible) language strings
- * from templates.
+ * Smarty postfilter
*/
- static function prefilter_language($source, $smarty)
+ static function postfilter_language($source, $smarty)
{
- global $lang;
- $ldq = preg_quote($smarty->left_delimiter, '~');
- $rdq = preg_quote($smarty->right_delimiter, '~');
-
- $regex = "~$ldq\'([^'$]+)\'\|@translate *$rdq~";
- $source = preg_replace_callback( $regex, create_function('$m', 'global $lang; return isset($lang[$m[1]]) ? $lang[$m[1]] : $m[0];'), $source);
-
+ // replaces echo PHP_STRING_LITERAL; with the string literal value
+ $source = preg_replace_callback(
+ '/\\<\\?php echo ((?:\'(?:(?:\\\\.)|[^\'])*\')|(?:"(?:(?:\\\\.)|[^"])*"));\\?\\>\\n/',
+ create_function('$matches', 'eval(\'$tmp=\'.$matches[1].\';\');return $tmp;'),
+ $source);
return $source;
}