* @license http://www.contenido.org/license/LIZENZ.txt * @link http://www.4fb.de * @link http://www.contenido.org * @since file available since contenido release <= 4.6 * * {@internal * created unknown * modified 2008-06-30, Frederic Schneider, add security fix * modified 2008-07-03, Timo.Trautmann, added linebreaks for readable source code * * $Id$: * }} * */ if (!defined('CON_FRAMEWORK')) { die('Illegal call'); } class Table { /** * Table border color * @var string */ var $border_color = ''; /** * Table border style * @var string */ var $border_style = ''; /** * Table cell spacing * @var string */ var $cell_spacing = ''; /** * Table cell padding * @var string */ var $cell_padding = ''; /** * Table header color * @var string */ var $header_color = ''; /** * Table light row color * @var string */ var $light_color = ''; /** * Table dark row color * @var string */ var $dark_color = ''; /** * Internal dark/light row counter * @var bool */ var $dark_row = 0; /** * Internal table width counter * @var int */ var $table_cols = 0; /** * Internal first cell checker * @var bool */ var $first_cell = 0; /** * Internal full border checker * @var bool */ var $fullborder = false; /** * Directly output table if true * */ var $directoutput = true; /** * Constructor */ function __construct($m_bordercolor = "#EEEEEE", $m_borderstyle = "solid", $m_cellspacing = "0", $m_cellpadding = "2", $m_header_color = "#222222", $m_light_color = "#AAAAAA", $m_dark_color = "#777777", $m_fullborder = false, $m_directoutput = true) { $this->border_color = $m_bordercolor; $this->border_style = $m_borderstyle; $this->cellspacing = $m_cellspacing; $this->cellpadding = $m_cellpadding; $this->header_color = $m_header_color; $this->dark_color = $m_dark_color; $this->light_color = $m_light_color; $this->fullborder = $m_fullborder; $this->directoutput = $m_directoutput; } # end function /** * Begins the new table * @param none * @return void */ function start_table() { if (!$this->fullborder) { $starttable = ''; } else { $starttable = '
'; } if ($this->directoutput) { echo $starttable . "\n"; } else { return $starttable . "\n"; } } # end function /** * Outputs a header row * @param none * @return void */ function header_row($additional = "") { $headerrow = ''; if ($this->directoutput) { echo $headerrow . "\n"; } else { return $headerrow . "\n"; } } # end function /** * Outputs a regular row * @param none * @return void */ function row($id = '') { if ($this->dark_row) { $bgColor = $this->light_color; } else { $bgColor = $this->dark_color; } $this->dark_row = !$this->dark_row; $row = ''; if ($this->directoutput) { echo $row . "\n"; } else { return $row . "\n"; } } # end function /** * Outputs a header cell * @param $content The content which will fill the cell * @param $align The horizontal alignment of the cell, default "center" * @param $valign The vertical alignment of the cell, default "top" * @return void */ function header_cell($content, $align = "center", $valign = "top", $additional = "", $borderTop = 1) { $header_cell = ''; if ($this->first_cell) { $this->table_cols = 0; $this->first_cell = false; } $this->table_cols++; if ($this->directoutput) { echo $header_cell . "\n"; } else { return $header_cell . "\n"; } } # end function /** * Outputs a regular cell * @param $content The content which will fill the cell * @param $align The horizontal alignment of the cell, default "center" * @param $valign The vertical alignment of the cell, default "top" * @param $additional Additional flags for the table */ function cell($content, $align = "center", $valign = "top", $additional = "", $bSetStyle = true) { if (strlen($content) == 0) { $content = " "; } $cell = ''; if ($this->first_cell) { $this->table_cols = 0; $this->first_cell = false; } $this->table_cols++; if ($this->directoutput) { echo $cell . "\n"; } else { return $cell . "\n"; } } # end function /** * Outputs a borderless cell * @param $content The content which will fill the cell * @param $align The horizontal alignment of the cell, default "center" * @param $valign The vertical alignment of the cell, default "top" * @param $additional Additional flags for the table */ function borderless_cell($content, $align = "center", $valign = "top", $additional = "") { if (strlen($content) == 0) { $content = " "; } $borderless_cell = ''; if ($this->first_cell) { $this->table_cols = 0; $this->first_cell = false; } $this->table_cols++; if ($this->directoutput) { echo $borderless_cell . "\n"; } else { return $borderless_cell . "\n"; } } # end function /** * Outputs a sum cell * @param $content The content which will fill the cell * @param $align The horizontal alignment of the cell, default "center" * @param $valign The vertical alignment of the cell, default "top" */ function sumcell($content, $align = "center", $valign = "top") { if (strlen($content) == 0) { $content = " "; } $sumcell = ''; if ($this->directoutput) { echo $sumcell . "\n"; } else { return $sumcell . "\n"; } } # end function /** * Ends a row * @param none * @return void */ function end_row() { $end_row = ''; $this->first_cell = true; if ($this->directoutput) { echo $end_row . "\n"; } else { return $end_row . "\n"; } } /** * Ends a table * @param none * @return void */ function end_table() { $end_table = '
' . $content . 'border_color . '; border-style: ' . $this->border_style . '"'; } if ($align != '') { $cell .= ' align="' . $align . '"'; } $cell .= '>' . $content . '' . $content . '' . $content . '
'; if ($this->directoutput) { echo $end_table . "\n"; } else { return $end_table . "\n"; } } # end function } # end class Table ?>