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.

<?php
require_once 'HTML/Progress2/Generator.php';

session_start(); 1

$tabbed = new HTML_Progress2_Generator(); 2
$tabbed->run(); 3
?>
   

1

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.

2

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

$tabbed =& HTML_Progress2_Generator::singleton();
        

and of course, continue to use direct instanciation (backward compatibility is not break).

3

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.

<?php
require_once 'HTML/Progress2/Generator.php';

session_start();

$tabbed =& HTML_Progress2_Generator::singleton();

$tabbed->addActions(array('dump' => 'ActionDump')); 1

$css = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'generator.css'; 2
$tabbed->addAction('display', new ActionDisplay($css)); 3

$tabbed->run();
?>
   

1

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.

2

$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.

3

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 :

<?php
require_once 'HTML/Progress2/Generator.php';
require_once 'HTML/Progress2/Generator/Default.php';

session_start();

$css = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'generator.css';

$display = new ActionDisplay();
$display->setStyleSheet($css);

// var_dump($display->getStyleSheet(true));
// var_dump($display->getStyleSheet());

$tabbed =& HTML_Progress2_Generator::singleton();
$tabbed->addAction('display', $display);
$tabbed->run();
?>
      

HTML_Progress2 : The Definitive Guide v 2.1.0 : August 12, 2006