[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wact/src/compiler/attribute/ -> WactAttributeExpressionFragment.class.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  
  11  /**
  12   * Used to store expressions like "{$var}" found inside tag attributes
  13   * @package wact
  14   * @version $Id$
  15   */
  16  class WactAttributeExpressionFragment implements WactExpressionInterface
  17  {
  18    protected $expression;
  19  
  20    function __construct($expression, $context, $filter_dictionary)
  21    {
  22      $this->expression = new WactExpression($expression, $context, $filter_dictionary, 'raw');
  23    }
  24  
  25    function isConstant()
  26    {
  27      return $this->expression->isConstant();
  28    }
  29  
  30    function getValue()
  31    {
  32      return $this->expression->getValue();
  33    }
  34  
  35    function generateFragment($code_writer)
  36    {
  37      if ($this->isConstant())
  38      {
  39        $value = $this->getValue();
  40        if (!is_null($value))
  41          $code_writer->writeHTML(htmlspecialchars($value, ENT_QUOTES));
  42      }
  43      else
  44      {
  45        $code_writer->writePHP('echo htmlspecialchars(');
  46        $this->expression->generateExpression($code_writer);
  47        $code_writer->writePHP(', ENT_QUOTES);');
  48      }
  49    }
  50  
  51    function generatePreStatement($code_writer)
  52    {
  53      $this->expression->generatePreStatement($code_writer);
  54    }
  55  
  56    function generateExpression($code_writer)
  57    {
  58      $this->expression->generateExpression($code_writer);
  59    }
  60  
  61    function generatePostStatement($code_writer)
  62    {
  63      $this->expression->generatePostStatement($code_writer);
  64    }
  65  
  66    function prepare()
  67    {
  68      return $this->expression->prepare();
  69    }
  70  
  71    function getExpression()
  72    {
  73      return $this->expression;
  74    }
  75  }
  76  ?>


Generated: Fri Aug 29 04:49:26 2008 Cross-referenced by PHPXref 0.7