[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/inc/savant2/Savant2/ -> Savant2_Plugin_modify.php (source)

   1  <?php
   2  
   3  /**
   4  * Base plugin class.
   5  */
   6  require_once 'Savant2/Plugin.php';
   7  
   8  /**
   9  * 
  10  * Modifies a value with a series of functions.
  11  * 
  12  * $Id: Savant2_Plugin_modify.php 18360 2005-05-26 19:38:09Z mipmip $
  13  * 
  14  * @author Paul M. Jones <pmjones@ciaweb.net>
  15  * 
  16  * @package Savant2
  17  * 
  18  * @license http://www.gnu.org/copyleft/lesser.html LGPL
  19  * 
  20  * This program is free software; you can redistribute it and/or modify
  21  * it under the terms of the GNU Lesser General Public License as
  22  * published by the Free Software Foundation; either version 2.1 of the
  23  * License, or (at your option) any later version.
  24  * 
  25  * This program is distributed in the hope that it will be useful, but
  26  * WITHOUT ANY WARRANTY; without even the implied warranty of
  27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28  * Lesser General Public License for more details.
  29  * 
  30  */
  31  
  32  class Savant2_Plugin_modify extends Savant2_Plugin {
  33      
  34      /**
  35      * 
  36      * Modifies a value with a series of functions.
  37      * 
  38      * Allows you to pass a space-separated list of value-manipulation
  39      * functions so that the value is "massaged" before output. For
  40      * example, if you want to strip slashes, force to lower case, and
  41      * convert to HTML entities (as for an input text box), you might do
  42      * this:
  43      * 
  44      * $this->modify($value, 'stripslashes strtolower htmlentities');
  45      * 
  46      * @param object &$savant A reference to the calling Savant2 object.
  47      * 
  48      * @access public
  49      * 
  50      * @param string $value The value to be printed.
  51      * 
  52      * @param string $functions A space-separated list of
  53      * single-parameter functions to be applied to the $value before
  54      * printing.
  55      * 
  56      * @return string
  57      * 
  58      */
  59      
  60  	function plugin($value, $functions = null)
  61      {
  62          // is there a space-delimited function list?
  63          if (is_string($functions)) {
  64              
  65              // yes.  split into an array of the
  66              // functions to be called.
  67              $list = explode(' ', $functions);
  68              
  69              // loop through the function list and
  70              // apply to the output in sequence.
  71              foreach ($list as $func) {
  72                  if (function_exists($func)) {
  73                      $value = $func($value);
  74                  }
  75              }
  76          }
  77          
  78          return $value;
  79      }
  80  
  81  }
  82  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7