HTML_Progress
[ class tree: HTML_Progress ] [ index: HTML_Progress ] [ all elements ]
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:

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. $bar = new HTML_Progress();
  5.  
  6. // ...
  7.  
  8. do {
  9. $bar->display();
  10. if ($bar->getPercentComplete() == 1) {
  11. $break;
  12. }
  13. $bar->incValue();
  14. } while(1)
  15. ?>

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:

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. $bar = new HTML_Progress();
  5.  
  6. // ...
  7.  
  8. do {
  9. $bar->display();
  10. if ($bar->getPercentComplete() == 1) {
  11. $break;
  12. }
  13. $bar->sleep();
  14. $bar->incValue();
  15. } while(1)
  16. ?>


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.

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. $bar = new HTML_Progress();
  5. $e = $bar->setAnimSpeed(10000); // < - - - will generate an API error
  6.  
  7. if ($bar->hasErrors()) {
  8. $err = $bar->getError();
  9. echo '<h1>Catch HTML_Progress Error</h1>';
  10. echo '<pre>';
  11. print_r($err);
  12. echo '</pre>';
  13. }
  14. ?>


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