NTKVBox.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. class NTKVBox
  3. {
  4. function NTKVBox($id, $padding, $spacing, $debug = False)
  5. {
  6. $this->id = $id;
  7. $this->padding = $padding;
  8. $this->spacing = $spacing;
  9. $this->debug = $debug;
  10. $this->elems = array();
  11. }
  12. function add($elem, $width = False, $height = False, $style = "")
  13. {
  14. $this->elems[] = array($elem, $width, $height, $style);
  15. }
  16. function getHtml()
  17. {
  18. $html = "";
  19. $html .= "<table id=\"$this->id\" class=\"vbox\" ";
  20. if($this->debug)
  21. $html .= "border=\"1\" ";
  22. $html .= "cellspacing=\"$this->spacing\" cellpadding=\"$this->padding\" style=\"table-layout: fixed; width: 100%; height: 100%;\">\n";
  23. for($i = 0; $i < count($this->elems); $i++)
  24. {
  25. $html .= "<tr>\n";
  26. if($this->elems[$i][1])
  27. $width = "100%";
  28. else
  29. $width = "1%";
  30. if($this->elems[$i][2])
  31. $height = "100%";
  32. else
  33. $height = "1%";
  34. $html .= "<td style=\"width: $width; height: $height; ".$this->elems[$i][3]."\">\n";
  35. $html .= "<center>\n";
  36. $html .= $this->elems[$i][0]->getHtml();
  37. $html .= "</center>\n";
  38. $html .= "</td>\n";
  39. $html .= "</tr>\n";
  40. }
  41. $html .= "</table>\n";
  42. return $html;
  43. }
  44. }
  45. ?>