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_Model';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     if (!file_exists($file)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$file', 'was' => $file, 'expected' => 'file exists', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     }
     $conf = new Config();
     if (!$conf->isConfigTypeRegistered($type)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$type', 'was' => $type, 'expected' => implode(" | ", array_keys($GLOBALS['CONFIG_TYPES'])), 'paramnum' => 2), PEAR_ERROR_TRIGGER);
     }
     $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
 /**
  * The progress uploader class constructor
  *
  * @param      string    $formName      (optional) Name of monitor dialog box (QuickForm)
  * @param      array     $attributes    (optional) List of renderer options
  *
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Uploader($formName = 'ProgressUploader', $attributes = array())
 {
     $this->_package = 'HTML_Progress_Uploader';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     if (!is_string($formName)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$formName', 'was' => gettype($formName), 'expected' => 'string', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     } elseif (!is_array($attributes)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
     }
     parent::FTP_Upload();
     // checks all necessary dependencies
     $this->_form = new HTML_QuickForm($formName);
     $this->windowname = isset($attributes['title']) ? $attributes['title'] : 'Upload ...';
     $this->captionMask = isset($attributes['mask']) ? $attributes['mask'] : '%s';
     $this->buttonStart = isset($attributes['start']) ? $attributes['start'] : 'Start';
     $this->buttonCancel = isset($attributes['cancel']) ? $attributes['cancel'] : 'Cancel';
     $buttonAttr = isset($attributes['button']) ? $attributes['button'] : '';
     $this->_form->addElement('header', 'windowname', $this->windowname);
     $this->_form->addElement('static', 'progressBar');
     $this->_form->addElement('static', 'progressStatus');
     $style = $this->isStarted() ? array('disabled' => 'true') : null;
     $buttons[] =& $this->_form->createElement('submit', 'start', $this->buttonStart, $style);
     $buttons[] =& $this->_form->createElement('submit', 'cancel', $this->buttonCancel);
     $buttons[0]->updateAttributes($buttonAttr);
     $buttons[1]->updateAttributes($buttonAttr);
     $this->_form->addGroup($buttons, 'buttons', '', ' ', false);
     // default embedded progress element with look-and-feel
     $this->_progress = new HTML_Progress();
     $this->setProgressElement($this->_progress);
     $str =& $this->_form->getElement('progressStatus');
     $str->setText('<div id="status" class="progressStatus">&nbsp;</div>');
 }
Example #3
0
 /**
  * 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()
 {
     $this->_package = 'HTML_Progress_DM';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     $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 Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif ($args[0] < 0) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'positive', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif ($args[0] > $args[1]) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'less than $max = ' . $args[1], 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             }
             $this->_minimum = $args[0];
             if (!is_int($args[1])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             } elseif ($args[1] < 0) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'positive', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             }
             $this->_maximum = $args[1];
             break;
         case 3:
             /*   int min, int max, int inc   */
             if (!is_int($args[0])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif ($args[0] < 0) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'positive', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif ($args[0] > $args[1]) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'less than $max = ' . $args[1], 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             }
             $this->_minimum = $args[0];
             if (!is_int($args[1])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             } elseif ($args[1] < 0) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'positive', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             }
             $this->_maximum = $args[1];
             if (!is_int($args[2])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$inc', 'was' => $args[2], 'expected' => 'integer', 'paramnum' => 3), PEAR_ERROR_TRIGGER);
             } elseif ($args[2] < 1) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$inc', 'was' => $args[2], 'expected' => 'greater than zero', 'paramnum' => 3), PEAR_ERROR_TRIGGER);
             }
             $this->_increment = $args[2];
             break;
         default:
     }
     $this->_value = $this->_minimum;
 }
