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

Source for file half_monitor.php

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

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