home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / HTML / Progress / generator / preview.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  2.9 KB  |  81 lines

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