seems not to be used (anymore)

This commit is contained in:
Ralf Becker 2005-03-03 15:13:30 +00:00
parent 8a0ca7a6be
commit 08bc681ab9
3 changed files with 0 additions and 1033 deletions

View File

@ -1,364 +0,0 @@
<?php
/*******************************************************************\
* eGroupWare - GD Graph *
* http://www.egroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/ *
* *
* Written by Bettina Gille [ceb@phpgroupware.org] *
* *
* Creates graphical statistics using GD graphics library *
* Copyright (C) 2003 Free Software Foundation, Inc *
* ----------------------------------------------------------------- *
* This class based on boGraph.php3 *
* Double Choco Latte - Source Configuration Management System *
* Copyright (C) 1999 Michael L. Dean & Tim R. Norman *
* ----------------------------------------------------------------- *
* This library is part of the eGroupWare API *
* ----------------------------------------------------------------- *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\*******************************************************************/
/* $Id$ */
class gdgraph
{
var $debug;
var $title;
var $caption_x;
var $caption_y;
var $lines_x;
var $lines_y;
var $line_captions_x;
var $data;
var $colors;
var $color_legend;
var $graph_width;
var $graph_height;
var $margin_top;
var $margin_left;
var $margin_bottom;
var $margin_right;
var $img;
function gdgraph($debug = False)
{
$this->debug = $debug;
$this->title = 'Gantt Chart';
$this->caption_x = 'x';
$this->caption_y = 'y';
$this->num_lines_x = 30;
$this->num_lines_y = 10;
$this->line_captions_x = array();
$this->line_captions_y = array();
$this->data = array();
$this->colors = array('red','green','blue','bright red','bright green','bright blue','dark red','dark green','dark blue');
$this->color_legend = array();
$this->color_extra = 'yellow';
$this->graph_width = 800;
$this->graph_height = 400;
$this->margin_top = 20;
$this->margin_left = 80;
$this->margin_bottom = 40;
$this->margin_right = 20;
$this->img = CreateObject('phpgwapi.gdimage');
$this->temp_file = $this->img->temp_file;
}
function rRender()
{
// Initialize image - map white since it's our background
$this->img->width = $this->graph_width;
$this->img->height = $this->graph_height;
$this->img->Init();
$this->img->SetColor(255, 255, 0);
$this->img->ToBrowser();
$this->img->Done();
}
function Render()
{
// Initialize image - map white since it's our background
$this->img->width = $this->graph_width;
$this->img->height = $this->graph_height;
$this->img->Init();
$this->img->SetColor(255, 255, 255, True);
// Draw the captions
$this->img->SetFont(3);
$this->img->SetColor(0, 0, 0);
$this->img->MoveTo($this->graph_width / 2, 2);
$this->img->DrawText(array('text' => $this->title));
//$this->img->MoveTo(2, $this->graph_height / 2);
//$this->img->DrawText($this->caption_y, 'up', 'center');
//$this->img->MoveTo($this->graph_width / 2, $this->graph_height - $this->img->GetFontHeight() - 2);
//$this->img->DrawText($this->caption_x, '', 'center');
// Draw the two axis
$this->img->Line($this->margin_left, $this->margin_top, $this->margin_left, $this->graph_height - $this->margin_bottom + 4);
$this->img->Line($this->margin_left - 4, $this->graph_height - $this->margin_bottom, $this->graph_width - $this->margin_right, $this->graph_height - $this->margin_bottom);
// Draw dashed lines for x axis
$linespace = ($this->graph_width - $this->margin_left - $this->margin_right) / ($this->num_lines_x - 1);
for ($i = 1; $i < $this->num_lines_x; $i++)
{
$x = $i * $linespace + $this->margin_left;
$this->img->SetColor(0, 0, 0);
$this->img->Line($x, $this->graph_height - $this->margin_bottom - 4, $x, $this->graph_height - $this->margin_bottom + 4);
$this->img->SetColor(200, 200, 200);
$this->img->Line($x, $this->margin_top, $x, $this->graph_height - $this->margin_bottom - 4, 'dashed');
}
// Draw dashed lines for y axis
$linespace = ($this->graph_height - $this->margin_top - $this->margin_bottom) / ($this->num_lines_y - 1);
for ($i = 1; $i < $this->num_lines_y; $i++)
{
$y = $this->graph_height - $this->margin_bottom - ($i * $linespace);
$this->img->SetColor(0, 0, 0);
$this->img->Line($this->margin_left - 4, $y, $this->margin_left + 4, $y);
$this->img->SetColor(200, 200, 200);
$this->img->Line($this->margin_left + 4, $y, $this->graph_width - $this->margin_right, $y, 'dashed');
}
/* Find the largest numeric value in data (an array of arrays representing data)
$largest = 0;
reset($this->data);
while (list($junk, $line) = each($this->data))
{
reset($line);
while (list($junk2, $value) = each($line))
{
if ($value > $largest)
{
$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);*/
$largest = $this->num_lines_x;
// Draw the x axis text
$this->img->SetColor(0, 0, 0);
$this->img->SetFont(2);
$linespace = ($this->graph_width - $this->margin_left - $this->margin_right) / ($this->num_lines_x - 1);
reset($this->line_captions_x);
$i = 0;
while (list(,$text) = each($this->line_captions_x))
{
$this->img->MoveTo($i * $linespace + $this->margin_left, $this->graph_height - $this->margin_bottom + 8);
$this->img->DrawText(array('text' => $text['date_formatted']));
$i++;
}
// Draw the lines for the data
$this->img->SetColor(255, 0, 0);
reset($this->data);
if($this->debug)
{
_debug_array($this->data);
}
$i = 1;
while (is_array($this->data) && list(,$line) = each($this->data))
{
if($line['extracolor'])
{
$this->img->SetColorByName($line['extracolor']);
}
else
{
$this->img->SetColorByName($this->colors[$line['color']]);
}
$x1 = $x2 = $y1 = $y2 = 0;
$linespace = ($this->graph_height - $this->margin_top - $this->margin_bottom) / ($this->num_lines_y - 1);
$y1 = $y2 = $this->graph_height - $this->margin_bottom - ($i * $linespace);
$linespace = ($this->graph_width - $this->margin_left - $this->margin_right) / ($this->num_lines_x - 1);
if ($line['sdate'] <= $this->line_captions_x[0]['date'] && $line['edate'] > $this->line_captions_x[0]['date'])
{
if($this->debug)
{
echo 'PRO sdate <= x sdate | PRO edate > x sdate<br>';
}
$x1 = $this->margin_left;
}
elseif($line['sdate'] >= $this->line_captions_x[0]['date'] && $line['edate'] <= $this->line_captions_x[$largest]['date'])
{
if($this->debug)
{
echo 'PRO sdate >= date! pro_sdate = ' . $line['sdate'] . ', pro_edate = ' . $line['edate'] . '<br>';
echo 'PRO sdate >= date! pro_sdate_formatted = ' . $GLOBALS['phpgw']->common->show_date($line['sdate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . ', pro_edate_formatted = ' . $GLOBALS['phpgw']->common->show_date($line['edate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . '<br>';
echo 'x sdate: ' . $this->line_captions_x[0]['date'] . ', x edate: ' . $this->line_captions_x[$largest]['date'] . '<br><br>';
}
for($y=0;$y<$largest;$y++)
{
if($line['sdate'] == $this->line_captions_x[$y]['date'])
{
$x1 = $y * $linespace + $this->margin_left;
}
}
}
else
{
$x1 = $largest * $linespace + $this->margin_left;
}
if ($line['edate'] >= $this->line_captions_x[$largest]['date'])
{
if($this->debug)
{
echo 'PRO edate >= x edate! pro_edate = ' . $line['edate'] . '<br>';
echo 'PRO edate >= x edate! pro_edate_formatted = ' . $GLOBALS['phpgw']->common->show_date($line['edate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']) . '<br>';
echo 'x edate: ' . $this->line_captions_x[$largest]['date'] . '<br>';
}
$x2 = $this->graph_width - $this->margin_right;
}
elseif($line['edate'] <= $this->line_captions_x[$largest]['date'] && $line['edate'] >= $this->line_captions_x[0]['date'])
{
for($y=0;$y<$largest;$y++)
{
if($line['edate'] == $this->line_captions_x[$y]['date'])
{
$x2 = $y * $linespace + $this->margin_left;
}
}
}
else
{
$x2 = $largest * $linespace + $this->margin_left;
}
for ($w = -3; $w < 4; $w++)
{
$this->img->Line(1+$x1,$y1+$w,$x2,$y2+$w);
}
$color_index++;
$i++;
}
// Draw the y axis text
$this->img->SetColor(0, 0, 0);
$this->img->SetFont(2);
$linespace = ($this->graph_height - $this->margin_top - $this->margin_bottom) / ($this->num_lines_y - 1);
$space = 1;
for ($i = 0;$i<count($this->data);$i++)
{
$y = $this->graph_height - $this->margin_bottom - ($space * $linespace) - 7;
$this->img->MoveTo($this->margin_left - 6, $y);
$this->img->DrawText(array('text' => $this->data[$i]['title'],'justification' => 'right','margin_left' => $this->margin_left));
$space++;
}
$this->img->ToBrowser();
$this->img->Done();
}
function Open()
{
print('<script language="JavaScript">');
print('window.open(\'main.php3?menuAction=boGraph.Show&');
if(strstr($GLOBALS['HTTP_USER_AGENT'],'MSIE'))
{
print('DCLINFO=' . $GLOBALS['DCLINFO'] . '&');
}
print($this->ToURL() . '\', \'graph\', \'width=' . ($this->graph_width + 20) . ',height=' . ($this->graph_height + 20) . ',resizable=yes,scrollbars=yes\');');
print('</script>');
}
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;
}
}
?>

View File

@ -1,325 +0,0 @@
<?php
/*******************************************************************\
* eGroupWare - GD Image *
* http://www.egroupware.org *
* *
* Written by by Bettina Gille [ceb@phpgroupware.org] *
* *
* Creates images using GD graphics library *
* Copyright (C) 2003 Free Software Foundation, Inc *
* ----------------------------------------------------------------- *
* This class based on htmlGD.php3 *
* Double Choco Latte - Source Configuration Management System *
* Copyright (C) 1999 Michael L. Dean & Tim R. Norman *
* ----------------------------------------------------------------- *
* This library is part of the eGroupWare API *
* ----------------------------------------------------------------- *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
\*******************************************************************/
/* $Id$ */
class gdimage
{
var $filename;
var $type;
var $cur_x;
var $cur_y;
var $width;
var $height;
var $hImage;
var $colormap;
var $hColor;
var $font;
function gdimage()
{
$this->gd = $this->check_gd();
if ($this->gd == 0)
{
echo 'Your PHP installation does not seem to have the required GD library.
Please see the PHP documentation on how to install and enable the GD library.';
exit;
}
$this->cur_x = 0;
$this->cur_y = 0;
$this->width = 0;
$this->height = 0;
$this->hImage = 0;
$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';
}
function check_gd()
{
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
{
$r=0; //$v=$m[1];
}
return $r;
}
function Init()
{
$this->hImage = ImageCreate($this->width, $this->height) or die;
return True;
}
function Done()
{
ImageDestroy($this->hImage);
}
function MoveTo($x, $y)
{
if ($x >= 0 && $x <= $this->width && $y >= 0 && $y <= $this->height)
{
$this->cur_x = $x;
$this->cur_y = $y;
return true;
}
return false;
}
function LineTo($x, $y, $linestyle = 'solid')
{
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;
return true;
}
return false;
}
function Line($x1, $y1, $x2, $y2, $linestyle = 'solid')
{
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;
return true;
}
return false;
}
function SetColor($r, $g, $b, $set_transparent=False)
{
$key = "$r,$g,$b";
if (!IsSet($this->colormap[$key]))
{
$this->hColor = ImageColorAllocate($this->hImage, $r, $g, $b);
$this->colormap[$key] = $this->hColor;
}
else
{
$this->hColor = $this->colormap[$key];
}
if ($set_transparent)
{
ImageColorTransparent($this->hImage,$this->hColor);
}
return true;
}
function SetColorByName($name)
{
$r = 0;
$g = 0;
$b = 0;
switch ($name)
{
case 'red':
$r = 180;
break;
case 'green':
$g = 180;
break;
case 'blue':
$b = 180;
break;
case 'bright red':
$r = 255;
break;
case 'bright green':
$g = 255;
break;
case 'bright blue':
$b = 255;
break;
case 'dark red':
$r = 80;
break;
case 'dark green':
$g = 80;
break;
case 'dark blue':
$b = 80;
break;
case 'yellow':
$r = 255;
$g = 215;
break;
}
return $this->SetColor($r, $g, $b);
}
function SetFont($font)
{
if ($font < 1 || $font > 5)
{
return false;
}
$this->font = $font;
return true;
}
function GetFontHeight()
{
return ImageFontHeight($this->font);
}
function GetFontWidth()
{
return ImageFontWidth($this->font);
}
function DrawText($params)
{
$text = $params['text'];
$direction = (isset($params['direction'])?$params['direction']:'');
$justification = (isset($params['justification'])?$params['justification']:'center');
$margin_left = (isset($params['margin_left'])?$params['margin_left']:'');
$textwidth = ImageFontWidth($this->font) * strlen($text);
/*if (isset($margin_left) && $textwidth >= $margin_left)
{
$text = strlen($text) - 1 . '.';
}*/
if ($justification == 'center')
{
if ($direction == 'up')
{
$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;
}
}
}
elseif ($justification == 'right')
{
if ($direction == 'up')
{
$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;
}
}
}
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;
}
function ToBrowser()
{
//header('Content-type: image/' . $this->type);
switch ($this->type)
{
case 'png':
ImagePNG($this->hImage,$this->temp_file);
break;
case 'gif':
ImageGIF($this->hImage);
break;
case 'jpeg':
ImageJPEG($this->hImage);
break;
}
}
}
?>

