$Date: 2004/04/18 13:25:44 $
This example will run a ProgressBar with a default observer mechanism. 'progress_observer.log' is a flat file generated by HTML_Progress_Observer class. Here are the contents of a such file :
[Top]
Build the progress bar
<?php require_once 'HTML/Progress.php'; $bar = new HTML_Progress(); $bar->setAnimSpeed(100); $bar->setBorderPainted(true); $bar->setIncrement(10); ?>
[Top]
width = 2
[Top]
[Top]
Run the script below :
<?php require_once 'HTML/Progress.php'; require_once 'HTML/Progress/observer.php'; // 1. Creates ProgressBar $bar = new HTML_Progress(); $bar->setAnimSpeed(100); $bar->setBorderPainted(true); $bar->setIncrement(10); // 2. Creates and attach a listener $observer = new HTML_Progress_Observer(); $ok = $bar->addListener($observer); if (!$ok) { die ("Cannot add a valid listener to progress bar !"); } // 3. Changes look-and-feel of ProgressBar $ui =& $bar->getUI(); $ui->setBorderAttributes('width = 2'); // border: 2px, solid, #000000 $ui->setComment('Standard Observer ProgressBar example'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Standard Observer ProgressBar example</title> <style type="text/css"> <!-- <?php echo $bar->getStyle(); ?> body { background-color: #FFFFFF; color: #000000; font-family: Verdana, Arial; } a:visited, a:active, a:link { color: navy; } // --> </style> <script type="text/javascript"> <!-- <?php echo $bar->getScript(); ?> //--> </script> </head> <body> <?php echo $bar->toHTML(); do { $bar->display(); if ($bar->getPercentComplete() == 1) { break; // the progress bar has reached 100% } $bar->incValue(); } while(1); ?> </body> </html>
[Top]