HTML_Progress::setString

HTML_Progress

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.

    <?php
    require_once 'HTML/Progress.php';

    $bar = new HTML_Progress();
    $bar->setAnimSpeed(100);
    $bar->setIncrement(5);
    $bar->setStringPainted(true);     // get space for the string
    $bar->setString('');              // but don't paint it

    $ui =& $bar->getUI();
    $ui->setStringAttributes('width=350 align=left');
    ?>
    <html>
    <head>
    <title>setString example</title>
    <style type="text/css">
    <!--
    <?php echo $bar->getStyle(); ?>
    // -->
    </style>
    <script type="text/javascript">
    <!--
    <?php echo $bar->getScript(); ?>
    //-->
    </script>
    </head>
    <body>

    <?php
    echo $bar->toHtml();

    $pkg = array('PEAR', 'Archive_Tar', 'Config',
        'HTML_QuickForm', 'HTML_CSS', 'HTML_Page', 'HTML_Template_Sigma',
        'Log', 'MDB', 'PHPUnit');

    do {
        $val = $bar->getValue();
        $i = floor($val / 10);
        if ($val == 100) {
            $msg = '';
        } else {
            $msg  = "&nbsp; installing package ($val %) ... : ";
            $msg .= $pkg[$i];
        }
        $bar->setString($msg);

        $bar->display();
        if ($bar->getPercentComplete() == 1) {
            break;   // the progress bar has reached 100%
        }
        $bar->sleep();  // for purpose of demo only
        $bar->incValue();
    } while(1);
    ?>

    </body>
    </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