[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/pattemplate/patTemplate/Modifier/ -> Expression.php (source)

   1  <?PHP
   2  /**
   3   * patTemplate modfifier Expression
   4   *
   5   * $Id: Expression.php 10381 2008-06-01 03:35:53Z pasamio $
   6   *
   7   * @package        patTemplate
   8   * @subpackage    Modifiers
   9   * @author        Stephan Schmidt <schst@php.net>
  10   */
  11  
  12  // Check to ensure this file is within the rest of the framework
  13  defined('JPATH_BASE') or die();
  14  
  15  /**
  16   * patTemplate modfifier Expression
  17   *
  18   * Evaluates an expression and returns one of
  19   * the defined values for true and false.
  20   *
  21   * Possible attributes are:
  22   * - expression (string)
  23   * - true (string)
  24   * - false (string)
  25   *
  26   * @package        patTemplate
  27   * @subpackage    Modifiers
  28   * @author        Stephan Schmidt <schst@php.net>
  29   * @link        http://www.php.net/manual/en/function.wordwrap.php
  30   */
  31  class patTemplate_Modifier_Expression extends patTemplate_Modifier
  32  {
  33      /**
  34      * modify the value
  35      *
  36      * @access    public
  37      * @param    string        value
  38      * @return    string        modified value
  39      */
  40  	function modify( $value, $params = array() )
  41      {
  42          /*
  43           * true and false
  44           */
  45          if( !isset( $params['true'] ) )
  46              $params['true']    =    'true';
  47          if( !isset( $params['false'] ) )
  48              $params['false']=    'false';
  49  
  50          /*
  51           * replace the value in the expression
  52           */
  53          $params['expression'] = str_replace( '$self', "'$value'", $params['expression'] );
  54  
  55          @eval( '$result = '.$params['expression'].';' );
  56  
  57          if ($result === true) {
  58              return str_replace( '$self', $value, $params['true'] );
  59          }
  60          return str_replace( '$self', $value, $params['false'] );
  61      }
  62  }
  63  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1