[ Index ]
 

Code source de Joomla 1.0.13

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/includes/patTemplate/patTemplate/Modifier/ -> Expression.php (source)

   1  <?PHP
   2  /**

   3   * patTemplate modfifier Expression

   4   *

   5   * $Id: Expression.php 49 2005-09-15 02:55:27Z rhuk $

   6   *

   7   * @package        patTemplate

   8   * @subpackage    Modifiers

   9   * @author        Stephan Schmidt <schst@php.net>

  10   */
  11  
  12  /**

  13   * patTemplate modfifier Expression

  14   *

  15   * Evaluates an expression and returns one of

  16   * the defined values for true and false.

  17   *

  18   * Possible attributes are:

  19   * - expression (string)

  20   * - true (string)

  21   * - false (string)

  22   *

  23   * @package        patTemplate

  24   * @subpackage    Modifiers

  25   * @author        Stephan Schmidt <schst@php.net>

  26   * @link        http://www.php.net/manual/en/function.wordwrap.php

  27   */
  28  class patTemplate_Modifier_Expression extends patTemplate_Modifier
  29  {
  30     /**

  31      * modify the value

  32      *

  33      * @access    public

  34      * @param    string        value

  35      * @return    string        modified value

  36      */
  37  	function modify( $value, $params = array() )
  38      {
  39          /*

  40           * true and false

  41           */
  42          if( !isset( $params['true'] ) )
  43              $params['true']    =    'true';
  44          if( !isset( $params['false'] ) )
  45              $params['false']=    'false';
  46  
  47          /*

  48           * replace the value in the expression

  49           */
  50          $params['expression'] = str_replace( '$self', "'$value'", $params['expression'] );
  51  
  52          @eval( '$result = '.$params['expression'].';' );
  53  
  54          if ($result === true) {
  55              return str_replace( '$self', $value, $params['true'] );
  56          }
  57          return str_replace( '$self', $value, $params['false'] );
  58      }
  59  }
  60  ?>


Généré le : Wed Nov 21 14:43:32 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics