$Date: 2004/04/18 13:25:43 $
IntroductionThis example will run a template style ProgressBar Monitor, handled by class-method user callback. Used ITDynamic QuickForm renderer with a non-standard color scheme for form template and progress bar.
[Top]
PHP scriptUser-Callback
<?php
class my2ClassHandler
{
function my1Method($progressValue, &$obj)
{
switch ($progressValue) {
case 10:
$pic = 'picture1.jpg';
break;
case 45:
$pic = 'picture2.jpg';
break;
case 70:
$pic = 'picture3.jpg';
break;
default:
$pic = null;
}
if (!is_null($pic)) {
$obj->setCaption('upload <b>%file%</b> in progress ... Start at %percent%%',
array('file'=>$pic, 'percent'=>$progressValue)
);
}
}
}
?>
[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';
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
require_once 'HTML/Template/ITX.php';
$monitor = new HTML_Progress_Monitor('frmMonitor5', array(
'title' => 'Upload your pictures',
'start' => 'Upload',
'cancel' => 'Stop',
'button' => array('style' => 'width:80px;')
)
);
$monitor->setProgressHandler(array('my2ClassHandler','my1Method'));
// Attach a progress ui-model (see file progressModels.php for attributes definition)
$progress = new HTML_Progress();
$progress->setUI('Progress_ITDynamic');
$progress->setAnimSpeed(50);
$monitor->setProgressElement($progress);
// can use either HTML_Template_Sigma or HTML_Template_ITX
$tpl =& new HTML_Template_ITX('./templates');
$tpl->loadTemplateFile('itdynamic_monitor.html');
$tpl->setVariable(array(
'qf_style' => "body {font-family: Verdana, Arial; } \n" . $monitor->getStyle(),
'qf_script' => $monitor->getScript()
)
);
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
$renderer->setElementBlock(array(
'buttons' => 'qf_buttons'
));
$monitor->accept($renderer);
// Display progress uploader dialog box
$tpl->show();
$monitor->run();
?>
[Top]