home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / observer_standard.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.4 KB  |  94 lines

  1. <?php 
  2. /**
  3.  * Observer ProgressBar example. Uses the default observer class.
  4.  * 
  5.  * @version    $Id: observer_standard.php,v 1.1 2003/11/15 18:27:10 thesaur Exp $
  6.  * @author     Laurent Laville <pear@laurent-laville.org>
  7.  * @package    HTML_Progress
  8.  */
  9.  
  10. require_once ('HTML/Progress.php');
  11. require_once ('HTML/Progress/observer.php');
  12.  
  13. // 1. Creates ProgressBar
  14. $bar = new HTML_Progress();
  15. $bar->setBorderPainted(true);
  16. $bar->setIncrement(10);
  17.  
  18. // 2. Creates and attach a listener 
  19. $observer = new HTML_Progress_Observer();
  20.  
  21. $ok = $bar->addListener($observer);
  22. if (!$ok) {
  23.     die ("Cannot add a valid listener to progress bar !");
  24. }
  25.  
  26. // 3. Changes look-and-feel of ProgressBar
  27. $ui =& $bar->getUI();
  28. $ui->setBorderAttributes('width = 2');                     // border: 2px, solid, #000000
  29. $ui->setComment('Standard Observer ProgressBar example');
  30.  
  31. ?>
  32. <!DOCTYPE html
  33.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  34.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  35.  
  36. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  37. <head>
  38. <title>Standard Observer ProgressBar example</title>
  39. <style type="text/css">
  40. <!--
  41. <?php echo $bar->getStyle(); ?>
  42.  
  43. body {
  44.     background-color: #FFFFFF;
  45.     color: #000000;
  46.     font-family: Verdana, Arial;
  47. }
  48.  
  49. a:visited, a:active, a:link {
  50.     color: navy;
  51. }
  52. // -->
  53. </style>
  54. <script type="text/javascript">
  55. <!--
  56. <?php echo $bar->getScript(); ?>
  57. //-->
  58. </script>
  59. </head>
  60. <body>
  61. <h1><?php echo basename(__FILE__); ?></h1>
  62.  
  63. <?php 
  64. echo $bar->toHTML(); 
  65.  
  66. do {
  67.     $bar->display();
  68.     if ($bar->getPercentComplete() == 1) {
  69.         break;   // the progress bar has reached 100%
  70.     }
  71.     $bar->incValue();
  72. } while(1);
  73. ?>
  74.  
  75. <form>
  76. Contents of file 'progress_observer.log' generated by HTML_Progress_Observer class
  77. <textarea readOnly="true" rows="12" cols="80" wrap="virtual">
  78. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:10;} 
  79. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:20;} 
  80. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:30;} 
  81. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:40;} 
  82. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:50;} 
  83. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:60;} 
  84. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:70;} 
  85. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:80;} 
  86. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:90;} 
  87. a:2:{s:3:"log";s:8:"incValue";s:5:"value";i:100;} 
  88. </textarea>
  89. </form>
  90.  
  91. <p><< <a href="index.html">Back examples TOC</a></p>
  92.  
  93. </body>
  94. </html>