View File

@ -1,344 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare API - Matrix View Generator *
* This file written by Marc Logemann <loge@phpgroupware.org> *
* class for creating matrix like timeframes for items *
* *
* this matrix is having the days of actual month in the x-axis and the *
* items, which could be projects, in the y-axis. *
* You will see a top-down view of all items and their associated *
* timeframes. You probably saw this in projectmanagement apps *
* *
* Copyright (C) 2000, 2001 Marc Logemann *
* -------------------------------------------------------------------------*
* This library is part of the eGroupWare API *
* http://www.egroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
class matrixview
{
var $sumdays = 0;
var $month = 0;
var $monthname = '';
var $year = 0;
var $day = 0;
var $items_content = array();
var $items_count = 0;
var $arr_second_dim = 0;
var $image1pix = 'images/pix.gif';
var $color_headerfield = '#FFFF33';
var $color_emptyfield = '#CCCCCC';
var $selection = 1;
/**
*
* construtor: graphview class
*
* constructor waits for the desired month in
* integer presentation and the desired year also
* in integer presentation 4 digits (ex. 2001)
*
* @param int month (for example: 02)
* @param int year (for example: 2001)
*
*/
function matrixview ($month_int = 0, $year_int = 0)
{
for($i;$i<32;$i++)
{
if(checkdate($month_int,$i,$year_int)) $days++;
}
$this->month = $month_int;
$this->year = $year_int;
$this->set1PixelGif($GLOBALS['phpgw']->common->get_image_path('todo').'/pix.gif');
}
/**
*
* set a Period for a specified item
*
* setting a period for an element means to define
* a fromDate and and a toDate together with the
* item itself. This will store a timeframe associated
* with an item for later usage
*
* @param string item for the timeframe
* @param date fromdate in format yyyymmdd
* @param date todate in format yyyymmdd
*
* @return boolean false if item cannot be saved
* otherwise true
*/
function setPeriod ($item, $fromdate, $todate, $color='#990033')
{
$fyear = substr($fromdate,0,4);
$fmonth = substr($fromdate,4,2);
$fday = substr($fromdate,6,2);
$tyear = substr($todate,0,4);
$tmonth = substr($todate,4,2);
$tday = substr($todate,6,2);
if(mktime(0,0,0, $tmonth, $tday, $tyear) < mktime(0,0,0, $this->month+1,0,$this->year))
{
$this->day = $tday;
}
else
{
$dinfo = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->day = $dinfo[mday];
}
$go = 1;
$i = 0;
$z = 0;
while($go == 1)
{
// calculates fromdate
// echo date("d/m/Y", mktime(0,0,0, $fmonth, $fday+$i, $fyear)); echo "<br>";
$datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear));
if($datinfo['mon'] == $this->month
&& $datinfo['year'] == $this->year
&& $datinfo['mday'] <= $this->day)
{
$t = $datinfo['mday'];
$this->items_content[$this->items_count][$t] = 'x';
}
if (mktime(0,0,0, $fmonth, $fday+$i, $fyear) >= mktime(0,0,0, $this->month+1, 0, $this->year) ||
mktime(0,0,0, $fmonth, $fday+$i, $fyear) >= mktime(0,0,0, $tmonth, $tday, $tyear))
{
$go = 0;
}
$i++;
}
$this->items_content[$this->items_count][0] = $item;
$this->items_color[$this->items_count] = $color;
// increase number of items in two-dimensional array
$this->items_count++;
}
/**
*
* sets the color for empty dayfields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setEmptyFieldColor ($color)
{
$this->color_emptyfield=$color;
}
/**
*
* sets the color for calendar day fields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setHeaderFieldColor ($color)
{
$this->color_headerfield=$color;
}
/**
*
* sets a new path for 1pixel (pix.gif) gif needed for the table
* default is set actual script dir + /images
*
* @param string path and name to 1pixel gif
*/
function set1PixelGif ($filepath)
{
$this->image1pix=$filepath;
}
/**
*
* disable selection of new timeframe
*
*/
function disableSelection ()
{
$this->selection=0;
}
/**
*
* return the html code for the matrix
*
* will return the complete html code for the matrix.
* In the calling program you can do some other
* operations on it, because it wont be echoed directly
*
* @return string html code for the matrix
*/
function out($form_link)
{
// get days of desired month (month submitted in constructor)
$in = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->sumdays = $in[mday];
$this->monthname = $in[month];
$this->out_monthyear($form_link);
echo '<div align="center">' . "\n";
echo '<table border="0">' . "\n";
$this->out_header();
// loop through number of items
for($z=0;$z<$this->items_count;$z++)
{
// seperate color and name from first array element
$itemname = $this->items_content[$z][0];
$itemcolor = $this->items_color[$z];
echo '<tr>' . "\n";
echo '<td>' . $itemname . '</td>' . "\n";
// loop through days of desired month
for($r=1;$r<$this->sumdays+1;$r++)
{
if($this->items_content[$z][$r] == 'x')
{
$color = $itemcolor;
}
else
{
$color = $this->color_emptyfield;
}
echo '<td bgcolor="' . $color . '">&nbsp;</td>' . "\n";
}
echo '</tr>' . "\n";
$this->out_ruler();
}
echo '</table>';
echo '</div>' . "\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_header ()
{
echo '<tr>' . "\n";
echo '<td height="1" colspan="'; echo $this->sumdays+1; echo '" bgcolor="black"><img src="' . $this->image1pix . '"></td>' . "\n";
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td>' . lang('Title') . '</td>' . "\n";
for($i=1;$i<$this->sumdays+1;$i++)
{
echo '<td bgcolor="'; echo $this->color_headerfield; echo '">' . sprintf("%02d",$i) . '</td>' . "\n";
}
echo '</tr>' . "\n";
echo '<tr>' . "\n";
echo '<td height="1" colspan="'; echo $this->sumdays+1; echo '" bgcolor="black"><img src="' . $this->image1pix . '"></td>' . "\n";
echo '</tr>' . "\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_ruler ()
{
echo '<tr>' . "\n";
echo '<td colspan="'; echo $this->sumdays+1; echo '" bgcolor="#999999"><img src="' . $this->image1pix .'"></td>' . "\n";
echo '</tr>' . "\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_monthyear($form_link)
{
echo '<form action="' . $form_link . '" method="post">' . "\n";
echo '<table border="0" width="100%" cellpadding="0" cellspacing="0">' . "\n";
echo '<tr>' . "\n";
echo '<td align="center"><h2>'; echo lang($this->monthname); echo ' '; echo $this->year; echo '</h2></td>' . "\n";
if($this->selection == 1)
{
echo '<td align="right">' . "\n";
echo '<select name="month"';
for($i=0;$i<13;$i++)
{
if ($this->month == $i)
{
$sel = ' selected';
}
else
{
unset($sel);
}
echo '<option value="' . $i . '"' . $sel . '>' . $i . '</option>';
}
echo '</select>' . "\n";
echo '<select name="year"';
for($i = date('Y') -2;$i<date('Y')+5;$i++)
{
if($this->year == $i)
{
$sel = ' selected';
}
else
{
unset($sel);
}
echo '<option value="' . $i . '"' . $sel . '>' . $i .'</option>';
}
echo '</select>' . "\n";
echo '&nbsp;&nbsp;<input type="submit" name="selection" value="' . lang('Filter') . '">&nbsp;&nbsp;';
echo '</td>' . "\n";
}
echo '</tr>' . "\n";
echo '</table>' . "\n";
echo '</form>' . "\n";
}
}
?>