HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]

Source for file half_basic.php

Documentation is available at half_basic.php

  1. <?php 
  2. @include '../include_path.php';
  3. /**
  4.  * Horizontal ProgressBar in indeterminate mode
  5.  * without using the Progress_Monitor V2 solution.
  6.  * 
  7.  * @version    $Id: half_basic.php,v 1.1 2004/06/27 13:36:44 farell Exp $
  8.  * @author     Laurent Laville <pear@laurent-laville.org>
  9.  * @package    HTML_Progress
  10.  */
  11.  
  12. require_once 'HTML/Progress.php';
  13.  
  14. /**
  15.  *  This user callback process simulate a reply given after 12 seconds
  16.  *  Parameters
  17.  *  1. current value of the progress bar
  18.  *  2. the progress bar (object) itself
  19.  */ 
  20. function myProgressHandler($progressValue&$bar)
  21. {
  22.     static $c;
  23.     
  24.     if (!isset($c)) 
  25.         $c time();
  26.     }
  27.  
  28.     // wait a bit ... 
  29.     $bar->sleep();
  30.  
  31.     /* rules to determine when switch back from indeterminate to determinate mode */
  32.     $elapse time($c;
  33.  
  34.     echo "myProgressHandler -> elapse time = $elapse s.<br/>\n";
  35.     if ($elapse >= 12{
  36.         if ($bar->isIndeterminate()) {
  37.             $bar->setIndeterminate(false);
  38.             $bar->setValue(100);
  39.         }
  40.     }
  41. }
  42.  
  43. $progress = new HTML_Progress();
  44. $ui $progress->getUI();
  45. $ui->setProgressAttributes(array(
  46.     'background-color' => '#e0e0e0'
  47. ));        
  48. $ui->setStringAttributes(array(
  49.     'color'  => '#996',
  50.     'background-color' => '#CCCC99'
  51. ));        
  52. $ui->setCellAttributes(array(
  53.     'active-color' => '#996'
  54. ));
  55.  
  56. $progress->setAnimSpeed(200);
  57. $progress->setIncrement(10);
  58. $progress->setStringPainted(true);     // get space for the string
  59. $progress->setString("");              // but don't paint it
  60. $progress->setIndeterminate(true);     // Progress start in indeterminate mode
  61. $progress->setProgressHandler('myProgressHandler');
  62. ?>
  63. <html>
  64. <head>
  65. <title>Basic Indeterminate Mode Progress example</title>
  66. <style type="text/css">
  67. <!--
  68. body {
  69.     background-color: #CCCC99;
  70.     color: #996;
  71.     font-family: Verdana, Arial;
  72. }
  73.  
  74. a:visited, a:active, a:link {
  75.     color: yellow;
  76. }
  77.  
  78. <?php echo $progress->getStyle()?>
  79. // -->
  80. </style>
  81. <script type="text/javascript">
  82. <!--
  83. <?php echo $progress->getScript()?>
  84. //-->
  85. </script>
  86. </head>
  87. <body>
  88. <h1><?php echo basename(__FILE__)?></h1>
  89.  
  90. <?php 
  91. echo $progress->toHtml()
  92.  
  93. $progress->run();
  94. ?>
  95.  
  96. <p>&lt;&lt; <a href="../index.html">Back examples TOC</a></p>
  97.  
  98. </body>
  99. </html>

Documentation generated on Mon, 11 Mar 2019 13:52:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.