/** * The progress bar's UI model class constructor * * Constructor Summary * * o Creates a natural horizontal progress bar that displays ten cells/units. * <code> * $html = new HTML_Progress_UI(); * </code> * * o Creates a natural horizontal progress bar with the specified cell count, * which cannot be less than 1 (minimum), but has no maximum limit. * <code> * $html = new HTML_Progress_UI($cell); * </code> * * @param int $cell (optional) Cell count * * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT */ function HTML_Progress_UI() { // if you've not yet created an instance of html_progress if (!$GLOBALS['_HTML_PROGRESS_CALLBACK_ERRORHANDLER']) { // init default error handling system, HTML_Progress::_initErrorHandler(); } $args = func_get_args(); switch (count($args)) { case 1: /* int cell */ if (!is_int($args[0])) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$cell', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1)); } elseif ($args[0] < 1) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$cell', 'was' => $args[0], 'expected' => 'greater or equal 1', 'paramnum' => 1)); } $this->_cellCount = $args[0]; break; default: $this->_cellCount = 10; break; } $this->_orientation = HTML_PROGRESS_BAR_HORIZONTAL; $this->_fillWay = 'natural'; $this->_script = null; // uses internal javascript code $this->_progress = array('cell' => array('id' => "progressCell%01s", 'class' => "cell", 'active-color' => "#006600", 'inactive-color' => "#CCCCCC", 'font-family' => "Courier, Verdana", 'font-size' => 8, 'color' => "#000000", 'background-color' => "#FFFFFF", 'width' => 15, 'height' => 20, 'spacing' => 2), 'border' => array('class' => "progressBarBorder", 'width' => 0, 'style' => "solid", 'color' => "#000000"), 'string' => array('id' => "installationProgress", 'width' => 50, 'font-family' => "Verdana, Arial, Helvetica, sans-serif", 'font-size' => 12, 'color' => "#000000", 'background-color' => "#FFFFFF", 'align' => "right", 'valign' => "right"), 'progress' => array('class' => "progressBar", 'background-color' => "#FFFFFF", 'auto-size' => true)); $this->_updateProgressSize(); // updates the new size of progress bar }
/** * 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); }
/** * The data model class constructor * * Constructor Summary * * o Creates a progress mathematical model with a minimum value set to 0, * a maximum value set to 100, and a increment value set to +1. * By default, the value is initialized to be equal to the minimum value. * <code> * $html = new HTML_Progress_DM(); * </code> * * o Creates a progress mathematical model with minimum and maximum set to * specified values, and a increment value set to +1. * By default, the value is initialized to be equal to the minimum value. * <code> * $html = new HTML_Progress_DM($min, $max); * </code> * * o Creates a progress mathematical model with minimum, maximum and increment * set to specified values. * By default, the value is initialized to be equal to the minimum value. * <code> * $html = new HTML_Progress_DM($min, $max, $inc); * </code> * * @since 1.0 * @access public * @throws HTML_PROGRESS_ERROR_INVALID_INPUT */ function HTML_Progress_DM() { // if you've not yet created an instance of html_progress if (!$GLOBALS['_HTML_PROGRESS_CALLBACK_ERRORHANDLER']) { // init default error handling system, HTML_Progress::_initErrorHandler(); } $this->_minimum = 0; $this->_maximum = 100; $this->_increment = +1; $args = func_get_args(); switch (count($args)) { 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 ($args[0] < 0) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$min', 'was' => $args[0], 'expected' => 'positive', 'paramnum' => 1)); } elseif ($args[0] > $args[1]) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$min', 'was' => $args[0], 'expected' => 'less than $max = ' . $args[1], 'paramnum' => 1)); } $this->_minimum = $args[0]; if (!is_int($args[1])) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2)); } elseif ($args[1] < 0) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$max', 'was' => $args[1], 'expected' => 'positive', 'paramnum' => 2)); } $this->_maximum = $args[1]; break; case 3: /* int min, int max, int inc */ 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 ($args[0] < 0) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$min', 'was' => $args[0], 'expected' => 'positive', 'paramnum' => 1)); } elseif ($args[0] > $args[1]) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$min', 'was' => $args[0], 'expected' => 'less than $max = ' . $args[1], 'paramnum' => 1)); } $this->_minimum = $args[0]; if (!is_int($args[1])) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2)); } elseif ($args[1] < 0) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$max', 'was' => $args[1], 'expected' => 'positive', 'paramnum' => 2)); } $this->_maximum = $args[1]; if (!is_int($args[2])) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$inc', 'was' => $args[2], 'expected' => 'integer', 'paramnum' => 3)); } elseif ($args[2] < 1) { return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$inc', 'was' => $args[2], 'expected' => 'greater than zero', 'paramnum' => 3)); } $this->_increment = $args[2]; break; default: } $this->_value = $this->_minimum; }