[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/i18n/src/template/tags/i18n/ -> i18n.filter.php (source)

   1  <?php
   2  /*
   3   * Limb PHP Framework
   4   *
   5   * @link http://limb-project.com 
   6   * @copyright  Copyright &copy; 2004-2007 BIT(http://bit-creative.com)
   7   * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
   8   */
   9  /**
  10   * @filter i18n
  11   * @min_attributes 1
  12   * @max_attributes 100
  13   * @package i18n
  14   * @version $Id: i18n.filter.php 5945 2007-06-06 08:31:43Z pachanga $
  15   */
  16  class lmbI18NStringFilter extends WactCompilerFilter
  17  {
  18    function getValue()
  19    {
  20      if(!isset($this->parameters[0]) || !$this->parameters[0]->getValue())
  21        throw new WactException('MISSING_FILTER_PARAMETER');
  22      else
  23        $domain = $this->parameters[0]->getValue();
  24  
  25      $value = $this->base->getValue();
  26  
  27      if($this->isConstant())
  28        return lmb_i18n($value, $this->_getAttributes(), $domain);
  29      else
  30        $this->raiseUnresolvedBindingError();
  31    }
  32  
  33    function _getAttributes()
  34    {
  35      $result = array();
  36  
  37      for($i=1; $i < sizeof($this->parameters); $i+=2)
  38      {
  39        $var = $this->parameters[$i]->getValue();
  40        $value = $this->parameters[$i+1]->getValue();
  41        $result[$var] = $value;
  42      }
  43  
  44      return $result;
  45    }
  46  
  47    function generatePreStatement($code)
  48    {
  49      parent :: generatePreStatement($code);
  50  
  51      $this->params_var = $code->getTempVarRef();
  52      $code->writePhp($this->params_var . ' = array();');
  53  
  54      for($i=1; $i < sizeof($this->parameters); $i+=2)
  55      {
  56        $var = $this->parameters[$i]->getValue();
  57        $code->writePhp($this->params_var . '["' . $this->parameters[$i]->getValue() . '"] = ');
  58        $code->writePhp($this->parameters[$i+1]->generateExpression($code));
  59        $code->writePhp(';'. "\n");
  60      }
  61    }
  62  
  63    function generateExpression($code)
  64    {
  65      $code->writePhp('lmb_i18n(');
  66  
  67      $this->base->generateExpression($code);
  68  
  69      $code->writePhp(',' . $this->params_var . ', ');
  70  
  71      $code->writePhp($this->parameters[0]->generateExpression($code));
  72      $code->writePhp(')');
  73    }
  74  }
  75  
  76  ?>


Generated: Sat Nov 22 03:48:54 2008 Cross-referenced by PHPXref 0.7