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

setString Manual

set the current value of the progress string

by by Laurent Laville
mailto:pear@laurent-laville.org
November 2003, Laurent Laville
(HTML_Progress 1.0+)

Synopsis

void setString( $str )

Attributes

Name Type
str string

Description

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

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

The progress string is painted only if the isStringPainted() method returns TRUE.

Example

Example below 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. <!DOCTYPE html
  14.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  15.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  16.  
  17. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  18. <head>
  19. <title>setString example</title>
  20. <style type="text/css">
  21. <!--
  22. <?php echo $bar->getStyle()?>
  23. // -->
  24. </style>
  25. <script type="text/javascript">
  26. <!--
  27. <?php echo $bar->getScript()?>
  28. //-->
  29. </script>
  30. </head>
  31. <body>
  32.  
  33. <?php 
  34. echo $bar->toHtml()
  35.  
  36. $pkg = array('PEAR''Archive_Tar''Config'
  37.     'HTML_QuickForm''HTML_CSS''HTML_Page''HTML_Template_Sigma'
  38.     'Log''MDB''PHPUnit');
  39.  
  40. do {
  41.     $val $bar->getValue();
  42.     $i floor($val / 10);
  43.     $msg ($val == 100'' : "&nbsp; installing package ($val %) ... : ".$pkg[$i];
  44.     $bar->setString($msg);
  45.  
  46.     $bar->display();
  47.     if ($bar->getPercentComplete(== 1{
  48.         break;   // the progress bar has reached 100%
  49.     }
  50.     $bar->incValue();
  51. while(1);
  52. ?>
  53.  
  54. </body>
  55. </html>

See Also

getString Manual, isStringPainted Manual, setStringPainted Manual

Prev Up Next
getString Manual Reference Guides isStringPainted Manual

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