2 /******************************* PHP-P10 v2 *****************************
3 * Copyright (C) 2011-2012 Philipp Kreil (pk910) *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 ************************************************************************
20 * Tools/Table.class.php
28 public function Table($colums) {
29 $this->table = array();
30 $this->table['set'] = array();
31 $this->table['data'] = array();
32 $this->table['set']['col'] = $colums;
33 $this->table['set']['bold'] = array();
34 for($i = 0; $i < $this->table['set']['col']; $i++) {
35 $this->table['set']['max'.$i] = 0;
36 $this->table['set']['bold'][$i] = false;
40 public function setBold($colum) {
41 $this->table['set']['bold'][$colum] = true;
44 public function add() {
45 $args = func_get_args();
47 for($i = 0; $i < $this->table['set']['col']; $i++) {
48 if(count($args) <= $i) $args[$i]= "";
50 if(count($args) >= $i)
51 if(strlen($args[$i]) > $this->table['set']['max'.$i]) $this->table['set']['max'.$i] = strlen($args[$i]);
53 $this->table['data'][] = $row;
57 public function end() {
60 for($row = 0; $row < count($this->table['data']); $row++) {
62 for($i = 0; $i < $this->table['set']['col']; $i++) {
63 if($i < $this->table['set']['col'] - 1)
64 $this->table['data'][$row][$i] .= substr($space,0,$this->table['set']['max'.$i] - strlen($this->table['data'][$row][$i]) + 1);
65 $bold = $this->table['set']['bold'][$i];
66 $out .= ($bold ? "\002" : "").$this->table['data'][$row][$i].($bold ? "\002" : "");