| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- class NTKTable
- {
- function NTKTable($id, $row_count, $col_count, $debug = False)
- {
- $this->id = $id;
- $this->row_count = $row_count;
- $this->col_count = $col_count;
- $this->debug = $debug;
- $this->style = "";
- $this->spacing = "";
- $this->padding = "";
-
- $this->elems = array();
- $this->forms = array();
- for($i = 0; $i < $row_count; $i++)
- {
- $this->forms[$i] = "";
- for($j = 0; $j < $col_count; $j++)
- $this->elems[$i][$j] = " ";
- }
- }
-
- function add($elem, $row, $col, $width = False, $height = False, $style = "")
- {
- $this->elems[$row][$col] = array($elem, $width, $height, $style);
- }
-
- function addFormRow($form_name, $action, $row_number, $values = array())
- {
- $this->forms[$row_number] = array($form_name,$action,$values);
- }
-
- function setStyle($style)
- {
- $this->style = $style;
- }
-
- function getHtml()
- {
- $html = "";
-
- $html .= "<table id=\"$this->id\" class=\"table\" style=\"".$this->style."\" ";
- if($this->debug)
- $html .= "border=\"1\" ";
- $html .= "cellspacing=\"$this->spacing\" cellpadding=\"$this->padding\" style=\"\">\n";
-
- for($i = 0; $i < $this->row_count; $i++)
- {
- $html .= "<tr>\n";
-
- if($this->forms[$i] != "")
- {
- $html .= "<form name=\"".$this->forms[$i][0]."\" action=\"".$this->forms[$i][1]."\" method=\"POST\">\n";
- for($j = 0; $j < count($this->forms[$i][2]); $j++)
- $html .= "<input type=\"hidden\" name=\"".$this->forms[$i][2][$j][0]."\" value=\"".$this->forms[$i][2][$j][1]."\">\n";
- }
-
- for($j = 0; $j < $this->col_count; $j++)
- {
- if($this->elems[$i][$j] == " ")
- {
- $html .= "<td>\n";
- $html .= $this->elems[$i][$j];
- $html .= "</td>\n";
- }
- else
- {
- if($this->elems[$i][$j][1] == "True")
- $width = "100%";
- elseif($this->elems[$i][$j][1] == "False")
- $width = "1%";
- else
- $width = $this->elems[$i][$j][1];
-
- if($this->elems[$i][$j][2] == "True")
- $height = "100%";
- elseif($this->elems[$i][$j][2] == "False")
- $height = "1%";
- else
- $height = $this->elems[$i][$j][2];
-
- $html .= "<td style=\"width: $width; height: $height; ".$this->elems[$i][$j][3]."\">\n";
- $html .= $this->elems[$i][$j][0]->getHtml();
- $html .= "</td>\n";
- }
- }
-
- if($this->forms[$i] != "")
- {
- $html .= "<input type=\"submit\" value=\"\" style=\"visibility: hidden; position: absolute; width: 0px; height: 0px;\">";
- $html .= "</form>\n";
- }
-
- $html .= "</tr>\n";
- }
- $html .= "</table>\n";
-
- return $html;
- }
- }
- ?>
|