HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next
HTML_Progress::sleep
delays execution of the progress meter

Synopsis

require_once 'HTML/Progress.php';

void HTML_Progress::sleep()

Description

This method is used to delay execution of the progress meter.

This is the default user callback called by HTML_Progress::process in the do-while loop of the HTML_Progress::run method.

Note

( HTML_Progress >= 1.2.0RC3 )

This function can not be called statically.

Useful when you want to show some demonstrations. In real world, there is no need to delay execution because the user-task (process) should be long enough to make a smooth animation. If it was not the case, then use the HTML_Progress::setAnimSpeed method.

The function http://www.php.net/manual/en/function.usleep.php did not work on Windows systems until PHP 5.0.0; For PHP4 on Windows platform, HTML_Progress uses a empty-for loop to delay execution.

See

HTML_Progress::setAnimSpeed, HTML_Progress::process, HTML_Progress::run, HTML_Progress::setProgressHandler

Example

Example below (that requires HTML_Progress >= 1.2.0RC3) demonstrates usage of a simple user callback (lines 10 to 13, and 18), which only wait 1 second (line 16).

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. /*
  5. user callback: job to do while the progress meter is running
  6.  
  7. $obj is an instance of the progress meter object (see line 13)
  8. $progressValue contains the current value of the progress meter
  9. */
  10. function myFunctionHandler($progressValue, &$obj)
  11. {
  12. $obj->sleep(); // nothing to do here, except sleep a bit ...
  13. }
  14.  
  15. $progress = new HTML_Progress();
  16. $progress->setAnimSpeed(1000); // defines delay of one second
  17. $progress->setIncrement(10);
  18. $progress->setProgressHandler('myFunctionHandler');
  19. ?>
  20. <html>
  21. <head>
  22. <style type="text/css">
  23. <!--
  24. <?php echo $progress->getStyle(); ?>
  25. // -->
  26. </style>
  27. <script type="text/javascript">
  28. <!--
  29. <?php echo $progress->getScript(); ?>
  30. //-->
  31. </script>
  32. </head>
  33. <body>
  34.  
  35. <?php
  36. echo $progress->toHtml();
  37. $progress->run();
  38. ?>
  39.  
  40. </body>
  41. </html>

Prev Up Next
HTML_Progress::toArray Reference Guide HTML_Progress::setProgressHandler

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