[ PHPXref.com ] [ Generated: Sun Jul 20 20:24:08 2008 ] [ Smart Publisher 1.0.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/libraries/ -> cprogbar.php (source)

   1  <?
   2  include_once ("html.php");
   3  include_once ("ctable.php");
   4  
   5  define("SHIM_H14","<img src=images/shim.png width=1 height=14 border=0>");
   6  
   7  class CProgbar
   8  {
   9      var $Id;
  10      var $CurPos=0;
  11      var $CurPosInt=0;
  12      var $Max=100;
  13      var $Step=1;
  14      
  15  	function CProgbar($id,$pos=0)
  16      {
  17          $this->Id=$id;
  18          $this->CurPos=$pos;
  19          $this->CurPosInt=(int)$pos;
  20      }
  21      
  22  	function show($text="",$width='100%',$border='#909090',$bgcolor='#ff8400')
  23      {
  24          $pos=$this->CurPosInt;
  25          $tbl=new CTable($width ? "width='$width'" : "","class=progbar");
  26          $tbl->tr();
  27          $tbl->td
  28          (
  29              ($pos?"$pos%":"&nbsp;"),
  30              "align=center",
  31              "style='border-left:1px solid $border;border-top:1px solid $border;border-bottom:1px solid $border'",
  32              "id='Prog_".$this->Id."_Txt'",
  33              "width=40"
  34          );
  35          if ($text) $pos=100;
  36          $tbl->td
  37          (
  38              "<div style='border:1px solid $border;width:100%;'>".
  39              "<div id='Prog_".$this->Id."' style='width:$pos%;height:14px;background:$bgcolor'>".
  40              "$text</div></div>"
  41          );
  42          return $tbl->html();
  43      }
  44  
  45  	function init($max=100,$frame='')
  46      {
  47          $this->Max=($max<100) ? 100 : $max;
  48          $this->Step=$max ? 100/$max : 100;
  49          print
  50          (
  51              "<script>var show=false;".
  52              "var docP=parent.document".($frame?".frames['$frame'].document":"").";".
  53              "if(!docP) alert('Frame \'$frame\' does not exists!');".
  54              "var elP=docP.getElementById('Prog_".$this->Id."');".
  55              "var elPT=docP.getElementById('Prog_".$this->Id."_Txt');".
  56              "if(!elP) alert('Progbar \'".$this->Id."\' does not exists!');".
  57              "function progbar(percent){".
  58              "if(!elP) return;".
  59              "elP.style.textAlign='';".
  60              "elP.style.width=percent;".
  61              "elP.innerHTML='".SHIM_H14."';".
  62              "elPT.innerHTML=percent;}".
  63              "function progbar_text(text,color,bgcolor,fontWeight){".
  64              "if(!elP) return;".
  65              "elP.style.width='100%';".
  66              "if (color) elP.style.color=color;".
  67              "if (bgcolor) elP.style.backgroundColor=bgcolor;".
  68              "if (fontWeight) elP.style.fontWeight=fontWeight;".
  69              "elP.style.textAlign='center';".
  70              "elP.innerHTML=text;}".
  71              "</script>\n"
  72          );
  73          flush();
  74      }
  75  
  76  	function step()
  77      {
  78          $this->CurPos+=$this->Step;
  79          if ((int)$this->CurPos>$this->CurPosInt)
  80          {
  81              $this->CurPosInt=(int)$this->CurPos;
  82              if ($this->CurPosInt>$this->Max) $this->CurPos=$this->CurPosInt=$this->Max;
  83              print("<script>progbar('".$this->CurPosInt."%');</script>\n");
  84              flush();
  85          }
  86      }
  87  
  88  	function full()
  89      {
  90          $this->CurPos=$this->CurPosInt=100;
  91          print("<script>progbar('100%');</script>\n");
  92          flush();
  93      }
  94  
  95  	function text($text,$color="",$bgcolor="",$fontWeight="normal")
  96      {
  97          if($text)
  98          {
  99              print("<script>progbar_text('".addslashes($text)."','$color','$bgcolor','$fontWeight');</script>\n");
 100              flush();
 101          }
 102      }
 103  
 104  	function error($text,$color="#ffffff",$bgcolor="#ff0000",$fontWeight="bold")
 105      {
 106          $this->text($text,$color,$bgcolor,$fontWeight);
 107      }
 108  }
 109  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]