- Timestamp:
- Jun 21, 2013, 7:04:57 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/template/cat_modify.tpl
r17007 r23425 84 84 <strong>{'Lock'|@translate}</strong> 85 85 <br> 86 {html_radios name='visible' values='true,false'|@explode output='No,Yes'|@explode|translateselected=$CAT_VISIBLE}86 {html_radios name='visible' values=['true','false'] output=['No'|translate,'Yes'|translate] selected=$CAT_VISIBLE} 87 87 </p> 88 88 … … 91 91 <strong>{'Comments'|@translate}</strong> 92 92 <br> 93 {html_radios name='commentable' values='false,true'|@explode output='No,Yes'|@explode|translateselected=$CAT_COMMENTABLE}93 {html_radios name='commentable' values=['false','true'] output=['No'|translate,'Yes'|translate] selected=$CAT_COMMENTABLE} 94 94 </p> 95 95 {/if} -
trunk/include/template.class.php
r23384 r23425 59 59 $this->smarty = new SmartyBC; 60 60 $this->smarty->debugging = $conf['debug_template']; 61 if (!$this->smarty->debugging) 62 $this->smarty->error_reporting = error_reporting() & ~E_NOTICE; 61 63 $this->smarty->compile_check = $conf['template_compile_check']; 62 64 $this->smarty->force_compile = $conf['template_force_compile']; … … 89 91 90 92 $this->smarty->assign( 'pwg', new PwgTemplateAdapter() ); 91 $this->smarty->register _modifier( 'translate', array('Template', 'mod_translate') );92 $this->smarty->register _modifier('explode', array('Template', 'mod_explode') );93 $this->smarty->register _modifier( 'get_extent', array(&$this, 'get_extent') );94 $this->smarty->register _block('html_head', array(&$this, 'block_html_head') );95 $this->smarty->register _block('html_style', array(&$this, 'block_html_style') );96 $this->smarty->register _function('combine_script', array(&$this, 'func_combine_script') );97 $this->smarty->register _function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') );98 $this->smarty->register _function('combine_css', array(&$this, 'func_combine_css') );99 $this->smarty->register _function('define_derivative', array(&$this, 'func_define_derivative') );100 $this->smarty->register _compiler_function('get_combined_css', array(&$this, 'func_get_combined_css') );101 $this->smarty->register _block('footer_script', array(&$this, 'block_footer_script') );102 $this->smarty->register _prefilter(array('Template', 'prefilter_white_space') );93 $this->smarty->registerPlugin('modifiercompiler', 'translate', array('Template', 'modcompiler_translate') ); 94 $this->smarty->registerPlugin('modifier', 'explode', array('Template', 'mod_explode') ); 95 $this->smarty->registerPlugin( 'modifier', 'get_extent', array($this, 'get_extent') ); 96 $this->smarty->registerPlugin('block', 'html_head', array($this, 'block_html_head') ); 97 $this->smarty->registerPlugin('block', 'html_style', array($this, 'block_html_style') ); 98 $this->smarty->registerPlugin('function', 'combine_script', array($this, 'func_combine_script') ); 99 $this->smarty->registerPlugin('function', 'get_combined_scripts', array($this, 'func_get_combined_scripts') ); 100 $this->smarty->registerPlugin('function', 'combine_css', array($this, 'func_combine_css') ); 101 $this->smarty->registerPlugin('function', 'define_derivative', array($this, 'func_define_derivative') ); 102 $this->smarty->registerPlugin('compiler', 'get_combined_css', array($this, 'func_get_combined_css') ); 103 $this->smarty->registerPlugin('block', 'footer_script', array($this, 'block_footer_script') ); 104 $this->smarty->registerFilter('pre', array('Template', 'prefilter_white_space') ); 103 105 if ( $conf['compiled_template_cache_language'] ) 104 106 { 105 $this->smarty->register _prefilter(array('Template', 'prefilter_language') );107 $this->smarty->registerFilter('pre', array('Template', 'prefilter_language') ); 106 108 } 107 109 … … 170 172 if (!isset($this->smarty->compile_id)) 171 173 { 172 $ real_dir = realpath($dir);173 $compile_id = crc32( $real_dir===false ? $dir : $real_dir);174 $this->smarty->compile_id = base_convert( $compile_id, 10, 36 );174 $compile_id = "1"; 175 $compile_id .= ($real_dir = realpath($dir))===false ? $dir : $real_dir; 176 $this->smarty->compile_id = base_convert(crc32($compile_id), 10, 36 ); 175 177 } 176 178 } … … 323 325 function concat($tpl_var, $value) 324 326 { 325 $old_val = & $this->smarty->get_template_vars($tpl_var); 326 if ( isset($old_val) ) 327 { 328 $old_val .= $value; 329 } 330 else 331 { 332 $this->assign($tpl_var, $value); 333 } 327 $this->assign($tpl_var, 328 $this->smarty->getTemplateVars($tpl_var) . $value); 334 329 } 335 330 … … 490 485 } 491 486 492 /** 493 * translate variable modifier - translates a text to the currently loaded 494 * language 495 */ 496 static function mod_translate($text) 497 { 498 return l10n($text); 487 static function get_php_str_val($str) 488 { 489 if (is_string($str) && strlen($str)>1) 490 { 491 if ( ($str[0]=='\'' && $str[strlen($str)-1]=='\'') 492 || ($str[0]=='"' && $str[strlen($str)-1]=='"')) 493 { 494 eval('$tmp='.$str.';'); 495 return $tmp; 496 } 497 } 498 return null; 499 } 500 501 /** 502 * translate variable modifier - translates a text to the currently loaded language 503 */ 504 static function modcompiler_translate($params) 505 { 506 global $conf, $lang; 507 if ( $conf['compiled_template_cache_language'] 508 && ($key=self::get_php_str_val($params[0])) !== null) 509 { 510 if (isset($lang[$key])) 511 return var_export($lang[$key], true); 512 } 513 return 'l10n('.$params[0].')'; 499 514 } 500 515 … … 810 825 $rdq = preg_quote($smarty->right_delimiter, '~'); 811 826 812 $regex = "~$ldq *\'([^'$]+)\'\|@translate *$rdq~";827 $regex = "~$ldq\'([^'$]+)\'\|@translate *$rdq~"; 813 828 $source = preg_replace_callback( $regex, create_function('$m', 'global $lang; return isset($lang[$m[1]]) ? $lang[$m[1]] : $m[0];'), $source); 814 815 $regex = "~$ldq *\'([^'$]+)\'\|@translate\|~";816 $source = preg_replace_callback( $regex, create_function('$m', 'global $lang; return isset($lang[$m[1]]) ? \'{\'.var_export($lang[$m[1]],true).\'|\' : $m[0];'), $source);817 818 $regex = "~($ldq *assign +var=.+ +value=)\'([^'$]+)\'\|@translate~";819 $source = preg_replace_callback( $regex, create_function('$m', 'global $lang; return isset($lang[$m[2]]) ? $m[1].var_export($lang[$m[2]],true) : $m[0];'), $source);820 829 821 830 return $source; … … 877 886 { 878 887 ksort($this->picture_buttons); 879 $this->assign('PLUGIN_PICTURE_BUTTONS', 888 $this->assign('PLUGIN_PICTURE_BUTTONS', 880 889 array_reduce( 881 $this->picture_buttons, 882 create_function('$v,$w', 'return array_merge($v, $w);'), 890 $this->picture_buttons, 891 create_function('$v,$w', 'return array_merge($v, $w);'), 883 892 array() 884 893 )); … … 891 900 { 892 901 ksort($this->index_buttons); 893 $this->assign('PLUGIN_INDEX_BUTTONS', 902 $this->assign('PLUGIN_INDEX_BUTTONS', 894 903 array_reduce( 895 $this->index_buttons, 896 create_function('$v,$w', 'return array_merge($v, $w);'), 904 $this->index_buttons, 905 create_function('$v,$w', 'return array_merge($v, $w);'), 897 906 array() 898 907 ));
Note: See TracChangeset
for help on using the changeset viewer.