Example #1
0
 /**
  * The progress bar's UI extended model class constructor
  *
  * @param      string    $file          file name of model properties
  * @param      string    $type          type of external ressource (phpArray, iniFile, XML ...)
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Model($file, $type)
 {
     $this->_package = 'HTML_Progress';
     if (!file_exists($file)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1));
     }
     $conf = new Config();
     if (!$conf->isConfigTypeRegistered($type)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2));
     }
     $data = $conf->parseConfig($file, $type);
     $structure = $data->toArray(false);
     $this->_progress =& $structure['root'];
     if (is_array($this->_progress['cell']['font-family'])) {
         $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
     }
     if (is_array($this->_progress['string']['font-family'])) {
         $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
     }
     $this->_orientation = $this->_progress['orientation']['shape'];
     $this->_fillWay = $this->_progress['orientation']['fillway'];
     if (isset($this->_progress['script']['file'])) {
         $this->_script = $this->_progress['script']['file'];
     } else {
         $this->_script = null;
     }
     if (isset($this->_progress['cell']['count'])) {
         $this->_cellCount = $this->_progress['cell']['count'];
     } else {
         $this->_cellCount = 10;
     }
     $this->_updateProgressSize();
 }
Example #2
0
 /**
  * Sets the user callback function that execute all actions pending progress
  *
  * @param      mixed     $handler       Name of function or a class-method.
  *
  * @return     void
  * @since      1.2.0RC3
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_CALLBACK
  * @see        process()
  */
 function setProgressHandler($handler)
 {
     if (!is_callable($handler)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_CALLBACK, 'warning', array('var' => '$handler', 'element' => 'valid Class-Method/Function', 'was' => 'element', 'paramnum' => 1));
     }
     $this->_callback = $handler;
 }
Example #3
0
 /**
  * Disables certain buttons for a page.
  *
  * Buttons [ = events] : back, next, cancel, reset, apply, help
  *
  * @param      object    $page          Page where you want to activate buttons
  * @param      array     $events        (optional) List of buttons
  *
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        enableButton()
  */
 function disableButton(&$page, $events = array())
 {
     if (!is_a($page, 'HTML_QuickForm_Page')) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$page', 'was' => gettype($page), 'expected' => 'HTML_QuickForm_Page object', 'paramnum' => 1));
     } elseif (!is_array($events)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$events', 'was' => gettype($events), 'expected' => 'array', 'paramnum' => 2));
     }
     static $all;
     if (!isset($all)) {
         $all = array('back', 'next', 'cancel', 'reset', 'apply', 'help');
     }
     $buttons = count($events) == 0 ? $all : $events;
     foreach ($buttons as $event) {
         $group = $page->getElement('buttons');
         $elements = $group->getElements();
         foreach (array_keys($elements) as $key) {
             if ($group->getElementName($key) == $page->getButtonName($event)) {
                 $elements[$key]->updateAttributes(array('disabled' => 'true'));
             }
         }
     }
 }
 /**
  * Draw all circle segment pictures
  *
  * @param      string    $dir           (optional) Directory where pictures should be created
  * @param      string    $fileMask      (optional) sprintf format for pictures filename
  *
  * @return     array
  * @since      1.2.0RC1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function drawCircleSegments($dir = '.', $fileMask = 'c%s.png')
 {
     if (!is_string($dir)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$dir', 'was' => gettype($dir), 'expected' => 'string', 'paramnum' => 1));
     } elseif (!is_string($fileMask)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$fileMask', 'was' => gettype($fileMask), 'expected' => 'string', 'paramnum' => 2));
     }
     include_once 'Image/Color.php';
     $cellAttr = $this->getCellAttributes();
     $cellCount = $this->getCellCount();
     $w = $cellAttr['width'];
     $h = $cellAttr['height'];
     $s = $cellAttr['spacing'];
     $c = intval(360 / $cellCount);
     $cx = floor($w / 2);
     if (fmod($w, 2) == 0) {
         $cx = $cx - 0.5;
     }
     $cy = floor($h / 2);
     if (fmod($h, 2) == 0) {
         $cy = $cy - 0.5;
     }
     $image = imagecreate($w, $h);
     $bg = Image_Color::allocateColor($image, $cellAttr['background-color']);
     $colorA = Image_Color::allocateColor($image, $cellAttr['active-color']);
     $colorI = Image_Color::allocateColor($image, $cellAttr['inactive-color']);
     imagefilledarc($image, $cx, $cy, $w, $h, 0, 360, $colorI, IMG_ARC_EDGED);
     $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, 0);
     imagepng($image, $filename);
     $this->setCellAttributes(array('background-image' => $filename), 0);
     for ($i = 0; $i < $cellCount; $i++) {
         if ($this->getFillWay() == 'natural') {
             $sA = $i * $c;
             $eA = ($i + 1) * $c;
             $sI = ($i + 1) * $c;
             $eI = 360;
         } else {
             $sA = 360 - ($i + 1) * $c;
             $eA = 360 - $i * $c;
             $sI = 0;
             $eI = 360 - ($i + 1) * $c;
         }
         if ($s > 0) {
             imagefilledarc($image, $cx, $cy, $w, $h, 0, $sA, $colorI, IMG_ARC_EDGED);
         }
         imagefilledarc($image, $cx, $cy, $w, $h, $sA, $eA, $colorA, IMG_ARC_EDGED);
         imagefilledarc($image, $cx, $cy, $w, $h, $sI, $eI, $colorI, IMG_ARC_EDGED);
         $filename = $dir . DIRECTORY_SEPARATOR . sprintf($fileMask, $i + 1);
         imagepng($image, $filename);
         $this->setCellAttributes(array('background-image' => $filename), $i + 1);
     }
     imagedestroy($image);
 }
Example #5
0
 /**
  * Sets the progress bar's current value.
  * If the new value is different from previous value, all change listeners
  * are notified.
  *
  * @param      integer   $val           progress bar's current value
  *
  * @return     void
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        getValue()
  * @tutorial   dm.setvalue.pkg
  */
 function setValue($val)
 {
     if (!is_int($val)) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$val', 'was' => gettype($val), 'expected' => 'integer', 'paramnum' => 1));
     } elseif ($val < $this->getMinimum()) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$val', 'was' => $val, 'expected' => 'greater than $min = ' . $this->getMinimum(), 'paramnum' => 1));
     } elseif ($val > $this->getMaximum()) {
         return HTML_Progress::raiseError(HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$val', 'was' => $val, 'expected' => 'less than $max = ' . $this->getMaximum(), 'paramnum' => 1));
     }
     $this->_value = $val;
 }
Example #6
0
 /**
  * Returns the percent complete for the progress bar. Note that this number is
  * between 0.00 and 1.00 or 0 and 100.
  *
  * @param      boolean   $float         (optional) float or integer format
  *
  * @return     mixed
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS2_ERROR_INVALID_INPUT
  * @see        getValue(), getMaximum()
  */
 function getPercentComplete($float = true)
 {
     if (!is_bool($float)) {
         return HTML_Progress::raiseError(HTML_PROGRESS2_ERROR_INVALID_INPUT, 'exception', array('var' => '$float', 'was' => gettype($float), 'expected' => 'boolean', 'paramnum' => 1));
     }
     $min = $this->_minimum;
     $max = $this->_maximum;
     $val = $this->_value;
     $percent = round(($val - $min) / ($max - $min), 4);
     if ($float) {
         return $percent;
     } else {
         return intval($percent * 100);
     }
 }