HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next
HTML_Progress_Monitor::run
runs the monitor and catch user action (cancel)

Synopsis

require_once 'HTML/Progress/monitor.php';

void HTML_Progress_Monitor::run()

Description

This method launch the monitoring process after user has clicked on Start button.

At any time, the user can stop the process with the Cancel button.

Note

( HTML_Progress >= 1.0 )

This function can not be called statically.

See

HTML_Progress::setAnimSpeed, HTML_Progress::sleep, HTML_Progress_Monitor::setProgressHandler, HTML_Progress_Monitor::callProgressHandler

Example

The full example below will run a progress monitor starting in indeterminate mode, and then switch back to determinate mode.

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

Prev Up Next
HTML_Progress_Monitor::isCanceled Reference Guide HTML_Progress_Monitor::setProgressElement

Documentation generated on Sun, 12 Sep 2004 20:23:33 +0200 by phpDocumentor 1.3.0RC3