$Date: 2004/04/18 13:25:43 $
IntroductionThis example will run a ProgressBar Monitor, handled by function user callback. Its started in indeterminate mode then switch back in determinate mode. Used default QuickForm renderer with a non-standard color scheme for form template and progress bar.
[Top]
PHP scriptUser-Callback
<?php
// progressHandler.php
function myFunctionHandler($progressValue, &$obj)
{
$bar =& $obj->getProgressElement();
if (!$bar->isIndeterminate()) {
if (fmod($progressValue,10) == 0) {
$obj->setCaption("myFunctionHandler -> progress value is = $progressValue");
}
} else {
/* in case we have attached an indeterminate progress bar to the monitor ($obj)
after a first pass that reached 60%,
we swap from indeterminate mode to determinate mode
and run a standard progress bar from 0 to 100%
*/
if ($progressValue == 60) {
$bar->setIndeterminate(false);
$bar->setString(null); // show percent-info
$bar->setValue(0);
}
}
}
?>
[Top]
Render options Used a pre-set UI model: Progress_ITDynamic in file progressModels.php
Here are the progress attributes:background-color = #EEE
color = navy background-color = #EEE
inactive-color = #FFF active-color = #444444
[Top]
Output
[Top]
Play full exampleRun the script below :
<?php
require_once 'HTML/Progress/monitor.php';
require_once 'progressModels.php';
require_once 'progressHandler.php';
$monitor = new HTML_Progress_Monitor('frmMonitor4', array(
'button' => array('style' => 'width:80px;')
)
);
$monitor->setProgressHandler('myFunctionHandler');
// Attach a progress ui-model (see file progressModels.php for attributes definition)
$progress = new HTML_Progress();
$progress->setAnimSpeed(50);
$progress->setUI('Progress_ITDynamic');
$progress->setStringPainted(true); // get space for the string
$progress->setString(""); // but don't paint it
$progress->setIndeterminate(true); // Progress start in indeterminate mode
$monitor->setProgressElement($progress);
?>
<html>
<head>
<title>ProgressBar Monitor - Default renderer </title>
<style type="text/css">
<!--
body {
background-color: lightgrey;
font-family: Verdana, Arial;
}
.progressStatus {
color: navy;
font-size:10px;
}
<?php echo $monitor->getStyle(); ?>
// -->
</style>
<script type="text/javascript">
<!--
<?php echo $monitor->getScript(); ?>
//-->
</script>
</head>
<body>
<?php
$renderer =& HTML_QuickForm::defaultRenderer();
$renderer->setFormTemplate('
<table width="450" border="0" cellpadding="3" cellspacing="2" bgcolor="#EEEEEE">
<form{attributes}>{content}
</form>
</table>
');
$renderer->setHeaderTemplate('
<tr>
<td style="white-space:nowrap;background:#7B7B88;color:#ffc;" align="left" colspan="2"><b>{header}</b></td>
</tr>
');
$monitor->accept($renderer);
echo $renderer->toHtml();
$monitor->run();
?>
</body>
</html>
[Top]