diff options
Diffstat (limited to 'frontends/php/include/classes')
| -rw-r--r-- | frontends/php/include/classes/table.inc.php | 80 |
1 files changed, 78 insertions, 2 deletions
diff --git a/frontends/php/include/classes/table.inc.php b/frontends/php/include/classes/table.inc.php index 8a1385bb..7f0c8f26 100644 --- a/frontends/php/include/classes/table.inc.php +++ b/frontends/php/include/classes/table.inc.php @@ -21,10 +21,86 @@ <?php class Ctable { - var $elements; + var $rows; + var $header; + var $msg_empty; + + function Ctable($msg_empty="") + { + $this->rows=array(); + $this->header=array(); + $this->msg_empty=$msg_empty; + } + + function addRow($row) + { + $this->rows = array_merge($this->rows, array($row)); + } + +// Private + function setHeader($header) + { + $this->header = $header; + } + +// Private + function showHeader($class="tborder") + { + echo "<table class=\"$class\" border=0 width=\"100%\" bgcolor='#AAAAAA' cellspacing=1 cellpadding=3>"; + echo "\n"; + echo "<tr bgcolor='#CCCCCC'>"; + while(list($num,$element)=each($this->header)) + { + echo "<td><b>".$element."</b></td>"; + } + echo "</tr>"; + echo "\n"; + } + +// Private + function showFooter() + { + echo "</table>"; + echo "\n"; + } + +// Private + function showRow($elements, $rownum) + { + if($rownum%2 == 1) { echo "<TR BGCOLOR=\"#DDDDDD\">"; } + else { echo "<TR BGCOLOR=\"#EEEEEE\">"; } + + while(list($num,$element)=each($elements)) + { + if(is_array($element)&&isset($element["hide"])&&($element["hide"]==1)) continue; + if(is_array($element)) + { + if(isset($element["class"])) + echo "<td class=\"".$element["class"]."\">".$element["value"]."</td>"; + else + echo "<td>".$element["value"]."</td>"; + } + else + { + echo "<td>".$element."</td>"; + } + } + echo "</tr>"; + echo "\n"; + } - function addRow() + function show() { + $this->showHeader(); + while (list($num,$row) = each($this->rows)) + { + $this->showRow($row,$num); + } + if(count($this->rows) == 0) + { + echo "<tr bgcolor=#eeeeee><td colspan=".count($this->header)." align=center>".$this->msg_empty."</td></tr>\n"; + } + $this->showFooter(); } } ?> |
