00001 <?php
00003
00008
00009
00014 class MTable
00015 {
00016 private $titles = array();
00017 private $entries = array();
00018 private $compress_chars = array("\n", "\t");
00020 public $default_cleanhtml = false;
00022 public $default_tableprefix = "table_";
00024 public $default_compress = false;
00026 public $default_limit = 0;
00028 public $default_start = 1;
00030
00035 function addEntry($title, $value, $override_cleanhtml = "false")
00036 {
00037 if (($this->defaults["cleanhtml"] == true) && ($override_cleanhtml == false))
00038 {
00039 $this->titles[] = htmlentities($title);
00040 $this->entries[] = htmlentities($value);
00041 }
00042 else
00043 {
00044 $this->titles[] = $title;
00045 $this->entries[] = $value;
00046 }
00047 }
00048
00049
00050
00051
00052
00053
00054
00055
00057
00062 function displayTable()
00063 {
00064 $tstart = ($this->default_start < 1) ? 1 : $this->default_start;
00065 $p = $this->default_tableprefix;
00066 $start = "<table id='{$p}table'>\n";
00067 $content = "";
00068 $end = "</table>\n";
00069 $times = ($this->default_limit == 0) ? count($this->titles) : $this->default_limit ;
00070 $i = ($tstart - 1);
00071 while ($i < ($times))
00072 {
00073 if ($i == 0)
00074 {
00075 $content .= "\t<tr class='{$p}first {$p}row1'>\n\t\t<td class='{$p}title {$p}cell'>{$this->titles[$i]}</td>\n\t\t<td class='{$p}entry {$p}cell'>{$this->entries[$i]}</td>\n\t</tr>\n";
00076 }
00077 else
00078 {
00079 $row = ($row % 2 == 0) ? 1 : 2;
00080 $content .= "\t<tr class='{$p}row{$row}'>\n\t\t<td class='{$p}title {$p}cell'>{$this->titles[$i]}</td>\n\t\t<td class='{$p}entry {$p}cell'>{$this->entries[$i]}</td>\n\t</tr>\n";
00081 }
00082 $i++;
00083 }
00084 if ($this->default_compress == false)
00085 {
00086 return ($start . $content . $end);
00087 }
00088 else
00089 {
00090 return str_replace($this->compress_chars, '', ($start . $content . $end));
00091 }
00092 }
00093 }
00094 ?>