IT dynamic renderer

Overview

This example will run a basic Progress2 Monitor, which used a IT dynamic QuickForm renderer.
The process is a picture file upload simulation.

Screenshot

sample screenshot

Demonstration

Give it a try

Dependencies

This example requires mandatory resources :

And also but optional :

Explains step by step

The progress meter wait 50ms (line 53) between each step of 1% (default).

The form windows (frmMonitor5) have title (Upload your pictures), buttons name (Upload, Stop) with size set to 80 pixels width : see class constructor parameters (lines 45-50).

There are 20 cells (line 54) 15x20 line 56:

Property Value Default
active-color #444444 #006600
inactive-color #FFF #CCCCCC
width   15
height   20
spacing   2
See also :

With percent text info aligned on right side:

Property Value Default
left   5
top   5
width   50
height   0
align   right
valign   right
background-color   
font-size  11
font-family  Verdana, Tahoma, Arial
font-weight  normal
color navy #000000
class  progressPercentLabel%s

And the monitor status line (default monitorStatus) aligned at bottom of progress bar (line 58) with:

Property Value Default
left   5
top   5
width   50
height   0
align   right
valign   right
background-color   
font-size 10 11
font-family  Verdana, Tahoma, Arial
font-weight  normal
color navy #000000
class  progressPercentLabel%s
See also :

Source Code

  1. <?php
  2. /**
  3. * Progress2 Monitor using ITDynamic QF renderer,
  4. * and a class-method as user callback.
  5. *
  6. * @version    $Id: monitordyn.php,v 1.2 2005/08/01 08:35:03 farell Exp $
  7. * @author     Laurent Laville <pear@laurent-laville.org>
  8. * @package    HTML_Progress2
  9. * @subpackage Examples
  10. * @access     public
  11. */
  12. require_once 'HTML/Progress2/Monitor.php';
  13. require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
  14. require_once 'HTML/Template/Sigma.php';
  15.  
  16. class myClassHandler
  17. {
  18.     function myMethod($pValue, &$pb)
  19.     {
  20.         global $pm;
  21.  
  22.         switch ($pValue) {
  23.          case 10:
  24.             $pic = 'picture1.jpg';
  25.             break;
  26.          case 45:
  27.             $pic = 'picture2.jpg';
  28.             break;
  29.          case 70:
  30.             $pic = 'picture3.jpg';
  31.             break;
  32.          default:
  33.             $pic = null;
  34.         }
  35.         if (!is_null($pic)) {
  36.             $pm->setCaption('upload %file% in progress ... '
  37.                           . 'Start at %percent%%',
  38.                             array('file' => $pic, 'percent' => $pValue)
  39.             );
  40.         }
  41.         $pb->sleep();
  42.     }
  43. }
  44.  
  45. $pm = new HTML_Progress2_Monitor('frmMonitor5', array(
  46.     'title'  => 'Upload your pictures',
  47.     'start'  => 'Upload',
  48.     'cancel' => 'Stop',
  49.     'button' => array('style' => 'width:80px;')
  50. ));
  51.  
  52. $pb =& $pm->getProgressElement();
  53. $pb->setAnimSpeed(50);
  54. $pb->setCellCount(20);
  55. $pb->setProgressAttributes('background-color=#EEE');
  56. $pb->setCellAttributes('inactive-color=#FFF active-color=#444444');
  57. $pb->setLabelAttributes('pct1', 'color=navy');
  58. $pb->setLabelAttributes('monitorStatus', 'color=navy font-size=10');
  59. $pb->setProgressHandler(array('myClassHandler','myMethod'));
  60.  
  61. $pm->setProgressElement($pb);
  62.  
  63. $tpl =& new HTML_Template_Sigma('.');
  64. $tpl->loadTemplateFile('itdynamic.html');
  65.  
  66. $tpl->setVariable(array(
  67.     'qf_style'  => $pm->getStyle(),
  68.     'qf_script' => $pm->getScript(false)
  69.     )
  70. );
  71.  
  72. $renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
  73. $renderer->setElementBlock(array('buttons' => 'qf_buttons'));
  74.  
  75. $pm->accept($renderer);
  76.  
  77. $tpl->show();
  78. $pm->run();
  79. ?>
  80.  
  81. </body>
  82. </html>