NTKTable.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. class NTKTable
  3. {
  4. function NTKTable($id, $row_count, $col_count, $debug = False)
  5. {
  6. $this->id = $id;
  7. $this->row_count = $row_count;
  8. $this->col_count = $col_count;
  9. $this->debug = $debug;
  10. $this->style = "";
  11. $this->spacing = "";
  12. $this->padding = "";
  13. $this->elems = array();
  14. $this->forms = array();
  15. for($i = 0; $i < $row_count; $i++)
  16. {
  17. $this->forms[$i] = "";
  18. for($j = 0; $j < $col_count; $j++)
  19. $this->elems[$i][$j] = "&nbsp;";
  20. }
  21. }
  22. function add($elem, $row, $col, $width = False, $height = False, $style = "")
  23. {
  24. $this->elems[$row][$col] = array($elem, $width, $height, $style);
  25. }
  26. function addFormRow($form_name, $action, $row_number, $values = array())
  27. {
  28. $this->forms[$row_number] = array($form_name,$action,$values);
  29. }
  30. function setStyle($style)
  31. {
  32. $this->style = $style;
  33. }
  34. function getHtml()
  35. {
  36. $html = "";
  37. $html .= "<table id=\"$this->id\" class=\"table\" style=\"".$this->style."\" ";
  38. if($this->debug)
  39. $html .= "border=\"1\" ";
  40. $html .= "cellspacing=\"$this->spacing\" cellpadding=\"$this->padding\" style=\"\">\n";
  41. for($i = 0; $i < $this->row_count; $i++)
  42. {
  43. $html .= "<tr>\n";
  44. if($this->forms[$i] != "")
  45. {
  46. $html .= "<form name=\"".$this->forms[$i][0]."\" action=\"".$this->forms[$i][1]."\" method=\"POST\">\n";
  47. for($j = 0; $j < count($this->forms[$i][2]); $j++)
  48. $html .= "<input type=\"hidden\" name=\"".$this->forms[$i][2][$j][0]."\" value=\"".$this->forms[$i][2][$j][1]."\">\n";
  49. }
  50. for($j = 0; $j < $this->col_count; $j++)
  51. {
  52. if($this->elems[$i][$j] == "&nbsp;")
  53. {
  54. $html .= "<td>\n";
  55. $html .= $this->elems[$i][$j];
  56. $html .= "</td>\n";
  57. }
  58. else
  59. {
  60. if($this->elems[$i][$j][1] == "True")
  61. $width = "100%";
  62. elseif($this->elems[$i][$j][1] == "False")
  63. $width = "1%";
  64. else
  65. $width = $this->elems[$i][$j][1];
  66. if($this->elems[$i][$j][2] == "True")
  67. $height = "100%";
  68. elseif($this->elems[$i][$j][2] == "False")
  69. $height = "1%";
  70. else
  71. $height = $this->elems[$i][$j][2];
  72. $html .= "<td style=\"width: $width; height: $height; ".$this->elems[$i][$j][3]."\">\n";
  73. $html .= $this->elems[$i][$j][0]->getHtml();
  74. $html .= "</td>\n";
  75. }
  76. }
  77. if($this->forms[$i] != "")
  78. {
  79. $html .= "<input type=\"submit\" value=\"\" style=\"visibility: hidden; position: absolute; width: 0px; height: 0px;\">";
  80. $html .= "</form>\n";
  81. }
  82. $html .= "</tr>\n";
  83. }
  84. $html .= "</table>\n";
  85. return $html;
  86. }
  87. }
  88. ?>