• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Smarty/libs/plugins/block.t.php

00001 <?php
00038 function smarty_gettext_strarg($str)
00039 {
00040        $tr = array();
00041        $p = 0;
00042 
00043        for ($i=1; $i < func_num_args(); $i++) {
00044               $arg = func_get_arg($i);
00045               
00046               if (is_array($arg)) {
00047                      foreach ($arg as $aarg) {
00048                             $tr['%'.++$p] = $aarg;
00049                      }
00050               } else {
00051                      $tr['%'.++$p] = $arg;
00052               }
00053        }
00054        
00055        return strtr($str, $tr);
00056 }
00057 
00073 function smarty_block_t($params, $text, &$smarty)
00074 {
00075        $text = stripslashes($text);
00076        
00077        // set escape mode
00078        if (isset($params['escape'])) {
00079               $escape = $params['escape'];
00080               unset($params['escape']);
00081        }
00082        
00083        // set plural version
00084        if (isset($params['plural'])) {
00085               $plural = $params['plural'];
00086               unset($params['plural']);
00087               
00088               // set count
00089               if (isset($params['count'])) {
00090                      $count = $params['count'];
00091                      unset($params['count']);
00092               }
00093        }
00094        //debut modif lolo
00095        //utilisons Zend_translate
00096        // use plural if required parameters are set
00097        /*if (isset($count) && isset($plural)) {
00098               $text = ngettext($text, $plural, $count);
00099        } else { // use normal
00100               $text = gettext($text);
00101        }*/
00102        //$text=I18n::getInstance()->translate($text);
00103        $module = $smarty->_tpl_vars['module'];
00104        $key = strtoupper('STRING_'.md5($text));
00105        $text = I18n::t($text, $key, $module);
00106        //fin modif lolo
00107 
00108        // run strarg if there are parameters
00109        if (count($params)) {
00110               $text = smarty_gettext_strarg($text, $params);
00111        }
00112 
00113        if (!isset($escape) || $escape == 'html') { // html escape, default
00114           $text = nl2br(htmlspecialchars($text));
00115    } elseif (isset($escape)) {
00116               switch ($escape) {
00117                      case 'javascript':
00118                      case 'js':
00119                             // javascript escape
00120                             $text = str_replace('\'', '\\\'', stripslashes($text));
00121                             break;
00122                      case 'url':
00123                             // url escape
00124                             $text = urlencode($text);
00125                             break;
00126               }
00127        }
00128        
00129        return $text;
00130 }
00131 
00132 ?>

Generated on Thu Apr 19 2012 17:01:16 for openbiz by  doxygen 1.7.2