home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / progress.setstring.cls < prev    next >
Encoding:
Text File  |  2004-03-24  |  3.5 KB  |  126 lines

  1. <refentry id="{@id}">
  2.  <refnamediv>
  3.   <refname>setString Manual</refname>
  4.   <refpurpose>sets the current value of the progress string</refpurpose>
  5.  </refnamediv>
  6.  <refsynopsisdiv>
  7.   <refsynopsisdivinfo>
  8.    <author>
  9.     by Laurent Laville
  10.     <authorblurb>{@link mailto:pear@laurent-laville.org}</authorblurb>
  11.    </author>
  12.    <copyright>November 2003, Laurent Laville</copyright>
  13.    <releaseinfo>HTML_Progress 1.0+</releaseinfo>
  14.   </refsynopsisdivinfo>
  15.  </refsynopsisdiv>
  16.  <refsect1 id="{@id synopsis}">
  17.   <title>Synopsis</title>
  18.   <para><emphasis>void</emphasis> <important>setString</important>( $str )</para>
  19.  </refsect1>
  20.  <refsect1 id="{@id attributes}">
  21.   <title>Attributes</title>
  22.   <para>
  23.    <table frame="all">
  24.     <tgroup cols="3">
  25.     <thead align="center">
  26.       <row>
  27.        <entry><important>Name</important></entry>
  28.        <entry><important>Type</important></entry>
  29.        <entry><important>Default</important></entry>
  30.       </row>
  31.     </thead>
  32.     <tbody>
  33.      <row>
  34.       <entry><emphasis>str</emphasis> </entry>
  35.       <entry>string                   </entry>
  36.       <entry>Null                     </entry>
  37.      </row>
  38.     </tbody>
  39.     </tgroup>
  40.    </table>
  41.   </para>
  42.  </refsect1>
  43.  <refsect1 id="{@id description}">
  44.   <title>Description</title>
  45.   <para>The <emphasis>setString()</emphasis> method is used to print a custom string.
  46.    The default value is null, that means the progress bar displays the value returned by 
  47.    {@link HTML_Progress::getPercentComplete()} method formatted as a percent such as 33%.
  48.   </para>
  49.  </refsect1>
  50.  <refsect1 id="{@id example}">
  51.   <title>Example</title>
  52.   <para>
  53.    Example below will produced a progress bar with a custom string. It's a dynamic example, 
  54.    the progress bar will run.
  55.    <para><graphic fileref="../media/screenshots/string.png"></graphic></para>
  56.    <programlisting role="php">
  57.    <![CDATA[
  58. <?php 
  59. require_once ('HTML/Progress.php');
  60.  
  61. $bar = new HTML_Progress();
  62. $bar->setIncrement(5);
  63. $bar->setStringPainted(true);          // get space for the string
  64. $bar->setString('');                   // but don't paint it
  65.  
  66. $ui =& $bar->getUI();
  67. $ui->setStringAttributes('width=350 align=left');
  68.  
  69. ?>
  70. <!DOCTYPE html
  71.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  72.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  73.  
  74. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  75. <head>
  76. <title>Horizontal String ProgressBar example</title>
  77. <style type="text/css">
  78. <!--
  79. <?php echo $bar->getStyle(); ?>
  80. // -->
  81. </style>
  82. <script type="text/javascript">
  83. <!--
  84. <?php echo $ui->getScript(); ?>
  85. //-->
  86. </script>
  87. </head>
  88. <body>
  89.  
  90. <?php 
  91. echo $bar->toHtml(); 
  92.  
  93. $pkg = array('PEAR', 'Archive_Tar', 'Config', 
  94.     'HTML_QuickForm', 'HTML_CSS', 'HTML_Page', 'HTML_Template_Sigma', 
  95.     'Log', 'MDB', 'PHPUnit');
  96.  
  97. do {
  98.     $val = $bar->getValue();
  99.     $i = floor($val / 10);
  100.     $msg = ($val == 100) ? '' : "  installing package ($val %) ... : ".$pkg[$i];
  101.     $bar->setString($msg);
  102.  
  103.     $bar->display();
  104.     if ($bar->getPercentComplete() == 1) {
  105.         break;   // the progress bar has reached 100%
  106.     }
  107.     $bar->incValue();
  108. } while(1);
  109. ?>
  110.  
  111. </body>
  112. </html>
  113.    ]]>
  114.    </programlisting>
  115.   </para>
  116.  </refsect1>
  117.  <refsect1 id="{@id seealso}">
  118.   <title>See Also</title>
  119.   <para>
  120.    Take care that <emphasis>setString()</emphasis> method is not enough to display
  121.    a custom string. You should also decide to paint the custom string. To do it, see 
  122.    {@tutorial progress.setstringpainted.cls}.
  123.   </para>
  124.  </refsect1>
  125. </refentry>
  126.