2011-11-25 Sergio Martin <sergio.martin@artica.es>

* include/graphs/functions_gd.php: Fixed rounded corners in progress bar
	graphs for bug 3442005



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@5172 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
zarzuelo 2011-11-25 11:43:23 +00:00
parent 765f78ee12
commit 01afa82637
2 changed files with 60 additions and 17 deletions

View File

@ -1,3 +1,8 @@
2011-11-25 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_gd.php: Fixed rounded corners in progress bar
graphs for bug 3442005
2011-11-25 Juan Manuel Ramon <juanmanuel.ramon@artica.es> 2011-11-25 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* include/functions_agents.php: Fixed sql error in agents_get_agents * include/functions_agents.php: Fixed sql error in agents_get_agents

View File

@ -164,7 +164,15 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode, $fontsize) { function drawRating($rating, $width, $height, $font, $out_of_lim_str, $mode, $fontsize) {
global $config; global $config;
global $REMOTE_ADDR; global $REMOTE_ADDR;
// Round corners defined in global setup
if ($config["round_corner"] != 0) {
$radius = ($height > 18) ? 8 : 0;
}
else {
$radius = 0;
}
if ($width == 0) { if ($width == 0) {
$width = 150; $width = 150;
} }
@ -192,30 +200,28 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
$soft_red = ImageColorAllocate($image,255, 154, 84); $soft_red = ImageColorAllocate($image,255, 154, 84);
$other_red = ImageColorAllocate($image,238, 0, 0); $other_red = ImageColorAllocate($image,238, 0, 0);
ImageFilledRectangle($image,0,0,$width-1,$height-1,$back); ImageRectangleWithRoundedCorners($image,0,0,$width-1,$height-1,$radius,$back,false);
switch ($mode) switch ($mode)
{ {
case 0: case 0:
if ($rating > 70) if ($rating > 70)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_green); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_green, $border);
elseif ($rating > 50) elseif ($rating > 50)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_yellow); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_yellow, $border);
elseif ($rating > 30) elseif ($rating > 30)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_red); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_red, $border);
else else
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $other_red); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $other_red, $border);
ImageRectangle($image,0,0,$width-1,$height-1,$border);
break; break;
case 1: case 1:
if ($rating > 100) if ($rating > 100)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$red); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$red, $border);
elseif ($rating == 100) elseif ($rating == 100)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$green); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$green, $border);
else else
ImageFilledRectangle($image,1,1,$ratingbar,$height-1,$blue); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1,$radius,$blue, $border);
ImageRectangle($image,0,0,$width-1,$height-1,$border);
if ($rating > 50) if ($rating > 50)
if ($rating > 100) if ($rating > 100)
@ -227,21 +233,53 @@ function gd_progress_bar ($width, $height, $progress, $title, $font, $out_of_lim
break; break;
case 2: case 2:
if ($rating > 70) if ($rating > 70)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $other_red); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $other_red, $border);
elseif ($rating > 50) elseif ($rating > 50)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_red); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_red, $border);
elseif ($rating > 30) elseif ($rating > 30)
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_yellow); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_yellow, $border);
else else
ImageFilledRectangle($image,1,1,$ratingbar,$height-1, $soft_green); ImageRectangleWithRoundedCorners($image,1,1,$ratingbar,$height-1, $radius, $soft_green, $border);
ImageRectangle($image,0,0,$width-1,$height-1,$border);
break; break;
} }
/*
ImageRectangle($image,0,0,$width-1,$height-1,$border);
*/
imagePNG($image); imagePNG($image);
imagedestroy($image); imagedestroy($image);
}
}
function ImageRectangleWithRoundedCorners(&$im, $x1, $y1, $x2, $y2, $radius, $color, $bordercolor)
{
// Draw rectangle without corners
ImageFilledRectangle($im, $x1+$radius, $y1, $x2-$radius, $y2, $color);
ImageFilledRectangle($im, $x1, $y1+$radius, $x2, $y2-$radius, $color);
// Draw circled corners
ImageFilledEllipse($im, $x1+$radius, $y1+$radius, $radius*2, $radius*2, $color);
ImageFilledEllipse($im, $x2-$radius, $y1+$radius, $radius*2, $radius*2, $color);
ImageFilledEllipse($im, $x1+$radius, $y2-$radius, $radius*2, $radius*2, $color);
ImageFilledEllipse($im, $x2-$radius, $y2-$radius, $radius*2, $radius*2, $color);
if($bordercolor !== false) {
$x1--;
$y1--;
$x2++;
imageline($im, $x1+$radius, $y1, $x2-$radius, $y1, $bordercolor);
imageline($im, $x1+$radius, $y2, $x2-$radius, $y2, $bordercolor);
imageline($im, $x1, $y1+$radius, $x1, $y2-$radius, $bordercolor);
imageline($im, $x2, $y1+$radius, $x2, $y2-$radius, $bordercolor);
imagearc($im,$x1+$radius, $y1+$radius, $radius*2, $radius*2, 180 , 270, $bordercolor);
imagearc($im,$x2-$radius, $y1+$radius, $radius*2, $radius*2, 270 , 360, $bordercolor);
imagearc($im,$x1+$radius, $y2-$radius, $radius*2, $radius*2, 90 , 180, $bordercolor);
imagearc($im,$x2-$radius, $y2-$radius, $radius*2, $radius*2, 360 , 90, $bordercolor);
}
}
Header("Content-type: image/png"); Header("Content-type: image/png");
switch ($mode) switch ($mode)