![]() HTML_Progress2 : The Definitive Guide
|
Goals of this example are to show how to use another driver (HTMLPage2) than the standard (Default), use another external stylesheet to change color scheme easily, and add a user-process to download the PHP/CSS code results.
HTMLPage2 driver used its own default stylesheet which is a blue skin. Here, we prefer to use the dark-grey skin of SmartyDynamic driver (see $css).
Example 19.6. Progress Generator build with PEAR::HTML_Page2
<?php require_once 'HTML/Progress2/Generator.php'; require_once 'HTML/Progress2/Generator/HTMLPage2.php'; require_once 'HTML/Progress2/Generator/Process.php'; class MyProcessHandler extends ActionProcess { function perform(&$page, $actionName) { if ($actionName == 'cancel') { echo '<h1>Progress2 Generator Demonstration is Over</h1>'; echo '<p>Hope you\'ve enjoyed. See you later!</p>'; } else { // Checks whether the pages of the controller are valid $page->isFormBuilt() or $page->buildForm(); $page->controller->isValid(); // what kind of source code is requested $code = $page->exportValue('phpcss'); $pb = $page->controller->createProgressBar(); $phpCode = (isset($code['P']) === true); $cssCode = (isset($code['C']) === true); if ($cssCode && !$phpCode) { $strCSS = $this->sprintCSS($pb); $this->exportOutput($strCSS, 'text/css'); } if ($phpCode) { $strPHP = $this->sprintPHP($pb, $cssCode); $this->exportOutput($strPHP, 'text/php'); } // reset session data $page->controller->container(true); } } } session_start(); $tabbed =& HTML_Progress2_Generator::singleton(); $tabbed->addActions(array('dump' => 'ActionDump', 'process' => 'MyProcessHandler')); $pear = 'c:\php4'; $css = $pear . '\pear\data\HTML_Progress2\smartydynamic.css'; $tabbed->addAction('display', new ActionDisplay($css)); $tabbed->run(); ?>
![]() |
Caution |
---|---|
Of course you should fix the path of $pear to your own PEAR directory installation. |
HTML_Progress2 : The Definitive Guide | v 2.1.0 : August 12, 2006 |