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 / HTML / Table / Matrix / Filler.php
Encoding:
PHP Script  |  2008-07-02  |  3.8 KB  |  133 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Ian Eure <ieure@php.net>                                    |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Filler.php,v 1.5 2005/09/10 18:52:43 ieure Exp $
  20.  
  21. /**
  22.  * Base class common to all Fillers
  23.  *
  24.  * @author Ian Eure <ieure@php.net>
  25.  * @package HTML_Table_Matrix
  26.  * @since 1.0
  27.  */
  28. class HTML_Table_Matrix_Filler {
  29.     /**
  30.      * Default filler options
  31.      *
  32.      * @type array
  33.      * @access protected
  34.      * @see setOptions()
  35.      */
  36.     var $_defaultOptions = array();
  37.     
  38.     /**
  39.      * Filler options
  40.      *
  41.      * @type array
  42.      * @see setOptions()
  43.      */
  44.     var $options = '';
  45.     
  46.     /**
  47.      * Reference to the HTML_Table_Matrix instance we will be Filling for
  48.      *
  49.      * @type object
  50.      */
  51.     var $matrix = '';
  52.     
  53.     /**
  54.      * Current row to fill
  55.      *
  56.      * @type int
  57.      */
  58.     var $row = 0;
  59.     
  60.     /**
  61.      * Current column to fill
  62.      *
  63.      * @type int
  64.      */
  65.     var $col = 0;
  66.  
  67.     /**
  68.      * Callback function applied to _data
  69.      *
  70.      * @type mixed
  71.      */
  72.     var $callback;
  73.  
  74.     /**
  75.      * Create an instance of a Filler
  76.      *
  77.      * @param string $type Type of filler to instantiate
  78.      * @param Object $matrix Reference to the HTML_Table_Matrix instance
  79.      *                       the Filler will work with
  80.      * @param array $options Filler options
  81.      * @return mixed Filler instance on success, PEAR_Error otherwise
  82.      */
  83.     function &factory($type, &$matrix, $options = array())
  84.     {
  85.         $class = 'HTML_Table_Matrix_Filler_'.$type;
  86.         $file = str_replace('_', '/', $class).'.php';
  87.         @include_once $file;
  88.         if (!class_exists($class)) {
  89.             return PEAR::raiseError("Filler \"$type\" does not exist.");
  90.         }
  91.         $instance = new $class($matrix, $options);
  92.         return $instance;
  93.     }
  94.     
  95.     /**
  96.      * Set options for this Filler
  97.      *
  98.      * @param array $options Options to set
  99.      * @return void
  100.      */
  101.     function setOptions($options = array()) {
  102.         $opts = array_merge($this->_defaultOptions, $options);
  103.         $this->options = $opts;
  104.     }
  105.  
  106.     /**
  107.      * Determine if a given object is a valid H_T_M Filler
  108.      *
  109.      * @param mixed $object Object to check
  110.      * @return boolean true if valid, false otherwise
  111.      */
  112.     function isValid(&$object)
  113.     {
  114.         if (!is_a($object, 'HTML_Table_Matrix_Filler')) {
  115.             return false;
  116.         }
  117.         return true;
  118.     }
  119.  
  120.     /**
  121.      * Get the next cell.
  122.      *
  123.      * @param int $index Where we're at in the data-set
  124.      * @return array 1-dimensional array in the form of (row, col) containing the
  125.      *               coordinates to put the data for this loop iteration
  126.      */
  127.     function next($index)
  128.     {
  129.         return PEAR::raiseError("Function not implemented.");
  130.     }
  131. }
  132. ?>
  133.