PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

Default render

Without any change, we can get a decent dialog box with a default progress meter such as :

As you can see in source code below, there are no difficulty.

  1. <?php
  2. require_once 'HTML/Progress2/Monitor.php';
  3.  
  4. $pm = new HTML_Progress2_Monitor();
  5.  
  6. $pb =& $pm->getProgressElement();
  7. $pb->setAnimSpeed(200);
  8. $pb->setIncrement(10);
  9. ?>
  10. <html>
  11. <head>
  12. <?php
  13. echo $pm->getStyle(false);
  14. echo $pm->getScript(false);
  15. ?>
  16. </head>
  17.  
  18. <body>
  19. <?php
  20. $pm->display();
  21. $pm->run();
  22. ?>
  23. </body>
  24. </html>
Line 4 :

Without any arguments, all defaults are applied on HTML_Progress2_Monitor new instance construction.

$formName (argument 1 of class constructor)

Name of monitor dialog box (QuickForm). Default is ProgressMonitor

$attributes (argument 2 of class constructor)

List of renderer options. Default are

  • dialog box title = In progress ...
  • dialog box start button = Start
  • dialog box cancel button = Cancel
  • dialog box button style = no style
  • autorun feature = false
  • dialog box caption = bottom left aligned under progress meter
Line 6 :

For demonstration purpose only, we get embedded basic progress meter into the progress monitor and change increment and speed(delay) to do a smooth animation.

Lines 13, 14 :

We get cascading stylesheet and javascript code mandatory to a good progress meter presentation and handling.

Line 20 :

Show initial state of progress monitor before running. Will works only with default QF renderer.

Line 21 :

Catch user actions (start, stop) and meter progression.

This monitor do nothing yet. In next example we will see how to improve a bit the presentation.

HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007