PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

Default render and css skin

Without any change, we can get a decent progress generator tabbed wizard such as :

Color, font, size and position are defined by default in stylesheet default.css you can find into PEAR HTML_Progress2 data directory.

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

  1. <?php
  2. require_once 'HTML/Progress2/Generator.php';
  3.  
  4. session_start();
  5.  
  6. $tabbed = new HTML_Progress2_Generator();
  7. $tabbed->run();
  8. ?>
Line 4 :

HTML_Progress2_Generator does not start a session automatically, you should explicitly call session_start before instantiating the controller class. A session is required to pass data between the tabbed multi-pages generator wizard.

Line 6 :

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

$controllerName (argument 1 of class constructor)

Name of generator tabbed wizard (QuickForm Controller). Default is ProgressGenerator

$attributes (argument 2 of class constructor)

List of renderer options. Default are

  • preview action class = ActionPreview (HTML/Progress2/Generator/Preview.php)
  • display action class = ActionDisplay (HTML/Progress2/Generator/Default.php)
  • process action class = ActionProcess (HTML/Progress2/Generator/Process.php)
  • dump action class = false (no interactive debugging tools by default)
[Note] Note
Since version 2.1.0, you can use the singleton pattern
  1. <?php
  2. $tabbed =& HTML_Progress2_Generator::singleton();
  3. ?>
and of course, continue to use direct instanciation (backward compatibility is not break).
Line 7 :

Catch all user actions (next, back, jump, apply, process) and display controller wizard contents.

Now we have seen basic usage, we will try to change the skin with only a new stylesheet.

  1. <?php
  2. require_once 'HTML/Progress2/Generator.php';
  3.  
  4. session_start();
  5.  
  6. $tabbed =& HTML_Progress2_Generator::singleton();
  7.  
  8. $tabbed->addActions(array('dump' => 'ActionDump'));
  9.  
  10. $css = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'generator.css';
  11. $tabbed->addAction('display', new ActionDisplay($css));
  12.  
  13. $tabbed->run();
  14. ?>
Line 8 :

This line allow to add/activate the interactive debugging tools that can give you informations on: progress meter, wizard controller forms data, list of included files (see get_included_files), list of declared classes (see get_declared_classes), and list of generator actions defined.

Line 10 :

$css defines the location of the new stylesheet to apply. This file will give a grey-orange look and feel such as :

[Note] Note
You may find this file into examples/generator of PEAR HTML_Progress2 docs directory.
Line 11 :

This line overload the default display action set during the class instantiation.

[Important] Important
We are still using the QF default renderer, and the ActionDisplay class (see HTML/Progress2/Generator/Default.php).

We have also possibility to get and set stylesheet with methods ActionDisplay::getStyleSheet(), ActionDisplay::setStyleSheet() like this :

  1. <?php
  2. require_once 'HTML/Progress2/Generator.php';
  3. require_once 'HTML/Progress2/Generator/Default.php';
  4.  
  5. session_start();
  6.  
  7. $css = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'generator.css';
  8.  
  9. $display = new ActionDisplay();
  10. $display->setStyleSheet($css);
  11.  
  12. // var_dump($display->getStyleSheet(true));
  13. // var_dump($display->getStyleSheet());
  14.  
  15. $tabbed =& HTML_Progress2_Generator::singleton();
  16. $tabbed->addAction('display', $display);
  17. $tabbed->run();
  18. ?>
HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007