false); // ProgressBar Frame /* 'show' => false, # frame show (true/false) 'left' => 200, # frame position from left 'top' => 100, # frame position from top 'width' => 300, # frame width 'height' => 75, # frame height 'color' => '#c0c0c0', # frame color 'border' => 2, # frame border 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' # frame border color */ var $label = array(); // ProgressBar Labels /* 'name' => array( # label name 'type' => 'text', # label type (text,button,step,percent,crossbar) 'value' => 'Please wait ...', # label value 'left' => 10, # label position from left 'top' => 20, # label position from top 'width' => 0, # label width 'height' => 0, # label height 'align' => 'left', # label align 'font-size' => 11, # label font size 'font-family' => 'Verdana, Tahoma, Arial', # label font family 'font-weight' => '', # label font weight 'color' => '#000000', # label font color 'bgr_color' => '' # label background color ) */ // constructor function ProgressBar($width=0,$height=0) { $this->code = substr(md5(microtime()), 0, 6); if ($width>0) {$this->width = $width;} if ($height>0) {$this->height = $height;} } // private functions function _calculatePercent($step) { $percent = round(($step - $this->min) / ($this->max - $this->min) * 100); if ($percent > 100) {$percent = 100;} return $percent; } function _calculatePosition($step) { switch ($this->direction) { case 'right': case 'left': $bar = $this->width; break; case 'down': case 'up': $bar = $this->height; break; } $pixel = round(($step - $this->min) * ($bar - ($this->pedding * 2)) / ($this->max - $this->min)); if ($step <= $this->min) {$pixel = 0;} if ($step >= $this->max) {$pixel = $bar - ($this->pedding * 2);} switch ($this->direction) { case 'right': $position['left'] = $this->pedding; $position['top'] = $this->pedding; $position['width'] = $pixel; $position['height'] = $this->height - ($this->pedding * 2); break; case 'left': $position['left'] = $this->width - $this->pedding - $pixel; $position['top'] = $this->pedding; $position['width'] = $pixel; $position['height'] = $this->height - ($this->pedding * 2); break; case 'down': $position['left'] = $this->pedding; $position['top'] = $this->pedding; $position['width'] = $this->width - ($this->pedding * 2); $position['height'] = $pixel; break; case 'up': $position['left'] = $this->pedding; $position['top'] = $this->height - $this->pedding - $pixel; $position['width'] = $this->width - ($this->pedding * 2); $position['height'] = $pixel; break; } return $position; } function _setStep($step) { if ($step > $this->max) {$step = $this->max;} if ($step < $this->min) {$step = $this->min;} $this->step = $step; } // public functions function setFrame($width=0,$height=0) { $this->frame = array( 'show' => true, 'left' => 20, 'top' => 35, 'width' => 320, 'height' => 90, 'color' => '#c0c0c0', 'border' => 2, 'brd_color' => '#dfdfdf #404040 #404040 #dfdfdf' ); if ($width>0) {$this->frame['width'] = $width;} if ($height>0) {$this->frame['height'] = $height;} } function addLabel($type,$name,$value=' ') { switch($type) { case 'text': $this->label[$name] = array( 'type' => 'text', 'value' => $value, 'left' => $this->left, 'top' => $this->top - 16, 'width' => 0, 'height' => 0, 'align' => 'left', 'font-size' => 11, 'font-family' => 'Verdana, Tahoma, Arial', 'font-weight' => 'normal', 'color' => '#000000', 'bgr_color' => '' ); break; case 'button': $this->label[$name] = array( 'type' => 'button', 'value' => $value, 'action' => '', 'target' => 'self', 'left' => $this->left, 'top' => $this->top + $this->height + 10, 'width' => 0, 'height' => 0, 'align' => 'center', 'font-size' => 11, 'font-family' => 'Verdana, Tahoma, Arial', 'font-weight' => 'normal', 'color' => '#000000', 'bgr_color' => '' ); break; case 'step': $this->label[$name] = array( 'type' => 'step', 'value' => $value, 'left' => $this->left + 5, 'top' => $this->top + 5, 'width' => 10, 'height' => 0, 'align' => 'right', 'font-size' => 11, 'font-family' => 'Verdana, Tahoma, Arial', 'font-weight' => 'normal', 'color' => '#000000', 'bgr_color' => '' ); break; case 'percent': $this->label[$name] = array( 'type' => 'percent', 'value' => $value, 'left' => $this->left + $this->width - 50, 'top' => $this->top - 16, 'width' => 50, 'height' => 0, 'align' => 'right', 'font-size' => 11, 'font-family' => 'Verdana, Tahoma, Arial', 'font-weight' => 'normal', 'color' => '#000000', 'bgr_color' => '' ); break; case 'crossbar': $this->label[$name] = array( 'type' => 'crossbar', 'value' => $value, 'left' => $this->left + ($this->width / 2), 'top' => $this->top - 16, 'width' => 10, 'height' => 0, 'align' => 'center', 'font-size' => 11, 'font-family' => 'Verdana, Tahoma, Arial', 'font-weight' => 'normal', 'color' => '#000000', 'bgr_color' => '' ); break; } } function addButton($name,$value,$action,$target='self') { $this->addLabel('button',$name,$value); $this->label[$name]['action'] = $action; $this->label[$name]['target'] = $target; } function setLabelPosition($name,$left,$top,$width,$height,$align='') { $this->label[$name]['top'] = intval($top); $this->label[$name]['left'] = intval($left); $this->label[$name]['width'] = intval($width); $this->label[$name]['height'] = intval($height); if ($align!='') {$this->label[$name]['align'] = $align;} if ($this->status!='new') { echo ''."\n"; flush(); } } function setLabelColor($name,$color) { $this->label[$name]['color'] = $color; if ($this->status!='new') { echo ''."\n"; flush(); } } function setLabelBackground($name,$color) { $this->label[$name]['bgr_color'] = $color; if ($this->status!='new') { echo ''."\n"; flush(); } } function setLabelFont($name,$size,$family='',$weight='') { $this->label[$name]['font-size'] = intval($size); if ($family!='') {$this->label[$name]['font-family'] = $family;} if ($weight!='') {$this->label[$name]['font-weight'] = $weight;} if ($this->status!='new') { echo ''."\n"; flush(); } } function setLabelValue($name,$value) { $this->label[$name]['value'] = $value; if ($this->status!='new') { echo ''."\n"; flush(); } } function setBarColor($color) { $this->color = $color; if ($this->status!='new') { echo ''."\n"; flush(); } } function setBarBackground($color) { $this->bgr_color = $color; if ($this->status!='new') { echo ''."\n"; flush(); } } function setBarDirection($direction) { $this->direction = $direction; if ($this->status!='new') { $this->position = $this->_calculatePosition($this->step); echo ''."\n"; flush(); } } function getHtml() { $html = ''; $js = ''; $this->_setStep($this->step); $this->position = $this->_calculatePosition($this->step); $style_brd = 'position:absolute;top:'.$this->top.'px;left:'.$this->left.'px;width:'.$this->width.'px;height:'.$this->height.'px;background:'.$this->bgr_color.';'; if ($this->border>0) {$style_brd .= 'border:'.$this->border.'px solid;border-color:'.$this->brd_color.';';} $style_bar = 'position:absolute;top:'.$this->position['top'].'px;left:'.$this->position['left'].'px;'.'width:'.$this->position['width'].'px;height:'.$this->position['height'].'px;background:'.$this->color.';'; if ($this->frame['show']==true) { if ($this->frame['border']>0) {$border = 'border:'.$this->frame['border'].'px solid;border-color:'.$this->frame['brd_color'].';';} $html = '