Example #1
0
 /**
  * Constructor Summary
  *
  * o Creates a natural horizontal progress bar that displays ten cells/units
  *   with no border and no progress string.
  *   The initial and minimum values are 0, and the maximum is 100.
  *   <code>
  *   $bar = new HTML_Progress();
  *   </code>
  *
  * o Creates a natural progress bar with the specified orientation, which can be
  *   either HTML_PROGRESS_BAR_HORIZONTAL or HTML_PROGRESS_BAR_VERTICAL
  *   By default, no border and no progress string are painted.
  *   The initial and minimum values are 0, and the maximum is 100.
  *   <code>
  *   $bar = new HTML_Progress($orient);
  *   </code>
  *
  * o Creates a natural horizontal progress bar with the specified minimum and
  *   maximum. Sets the initial value of the progress bar to the specified
  *   minimum, and the maximum that the progress bar can reach.
  *   By default, no border and no progress string are painted.
  *   <code>
  *   $bar = new HTML_Progress($min, $max);
  *   </code>
  *
  * o Creates a natural horizontal progress bar with the specified orientation,
  *   minimum and maximum. Sets the initial value of the progress bar to the
  *   specified minimum, and the maximum that the progress bar can reach.
  *   By default, no border and no progress string are painted.
  *   <code>
  *   $bar = new HTML_Progress($orient, $min, $max);
  *   </code>
  *
  * o Creates a natural horizontal progress that uses the specified model
  *   to hold the progress bar's data.
  *   By default, no border and no progress string are painted.
  *   <code>
  *   $bar = new HTML_Progress($model);
  *   </code>
  *
  *
  * @param      object    $model         (optional) Model that hold the progress bar's data
  * @param      int       $orient        (optional) Orientation of progress bar
  * @param      int       $min           (optional) Minimum value of progress bar
  * @param      int       $max           (optional) Maximum value of progress bar
  * @param      array     $errorPrefs    (optional) Always last argument of class constructor.
  *                                       hash of params to configure PEAR_ErrorStack and loggers
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        setIndeterminate(),
  *             setBorderPainted(), setStringPainted(), setString(),
  *             setDM(), setUI(), setIdent()
  */
 function HTML_Progress()
 {
     $args = func_get_args();
     $num_args = func_num_args();
     if ($num_args > 0) {
         $errorPrefs = func_get_arg($num_args - 1);
         if (!is_array($errorPrefs)) {
             $errorPrefs = array();
         } else {
             $num_args--;
         }
         HTML_Progress::_initErrorHandler($errorPrefs);
     } else {
         HTML_Progress::_initErrorhandler();
     }
     $this->_listeners = array();
     // none listeners by default
     $this->_DM = new HTML_Progress_DM();
     // new instance of a progress DataModel
     $this->_UI = new HTML_Progress_UI();
     // new instance of a progress UserInterface
     switch ($num_args) {
         case 1:
             if (is_object($args[0]) && is_a($args[0], 'html_progress_dm')) {
                 /*   object html_progress_dm extends   */
                 $this->_DM =& $args[0];
             } elseif (is_int($args[0])) {
                 /*   int orient   */
                 $this->_UI->setOrientation($args[0]);
             } else {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$model | $orient', 'was' => gettype($args[0]) == 'object' ? get_class($args[0]) . ' object' : gettype($args[0]), 'expected' => 'html_progress_dm object | integer', 'paramnum' => 1));
             }
             break;
         case 2:
             /*   int min, int max   */
             if (!is_int($args[0])) {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1));
             } elseif (!is_int($args[1])) {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2));
             } else {
                 $this->_DM->setMinimum($args[0]);
                 $this->_DM->setMaximum($args[1]);
             }
             break;
         case 3:
             /*   int orient, int min, int max   */
             if (!is_int($args[0])) {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$orient', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1));
             } elseif (!is_int($args[1])) {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2));
             } elseif (!is_int($args[2])) {
                 return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[2], 'expected' => 'integer', 'paramnum' => 3));
             } else {
                 $this->_UI->setOrientation($args[0]);
                 $this->_DM->setMinimum($args[1]);
                 $this->_DM->setMaximum($args[2]);
             }
             break;
         default:
     }
     $this->setString(null);
     $this->setStringPainted(false);
     $this->setBorderPainted(false);
     $this->setIndeterminate(false);
     $this->setIdent();
     $this->setAnimSpeed(0);
     // to fix a potential php config problem with PHP 4.2.0 : turn 'implicit_flush' ON
     ob_implicit_flush(1);
 }