home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / progressHandler.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  2.2 KB  |  78 lines

  1. <?php
  2. /**
  3.  * Few examples of user-callback
  4.  * to use with Progress Monitor.
  5.  *
  6.  * @version    $Id: progressHandler.php,v 1.1 2004/02/10 12:01:24 farell Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_Progress
  9.  */
  10.  
  11. function myFunctionHandler($progressValue, &$obj)
  12. {
  13.     $bar =& $obj->getProgressElement();
  14.     if (!$bar->isIndeterminate()) {
  15.         if (fmod($progressValue,10) == 0) {
  16.             $obj->setCaption("myFunctionHandler -> progress value is = $progressValue");
  17.         }
  18.     } else {
  19.         /* in case we have attached an indeterminate progress bar to the monitor ($obj)
  20.            after a first pass that reached 60%, 
  21.            we swap from indeterminate mode to determinate mode
  22.            and run a standard progress bar from 0 to 100%
  23.         */   
  24.         if ($progressValue == 60) {
  25.             $bar->setIndeterminate(false);
  26.             $bar->setString(null);           // show percent-info
  27.             $bar->setValue(0);
  28.         }
  29.     }
  30. }
  31.  
  32. class myClassHandler
  33. {
  34.     function myMethodHandler($progressValue, &$obj)
  35.     {
  36.         if (fmod($progressValue,10) == 0) {
  37.             echo "myMethodHandler -> progress value is = $progressValue <br/>\n";
  38.         }
  39.     }
  40. }
  41.  
  42. class my2ClassHandler
  43. {
  44.     function my1Method($progressValue, &$obj)
  45.     {
  46.         switch ($progressValue) {
  47.          case 10:
  48.             $pic = 'picture1.jpg';
  49.             break;
  50.          case 45:
  51.             $pic = 'picture2.jpg';
  52.             break;
  53.          case 70:
  54.             $pic = 'picture3.jpg';
  55.             break;
  56.          default:
  57.             $pic = null;
  58.         }
  59.         if (!is_null($pic)) {
  60.             $obj->setCaption('upload <b>%file%</b> in progress ... Start at %percent%%',
  61.                               array('file'=>$pic, 'percent'=>$progressValue)
  62.                              );
  63.         }
  64.     }
  65. }
  66.  
  67. function logger($progressValue, &$obj)
  68. {
  69.     include_once 'Log.php';
  70.     $logger = &Log::singleton('file', 'monitor.log', $_SERVER['REMOTE_ADDR']);
  71.  
  72.     if (fmod($progressValue,25) == 0) {
  73.         $logger->info("$progressValue % has been reached");
  74.     } else {
  75.         $logger->debug("Progress ... $progressValue %");
  76.     }
  77. }
  78. ?>