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

Source for file process.php

Documentation is available at process.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PEAR :: HTML :: Progress                                             |
  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: process.php,v 1.3 2004/07/03 14:48:31 farell Exp $
  19.  
  20. /**
  21.  * The ActionProcess class provides final step of ProgressBar creation.
  22.  * Manage php/css source-code save and cancel action.
  23.  *
  24.  * @version    1.2.0
  25.  * @author     Laurent Laville <pear@laurent-laville.org>
  26.  * @access     public
  27.  * @package    HTML_Progress
  28.  * @subpackage Progress_UI
  29.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  30.  */
  31.  
  32. class ActionProcess extends HTML_QuickForm_Action
  33. {
  34.     function perform(&$page$actionName)
  35.     {
  36.         if ($actionName == 'cancel'{
  37.             echo '<h1>Progress Generator Task was canceled</h1>';
  38.             echo '<p>None (PHP/CSS) source codes are available.</p>';
  39.         else {
  40.             // Checks whether the pages of the controller are valid
  41.             $page->isFormBuilt(or $page->buildForm();
  42.             $page->controller->isValid();
  43.  
  44.             // what kind of source code is requested  
  45.             $code $page->exportValue('phpcss');
  46.             $bar $page->controller->createProgressBar();
  47.             
  48.             if (isset($code['C'])) {
  49.                 $this->exportOutput($bar->getStyle());
  50.             }
  51.  
  52.             if (isset($code['P'])) {
  53.                 $structure $bar->toArray();
  54.  
  55.                 $lineEnd = OS_WINDOWS ? "\r\n" "\n";
  56.                 
  57.                 $strPHP  '<?php'.$lineEnd;
  58.                 $strPHP .= 'require_once \'HTML/Progress.php\';'.$lineEnd.$lineEnd;
  59.                 $strPHP .= '$progress = new HTML_Progress();'.$lineEnd;
  60.                 $strPHP .= '$progress->setIdent(\'PB1\');'.$lineEnd;
  61.                     
  62.                 if ($bar->isIndeterminate()) {
  63.                     $strPHP .= '$progress->setIndeterminate(true);'.$lineEnd;
  64.                 }
  65.                 if ($bar->isBorderPainted()) {
  66.                     $strPHP .= '$progress->setBorderPainted(true);'.$lineEnd;
  67.                 }
  68.                 if ($bar->isStringPainted()) {
  69.                     $strPHP .= '$progress->setStringPainted(true);'.$lineEnd;
  70.                 }
  71.                 if (is_null($structure['string'])) {
  72.                     $strPHP .= '$progress->setString(null);';
  73.                 else {
  74.                     $strPHP .= '$progress->setString('.$structure['string'].');';
  75.                 }
  76.                 $strPHP .= $lineEnd;
  77.                 if ($structure['animspeed'> 0{
  78.                     $strPHP .= '$progress->setAnimSpeed('.$structure['animspeed'].');'.$lineEnd;
  79.                 }
  80.                 if ($structure['dm']['minimum'!= 0{
  81.                     $strPHP .= '$progress->setMinimum('.$structure['dm']['minimum'].');'.$lineEnd;
  82.                 }
  83.                 if ($structure['dm']['maximum'!= 100{
  84.                     $strPHP .= '$progress->setMaximum('.$structure['dm']['maximum'].');'.$lineEnd;
  85.                 }
  86.                 if ($structure['dm']['increment'!= 1{
  87.                     $strPHP .= '$progress->setIncrement('.$structure['dm']['increment'].');'.$lineEnd;
  88.                 }
  89.                 $strPHP .= $lineEnd;
  90.                 $strPHP .= '$ui =& $progress->getUI();'.$lineEnd;
  91.  
  92.                 $orient ($structure['ui']['orientation'== '1''HTML_PROGRESS_BAR_HORIZONTAL' 'HTML_PROGRESS_BAR_VERTICAL';
  93.                 $strPHP .= '$ui->setOrientation('.$orient.');'.$lineEnd;
  94.                 $strPHP .= '$ui->setFillWay(\''.$structure['ui']['fillway'].'\');'.$lineEnd;
  95.  
  96.             /* Page 1: Progress attributes **************************************************/
  97.                 $strPHP .= $this->_attributesArray('$ui->setProgressAttributes('$structure['ui']['progress']);
  98.                 $strPHP .= $lineEnd;
  99.  
  100.             /* Page 2: Cell attributes ******************************************************/
  101.                 $strPHP .= '$ui->setCellCount('.$structure['ui']['cell']['count'].');'.$lineEnd;
  102.                 unset($structure['ui']['cell']['count']);  // to avoid dupplicate entry in attributes
  103.                 $strPHP .= $this->_attributesArray('$ui->setCellAttributes('$structure['ui']['cell']);
  104.                 $strPHP .= $lineEnd;
  105.  
  106.             /* Page 3: Border attributes ****************************************************/
  107.                 $strPHP .= $this->_attributesArray('$ui->setBorderAttributes('$structure['ui']['border']);
  108.                 $strPHP .= $lineEnd;
  109.  
  110.             /* Page 4: String attributes ****************************************************/
  111.                 $strPHP .= $this->_attributesArray('$ui->setStringAttributes('$structure['ui']['string']);
  112.                 $strPHP .= $lineEnd.$lineEnd;
  113.  
  114.                 $strPHP .= '// code below is only for run demo; its not ncecessary to create progress bar'.$lineEnd;
  115.                 $strPHP .= 'echo \'<style type="text/css">\'.$progress->getStyle().\'</style>\';'.$lineEnd;
  116.                 $strPHP .= 'echo \'<script type="text/javascript">\'.$progress->getScript().\'</script>\';'.$lineEnd;
  117.                 $strPHP .= 'echo $progress->toHtml();'.$lineEnd;
  118.                 $strPHP .= '$progress->run();'.$lineEnd;
  119.                 $strPHP .= '?>';
  120.                 $this->exportOutput($strPHP);
  121.             }
  122.  
  123.             // reset session data
  124.             $page->controller->container(true);
  125.         }
  126.     }
  127.  
  128.     function exportOutput($str$mime 'text/plain'$charset 'iso-8859-1')
  129.     {
  130.         if (!headers_sent()) {
  131.             header("Expires: Tue, 1 Jan 1980 12:00:00 GMT");
  132.             header("Last-Modified: " gmdate("D, d M Y H:i:s"" GMT");
  133.             header("Cache-Control: no-cache");
  134.             header("Pragma: no-cache");
  135.             header("Content-Type: $mime; charset=$charset");
  136.         }
  137.         print $str;
  138.     }
  139.  
  140.     function _attributesArray($str$attributes)
  141.     {
  142.         $strPHP $str 'array(';
  143.         foreach ($attributes as $attr => $val{
  144.             if (is_integer($val)) {
  145.                 $strPHP .= "'$attr'=>$val";
  146.             elseif (is_bool($val)) {
  147.                 $strPHP .= "'$attr'=>".($val?'true':'false').', ';
  148.             else {
  149.                 $strPHP .= "'$attr'=>'$val', ";
  150.             }   
  151.         }
  152.         $strPHP ereg_replace(', $'''$strPHP);
  153.         $strPHP .= '));';
  154.         return $strPHP;
  155.     }
  156. }
  157. ?>

Documentation generated on Mon, 11 Mar 2019 13:52:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.