Logger Monitor
Overview
This example will run a default Progress2 Monitor, which used a default
QuickForm renderer without any form template customization.
Each quarter percent reached, elapse time is printed.
Screenshot

Demonstration
Give it a try
Dependencies
This example requires mandatory resources :
And also but optional :
Explains step by step
The form windows (ProgressMonitor) have default title (In progress ...),
buttons name (Start, Cancel) and size :
see class constructor parameters (line 50).
There are 10 cells 15x20:
Property | Value | Default |
active-color | | #006600 |
inactive-color | | #CCCCCC |
width | | 15 |
height | | 20 |
spacing | | 2 |
See also :
With basic percent text info aligned on right side:
Property | Value | Default |
left | | 5 |
top | | 5 |
width | | 50 |
height | | 0 |
align | | right |
valign | | right |
background-color | | |
font-size | | 11 |
font-family | | Verdana, Tahoma, Arial |
font-weight | | normal |
color | | #000000 |
class | | progressPercentLabel%s |
See also :
Source Code
<?php
/**
* Progress2 Monitor with default QF renderer
* and a user listener for logging events.
*
* @version $Id: monitorlog.php,v 1.3 2005/08/01 08:20:36 farell Exp $
* @author Laurent Laville <pear@laurent-laville.org>
* @package HTML_Progress2
* @subpackage Examples
* @access public
*/
require_once 'HTML/Progress2/Monitor.php';
function getmicrotime($time)
{
list($usec, $sec) = explode(' ', $time);
return ((float)$usec + (float)$sec);
}
function logger(&$notification)
{
static $time_start;
global $pm;
$notifyName = $notification->getNotificationName();
$notifyInfo = $notification->getNotificationInfo();
if ($notifyName == 'onSubmit') {
$time_start = getmicrotime($notifyInfo['time']);
} elseif ($notifyName == 'onLoad') {
$elapse = getmicrotime($notifyInfo['time']) - $time_start;
printf('script runtime: %f seconds.', $elapse);
} elseif ($notifyName == 'onChange') {
if (fmod($notifyInfo['value'], 25) == 0) {
$time = getmicrotime($notifyInfo['time']);
$elapse = $time - $time_start;
$pm->setCaption('%value%% has been reached on %time% sec.',
array('value' => $notifyInfo['value'], 'time' => sprintf('%01.3f',$elapse))
);
}
}
}
$pm = new HTML_Progress2_Monitor();
$pb =& $pm->getProgressElement();
$pb->setAnimSpeed(100);
$pb->addListener('logger');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Logger Progress2 Monitor </title>
<?php
echo $pm->getStyle(false);
echo $pm->getScript(false);
?>
</head>
<body>
<?php
$pm->display();
$pm->run();
?>
</body>
</html>