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

  1. <?php 
  2. /**
  3.  * ProgressBar model example.
  4.  * 
  5.  * @version    $Id: constructor_model.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.  
  12. class TimerProgress extends HTML_Progress_DM
  13. {
  14.     function TimerProgress()
  15.     {       
  16.         $this->HTML_Progress_DM(0,60,5);
  17.     }
  18. }
  19.  
  20. $timer = new TimerProgress();
  21. $bar = new HTML_Progress($timer);
  22. $bar->setStringPainted(true);          // get space for the string
  23. $bar->setString('');                   // but don't paint it
  24.  
  25. $ui =& $bar->getUI();
  26. $ui->setStringAttributes('width=170 height=20 valign=bottom align=center');
  27.  
  28. ?>
  29. <!DOCTYPE html
  30.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  31.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  32.  
  33. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  34. <head>
  35. <title>ProgressBar model example</title>
  36. <style type="text/css">
  37. <!--
  38. <?php echo $bar->getStyle(); ?>
  39.  
  40. body {
  41.     background-color: #FFFFFF;
  42.     color: #000000;
  43.     font-family: Verdana, Arial;
  44. }
  45.  
  46. a:visited, a:active, a:link {
  47.     color: navy;
  48. }
  49. // -->
  50. </style>
  51. <script type="text/javascript">
  52. <!--
  53. <?php echo $bar->getScript(); ?>
  54. //-->
  55. </script>
  56. </head>
  57. <body>
  58. <h1><?php echo basename(__FILE__); ?></h1>
  59.  
  60. <?php 
  61. echo $bar->toHtml(); 
  62.  
  63. do {
  64.     $bar->display();
  65.     if ($bar->getPercentComplete() == 1) {
  66.         $bar->setString('All done!');
  67.         $bar->display();
  68.         break;   // the progress bar has reached 100%
  69.     }
  70.     if ($bar->getPercentComplete() == 0.25) {
  71.         $bar->setString('Fourth part way done!');
  72.     }
  73.     if ($bar->getPercentComplete() == 0.5) {
  74.         $bar->setString('Half way done!');
  75.     }
  76.     if ($bar->getPercentComplete() == 0.75) {
  77.         $bar->setString('Three quarters way done!');
  78.     }
  79.     $bar->incValue();
  80. } while(1);
  81. ?>
  82.  
  83. <p><< <a href="index.html">Back examples TOC</a></p>
  84.  
  85. <h2>print_r </h2>
  86. <pre>
  87. <?php 
  88. print_r($bar->toArray()); 
  89. ?>
  90. </pre>
  91.  
  92. </body>
  93. </html>