From f61e52640f7f11cd8672641a6740bf9b68ac8e59 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Sat, 10 Jan 2004 15:14:01 +0000 Subject: [PATCH] formatting --- phpgwapi/inc/class.gdgraph.inc.php | 146 +++++++++++++++-------------- phpgwapi/inc/class.gdimage.inc.php | 66 ++++++++----- 2 files changed, 122 insertions(+), 90 deletions(-) diff --git a/phpgwapi/inc/class.gdgraph.inc.php b/phpgwapi/inc/class.gdgraph.inc.php index 5b6a5d1434..944378980b 100644 --- a/phpgwapi/inc/class.gdgraph.inc.php +++ b/phpgwapi/inc/class.gdgraph.inc.php @@ -2,7 +2,7 @@ /*******************************************************************\ * phpGroupWare - GD Graph * * http://www.phpgroupware.org * - * This program is part of the GNU project, see http://www.gnu.org/ * + * This program is part of the GNU project, see http://www.gnu.org/ * * * * Written by Bettina Gille [ceb@phpgroupware.org] * * * @@ -50,7 +50,7 @@ var $margin_bottom; var $margin_right; var $img; - + function gdgraph($debug = False) { $this->debug = $debug; @@ -83,7 +83,7 @@ $this->img = CreateObject('phpgwapi.gdimage'); $this->temp_file = $this->img->temp_file; } - + function rRender() { // Initialize image - map white since it's our background @@ -148,12 +148,16 @@ while (list($junk2, $value) = each($line)) { if ($value > $largest) - $largest = $value; + { + $largest = $value; + } } } while ($largest < ($this->num_lines_y - 1)) + { $largest = ($this->num_lines_y - 1); + } $spread = ceil($largest / ($this->num_lines_y - 1)); $largest = $spread * ($this->num_lines_y - 1);*/ @@ -284,71 +288,77 @@ function Open() { - print(''); - } - - function Show() - { - $this->FromURL(); - $this->Render(); - } - - function FromURL() - { - $this->title = $GLOBALS['title']; - $this->caption_x = $GLOBALS['caption_x']; - $this->caption_y = $GLOBALS['caption_y']; - $this->num_lines_x = $GLOBALS['num_lines_x']; - $this->num_lines_y = $GLOBALS['num_lines_y']; - $this->line_captions_x = explode(',', $GLOBALS['line_captions_x']); - - $dataURL = explode('~', $GLOBALS['data']); - $this->data = array(); - while (list($junk, $line) = each($dataURL)) - $this->data[] = explode(',', $line); - - $this->colors = explode(',', $GLOBALS['colors']); - $this->color_legend = explode(',', $GLOBALS['color_legend']); - $this->graph_width = $GLOBALS['graph_width']; - $this->graph_height = $GLOBALS['graph_height']; - $this->margin_top = $GLOBALS['margin_top']; - $this->margin_left = $GLOBALS['margin_left']; - $this->margin_bottom = $GLOBALS['margin_bottom']; - $this->margin_right = $GLOBALS['margin_right']; - } - - function ToURL() - { - $url = 'title=' . rawurlencode($this->title) . '&'; - $url .= 'caption_x=' . rawurlencode($this->caption_x) . '&'; - $url .= 'caption_y=' . rawurlencode($this->caption_y) . '&'; - $url .= 'num_lines_x=' . $this->num_lines_x . '&'; - $url .= 'num_lines_y=' . $this->num_lines_y . '&'; - $url .= 'line_captions_x=' . rawurlencode(implode(',', $this->line_captions_x)) . '&'; - reset($this->data); - $dataURL = ''; - while(list($junk, $line) = each($this->data)) - { - if ($dataURL != '') - $dataURL .= '~'; - $dataURL .= implode(',', $line); + print(''); } - $url .= 'data=' . $dataURL . '&'; - $url .= 'colors=' . implode(',', $this->colors) . '&'; - $url .= 'color_legend=' . rawurlencode(implode(',', $this->color_legend)) . '&'; - $url .= 'graph_width=' . $this->graph_width . '&'; - $url .= 'graph_height=' . $this->graph_height . '&'; - $url .= 'margin_top=' . $this->margin_top . '&'; - $url .= 'margin_left=' . $this->margin_left . '&'; - $url .= 'margin_bottom=' . $this->margin_bottom . '&'; - $url .= 'margin_right=' . $this->margin_right; - return $url; - } + function Show() + { + $this->FromURL(); + $this->Render(); + } + + function FromURL() + { + $this->title = $GLOBALS['title']; + $this->caption_x = $GLOBALS['caption_x']; + $this->caption_y = $GLOBALS['caption_y']; + $this->num_lines_x = $GLOBALS['num_lines_x']; + $this->num_lines_y = $GLOBALS['num_lines_y']; + $this->line_captions_x = explode(',', $GLOBALS['line_captions_x']); + + $dataURL = explode('~', $GLOBALS['data']); + $this->data = array(); + while (list($junk, $line) = each($dataURL)) + { + $this->data[] = explode(',', $line); + } + + $this->colors = explode(',', $GLOBALS['colors']); + $this->color_legend = explode(',', $GLOBALS['color_legend']); + $this->graph_width = $GLOBALS['graph_width']; + $this->graph_height = $GLOBALS['graph_height']; + $this->margin_top = $GLOBALS['margin_top']; + $this->margin_left = $GLOBALS['margin_left']; + $this->margin_bottom = $GLOBALS['margin_bottom']; + $this->margin_right = $GLOBALS['margin_right']; + } + + function ToURL() + { + $url = 'title=' . rawurlencode($this->title) . '&'; + $url .= 'caption_x=' . rawurlencode($this->caption_x) . '&'; + $url .= 'caption_y=' . rawurlencode($this->caption_y) . '&'; + $url .= 'num_lines_x=' . $this->num_lines_x . '&'; + $url .= 'num_lines_y=' . $this->num_lines_y . '&'; + $url .= 'line_captions_x=' . rawurlencode(implode(',', $this->line_captions_x)) . '&'; + reset($this->data); + $dataURL = ''; + while(list($junk, $line) = each($this->data)) + { + if ($dataURL != '') + { + $dataURL .= '~'; + } + $dataURL .= implode(',', $line); + } + $url .= 'data=' . $dataURL . '&'; + $url .= 'colors=' . implode(',', $this->colors) . '&'; + $url .= 'color_legend=' . rawurlencode(implode(',', $this->color_legend)) . '&'; + $url .= 'graph_width=' . $this->graph_width . '&'; + $url .= 'graph_height=' . $this->graph_height . '&'; + $url .= 'margin_top=' . $this->margin_top . '&'; + $url .= 'margin_left=' . $this->margin_left . '&'; + $url .= 'margin_bottom=' . $this->margin_bottom . '&'; + $url .= 'margin_right=' . $this->margin_right; + + return $url; + } } ?> diff --git a/phpgwapi/inc/class.gdimage.inc.php b/phpgwapi/inc/class.gdimage.inc.php index d64eae4486..ee8b0fda1b 100644 --- a/phpgwapi/inc/class.gdimage.inc.php +++ b/phpgwapi/inc/class.gdimage.inc.php @@ -62,30 +62,30 @@ $this->colormap = array(); $this->hColor = 0; $this->font = 0; - $this->type = 'png'; - $this->temp_file = PHPGW_SERVER_ROOT . SEP . 'phpgwapi' . SEP . 'images' . SEP . 'draw_tmp.png'; + $this->type = 'png'; + $this->temp_file = PHPGW_SERVER_ROOT . SEP . 'phpgwapi' . SEP . 'images' . SEP . 'draw_tmp.png'; } function check_gd() { - ob_start(); - phpinfo(8); // Just get the modules loaded - $a = ob_get_contents(); - ob_end_clean(); + ob_start(); + phpinfo(8); // Just get the modules loaded + $a = ob_get_contents(); + ob_end_clean(); if(preg_match('/.*GD Version.*(1[0-9|\.]+).*/',$a,$m)) { $r=1; //$v=$m[1]; - } + } elseif(preg_match('/.*GD Version.*(2[0-9|\.]+).*/',$a,$m)) { $r=2; //$v=$m[1]; - } - else + } + else { $r=0; //$v=$m[1]; - } - return $r; + } + return $r; } function Init() @@ -116,9 +116,13 @@ if ($x >= 0 && $x <= $this->width && $y >= 0 && $y <= $this->height) { if ($linestyle == 'dashed') + { ImageDashedLine($this->hImage, $this->cur_x, $this->cur_y, $x, $y, $this->hColor); + } else + { ImageLine($this->hImage, $this->cur_x, $this->cur_y, $x, $y, $this->hColor); + } $this->cur_x = $x; $this->cur_y = $y; @@ -134,9 +138,13 @@ if ($x1 >= 0 && $x1 <= $this->width && $y1 >= 0 && $y1 <= $this->height && $x2 >= 0 && $x2 <= $this->width && $y2 >= 0 && $y2 <= $this->height) { if ($linestyle == 'solid') + { ImageLine($this->hImage, $x1, $y1, $x2, $y2, $this->hColor); + } else + { ImageDashedLine($this->hImage, $x1, $y1, $x2, $y2, $this->hColor); + } $this->cur_x = $x2; $this->cur_y = $y2; @@ -213,7 +221,9 @@ function SetFont($font) { if ($font < 1 || $font > 5) + { return false; + } $this->font = $font; @@ -250,35 +260,47 @@ { $this->cur_y += $textwidth / 2; if ($this->cur_y > $this->height) + { $this->cur_y = $this->height; + } } else { $this->cur_x -= $textwidth / 2; if ($this->cur_x < 0) + { $this->cur_x = 0; + } } } - else if ($justification == 'right') + elseif ($justification == 'right') + { + if ($direction == 'up') { - if ($direction == 'up') + $this->cur_y += $textwidth; + if ($this->cur_y > $this->height) { - $this->cur_y += $textwidth; - if ($this->cur_y > $this->height) - $this->cur_y = $this->height; - } - else - { - $this->cur_x -= $textwidth; - if ($this->cur_x < 0) - $this->cur_x = 0; + $this->cur_y = $this->height; } } + else + { + $this->cur_x -= $textwidth; + if ($this->cur_x < 0) + { + $this->cur_x = 0; + } + } + } if ($direction == 'up') + { ImageStringUp($this->hImage, $this->font, $this->cur_x, $this->cur_y, $text, $this->hColor); + } else + { ImageString($this->hImage, $this->font, $this->cur_x, $this->cur_y, $text, $this->hColor); + } return true; }