![]() HTML_Progress2 : The Definitive Guide
|
With some options and a new QF renderer, we will improve a lot in few lines, the decent but poor graphic of first example. Enjoy the new result:
Lets review now, how to do this in source code below:
<?php require_once 'HTML/Progress2/Monitor.php'; function myFunctionHandler($pValue, &$pb){ global $pm; $pb->sleep(); if ((fmod($pValue,10) == 0) and ($pValue > 0)) { $pm->setCaption('myFunctionHandler -> progress value is = '.$pValue);
} } $pm = new HTML_Progress2_Monitor('frmMonitor', array( 'button' => array('style' => 'width:80px;'), ));
$pb =& $pm->getProgressElement(); $pb->setAnimSpeed(75); $pb->setCellCount(20); $pb->setProgressAttributes('background-color=#EEE'); $pb->setCellAttributes('inactive-color=#FFF active-color=#444444'); $pb->setLabelAttributes('pct1', 'color=navy'); $pb->setLabelAttributes('monitorStatus', 'color=navy font-size=10');
$pb->setProgressHandler('myFunctionHandler');
$pm->setProgressElement($pb); ?> <html> <head> <?php echo $pm->getStyle(false); echo $pm->getScript(false); ?> </head> <body> <?php $renderer =& HTML_QuickForm::defaultRenderer();
$renderer->setFormTemplate('
<form{attributes}> <table width="450" border="0" cellpadding="3" cellspacing="2" bgcolor="#EEEEEE"> {content} </table> </form> '); $renderer->setElementTemplate('
<tr> <td valign="top" style="padding-left:15px;"> {element} </td> </tr> '); $renderer->setHeaderTemplate('
<tr> <td style="background:#7B7B88;color:#ffc;" align="left" colspan="2"> <b>{header}</b> </td> </tr> '); $pm->accept($renderer); echo $renderer->toHtml();
$pm->run(); ?> </body> </html>
Now we know how to customize the skin, in next example we will see how to combine a task with events observation.
HTML_Progress2 : The Definitive Guide | v 1.0.0 : September 23, 2005 |