home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Image / Graph / DataPreprocessor / Function.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  3.2 KB  |  92 lines

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * Image_Graph - PEAR PHP OO Graph Rendering Utility.
  7.  *
  8.  * PHP versions 4 and 5
  9.  *
  10.  * LICENSE: This library is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU Lesser General Public License as published by
  12.  * the Free Software Foundation; either version 2.1 of the License, or (at your
  13.  * option) any later version. This library is distributed in the hope that it
  14.  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
  15.  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
  16.  * General Public License for more details. You should have received a copy of
  17.  * the GNU Lesser General Public License along with this library; if not, write
  18.  * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19.  * 02111-1307 USA
  20.  *
  21.  * @category   Images
  22.  * @package    Image_Graph
  23.  * @subpackage DataPreprocessor
  24.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  25.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  26.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  27.  * @version    CVS: $Id: Function.php,v 1.7 2005/11/11 17:53:44 nosey Exp $
  28.  * @link       http://pear.php.net/package/Image_Graph
  29.  */
  30.  
  31. /**
  32.  * Include file Image/Graph/DataPreprocessor.php
  33.  */
  34. require_once 'Image/Graph/DataPreprocessor.php';
  35.  
  36. /**
  37.  * Formatting a value using a userdefined function.
  38.  *
  39.  * Use this method to convert/format a value to a 'displayable' lable using a (perhaps)
  40.  * more complex function. An example could be (not very applicable though) if one would
  41.  * need for values to be displayed on the reverse order, i.e. 1234 would be displayed as
  42.  * 4321, then this method can solve this by creating the function that converts the value
  43.  * and use the FunctionData datapreprocessor to make Image_Graph use this function.
  44.  *
  45.  * @category   Images
  46.  * @package    Image_Graph
  47.  * @subpackage DataPreprocessor
  48.  * @author     Jesper Veggerby <pear.nosey@veggerby.dk>
  49.  * @copyright  Copyright (C) 2003, 2004 Jesper Veggerby Hansen
  50.  * @license    http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1
  51.  * @version    Release: 0.7.2
  52.  * @link       http://pear.php.net/package/Image_Graph
  53.  */
  54. class Image_Graph_DataPreprocessor_Function extends Image_Graph_DataPreprocessor
  55. {
  56.  
  57.     /**
  58.      * The name of the PHP function
  59.      * @var string
  60.      * @access private
  61.      */
  62.     var $_dataFunction;
  63.  
  64.     /**
  65.      * Create a FunctionData preprocessor
  66.      *
  67.      * @param string $function The name of the PHP function to use as
  68.      *   a preprocessor, this function must take a single parameter and return a
  69.      *   formatted version of this parameter
  70.      */
  71.     function Image_Graph_DataPreprocessor_Function($function)
  72.     {
  73.         parent::Image_Graph_DataPreprocessor();
  74.         $this->_dataFunction = $function;
  75.     }
  76.  
  77.     /**
  78.      * Process the value
  79.      *
  80.      * @param var $value The value to process/format
  81.      * @return string The processed value
  82.      * @access private
  83.      */
  84.     function _process($value)
  85.     {
  86.         $function = $this->_dataFunction;
  87.         return call_user_func($function, $value);
  88.     }
  89.  
  90. }
  91.  
  92. ?>