aboutsummaryrefslogtreecommitdiffstats
path: root/include/template.class.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-06-23 18:39:31 +0000
committerrvelices <rv-github@modusoptimus.com>2013-06-23 18:39:31 +0000
commitb93085c7fbd1ee625354f612b3af62d2dcb90402 (patch)
tree42b33391f9ef7f36836934fb4afa44c6555b91d6 /include/template.class.php
parent67d736e3fd0399399e554c53503a2b24f50e5a70 (diff)
Smarty3 added 'translate_dec' compilermodifier (generated code is a lot better than $pwg->l10n_dec)
git-svn-id: http://piwigo.org/svn/trunk@23476 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/template.class.php')
-rw-r--r--include/template.class.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/include/template.class.php b/include/template.class.php
index 56a32b2ba..82d0c1f05 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -55,6 +55,8 @@ class Template {
{
global $conf, $lang_info;
+ SmartyException::$escape = false;
+
$this->scriptLoader = new ScriptLoader;
$this->smarty = new SmartyBC;
$this->smarty->debugging = $conf['debug_template'];
@@ -91,6 +93,7 @@ class Template {
$this->smarty->assign( 'pwg', new PwgTemplateAdapter() );
$this->smarty->registerPlugin('modifiercompiler', 'translate', array('Template', 'modcompiler_translate') );
+ $this->smarty->registerPlugin('modifiercompiler', 'translate_dec', array('Template', 'modcompiler_translate_dec') );
$this->smarty->registerPlugin('modifier', 'explode', array('Template', 'mod_explode') );
$this->smarty->registerPlugin( 'modifier', 'get_extent', array($this, 'get_extent') );
$this->smarty->registerPlugin('block', 'html_head', array($this, 'block_html_head') );
@@ -331,7 +334,7 @@ class Template {
/** see smarty append http://www.smarty.net/manual/en/api.clear_assign.php */
function clear_assign($tpl_var)
{
- $this->smarty->clear_assign( $tpl_var );
+ $this->smarty->clearAssign( $tpl_var );
}
/** see smarty get_template_vars http://www.smarty.net/manual/en/api.get_template_vars.php */
@@ -361,7 +364,7 @@ class Template {
global $conf, $lang_info;
if ( $conf['compiled_template_cache_language'] and isset($lang_info['code']) )
{
- $this->smarty->compile_id .= '.'.$lang_info['code'];
+ $this->smarty->compile_id .= '_'.$lang_info['code'];
}
$v = $this->smarty->fetch($this->files[$handle]);
@@ -513,6 +516,31 @@ class Template {
return 'l10n('.$params[0].')';
}
+ static function modcompiler_translate_dec($params)
+ {
+ global $conf, $lang, $lang_info;
+ if ( $conf['compiled_template_cache_language'])
+ {
+ $ret = 'sprintf(';
+ if ($lang_info['zero_plural'])
+ {
+ $ret .= '($tmp=('.$params[0].'))>1||$tmp==0';
+ }
+ else
+ {
+ $ret .= '('.$params[0].')>1';
+ }
+ $ret .= '?';
+ $ret .= self::modcompiler_translate( array($params[2]) );
+ $ret .= ':';
+ $ret .= self::modcompiler_translate( array($params[1]) );
+ $ret .= ','.$params[0];
+ $ret .= ')';
+ return $ret;
+ }
+ return 'l10n_dec('.$params[1].','.$params[2].','.$params[0].')';
+ }
+
/**
* explode variable modifier - similar to php explode
* 'Yes;No'|@explode:';' -> array('Yes', 'No')
@@ -769,7 +797,7 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
{
list($type, $callback) = $filter;
$compile_id .= $type.( is_array($callback) ? implode('', $callback) : $callback );
- call_user_func(array($this->smarty, 'register_'.$type), $callback);
+ $this->smarty->registerFilter($type, $callback);
}
}
$this->smarty->compile_id .= '.'.base_convert(crc32($compile_id), 10, 36);
@@ -785,7 +813,7 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
foreach ($filters as $filter)
{
list($type, $callback) = $filter;
- call_user_func(array($this->smarty, 'unregister_'.$type), $callback);
+ $this->smarty->unregisterFilter($type, $callback);
}
}
}