PEAR Progress2 logo

HTML_Progress2 : The Definitive Guide

Progress bar HTML design

[Note] Note

You can continue to use your old design built with versions 2.0.0 to 2.2.0, details are unchanged.

Since version 2.3.0 alpha 2, HTML_Progress2 support now the multiple-labels system introduced with version 2.0.0

See (on package distribution) examples/ajax/RequestStatus.class.php file, method getFullStatus() for a basic implementation example.

You have just to return a key-value pair for each label identified at design level with a "labels" key array.

  1. <?php
  2. require_once 'HTML/Progress2.php';
  3.  
  4. $pb = new HTML_Progress2();
  5. $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...');
  6. // label text identifier of "caption ..." is here: txt2
  7. ?>

So if we want to change 'txt2' label value, at middle of progress (50%), we have to return an array with something like that:

  1. <?php
  2. // ...
  3. $status = array('percentage' => 50,
  4.                 'labels' => array('txt2' => 'half task done')
  5.                );
  6. return $status;
  7. // ...
  8. ?>
[Important] Important

An (HTML_)AJAX server may return label values that are unkown at design level. No error/warning will be raise !

See RequestStatus.class.php file, getFullStatus() method, with this line

  1. <?php
  2. $this->status['labels']['txt4'] = 'Q4';
  3. ?>

'txt4' label is undefined on all examples. But if in future we want to add a new text label, we just have to add it in design progress bar level, like this:

  1. <?php
  2. $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt4', 'Total tasks : ');
  3. ?>
HTML_Progress2 : The Definitive Guide v 2.4.0 : April 20, 2007