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

Source for file indeterminate.php

Documentation is available at indeterminate.php

  1. <?php 
  2. @include '../../include_path.php';
  3. /**
  4.  * Horizontal ProgressBar in indeterminate mode
  5.  * using the Progress_Monitor V2 solution (with QF renderer).
  6.  * 
  7.  * @version    $Id: indeterminate.php,v 1.2 2004/04/18 13:25:43 farell Exp $
  8.  * @author     Laurent Laville <pear@laurent-laville.org>
  9.  * @package    HTML_Progress
  10.  */
  11.  
  12. require_once 'HTML/Progress/monitor.php';
  13.  
  14.  
  15. function myProgressHandler($progressValue&$obj)
  16. {
  17.     static $c;
  18.     
  19.     if (!isset($c)) 
  20.         $c = 0;
  21.     }
  22.     $c += 16;
  23.     $obj->setCaption("completed $c out of 400");
  24.  
  25.     $bar =$obj->getProgressElement();
  26.     /* rules to determine when switch back from indeterminate to determinate mode */
  27.     if ($c >= 240 && $bar->isIndeterminate()) {
  28.         $bar->setIndeterminate(false);
  29.         $bar->setString(null);           // show percent-info
  30.         $bar->setValue(0);
  31.     }
  32.     if ($bar->getPercentComplete(== 1{
  33.         if ($bar->isIndeterminate()) {
  34.             $bar->setValue(0);
  35.         else {
  36.             $bar->setString('');            // hide percent-info
  37.         }
  38.     }
  39. }
  40.  
  41. $monitor = new HTML_Progress_Monitor('frmMonitor'
  42.     array'button' => array('style' => 'width:80px;')
  43.            'title'  => 'Progress ...' )
  44. );
  45.  
  46. // your custom user process goes here !
  47. $monitor->setProgressHandler('myProgressHandler');
  48.  
  49. // Attach a progress bar custom model
  50. $progress = new HTML_Progress();
  51. $ui $progress->getUI();
  52. $ui->setProgressAttributes(array(
  53.     'background-color' => '#e0e0e0'
  54. ));        
  55. $ui->setStringAttributes(array(
  56.     'color'  => '#996',
  57.     'background-color' => '#CCCC99'
  58. ));        
  59. $ui->setCellAttributes(array(
  60.     'active-color' => '#996'
  61. ));
  62.  
  63. $progress->setAnimSpeed(100);
  64. $progress->setIncrement(10);
  65. $progress->setStringPainted(true);     // get space for the string
  66. $progress->setString("");              // but don't paint it
  67. $progress->setIndeterminate(true);     // Progress start in indeterminate mode
  68. $monitor->setProgressElement($progress);
  69. ?>
  70. <html>
  71. <head>
  72. <title>Indeterminate Mode Progress example</title>
  73. <style type="text/css">
  74. <!--
  75. .progressStatus {
  76.     color:#000000; 
  77.     font-size:10px;
  78. }
  79.  
  80. body {
  81.     background-color: #444444;
  82.     color: #EEEEEE;
  83.     font-family: Verdana, Arial;
  84. }
  85.  
  86. a:visited, a:active, a:link {
  87.     color: yellow;
  88. }
  89.  
  90. <?php echo $monitor->getStyle()?>
  91. // -->
  92. </style>
  93. <script type="text/javascript">
  94. <!--
  95. <?php echo $monitor->getScript()?>
  96. //-->
  97. </script>
  98. </head>
  99. <body>
  100. <h1><?php echo basename(__FILE__)?></h1>
  101.  
  102. <?php 
  103. $renderer =HTML_QuickForm::defaultRenderer();
  104. $renderer->setFormTemplate('
  105.     <table width="450" border="0" cellpadding="3" cellspacing="2" bgcolor="#CCCC99">
  106.     <form{attributes}>{content}
  107.     </form>
  108.     </table>
  109. ');
  110. $renderer->setHeaderTemplate('
  111.     <tr>
  112.     <td style="white-space:nowrap;background:#996;color:#ffc;" align="left" colspan="2"><b>{header}</b></td>
  113.     </tr>
  114. ');
  115. $monitor->accept($renderer);
  116.  
  117. // Display progress monitor dialog box
  118. echo $renderer->toHtml();
  119.  
  120.  
  121. $monitor->run();   
  122. ?>
  123.  
  124. <p>&lt;&lt; <a href="index.html">Back examples TOC</a></p>
  125.  
  126. </body>
  127. </html>

Documentation generated on Mon, 11 Mar 2019 10:15:08 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.