From 77fd33e471acaf5e219967130e4eba5cc17f579a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 29 Feb 2004 09:51:45 +0000 Subject: [PATCH] 1) fix for bug #905284, etemplate does not show images if webserver_url contains protocoll and domain 2) added a new progress-bar --- phpgwapi/inc/class.html.inc.php | 38 +++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index e3d7cbdb95..ce9a074c27 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -28,16 +28,9 @@ list(,$this->user_agent,$this->ua_version) = $parts; $this->user_agent = strtolower($this->user_agent); - $this->prefered_img_title = $this->user_agent == 'mozilla' && $this->ua_version < 5 ? 'alt' : 'title'; - //echo "

HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; - - $this->document_root = $_SERVER['DOCUMENT_ROOT']; - // this is because some webservers report their docroot without the leading slash - if (!is_dir($this->document_root) && is_dir('/'.$this->document_root)) - { - $this->document_root = '/' . $this->document_root; - } - //echo "

_SERVER[DOCUMENT_ROOT]='$_SERVER[DOCUMENT_ROOT]', this->document_root='$this->document_root'

\n"; + $this->netscape4 = $this->user_agent == 'mozilla' && $this->ua_version < 5; + $this->prefered_img_title = $this->netscape4 ? 'alt' : 'title'; + //echo "

HTTP_USER_AGENT='$_SERVER[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; if ($GLOBALS['phpgw']->translation) { @@ -373,6 +366,24 @@ return $html; } + function progressbar( $percent,$title='',$options='',$width='',$color='',$height='' ) + { + $percent = (int) $percent; + if (!$width) $width = '30px'; + if (!$height)$height= '5px'; + if (!$color) $color = '#D00000'; + $title = $title ? $this->htmlspecialchars($title) : $percent.'%'; + + if ($this->netscape4) + { + return $title; + } + return '
'."\n\t". + '
'."\n
\n"; + } + function image( $app,$name,$title='',$options='' ) { $name = str_replace(array('.gif','.GIF','.png','.PNG'),'',$name); @@ -381,8 +392,13 @@ { $path = $name; // name may already contain absolut path } - if (!@is_readable($this->document_root . $path)) + if (!@is_readable(str_replace($GLOBALS['phpgw_info']['server']['webserver_url'],PHPGW_SERVER_ROOT,$path))) { + // if the image-name is a percentage, use a progressbar + if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1))) + { + return $this->progressbar($percent,$title); + } return $title; } if ($title)