HTML_Progress2
[ class tree: HTML_Progress2 ] [ index: HTML_Progress2 ] [ all elements ]

Source for file RequestStatus.class.php

Documentation is available at RequestStatus.class.php

  1. <?php
  2. /**
  3.  * Sample of user-task script, that also handle response for progress meter
  4.  *
  5.  * @version    $Id$
  6.  * @author     Laurent Laville <pear@laurent-laville.org>
  7.  * @package    HTML_Progress2
  8.  * @subpackage Examples
  9.  * @access     public
  10.  */
  11. {
  12.     var $status = array('labels' => array()'percentage' => 0);
  13.  
  14.     function RequestStatus()
  15.     {
  16.         if (!isset($_SESSION['progressPercentage'])) {
  17.             $_SESSION['progressPercentage'= 0;
  18.         }
  19.     }
  20.  
  21.     /**
  22.      * Returns only new percentage value
  23.      *
  24.      * @return  array 
  25.      * @access  public
  26.      */
  27.     function getStatus()
  28.     {
  29.         return $this->status;
  30.     }
  31.  
  32.     /**
  33.      * Returns new percentage value with associate new labels values.
  34.      *
  35.      * You can define label value even, if its not declared in progress bar;
  36.      * no error will be raised.
  37.      * See example default3.php and label id 'txt4' usage
  38.      *
  39.      * @return  array 
  40.      * @access  public
  41.      */
  42.     function getFullStatus()
  43.     {
  44.         $status $this->getStatus();
  45.  
  46.         if ($status['percentage'< 25{
  47.             $this->status['labels']['txt1''1st quarter';
  48.             $this->status['labels']['txt2''Q1';
  49.         elseif ($status['percentage'< 50{
  50.             $this->status['labels']['txt1''2nd quarter';
  51.             $this->status['labels']['txt2''Q2';
  52.         elseif ($status['percentage'< 75{
  53.             $this->status['labels']['txt1''3rd quarter';
  54.             $this->status['labels']['txt2''Q3';
  55.         else {
  56.             $this->status['labels']['txt1''4th quarter';
  57.             $this->status['labels']['txt4''Q4';
  58.         }
  59.  
  60.         return $this->status;
  61.     }
  62.  
  63.     /**
  64.      * Move on current user-task and returns full status of progress meter.
  65.      *
  66.      * Here we simulate a user-task that take many cycles to complete, and we
  67.      * don't know how many.
  68.      *
  69.      * @return  array 
  70.      * @access  public
  71.      */
  72.     function updateTask()
  73.     {
  74.         $this->_updateStatus();
  75.         return $this->getFullStatus();
  76.     }
  77.  
  78.     /**
  79.      * Move on current user-task and returns only new percentage of progress meter.
  80.      *
  81.      * Here we simulate a user-task that take many cycles to complete, and we
  82.      * don't know how many.
  83.      *
  84.      * @return  array 
  85.      * @access  public
  86.      */
  87.     function updatePercentage()
  88.     {
  89.         $this->_updateStatus();
  90.         return $this->getStatus();
  91.     }
  92.  
  93.     /**
  94.      * Updates only progress meter status
  95.      *
  96.      * @return  void 
  97.      * @access  private
  98.      */
  99.     function _updateStatus()
  100.     {
  101.         $newVal $_SESSION['progressPercentage'mt_rand(125);
  102.         $_SESSION['progressPercentage'min(100$newVal);
  103.         $this->status['percentage'$_SESSION['progressPercentage'];
  104.     }
  105. }
  106. ?>

Documentation generated on Mon, 11 Mar 2019 15:46:43 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.