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

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2004 The PHP Group                                |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 3.0 of the PHP license,       |
  8. // | that is bundled with this package in the file LICENSE, and is        |
  9. // | available at through the world-wide-web at                           |
  10. // | http://www.php.net/license/3_0.txt.                                  |
  11. // | If you did not receive a copy of the PHP license and are unable to   |
  12. // | obtain it through the world-wide-web, please send a note to          |
  13. // | license@php.net so we can mail you a copy immediately.               |
  14. // +----------------------------------------------------------------------+
  15. // | Author: Laurent Laville <pear@laurent-laville.org>                   |
  16. // +----------------------------------------------------------------------+
  17. //
  18. // $Id: preview.php,v 1.1 2004/02/13 15:38:08 farell Exp $
  19.  
  20. /**
  21.  * The ActionPreview class provides a live demonstration
  22.  * of the progress bar built by HTML_Progress_Generator.
  23.  *
  24.  * @version    1.1
  25.  * @author     Laurent Laville <pear@laurent-laville.org>
  26.  * @access     public
  27.  * @category   HTML
  28.  * @package    HTML_Progress
  29.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  30.  */
  31.  
  32. class ActionPreview extends HTML_QuickForm_Action
  33. {
  34.     function perform(&$page, $actionName)
  35.     {
  36.         // like in Action_Next
  37.         $page->isFormBuilt() or $page->buildForm();
  38.         $page->handle('display');
  39.  
  40.         $strings = $page->controller->exportValue('page4','strings');
  41.         $bar = $page->controller->createProgressBar();
  42.  
  43.         do {
  44.             $percent = $bar->getPercentComplete();
  45.             if ($bar->isStringPainted()) {
  46.                 if (substr($strings, -1) == ";") {
  47.                     $str = explode(";", $strings);
  48.                 } else {
  49.                     $str = explode(";", $strings.";");
  50.                 }
  51.                 for ($i=0; $i<count($str)-1; $i++) {
  52.                     list ($p, $s) = explode(",", $str[$i]);
  53.                     if ($percent == floatval($p)/100) {
  54.                         $bar->setString(trim($s));
  55.                     }
  56.                 }
  57.             }
  58.             $bar->display();
  59.             if ($percent == 1) {
  60.                 break;   // the progress bar has reached 100%
  61.             }
  62.             $bar->incValue();
  63.         } while(1);
  64.     }
  65. }
  66. ?>