Example #4
0
 /**
  * Constructor Summary
  *
  * o Creates a standard progress bar generator wizard.
  *   <code>
  *   $generator = new HTML_Progress_Generator();
  *   </code>
  *
  * o Creates a progress bar generator wizard with 
  *   customized actions: 
  *   <ul>
  *   <li>your progress bar preview.
  *   <li>HTML_Progress_Generator form rendering (wizard display)
  *   <li>save and cancel actions manager.
  *   </ul>
  *   <code>
  *   $attributes = array(
  *        'preview' => name of a HTML_QuickForm_Action instance 
  *                     (default 'ActionPreview', see 'HTML/Progress/generator/preview.php')
  *        'display' => name of a HTML_QuickForm_Action_Display instance
  *                     (default 'ActionDisplay', see 'HTML/Progress/generator/default.php')
  *        'process' => name of a HTML_QuickForm_Action instance 
  *                     (default 'ActionProcess', see 'HTML/Progress/generator/process.php')
  *   );
  *   $generator = new HTML_Progress_Generator($attributes);
  *   </code>
  *
  * @param      string    $controllerName(optional) Name of generator wizard (QuickForm)
  * @param      array     $attributes    (optional) List of renderer options
  *
  * @since      1.1
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_Generator($controllerName = 'ProgressGenerator', $attributes = array())
 {
     $this->_package = 'HTML_Progress_Generator';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     if (!is_string($controllerName)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$controllerName', 'was' => gettype($controllerName), 'expected' => 'string', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
     } elseif (!is_array($attributes)) {
         return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$attributes', 'was' => gettype($attributes), 'expected' => 'array', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
     }
     parent::HTML_QuickForm_Controller($controllerName, false);
     // Check if Action(s) are customized
     $ActionPreview = isset($attributes['preview']) ? $attributes['preview'] : 'ActionPreview';
     $ActionDisplay = isset($attributes['display']) ? $attributes['display'] : 'ActionDisplay';
     $ActionProcess = isset($attributes['process']) ? $attributes['process'] : 'ActionProcess';
     $this->_tabs = array(0 => array('page1', 'Property1', 'Progress'), 1 => array('page2', 'Property2', 'Cell'), 2 => array('page3', 'Property3', 'Border'), 3 => array('page4', 'Property4', 'String'), 4 => array('page5', 'Preview', 'Preview'), 5 => array('page6', 'Save', 'Save'));
     foreach ($this->_tabs as $tab) {
         list($pageName, $className, $tabName) = $tab;
         // Add each tab of the wizard
         $this->addPage(new $className($pageName));
         // These actions manage going directly to the pages with the same name
         $this->addAction($pageName, new HTML_QuickForm_Action_Direct());
     }
     $preview =& $this->getPage('page5');
     // The customized actions
     if (!class_exists($ActionPreview)) {
         include_once 'HTML/Progress/generator/preview.php';
         $ActionPreview = 'ActionPreview';
     }
     if (!class_exists($ActionDisplay)) {
         include_once 'HTML/Progress/generator/default.php';
         $ActionDisplay = 'ActionDisplay';
     }
     if (!class_exists($ActionProcess)) {
         include_once 'HTML/Progress/generator/process.php';
         $ActionProcess = 'ActionProcess';
     }
     $preview->addAction('apply', new $ActionPreview());
     $this->addAction('display', new $ActionDisplay());
     $this->addAction('process', new $ActionProcess());
     $this->addAction('cancel', new $ActionProcess());
     // set ProgressBar default values on first run
     $sess = $this->container();
     $defaults = $sess['defaults'];
     if (count($sess['defaults']) == 0) {
         $this->setDefaults(array('progressclass' => 'progressBar', 'shape' => HTML_PROGRESS_BAR_HORIZONTAL, 'way' => 'natural', 'autosize' => true, 'progresssize' => array('bgcolor' => '#FFFFFF'), 'rAnimSpeed' => 100, 'borderpainted' => false, 'borderclass' => 'progressBarBorder', 'borderstyle' => array('style' => 'solid', 'width' => 0, 'color' => '#000000'), 'cellid' => 'progressCell%01s', 'cellclass' => 'cell', 'cellvalue' => array('min' => 0, 'max' => 100, 'inc' => 1), 'cellsize' => array('width' => 15, 'height' => 20, 'spacing' => 2, 'count' => 10), 'cellcolor' => array('active' => '#006600', 'inactive' => '#CCCCCC'), 'cellfont' => array('family' => 'Courier, Verdana', 'size' => 8, 'color' => '#000000'), 'stringpainted' => false, 'stringid' => 'installationProgress', 'stringsize' => array('width' => 50, 'height' => '', 'bgcolor' => '#FFFFFF'), 'stringvalign' => 'right', 'stringalign' => 'right', 'stringfont' => array('family' => 'Verdana, Arial, Helvetica, sans-serif', 'size' => 12, 'color' => '#000000'), 'strings' => implode(";\n", array(0 => '10,Hello world', 1 => '20,Welcome', 2 => '30,to', 3 => '40,HTML_Progress v1', 4 => '60,by', 5 => '70,Laurent Laville', 6 => '100,Have a nice day !')), 'phpcss' => array('P' => true)));
     }
 }
Example #5
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         Model that hold the progress bar's data
  * @param      int       $orient        Orientation of progress bar
  * @param      int       $min           Minimum value of progress bar
  * @param      int       $max           Maximum value of progress bar
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  * @see        setIndeterminate(), 
  *             setBorderPainted(), setStringPainted(), setString(),
  *             setDM(), setUI(), setIdent()
  */
 function HTML_Progress()
 {
     $this->_package = 'HTML_Progress';
     Error_Raise::initialize($this->_package, array(get_class($this), '_getErrorMessage'));
     $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
     $args = func_get_args();
     switch (count($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 Error_Raise::raise($this->_package, 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), PEAR_ERROR_TRIGGER);
             }
             break;
         case 2:
             /*   int min, int max   */
             if (!is_int($args[0])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif (!is_int($args[1])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             } 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 Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$orient', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif (!is_int($args[1])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$min', 'was' => $args[1], 'expected' => 'integer', 'paramnum' => 2), PEAR_ERROR_TRIGGER);
             } elseif (!is_int($args[2])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$max', 'was' => $args[2], 'expected' => 'integer', 'paramnum' => 3), PEAR_ERROR_TRIGGER);
             } 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();
     // to fix a potential php config problem with PHP 4.2.0 : turn 'implicit_flush' ON
     ob_implicit_flush(1);
 }
Example #6
0
 /**
  * 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>
  *
  * @since      1.0
  * @access     public
  * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  */
 function HTML_Progress_UI()
 {
     $this->_package = 'HTML_Progress_UI';
     Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
     $args = func_get_args();
     switch (count($args)) {
         case 1:
             /*   int cell  */
             if (!is_int($args[0])) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'exception', array('var' => '$cell', 'was' => $args[0], 'expected' => 'integer', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             } elseif ($args[0] < 1) {
                 return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'error', array('var' => '$cell', 'was' => $args[0], 'expected' => 'greater or equal 1', 'paramnum' => 1), PEAR_ERROR_TRIGGER);
             }
             $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", '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
 }