HTML Page2 renderer

Overview

This example will run a default Progress2 Monitor, which used a PEAR::HTML_Page2 generator as renderer.

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 29) between each step of 1% (default).

The form windows (ProgressMonitor) have default title (In progress ...), buttons name (Start, Cancel) and size : see class constructor parameters (line 26).

There are 10 cells 15x20:

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

With basic 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  #000000
class  progressPercentLabel%s
See also :

Source Code

  1. <?php
  2. /**
  3. * PEAR::HTML_Page2 package made it easy to build
  4. * a very simple Progress2 Monitor.
  5. *
  6. * @version    $Id: monitorpg2.php,v 1.1 2005/06/12 21:05:38 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/Page2.php';
  14.  
  15. $p = new HTML_Page2(array(
  16.         'charset'  => 'utf-8',
  17.         'lineend'  => PHP_EOL,
  18.         'doctype'  => "XHTML 1.0 Strict",
  19.         'language' => 'en',
  20.         'cache'    => 'false'
  21.      ));       
  22.  
  23. $p->setTitle('PEAR::HTML_Progress2 - Simple Monitor');
  24. $p->setMetaData('author', 'Laurent Laville');
  25.  
  26. $pm = new HTML_Progress2_Monitor();
  27.  
  28. $bar =& $pm->getProgressElement();
  29. $bar->setAnimSpeed(50);
  30.  
  31. $p->addStyleDeclaration(
  32.     $pm->getStyle()
  33.     );
  34. $p->addScriptDeclaration(
  35.     $pm->getScript()
  36.     );
  37. $p->addBodyContent(
  38.     $pm->toHtml()
  39.     );
  40. echo $p->toHtml();
  41.  
  42. $pm->run();
  43. ?>