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

Source for file liteall.php

Documentation is available at liteall.php

  1. <!--
  2.   Demonstration of all the features of Progress2_Lite
  3.   version of Progress2 without any dependencies
  4.  
  5.   @version    $Id: liteall.php,v 1.1 2005/06/12 21:05:18 farell Exp $
  6.   @author     Laurent Laville <pear@laurent-laville.org>
  7.   @package    HTML_Progress2
  8.   @subpackage Examples
  9.   @access     public
  10. // -->
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  12.     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  13. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  14. <head>
  15. <title>Progress2 Lite - Full features </title>
  16. </head>
  17. <body>
  18. <?php
  19. require_once 'HTML/Progress2_Lite.php';
  20.  
  21. /**
  22.  * NOTE: The function {@link http://www.php.net/manual/en/function.usleep.php}
  23.  *       did not work on Windows systems until PHP 5.0.0
  24.  */
  25. function _sleep($usecs)
  26. {
  27.     if ((substr(PHP_OS03== 'WIN'&& (substr(PHP_VERSION,0,1'5') ){
  28.         for ($i=0; $i<$usecs$i++}
  29.     else {
  30.         usleep($usecs);
  31.     }
  32. }
  33.  
  34. $opt1 = array('left' => 50'top' => 50'width' => 40'height' => 270,
  35.     'padding' => 2,
  36.     'max' => 220
  37. );
  38. $pbl1 = new HTML_Progress2_Lite($opt1);
  39. $pbl1->addLabel('percent','pct1');
  40. $pct1 = array('left' => 50'top'35'width' => 40);
  41. $pbl1->setLabelAttributes('pct1'$pct1);
  42. $pbl1->setDirection('down');
  43. $pbl1->display();
  44.  
  45. $opt2 = array('left' => 120'top' => 50'height' => 40);
  46. $pbl2 = new HTML_Progress2_Lite($opt2);
  47. $pbl2->setBarAttributes(array(
  48.     'border-width' => 2,
  49.     'border-color' => '#660066',
  50.     'color' => '#6699FF',
  51.     'background-color' => '#000000'
  52. ));
  53. $pbl2->addLabel('crossbar','crt1');
  54. $crt1 = array('left' => 120'top' => 30);
  55. $pbl2->setLabelAttributes('crt1'$crt1);
  56. $pbl2->display();
  57.  
  58. $opt3 = array('left' => 120'top' => 120'width' => 400'height' => 70);
  59. $pbl3 = new HTML_Progress2_Lite($opt3);
  60. $pbl3->setBarAttributes(array(
  61.     'color' => '#FF6633',
  62.     'background-color' => 'yellow'
  63. ));
  64. $pbl3->setDirection('left');
  65. $pbl3->addLabel('text','txt1');
  66. $pbl3->setLabelAttributes('txt1'array('color' => 'orange'));
  67. $pbl3->display();
  68.  
  69. $opt4 = array('left' => 120'top' => 220'width' => 600'height' => 100,
  70.     'min' => 50,
  71.     'max' => 150
  72. );
  73. $pbl4 = new HTML_Progress2_Lite($opt4);
  74. $pbl4->setBarAttributes(array(
  75.     'border-width' => 0,
  76.     'color' => '#CCCC66',
  77.     'background-color' => '#66CCFF'
  78. ));
  79. $pbl4->addLabel('percent','pct1');
  80. $pct1 = array('left' => 120'top' => 220'width' => 600'height' => 100,
  81.     'align' => 'center',
  82.     'font-size' => 78
  83. );
  84. $pbl4->setLabelAttributes('pct1'$pct1);
  85. $pbl4->display();
  86.  
  87.  
  88. for($i=1; $i<=220; $i++{
  89.     $pbl1->moveStep($i);
  90.     if ($i==50{$pbl2->hide();}
  91.     if ($i==100{$pbl3->hide();}
  92.     if ($i==200{$pbl4->hide();}
  93.     _sleep(10000);
  94. }
  95. $pbl1->moveMin();
  96. $pbl1->setDirection('up');
  97.  
  98. $pbl2->show();
  99. for($i=1; $i<=100; $i++{
  100.     $pbl2->moveStep($i);
  101.     $crt1 = array('left' => ($i * 3+ 120'top' => 30,
  102.         'width' => 10'height' => 0,
  103.         'align' => 'center');
  104.     $pbl2->setLabelAttributes('crt1'$crt1);
  105.     $pbl2->setBarAttributes(array(
  106.         'color' => '#00'.dechex(100-$i+100).dechex($i+80)
  107.     ));
  108.     $pbl1->moveNext();
  109.     _sleep(100000);
  110. }
  111. $pbl2->setLabelAttributes('crt1'array('value' => ''));
  112.  
  113. $pbl3->show();
  114. $pbl3->setLabelAttributes('txt1'array('value' => 'searching ...'));
  115. for($i=1; $i<=100; $i++{
  116.     if($i==30{
  117.         $pbl3->setLabelAttributes('txt1'array('value' => 'loading ...'));
  118.     }
  119.     if($i==60{
  120.         $pbl3->setLabelAttributes('txt1'array('value' => 'writing ...'));
  121.     }
  122.     $pbl3->moveStep($i);
  123.     $pbl1->moveNext();
  124.     _sleep(100000);
  125. }
  126. $pbl3->setLabelAttributes('txt1'array('value' => 'complete'));
  127.  
  128. $pbl4->show();
  129. for($i=50; $i<=150; $i+=5{
  130.     $pbl4->moveStep($i);
  131.     $pbl1->moveNext();
  132.     sleep(1);
  133. }
  134. ?>
  135. </body>
  136. </html>

Documentation generated on Mon, 11 Mar 2019 14:16:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.