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

Source for file function_callback.php

Documentation is available at function_callback.php

  1. <?php
  2. @include '../include_path.php';
  3. /**
  4.  * Monitor example with a new form template and progress bar
  5.  * color scheme. Used a function as user callback.
  6.  *
  7.  * @version    $Id: function_callback.php,v 1.1 2004/06/27 13:08:50 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. class Progress_ITDynamic extends HTML_Progress_UI
  15. {
  16.     function Progress_ITDynamic()
  17.     {
  18.         parent::HTML_Progress_UI();
  19.         
  20.         $this->setCellCount(20);
  21.         $this->setProgressAttributes('background-color=#EEE');
  22.         $this->setStringAttributes('background-color=#EEE color=navy');
  23.         $this->setCellAttributes('inactive-color=#FFF active-color=#444444');
  24.     }
  25. }
  26.  
  27. function myFunctionHandler($progressValue&$obj)
  28. {
  29.     $bar =$obj->getProgressElement();
  30.     $bar->sleep();
  31.     if (!$bar->isIndeterminate()) {
  32.         if (fmod($progressValue,10== 0{
  33.             $obj->setCaption("myFunctionHandler -> progress value is = $progressValue");
  34.         }
  35.     else {
  36.         /* in case we have attached an indeterminate progress bar to the monitor ($obj)
  37.            after a first pass that reached 60%, 
  38.            we swap from indeterminate mode to determinate mode
  39.            and run a standard progress bar from 0 to 100%
  40.         */   
  41.         if ($progressValue == 60{
  42.             $bar->setIndeterminate(false);
  43.             $bar->setString(null);           // show percent-info
  44.             $bar->setValue(0);
  45.         }
  46.     }
  47. }
  48.  
  49.  
  50. $monitor = new HTML_Progress_Monitor('frmMonitor4'array(
  51.     'button' => array('style' => 'width:80px;')
  52.     )
  53. );
  54. $monitor->setProgressHandler('myFunctionHandler');
  55.  
  56.  
  57. $progress = new HTML_Progress();
  58. $progress->setAnimSpeed(20);
  59. $progress->setUI('Progress_ITDynamic');// Attach a progress ui-model 
  60. $progress->setStringPainted(true);     // get space for the string
  61. $progress->setString("");              // but don't paint it
  62. $progress->setIndeterminate(true);     // Progress start in indeterminate mode
  63. $monitor->setProgressElement($progress);
  64. ?>
  65. <html>
  66. <head>
  67. <title>ProgressBar Monitor - Default renderer </title>
  68. <style type="text/css">
  69. <!--
  70. body {
  71.     background-color: lightgrey;
  72.     font-family: Verdana, Arial;
  73. }
  74. .progressStatus {
  75.     color: navy; 
  76.     font-size:10px;
  77. }
  78. <?php echo $monitor->getStyle()?>
  79. // -->
  80. </style>
  81. <script type="text/javascript">
  82. <!--
  83. <?php echo $monitor->getScript()?>
  84. //-->
  85. </script>
  86. </head>
  87. <body>
  88. <h1><?php echo basename(__FILE__)?></h1>
  89.  
  90. <?php 
  91. $renderer =HTML_QuickForm::defaultRenderer();
  92. $renderer->setFormTemplate('
  93.     <table width="450" border="0" cellpadding="3" cellspacing="2" bgcolor="#EEEEEE">
  94.     <form{attributes}>{content}
  95.     </form>
  96.     </table>
  97.     ');
  98. $renderer->setHeaderTemplate('
  99.     <tr>
  100.         <td style="white-space:nowrap;background:#7B7B88;color:#ffc;" align="left" colspan="2"><b>{header}</b></td>
  101.     </tr>
  102.     ');
  103. $monitor->accept($renderer);
  104.  
  105. echo $renderer->toHtml();
  106. $monitor->run();   
  107. ?>
  108.  
  109. <p>&lt;&lt; <a href="../index.html">Back examples TOC</a></p>
  110.  
  111. </body>
  112. </html>

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