HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
Prev Next
HTML_Progress::setString
sets the current value of the progress meter string

Synopsis

require_once 'HTML/Progress.php';

void HTML_Progress::setString( string $str)

Description

This method is used to print a custom string. The default value is null, that means the progress meter displays the value returned by HTML_Progress::getPercentComplete() method formatted as a percent such as 33%.

The custom progress meter string is painted only if the HTML_Progress::isStringPainted() method returns TRUE.

Parameter

    string $str
  • the progress meter custom string.

Note

( HTML_Progress >= 1.0 )

This function can not be called statically.

If you have provided a custom progress string and want to revert to the built-in-behavior, set the string back to NULL.

See

HTML_Progress::getString, HTML_Progress::isStringPainted, HTML_Progress::setStringPainted

Example

Example below (that requires HTML_Progress >= 1.2.0RC3) will produced a progress bar with a custom string. It's a dynamic example, the progress bar will run.

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

Prev Up Next
HTML_Progress::getString Reference Guide HTML_Progress::getDM

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