[ Index ]

PHP Cross Reference of Web Application Component Toolkit

title

Body

[close]

/framework/template/tags/data/ -> math.filter.php (source)

   1  <?php
   2  //--------------------------------------------------------------------------------
   3  // Copyright 2004 Procata, Inc.
   4  // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
   5  //--------------------------------------------------------------------------------
   6  /**
   7  * @package WACT_FILTER
   8  * @author    Jason E. Sweat < jsweat_php AT yahoo DOT com >
   9  * @version $Id: math.filter.php,v 1.3 2004/11/18 04:22:48 jeffmoore Exp $
  10  */
  11  
  12  FilterDictionary::registerFilter(
  13      new FilterInfo('math', 'MathFilter', 1, 1), __FILE__);
  14  
  15  class MathFilter extends CompilerFilter {
  16  
  17      /**
  18      * Return this value as a PHP value
  19      * @return String
  20      * @access public
  21      */
  22  	function getValue() {
  23          if ($this->isConstant()) {
  24              $value = $this->base->getValue();
  25              $exp = $this->parameters[0]->getValue();
  26              $code->writeHTML(math_filter($value, $exp));
  27          } else {
  28              RaiseError('compiler', 'UNRESOLVED_BINDING');
  29          }
  30      }
  31  
  32      /**
  33      * Generate the code to read the data value at run time
  34      * Must generate only a valid PHP Expression.
  35      * @param CodeWriter
  36      * @return void
  37      * @access protected
  38      */
  39  	function generateExpression(&$code) {
  40          $code->registerInclude(WACT_ROOT . 'template/components/data/math_filter.inc.php');
  41          $code->writePHP('math_filter(');
  42          $this->base->generateExpression($code);
  43          $code->writePHP(',');
  44          $this->parameters[0]->generateExpression($code);
  45          $code->writePHP(',');
  46          $code->writePHPLiteral($this->base->context->SourceFile);
  47          $code->writePHP(',');
  48          $code->writePHPLiteral($this->base->context->StartingLineNo);
  49          $code->writePHP(')');
  50      }
  51  
  52  }
  53  
  54  ?>


Generated: Sun Nov 28 19:36:09 2004 Cross-referenced by PHPXref 0.5