PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/php/HTML/tutorials/HTML_Progress/examples/setstring.php

https://bitbucket.org/adarshj/convenient_website
PHP | 57 lines | 48 code | 7 blank | 2 comment | 5 complexity | a9dc03125a7cccc2a863b3516ded5b98 MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0
  1. <?php
  2. require_once 'HTML/Progress.php';
  3. $bar = new HTML_Progress();
  4. $bar->setAnimSpeed(100);
  5. $bar->setIncrement(5);
  6. $bar->setStringPainted(true); // get space for the string
  7. $bar->setString(''); // but don't paint it
  8. $ui =& $bar->getUI();
  9. $ui->setStringAttributes('width=350 align=left');
  10. ?>
  11. <html>
  12. <head>
  13. <title>setString example</title>
  14. <style type="text/css">
  15. <!--
  16. <?php echo $bar->getStyle(); ?>
  17. // -->
  18. </style>
  19. <script type="text/javascript">
  20. <!--
  21. <?php echo $bar->getScript(); ?>
  22. //-->
  23. </script>
  24. </head>
  25. <body>
  26. <?php
  27. echo $bar->toHtml();
  28. $pkg = array('PEAR', 'Archive_Tar', 'Config',
  29. 'HTML_QuickForm', 'HTML_CSS', 'HTML_Page', 'HTML_Template_Sigma',
  30. 'Log', 'MDB', 'PHPUnit');
  31. do {
  32. $val = $bar->getValue();
  33. $i = floor($val / 10);
  34. if ($val == 100) {
  35. $msg = '';
  36. } else {
  37. $msg = "&nbsp; installing package ($val %) ... : ";
  38. $msg .= $pkg[$i];
  39. }
  40. $bar->setString($msg);
  41. $bar->display();
  42. if ($bar->getPercentComplete() == 1) {
  43. break; // the progress bar has reached 100%
  44. }
  45. $bar->sleep(); // for purpose of demo only
  46. $bar->incValue();
  47. } while(1);
  48. ?>
  49. </body>
  50. </html>