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 / Progress / UI.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  43.1 KB  |  1,215 lines

  1. <?php
  2. /**
  3.  * HTML loading bar with only PHP and JS interface.
  4.  *
  5.  * PHP versions 4 and 5
  6.  *
  7.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  8.  * that is available through the world-wide-web at the following URI:
  9.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  10.  * the PHP License and are unable to obtain it through the web, please
  11.  * send a note to license@php.net so we can mail you a copy immediately.
  12.  *
  13.  * @category   HTML
  14.  * @package    HTML_Progress
  15.  * @subpackage Progress_UI
  16.  * @author     Laurent Laville <pear@laurent-laville.org>
  17.  * @copyright  1997-2005 The PHP Group
  18.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  19.  * @version    CVS: $Id: UI.php,v 1.10 2005/09/14 08:32:30 farell Exp $
  20.  * @link       http://pear.php.net/package/HTML_Progress
  21.  * @since      File available since Release 1.0
  22.  */
  23.  
  24. require_once 'HTML/Common.php';
  25.  
  26. /**
  27.  * HTML loading bar with only PHP and JS interface.
  28.  *
  29.  * The HTML_Progress_UI class provides a basic look and feel
  30.  * implementation of a progress bar.
  31.  *
  32.  * @category   HTML
  33.  * @package    HTML_Progress
  34.  * @subpackage Progress_UI
  35.  * @author     Laurent Laville <pear@laurent-laville.org>
  36.  * @copyright  1997-2005 The PHP Group
  37.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  38.  * @version    Release: @package_version@
  39.  * @link       http://pear.php.net/package/HTML_Progress2
  40.  * @since      Class available since Release 1.0
  41.  */
  42.  
  43. class HTML_Progress_UI extends HTML_Common
  44. {
  45.     /**
  46.      * Whether the progress bar is horizontal, vertical, polygonal or circle.
  47.      * The default is horizontal.
  48.      *
  49.      * @var        integer
  50.      * @since      1.0
  51.      * @access     private
  52.      * @see        getOrientation(), setOrientation()
  53.      */
  54.     var $_orientation;
  55.  
  56.     /**
  57.      * Whether the progress bar is filled in 'natural' or 'reverse' way.
  58.      * The default fill way is 'natural'.
  59.      *
  60.      * <ul>
  61.      * <li>since 0.5 : 'way'  =  bar fill way
  62.      *   <ul>
  63.      *     <li>with Progress Bar Horizontal,
  64.      *              natural way is : left to right
  65.      *        <br />reverse way is : right to left
  66.      *     <li>with Progress Bar Vertical,
  67.      *              natural way is : down to up
  68.      *        <br />reverse way is : up to down
  69.      *     <li>with Progress Circle or Polygonal,
  70.      *              natural way is : clockwise
  71.      *        <br />reverse way is : anticlockwise
  72.      *   </ul>
  73.      * </ul>
  74.      *
  75.      * @var        string
  76.      * @since      1.0
  77.      * @access     private
  78.      * @see        getFillWay(), setFillWay()
  79.      */
  80.     var $_fillWay;
  81.  
  82.     /**
  83.      * The cell count of the progress bar. The default is 10.
  84.      *
  85.      * @var        integer
  86.      * @since      1.0
  87.      * @access     private
  88.      * @see        getCellCount(), setCellCount()
  89.      */
  90.     var $_cellCount;
  91.  
  92.     /**
  93.      * The cell coordinates for a progress polygonal shape.
  94.      *
  95.      * @var        array
  96.      * @since      1.2.0
  97.      * @access     private
  98.      * @see        getCellCoordinates(), setCellCoordinates()
  99.      */
  100.     var $_coordinates;
  101.  
  102.     /**
  103.      * The width of grid in cell-size of the polygonal shape.
  104.      *
  105.      * @var        integer
  106.      * @since      1.2.0
  107.      * @access     private
  108.      * @see        getCellCoordinates(), setCellCoordinates()
  109.      */
  110.     var $_xgrid;
  111.  
  112.     /**
  113.      * The height of grid in cell-size of the polygonal shape.
  114.      *
  115.      * @var        integer
  116.      * @since      1.2.0
  117.      * @access     private
  118.      * @see        getCellCoordinates(), setCellCoordinates()
  119.      */
  120.     var $_ygrid;
  121.  
  122.     /**
  123.      * The progress bar's structure
  124.      *
  125.      * <ul>
  126.      * <li>['cell']
  127.      *     <ul>
  128.      *     <li>since 1.0 : 'id'             =  cell identifier mask
  129.      *     <li>since 1.0 : 'class'          =  css class selector
  130.      *     <li>since 0.1 : 'width'          =  cell width
  131.      *     <li>since 0.1 : 'height'         =  cell height
  132.      *     <li>since 0.1 : 'active-color'   =  active color
  133.      *     <li>since 0.1 : 'inactive-color' =  inactive color
  134.      *     <li>since 0.1 : 'spacing'        =  cell spacing
  135.      *     <li>since 0.6 : 'color'          =  foreground color
  136.      *     <li>since 0.6 : 'font-size'      =  font size
  137.      *     <li>since 0.6 : 'font-family'    =  font family
  138.      *     <li>since 1.2 : 'background-color' = background color
  139.      *     </ul>
  140.      * <li>['border']
  141.      *     <ul>
  142.      *     <li>since 1.0 : 'class'  =  css class selector
  143.      *     <li>since 0.1 : 'width'  =  border width
  144.      *     <li>since 0.1 : 'style'  =  border style
  145.      *     <li>since 0.1 : 'color'  =  border color
  146.      *     </ul>
  147.      * <li>['string']
  148.      *     <ul>
  149.      *     <li>sicne 1.0 : 'id'                =  string identifier
  150.      *     <li>since 0.6 : 'width'             =  with of progress string
  151.      *     <li>since 0.6 : 'height'            =  height of progress string
  152.      *     <li>since 0.1 : 'font-family'       =  font family
  153.      *     <li>since 0.1 : 'font-size'         =  font size
  154.      *     <li>since 0.1 : 'color'             =  font color
  155.      *     <li>since 0.6 : 'background-color'  =  background color
  156.      *     <li>since 0.6 : 'align'             =  horizontal align  (left, center, right, justify)
  157.      *     <li>since 0.6 : 'valign'            =  vertical align  (top, bottom, left, right)
  158.      *     </ul>
  159.      * <li>['progress']
  160.      *     <ul>
  161.      *     <li>since 1.0 : 'class'             =  css class selector
  162.      *     <li>since 0.1 : 'background-color'  =  bar background color
  163.      *     <li>since 1.0 : 'auto-size'         = compute best progress size
  164.      *     <li>since 0.1 : 'width'             =  bar width
  165.      *     <li>since 0.1 : 'height'            =  bar height
  166.      *     </ul>
  167.      * </ul>
  168.      *
  169.      * @var        array
  170.      * @since      1.0
  171.      * @access     private
  172.      * @see        HTML_Progress::toArray()
  173.      */
  174.     var $_progress = array();
  175.  
  176.     /**
  177.      * External Javascript file to override internal default code
  178.      *
  179.      * @var        string
  180.      * @since      1.0
  181.      * @access     private
  182.      * @see        getScript(), setScript()
  183.      */
  184.     var $_script;
  185.  
  186.  
  187.     /**
  188.      * The progress bar's UI model class constructor
  189.      *
  190.      * Constructor Summary
  191.      *
  192.      * o Creates a natural horizontal progress bar that displays ten cells/units.
  193.      *   <code>
  194.      *   $html = new HTML_Progress_UI();
  195.      *   </code>
  196.      *
  197.      * o Creates a natural horizontal progress bar with the specified cell count,
  198.      *   which cannot be less than 1 (minimum), but has no maximum limit.
  199.      *   <code>
  200.      *   $html = new HTML_Progress_UI($cell);
  201.      *   </code>
  202.      *
  203.      * @param      int       $cell          (optional) Cell count
  204.      *
  205.      * @since      1.0
  206.      * @access     public
  207.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  208.      */
  209.     function HTML_Progress_UI()
  210.     {
  211.         // if you've not yet created an instance of html_progress
  212.         if (!$GLOBALS['_HTML_PROGRESS_CALLBACK_ERRORHANDLER']) {
  213.             // init default error handling system,
  214.             HTML_Progress::_initErrorHandler();
  215.         }
  216.  
  217.         $args = func_get_args();
  218.  
  219.         switch (count($args)) {
  220.          case 1:
  221.             /*   int cell  */
  222.             if (!is_int($args[0])) {
  223.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  224.                     array('var' => '$cell',
  225.                           'was' => $args[0],
  226.                           'expected' => 'integer',
  227.                           'paramnum' => 1));
  228.  
  229.             } elseif ($args[0] < 1) {
  230.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  231.                     array('var' => '$cell',
  232.                           'was' => $args[0],
  233.                           'expected' => 'greater or equal 1',
  234.                           'paramnum' => 1));
  235.             }
  236.             $this->_cellCount = $args[0];
  237.             break;
  238.          default:
  239.             $this->_cellCount = 10;
  240.             break;
  241.         }
  242.         $this->_orientation = HTML_PROGRESS_BAR_HORIZONTAL;
  243.         $this->_fillWay = 'natural';
  244.         $this->_script = null;              // uses internal javascript code
  245.  
  246.         $this->_progress = array(
  247.             'cell' =>
  248.                 array(
  249.                     'id' => "progressCell%01s",
  250.                     'class' => "cell",
  251.                     'active-color' => "#006600",
  252.                     'inactive-color' => "#CCCCCC",
  253.                     'font-family' => "Courier, Verdana",
  254.                     'font-size' => 8,
  255.                     'color' => "#000000",
  256.                     'background-color' => "#FFFFFF",
  257.                     'width' => 15,
  258.                     'height' => 20,
  259.                     'spacing' => 2
  260.                 ),
  261.             'border' =>
  262.                 array(
  263.                     'class' => "progressBarBorder",
  264.                     'width' => 0,
  265.                     'style' => "solid",
  266.                     'color' => "#000000"
  267.                 ),
  268.             'string' =>
  269.                 array(
  270.                     'id' => "installationProgress",
  271.                     'width' => 50,
  272.                     'font-family' => "Verdana, Arial, Helvetica, sans-serif",
  273.                     'font-size' => 12,
  274.                     'color' => "#000000",
  275.                     'background-color' => "#FFFFFF",
  276.                     'align' => "right",
  277.                     'valign' => "right"
  278.                 ),
  279.             'progress' =>
  280.                 array(
  281.                     'class' => "progressBar",
  282.                     'background-color' => "#FFFFFF",
  283.                     'auto-size' => true
  284.                 )
  285.         );
  286.         $this->_updateProgressSize();   // updates the new size of progress bar
  287.     }
  288.  
  289.     /**
  290.      * Returns HTML_PROGRESS_BAR_HORIZONTAL or HTML_PROGRESS_BAR_VERTICAL,
  291.      * depending on the orientation of the progress bar.
  292.      * The default orientation is HTML_PROGRESS_BAR_HORIZONTAL.
  293.      *
  294.      * @return     integer
  295.      * @since      1.0
  296.      * @access     public
  297.      * @see        setOrientation()
  298.      */
  299.     function getOrientation()
  300.     {
  301.         return $this->_orientation;
  302.     }
  303.  
  304.     /**
  305.      * Sets the progress bar's orientation, which must be HTML_PROGRESS_BAR_HORIZONTAL
  306.      * or HTML_PROGRESS_BAR_VERTICAL.
  307.      * The default orientation is HTML_PROGRESS_BAR_HORIZONTAL.
  308.      *
  309.      * @param      integer   $orient        Orientation (horizontal or vertical)
  310.      *
  311.      * @return     void
  312.      * @since      1.0
  313.      * @access     public
  314.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  315.      * @see        getOrientation()
  316.      */
  317.     function setOrientation($orient)
  318.     {
  319.         if (!is_int($orient)) {
  320.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  321.                 array('var' => '$orient',
  322.                       'was' => gettype($orient),
  323.                       'expected' => 'integer',
  324.                       'paramnum' => 1));
  325.  
  326.         } elseif (($orient != HTML_PROGRESS_BAR_HORIZONTAL) &&
  327.                   ($orient != HTML_PROGRESS_BAR_VERTICAL) &&
  328.                   ($orient != HTML_PROGRESS_POLYGONAL) &&
  329.                   ($orient != HTML_PROGRESS_CIRCLE)) {
  330.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  331.                 array('var' => '$orient',
  332.                       'was' => $orient,
  333.                       'expected' => HTML_PROGRESS_BAR_HORIZONTAL.' | '.
  334.                                     HTML_PROGRESS_BAR_VERTICAL.' | '.
  335.                                     HTML_PROGRESS_POLYGONAL.' | '.
  336.                                     HTML_PROGRESS_CIRCLE,
  337.                       'paramnum' => 1));
  338.         }
  339.  
  340.         $previous = $this->_orientation;    // gets previous orientation
  341.         $this->_orientation = $orient;      // sets the new orientation
  342.  
  343.         if ($previous != $orient) {
  344.             // if orientation has changed, we need to swap cell width and height
  345.             $w = $this->_progress['cell']['width'];
  346.             $h = $this->_progress['cell']['height'];
  347.  
  348.             $this->_progress['cell']['width']  = $h;
  349.             $this->_progress['cell']['height'] = $w;
  350.  
  351.             $this->_updateProgressSize();   // updates the new size of progress bar
  352.         }
  353.     }
  354.  
  355.     /**
  356.      * Returns 'natural' or 'reverse', depending of the fill way of progress bar.
  357.      * For horizontal progress bar, natural way is from left to right, and reverse
  358.      * way is from right to left.
  359.      * For vertical progress bar, natural way is from down to up, and reverse
  360.      * way is from up to down.
  361.      * The default fill way is 'natural'.
  362.      *
  363.      * @return     string
  364.      * @since      1.0
  365.      * @access     public
  366.      * @see        setFillWay()
  367.      */
  368.     function getFillWay()
  369.     {
  370.         return $this->_fillWay;
  371.     }
  372.  
  373.     /**
  374.      * Sets the progress bar's fill way, which must be 'natural' or 'reverse'.
  375.      * The default fill way is 'natural'.
  376.      *
  377.      * @param      string    $way           fill direction (natural or reverse)
  378.      *
  379.      * @return     void
  380.      * @since      1.0
  381.      * @access     public
  382.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  383.      * @see        getFillWay()
  384.      */
  385.     function setFillWay($way)
  386.     {
  387.         if (!is_string($way)) {
  388.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  389.                 array('var' => '$way',
  390.                       'was' => gettype($way),
  391.                       'expected' => 'string',
  392.                       'paramnum' => 1));
  393.  
  394.         } elseif ((strtolower($way) != 'natural') && (strtolower($way) != 'reverse')) {
  395.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  396.                 array('var' => '$way',
  397.                       'was' => $way,
  398.                       'expected' => 'natural | reverse',
  399.                       'paramnum' => 1));
  400.         }
  401.         $this->_fillWay = strtolower($way);
  402.     }
  403.  
  404.     /**
  405.      * Returns the number of cell in the progress bar. The default value is 10.
  406.      *
  407.      * @return     integer
  408.      * @since      1.0
  409.      * @access     public
  410.      * @see        setCellCount()
  411.      */
  412.     function getCellCount()
  413.     {
  414.         return $this->_cellCount;
  415.     }
  416.  
  417.     /**
  418.      * Sets the number of cell in the progress bar
  419.      *
  420.      * @param      integer   $cells         Cell count on progress bar
  421.      *
  422.      * @return     void
  423.      * @since      1.0
  424.      * @access     public
  425.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  426.      * @see        getCellCount()
  427.      */
  428.     function setCellCount($cells)
  429.     {
  430.         if (!is_int($cells)) {
  431.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  432.                 array('var' => '$cells',
  433.                       'was' => gettype($cells),
  434.                       'expected' => 'integer',
  435.                       'paramnum' => 1));
  436.  
  437.         } elseif ($cells < 1) {
  438.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  439.                 array('var' => '$cells',
  440.                       'was' => $cells,
  441.                       'expected' => 'greater or equal 1',
  442.                       'paramnum' => 1));
  443.         }
  444.         $this->_cellCount = $cells;
  445.  
  446.         $this->_updateProgressSize();   // updates the new size of progress bar
  447.     }
  448.  
  449.     /**
  450.      * Returns the common and private cell attributes. Assoc array (defaut) or string
  451.      *
  452.      * @param      bool      $asString      (optional) whether to return the attributes as string
  453.      *
  454.      * @return     mixed
  455.      * @since      1.0
  456.      * @access     public
  457.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  458.      * @see        setCellAttributes()
  459.      */
  460.     function getCellAttributes($asString = false)
  461.     {
  462.         if (!is_bool($asString)) {
  463.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  464.                 array('var' => '$asString',
  465.                       'was' => gettype($asString),
  466.                       'expected' => 'boolean',
  467.                       'paramnum' => 1));
  468.         }
  469.  
  470.         $attr = $this->_progress['cell'];
  471.  
  472.         if ($asString) {
  473.             return $this->_getAttrString($attr);
  474.         } else {
  475.             return $attr;
  476.         }
  477.     }
  478.  
  479.     /**
  480.      * Sets the cell attributes for an existing cell.
  481.      *
  482.      * Defaults are:
  483.      * <ul>
  484.      * <li>Common :
  485.      *     <ul>
  486.      *     <li>id             = progressCell%01s
  487.      *     <li>class          = cell
  488.      *     <li>spacing        = 2
  489.      *     <li>active-color   = #006600
  490.      *     <li>inactive-color = #CCCCCC
  491.      *     <li>font-family    = Courier, Verdana
  492.      *     <li>font-size      = lowest value from cell width, cell height, and font size
  493.      *     <li>color          = #000000
  494.      *     <li>background-color = #FFFFFF (added for progress circle shape on release 1.2.0)
  495.      *     <li>Horizontal Bar :
  496.      *         <ul>
  497.      *         <li>width      = 15
  498.      *         <li>height     = 20
  499.      *         </ul>
  500.      *     <li>Vertical Bar :
  501.      *         <ul>
  502.      *         <li>width      = 20
  503.      *         <li>height     = 15
  504.      *         </ul>
  505.      *     </ul>
  506.      * </ul>
  507.      *
  508.      * @param      mixed     $attributes    Associative array or string of HTML tag attributes
  509.      * @param      int       $cell          (optional) Cell index
  510.      *
  511.      * @return     void
  512.      * @since      1.0
  513.      * @access     public
  514.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  515.      * @see        getCellAttributes(), getCellCount()
  516.      */
  517.     function setCellAttributes($attributes, $cell = null)
  518.     {
  519.         if (!is_null($cell)) {
  520.             if (!is_int($cell)) {
  521.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  522.                     array('var' => '$cell',
  523.                           'was' => gettype($cell),
  524.                           'expected' => 'integer',
  525.                           'paramnum' => 2));
  526.  
  527.             } elseif ($cell < 0) {
  528.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  529.                     array('var' => '$cell',
  530.                           'was' => $cell,
  531.                           'expected' => 'positive',
  532.                           'paramnum' => 2));
  533.  
  534.             } elseif ($cell > $this->getCellCount()) {
  535.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  536.                     array('var' => '$cell',
  537.                           'was' => $cell,
  538.                           'expected' => 'less or equal '.$this->getCellCount(),
  539.                           'paramnum' => 2));
  540.             }
  541.  
  542.             $this->_updateAttrArray($this->_progress['cell'][$cell], $this->_parseAttributes($attributes));
  543.         } else {
  544.             $this->_updateAttrArray($this->_progress['cell'], $this->_parseAttributes($attributes));
  545.         }
  546.  
  547.         $font_size   = $this->_progress['cell']['font-size'];
  548.         $cell_width  = $this->_progress['cell']['width'];
  549.         $cell_height = $this->_progress['cell']['height'];
  550.         $margin = ($this->getOrientation() == HTML_PROGRESS_BAR_HORIZONTAL) ? 0 : 3;
  551.  
  552.         $font_size = min(min($cell_width, $cell_height) - $margin, $font_size);
  553.         $this->_progress['cell']['font-size'] = $font_size;
  554.  
  555.         $this->_updateProgressSize();   // updates the new size of progress bar
  556.     }
  557.  
  558.     /**
  559.      * Returns the coordinates of each cell for a polygonal progress shape.
  560.      *
  561.      * @return     array                    list of cell coordinates
  562.      * @since      1.2.0
  563.      * @access     public
  564.      * @see        setCellCoordinates()
  565.      */
  566.     function getCellCoordinates()
  567.     {
  568.         return isset($this->_coordinates) ? $this->_coordinates : array();
  569.     }
  570.  
  571.     /**
  572.      * Set the coordinates of each cell for a polygonal progress shape.
  573.      *
  574.      * @param      integer   $xgrid     The grid width in cell size
  575.      * @param      integer   $ygrid     The grid height in cell size
  576.      * @param      array     $coord     (optional) Coordinates (x,y) in the grid, of each cell
  577.      *
  578.      * @return     void
  579.      * @since      1.2.0
  580.      * @access     public
  581.      * @see        getCellCoordinates()
  582.      */
  583.     function setCellCoordinates($xgrid, $ygrid, $coord = array())
  584.     {
  585.         if (!is_int($xgrid)) {
  586.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  587.                 array('var' => '$xgrid',
  588.                       'was' => gettype($xgrid),
  589.                       'expected' => 'integer',
  590.                       'paramnum' => 1));
  591.  
  592.         } elseif ($xgrid < 3) {
  593.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  594.                 array('var' => '$xgrid',
  595.                       'was' => $xgrid,
  596.                       'expected' => 'greater than 2',
  597.                       'paramnum' => 1));
  598.  
  599.         } elseif (!is_int($ygrid)) {
  600.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  601.                 array('var' => '$ygrid',
  602.                       'was' => gettype($ygrid),
  603.                       'expected' => 'integer',
  604.                       'paramnum' => 2));
  605.  
  606.         } elseif ($ygrid < 3) {
  607.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  608.                 array('var' => '$ygrid',
  609.                       'was' => $ygrid,
  610.                       'expected' => 'greater than 2',
  611.                       'paramnum' => 2));
  612.  
  613.         } elseif (!is_array($coord)) {
  614.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  615.                 array('var' => '$coord',
  616.                       'was' => gettype($coord),
  617.                       'expected' => 'array',
  618.                       'paramnum' => 3));
  619.         }
  620.  
  621.         if (count($coord) == 0) {
  622.             // Computes all coordinates of a standard polygon (square or rectangle)
  623.             $coord = $this->_computeCoordinates($xgrid, $ygrid);
  624.         } else {
  625.             foreach ($coord as $id => $pos) {
  626.                 if (!is_array($pos)) {
  627.                     return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  628.                         array('var' => '$coord[,$pos]',
  629.                               'was' => gettype($pos),
  630.                               'expected' => 'array',
  631.                               'paramnum' => 3));
  632.                 }
  633.                 if ($pos[0] >= $ygrid) {
  634.                     return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  635.                         array('var' => '$pos[0]',
  636.                               'was' => $pos[0],
  637.                               'expected' => 'coordinate less than grid height',
  638.                               'paramnum' => 3));
  639.                 }
  640.                 if ($pos[1] >= $xgrid) {
  641.                     return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  642.                         array('var' => '$pos[1]',
  643.                               'was' => $pos[1],
  644.                               'expected' => 'coordinate less than grid width',
  645.                               'paramnum' => 3));
  646.                 }
  647.             }
  648.         }
  649.         $this->_coordinates = $coord;
  650.         $this->_xgrid = $xgrid;
  651.         $this->_ygrid = $ygrid;
  652.  
  653.         // auto-compute cell count
  654.         $this->_cellCount = count($coord);
  655.  
  656.         $this->_updateProgressSize();   // updates the new size of progress bar
  657.     }
  658.  
  659.     /**
  660.      * Returns the progress bar's border attributes. Assoc array (defaut) or string.
  661.      *
  662.      * @param      bool      $asString      (optional) whether to return the attributes as string
  663.      *
  664.      * @return     mixed
  665.      * @since      1.0
  666.      * @access     public
  667.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  668.      * @see        setBorderAttributes()
  669.      */
  670.     function getBorderAttributes($asString = false)
  671.     {
  672.         if (!is_bool($asString)) {
  673.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  674.                 array('var' => '$asString',
  675.                       'was' => gettype($asString),
  676.                       'expected' => 'boolean',
  677.                       'paramnum' => 1));
  678.         }
  679.  
  680.         $attr = $this->_progress['border'];
  681.  
  682.         if ($asString) {
  683.             return $this->_getAttrString($attr);
  684.         } else {
  685.             return $attr;
  686.         }
  687.     }
  688.  
  689.     /**
  690.      * Sets the progress bar's border attributes.
  691.      *
  692.      * Defaults are:
  693.      * <ul>
  694.      * <li>class   = progressBarBorder
  695.      * <li>width   = 0
  696.      * <li>style   = solid
  697.      * <li>color   = #000000
  698.      * </ul>
  699.      *
  700.      * @param      mixed     $attributes    Associative array or string of HTML tag attributes
  701.      *
  702.      * @return     void
  703.      * @since      1.0
  704.      * @access     public
  705.      * @see        getBorderAttributes(), HTML_Progress::setBorderPainted()
  706.      */
  707.     function setBorderAttributes($attributes)
  708.     {
  709.         $this->_updateAttrArray($this->_progress['border'], $this->_parseAttributes($attributes));
  710.  
  711.         $this->_updateProgressSize();   // updates the new size of progress bar
  712.     }
  713.  
  714.     /**
  715.      * Returns the string attributes. Assoc array (defaut) or string.
  716.      *
  717.      * @param      bool      $asString      (optional) whether to return the attributes as string
  718.      *
  719.      * @return     mixed
  720.      * @since      1.0
  721.      * @access     public
  722.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  723.      * @see        setStringAttributes()
  724.      */
  725.     function getStringAttributes($asString = false)
  726.     {
  727.         if (!is_bool($asString)) {
  728.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  729.                 array('var' => '$asString',
  730.                       'was' => gettype($asString),
  731.                       'expected' => 'boolean',
  732.                       'paramnum' => 1));
  733.         }
  734.  
  735.         $attr = $this->_progress['string'];
  736.  
  737.         if ($asString) {
  738.             return $this->_getAttrString($attr);
  739.         } else {
  740.             return $attr;
  741.         }
  742.     }
  743.  
  744.     /**
  745.      * Sets the string attributes.
  746.      *
  747.      * Defaults are:
  748.      * <ul>
  749.      * <li>id                = installationProgress
  750.      * <li>width             = 50
  751.      * <li>font-family       = Verdana, Arial, Helvetica, sans-serif
  752.      * <li>font-size         = 12
  753.      * <li>color             = #000000
  754.      * <li>background-color  = #FFFFFF
  755.      * <li>align             = right
  756.      * <li>Horizontal Bar :
  757.      *     <ul>
  758.      *     <li>valign        = right
  759.      *     </ul>
  760.      * <li>Vertical Bar :
  761.      *     <ul>
  762.      *     <li>valign        = bottom
  763.      *     </ul>
  764.      * </ul>
  765.      *
  766.      * @param      mixed     $attributes    Associative array or string of HTML tag attributes
  767.      *
  768.      * @return     void
  769.      * @since      1.0
  770.      * @access     public
  771.      * @see        getStringAttributes(), HTML_Progress::setStringPainted()
  772.      */
  773.     function setStringAttributes($attributes)
  774.     {
  775.         $this->_updateAttrArray($this->_progress['string'], $this->_parseAttributes($attributes));
  776.     }
  777.  
  778.     /**
  779.      * Returns the progress attributes. Assoc array (defaut) or string.
  780.      *
  781.      * @param      bool      $asString      (optional) whether to return the attributes as string
  782.      *
  783.      * @return     mixed
  784.      * @since      1.0
  785.      * @access     public
  786.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  787.      * @see        setProgressAttributes()
  788.      */
  789.     function getProgressAttributes($asString = false)
  790.     {
  791.         if (!is_bool($asString)) {
  792.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  793.                 array('var' => '$asString',
  794.                       'was' => gettype($asString),
  795.                       'expected' => 'boolean',
  796.                       'paramnum' => 1));
  797.         }
  798.  
  799.         $attr = $this->_progress['progress'];
  800.  
  801.         if ($asString) {
  802.             return $this->_getAttrString($attr);
  803.         } else {
  804.             return $attr;
  805.         }
  806.     }
  807.  
  808.     /**
  809.      * Sets the common progress bar attributes.
  810.      *
  811.      * Defaults are:
  812.      * <ul>
  813.      * <li>class             = progressBar
  814.      * <li>background-color  = #FFFFFF
  815.      * <li>auto-size         = true
  816.      * <li>Horizontal Bar :
  817.      *     <ul>
  818.      *     <li>width         = (cell_count * (cell_width + cell_spacing)) + cell_spacing
  819.      *     <li>height        = cell_height + (2 * cell_spacing)
  820.      *     </ul>
  821.      * <li>Vertical Bar :
  822.      *     <ul>
  823.      *     <li>width         = cell_width + (2 * cell_spacing)
  824.      *     <li>height        = (cell_count * (cell_height + cell_spacing)) + cell_spacing
  825.      *     </ul>
  826.      * </ul>
  827.      *
  828.      * @param      mixed     $attributes    Associative array or string of HTML tag attributes
  829.      *
  830.      * @return     void
  831.      * @since      1.0
  832.      * @access     public
  833.      * @see        getProgressAttributes()
  834.      */
  835.     function setProgressAttributes($attributes)
  836.     {
  837.         $this->_updateAttrArray($this->_progress['progress'], $this->_parseAttributes($attributes));
  838.     }
  839.  
  840.     /**
  841.      * Get the javascript code to manage progress bar.
  842.      *
  843.      * @return     string                   JavaScript URL or inline code to manage progress bar
  844.      * @since      0.5
  845.      * @access     public
  846.      * @see        setScript()
  847.      * @author     Stefan Neufeind <pear.neufeind@speedpartner.de> Contributor.
  848.      *             See details on thanks section of README file.
  849.      * @author     Christian Wenz <wenz@php.net> Helper.
  850.      *             See details on thanks section of README file.
  851.      */
  852.     function getScript()
  853.     {
  854.         if (!is_null($this->_script)) {
  855.             return $this->_script;   // URL to the linked Progress JavaScript
  856.         }
  857.  
  858.         $js = <<< JS
  859. var isDom = document.getElementById?true:false;
  860. var isIE  = document.all?true:false;
  861. var isNS4 = document.layers?true:false;
  862. var cellCount = %cellCount%;
  863.  
  864. function setprogress(pIdent, pValue, pString, pDeterminate)
  865. {
  866.     if (isDom) {
  867.         prog = document.getElementById(pIdent+'%installationProgress%');
  868.     } else if (isIE) {
  869.         prog = document.all[pIdent+'%installationProgress%'];
  870.     } else if (isNS4) {
  871.         prog = document.layers[pIdent+'%installationProgress%'];
  872.     }
  873.     if (prog != null) {
  874.         prog.innerHTML = pString;
  875.     }
  876.     if (pValue == pDeterminate) {
  877.         for (i=0; i < cellCount; i++) {
  878.             showCell(i, pIdent, "hidden");
  879.         }
  880.     }
  881.     if ((pDeterminate > 0) && (pValue > 0)) {
  882.         i = (pValue-1) % cellCount;
  883.         showCell(i, pIdent, "visible");
  884.     } else {
  885.         for (i=pValue-1; i >=0; i--) {
  886.             showCell(i, pIdent, "visible");
  887.         }
  888.     }
  889. }
  890.  
  891. function setVisibility(pElement, pVisibility)
  892. {
  893.     if (isDom) {
  894.         document.getElementById(pElement).style.visibility = pVisibility;
  895.     } else if (isIE) {
  896.         document.all[pElement].style.visibility = pVisibility;
  897.     } else if (isNS4) {
  898.         document.layers[pElement].style.visibility = pVisibility;
  899.     }
  900. }
  901.  
  902. function showCell(pCell, pIdent, pVisibility)
  903. {
  904.     setVisibility(pIdent+'%progressCell%'+pCell+'A', pVisibility);
  905. }
  906.  
  907. function hideProgress(pIdent)
  908. {
  909.     setVisibility(pIdent+'progress', 'hidden');
  910.  
  911.     for (i=0; i < cellCount; i++) {
  912.         showCell(i, pIdent, "hidden");
  913.     }
  914. }
  915.  
  916. JS;
  917.         $cellAttr = $this->getCellAttributes();
  918.         $attr = trim(sprintf($cellAttr['id'], '   '));
  919.         $stringAttr = $this->getStringAttributes();
  920.  
  921.         $placeHolders = array('%cellCount%', '%installationProgress%', '%progressCell%');
  922.         $jsElement = array($this->getCellCount(), $stringAttr['id'], $attr);
  923.  
  924.         $js = str_replace($placeHolders, $jsElement, $js);
  925.  
  926.         return $js;
  927.     }
  928.  
  929.     /**
  930.      * Set the external JavaScript code (file) to manage progress element.
  931.      *
  932.      * @param      string    $url           URL to the linked Progress JavaScript
  933.      *
  934.      * @return     void
  935.      * @since      1.0
  936.      * @access     public
  937.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  938.      * @see        getScript()
  939.      */
  940.     function setScript($url)
  941.     {
  942.         if (!is_null($url)) {
  943.             if (!is_string($url)) {
  944.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  945.                     array('var' => '$url',
  946.                           'was' => gettype($url),
  947.                           'expected' => 'string',
  948.                           'paramnum' => 1));
  949.  
  950.             } elseif (!is_file($url) || $url == '.' || $url == '..') {
  951.                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  952.                     array('var' => '$url',
  953.                           'was' => $url.' file does not exists',
  954.                           'expected' => 'javascript file exists',
  955.                           'paramnum' => 1));
  956.             }
  957.         }
  958.  
  959.         /*
  960.          - since version 0.5.0,
  961.          - default javascript code comes from getScript() method
  962.          - but may be overrided by external file.
  963.         */
  964.         $this->_script = $url;
  965.     }
  966.  
  967.     /**
  968.      * Get the cascading style sheet to put inline on HTML document
  969.      *
  970.      * @return     string
  971.      * @since      0.2
  972.      * @access     public
  973.      * @author     Stefan Neufeind <pear.neufeind@speedpartner.de> Contributor.
  974.      *             See details on thanks section of README file.
  975.      */
  976.     function getStyle()
  977.     {
  978.         $tab = $this->_getTab();
  979.         $lnEnd = $this->_getLineEnd();
  980.         $progressAttr = $this->getProgressAttributes();
  981.         $borderAttr = $this->getBorderAttributes();
  982.         $stringAttr = $this->getStringAttributes();
  983.         $cellAttr = $this->getCellAttributes();
  984.         $orient = $this->getOrientation();
  985.  
  986.         $css  = '{%pIdent%} .' . $progressAttr['class'] . ', {%pIdent%} .' . $borderAttr['class'] . ' {' . $lnEnd;
  987.         $css .= $tab . 'background-color: '. $progressAttr['background-color'] .';'. $lnEnd;
  988.         $css .= $tab . 'width: '. $progressAttr['width'] .'px;'. $lnEnd;
  989.         $css .= $tab . 'height: '. $progressAttr['height'] .'px;'. $lnEnd;
  990.         $css .= $tab . 'position: relative;'. $lnEnd;
  991.         $css .= $tab . 'left: 0;'. $lnEnd;
  992.         $css .= $tab . 'top: 0;'. $lnEnd;
  993.         $css .= '}'. $lnEnd . $lnEnd;
  994.  
  995.         $css .= '{%pIdent%} .' . $borderAttr['class'] . ' {' . $lnEnd;
  996.         $css .= $tab . 'border-width: '. $borderAttr['width'] .'px;'. $lnEnd;
  997.         $css .= $tab . 'border-style: '. $borderAttr['style'] .';'. $lnEnd;
  998.         $css .= $tab . 'border-color: '. $borderAttr['color'] .';'. $lnEnd;
  999.         $css .= '}'. $lnEnd . $lnEnd;
  1000.  
  1001.         $css .= '{%pIdent%} .' . $stringAttr['id'] . ' {' . $lnEnd;
  1002.         $css .= $tab . 'width: '. $stringAttr['width'] .'px;'. $lnEnd;
  1003.         if (isset($stringAttr['height'])) {
  1004.             $css .= $tab . 'height: '. $stringAttr['height'] .'px;'. $lnEnd;
  1005.         }
  1006.         $css .= $tab . 'text-align: '. $stringAttr['align'] .';'. $lnEnd;
  1007.         $css .= $tab . 'font-family: '. $stringAttr['font-family'] .';'. $lnEnd;
  1008.         $css .= $tab . 'font-size: '. $stringAttr['font-size'] .'px;'. $lnEnd;
  1009.         $css .= $tab . 'color: '. $stringAttr['color'] .';'. $lnEnd;
  1010.         $css .= $tab . 'background-color: '. $stringAttr['background-color'] .';'. $lnEnd;
  1011.         $css .= '}'. $lnEnd . $lnEnd;
  1012.  
  1013.         $css .= '{%pIdent%} .' . $cellAttr['class'] . 'I, {%pIdent%} .' . $cellAttr['class'] . 'A {' . $lnEnd;
  1014.         $css .= $tab . 'width: '. $cellAttr['width'] .'px;'. $lnEnd;
  1015.         $css .= $tab . 'height: '. $cellAttr['height'] .'px;'. $lnEnd;
  1016.         $css .= $tab . 'font-family: '. $cellAttr['font-family'] .';'. $lnEnd;
  1017.         $css .= $tab . 'font-size: '. $cellAttr['font-size'] .'px;'. $lnEnd;
  1018.         if ($orient == HTML_PROGRESS_BAR_HORIZONTAL) {
  1019.             $css .= $tab . 'float: left;'. $lnEnd;
  1020.         }
  1021.         if ($orient == HTML_PROGRESS_BAR_VERTICAL) {
  1022.             $css .= $tab . 'float: none;'. $lnEnd;
  1023.         }
  1024.         $css .= '}'. $lnEnd . $lnEnd;
  1025.  
  1026.         $css .= '{%pIdent%} .' . $cellAttr['class'] . 'I {' . $lnEnd;
  1027.         if ($orient !== HTML_PROGRESS_CIRCLE) {
  1028.             $css .= $tab . 'background-color: '. $cellAttr['inactive-color'] .';'. $lnEnd;
  1029.         }
  1030.         if ($orient == HTML_PROGRESS_CIRCLE) {
  1031.             $css .= $tab . 'background-image: url("'. $cellAttr[0]['background-image'] .'");'. $lnEnd;
  1032.             $css .= $tab . 'background-repeat: no-repeat;'. $lnEnd;
  1033.         }
  1034.         $css .= '}'. $lnEnd . $lnEnd;
  1035.  
  1036.         $css .= '{%pIdent%} .' . $cellAttr['class'] . 'A {' . $lnEnd;
  1037.         if ($orient !== HTML_PROGRESS_CIRCLE) {
  1038.             $css .= $tab . 'background-color: '. $cellAttr['active-color'] .';'. $lnEnd;
  1039.         }
  1040.         $css .= $tab . 'visibility: hidden;'. $lnEnd;
  1041.         if (isset($cellAttr['background-image'])) {
  1042.             $css .= $tab . 'background-image: url("'. $cellAttr['background-image'] .'");'. $lnEnd;
  1043.             $css .= $tab . 'background-repeat: no-repeat;'. $lnEnd;
  1044.         }
  1045.         $css .= '}'. $lnEnd . $lnEnd;
  1046.  
  1047.         return $css;
  1048.     }
  1049.  
  1050.     /**
  1051.      * Draw all circle segment pictures
  1052.      *
  1053.      * @param      string    $dir           (optional) Directory where pictures should be created
  1054.      * @param      string    $fileMask      (optional) sprintf format for pictures filename
  1055.      *
  1056.      * @return     array
  1057.      * @since      1.2.0RC1
  1058.      * @access     public
  1059.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  1060.      */
  1061.     function drawCircleSegments($dir = '.', $fileMask = 'c%s.png')
  1062.     {
  1063.         if (!is_string($dir)) {
  1064.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  1065.                 array('var' => '$dir',
  1066.                       'was' => gettype($dir),
  1067.                       'expected' => 'string',
  1068.                       'paramnum' => 1));
  1069.  
  1070.         } elseif (!is_string($fileMask)) {
  1071.             return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception',
  1072.                 array('var' => '$fileMask',
  1073.                       'was' => gettype($fileMask),
  1074.                       'expected' => 'string',
  1075.                       'paramnum' => 2));
  1076.         }
  1077.  
  1078.         include_once 'Image/Color.php';
  1079.  
  1080.         $cellAttr  = $this->getCellAttributes();
  1081.         $cellCount = $this->getCellCount();
  1082.         $w = $cellAttr['width'];
  1083.         $h = $cellAttr['height'];
  1084.         $s = $cellAttr['spacing'];
  1085.         $c = intval(360 / $cellCount);
  1086.         $cx = floor($w / 2);
  1087.         if (fmod($w,2) == 0) {
  1088.             $cx = $cx - 0.5;
  1089.         }
  1090.         $cy = floor($h / 2);
  1091.         if (fmod($h,2) == 0) {
  1092.             $cy = $cy - 0.5;
  1093.         }
  1094.  
  1095.         $image = imagecreate($w, $h);
  1096.  
  1097.         $bg     = Image_Color::allocateColor($image,$cellAttr['background-color']);
  1098.         $colorA = Image_Color::allocateColor($image,$cellAttr['active-color']);
  1099.         $colorI = Image_Color::allocateColor($image,$cellAttr['inactive-color']);
  1100.  
  1101.         imagefilledarc($image, $cx, $cy, $w, $h, 0, 360, $colorI, IMG_ARC_EDGED);
  1102.         $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask,0);
  1103.         imagepng($image, $filename);
  1104.         $this->setCellAttributes(array('background-image' => $filename),0);
  1105.  
  1106.         for ($i=0; $i<$cellCount; $i++) {
  1107.             if ($this->getFillWay() == 'natural') {
  1108.                 $sA = $i*$c;
  1109.                 $eA = ($i+1)*$c;
  1110.                 $sI = ($i+1)*$c;
  1111.                 $eI = 360;
  1112.             } else {
  1113.                 $sA = 360-(($i+1)*$c);
  1114.                 $eA = 360-($i*$c);
  1115.                 $sI = 0;
  1116.                 $eI = 360-(($i+1)*$c);
  1117.             }
  1118.             if ($s > 0) {
  1119.                 imagefilledarc($image, $cx, $cy, $w, $h, 0, $sA, $colorI, IMG_ARC_EDGED);
  1120.             }
  1121.             imagefilledarc($image, $cx, $cy, $w, $h, $sA, $eA, $colorA, IMG_ARC_EDGED);
  1122.             imagefilledarc($image, $cx, $cy, $w, $h, $sI, $eI, $colorI, IMG_ARC_EDGED);
  1123.             $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask,$i+1);
  1124.             imagepng($image, $filename);
  1125.  
  1126.             $this->setCellAttributes(array('background-image' => $filename),$i+1);
  1127.         }
  1128.         imagedestroy($image);
  1129.     }
  1130.  
  1131.     /**
  1132.      * Updates the new size of progress bar, depending of cell size, cell count
  1133.      * and border width.
  1134.      *
  1135.      * @since      1.0
  1136.      * @access     private
  1137.      * @see        setOrientation(), setCellCount(), setCellAttributes(),
  1138.      *             setBorderAttributes()
  1139.      */
  1140.     function _updateProgressSize()
  1141.     {
  1142.         if (!$this->_progress['progress']['auto-size']) {
  1143.             return;
  1144.         }
  1145.  
  1146.         $cell_width   = $this->_progress['cell']['width'];
  1147.         $cell_height  = $this->_progress['cell']['height'];
  1148.         $cell_spacing = $this->_progress['cell']['spacing'];
  1149.  
  1150.         $border_width = $this->_progress['border']['width'];
  1151.  
  1152.         $cell_count = $this->_cellCount;
  1153.  
  1154.         if ($this->getOrientation() == HTML_PROGRESS_BAR_HORIZONTAL) {
  1155.             $w = ($cell_count * ($cell_width + $cell_spacing)) + $cell_spacing;
  1156.             $h = $cell_height + (2 * $cell_spacing);
  1157.         }
  1158.         if ($this->getOrientation() == HTML_PROGRESS_BAR_VERTICAL) {
  1159.             $w  = $cell_width + (2 * $cell_spacing);
  1160.             $h  = ($cell_count * ($cell_height + $cell_spacing)) + $cell_spacing;
  1161.         }
  1162.         if ($this->getOrientation() == HTML_PROGRESS_POLYGONAL) {
  1163.             $w  = $cell_width * $this->_xgrid;
  1164.             $h  = $cell_height * $this->_ygrid;
  1165.         }
  1166.         if ($this->getOrientation() == HTML_PROGRESS_CIRCLE) {
  1167.             $w  = $cell_width;
  1168.             $h  = $cell_height;
  1169.         }
  1170.  
  1171.         $attr = array ('width' => $w, 'height' => $h);
  1172.  
  1173.         $this->_updateAttrArray($this->_progress['progress'], $attr);
  1174.     }
  1175.  
  1176.     /**
  1177.      * Computes all coordinates of a standard polygon (square or rectangle).
  1178.      *
  1179.      * @param      integer   $w             Polygon width
  1180.      * @param      integer   $h             Polygon height
  1181.      *
  1182.      * @return     array
  1183.      * @since      1.2.0
  1184.      * @access     private
  1185.      * @see        setCellCoordinates()
  1186.      */
  1187.     function _computeCoordinates($w, $h)
  1188.     {
  1189.         $coord = array();
  1190.  
  1191.         for ($y=0; $y<$h; $y++) {
  1192.             if ($y == 0) {
  1193.                 // creates top side line
  1194.                 for ($x=0; $x<$w; $x++) {
  1195.                     $coord[] = array($y, $x);
  1196.                 }
  1197.             } elseif ($y == ($h-1)) {
  1198.                 // creates bottom side line
  1199.                 for ($x=($w-1); $x>0; $x--) {
  1200.                     $coord[] = array($y, $x);
  1201.                 }
  1202.                 // creates left side line
  1203.                 for ($i=($h-1); $i>0; $i--) {
  1204.                     $coord[] = array($i, 0);
  1205.                 }
  1206.             } else {
  1207.                 // creates right side line
  1208.                 $coord[] = array($y, $w - 1);
  1209.             }
  1210.         }
  1211.         return $coord;
  1212.     }
  1213. }
  1214.  
  1215. ?>