Appendix B. Migration to version 1.2

HTML_Progress

Prev |  | Next
Appendix B. Migration to version 1.2 API changes to observe ## Why these changes ? HTML_Progress has improved a lot since version 1.1. New features and easy short links comes, but also some functionalities was removed. With release 1.2 HTML_Progress_Model class was removed, making HTML_Progress package much lighter. But don't worry, the feature still exists: see HTML_Progress::setModel method. ## How to adjust your code ### HTML_Progress::display() When you coded a loop such as:

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

    $bar = new HTML_Progress();

    // ...

    do {
        $bar->display();
        if ($bar->getPercentComplete() == 1) {
            $break;
        }
        $bar->incValue();
    } while(1)
    ?>
the sleep action in version 1.1 (an empty for-loop) was included inside HTML_Progress::display method. Now in version 1.2 a new API comes: HTML_Progress::sleep which used in most case the PHP function http://www.php.net/manual/en/function.usleep.php, rather than an empty for-loop. You should include this new method in your do-while loop, as in implementation below:

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

    $bar = new HTML_Progress();

    // ...

    do {
        $bar->display();
        if ($bar->getPercentComplete() == 1) {
            $break;
        }
        $bar->sleep();
        $bar->incValue();
    } while(1)
    ?>
| Of course, you need the HTML_Progress::sleep method only to produce demonstration. In real world the user task should at least enough long to delay and smooth progress meter animation.
### HTML_Progress::run() This new API allows to replace a do-while loop as in above example. Its also allows to call a user-callback defined by HTML_Progress::setProgressHandler and manage both progress meter mode (determinate and indeterminate). ### HTML_Progress::hasErrors(), HTML_Progress::getError() These new API allows to catch HTML_Progress internal errors more easily. See Advanced Error Handling for details.

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

    $bar = new HTML_Progress();
    $e = $bar->setAnimSpeed(10000);   // < - - - will generate an API error

    if ($bar->hasErrors()) {
        $err = $bar->getError();
        echo '<h1>Catch HTML_Progress Error</h1>';
        echo '<pre>';
        print_r($err);
        echo '</pre>';
    }
    ?>
Prev | Up | Next
Appendix A. Installation | Appendixes | Appendix C. Frequently Asked Questions
Documentation generated on Sun, 12 Sep 2004 20:23:36 +0200 by phpDocumentor 1.3.0RC3