Source for file xhtml_table.php

Documentation is available at xhtml_table.php

  1. <?
  2. /* These are a set of classes used to create tables. One of the most powerful
  3. * features of HTMLClass*/
  4.  
  5. /* Abstract cell*/
  6.  
  7. class cell extends xml_element
  8. {
  9. var $cell_content;
  10. function cell($content="",$attributes=array())
  11. {
  12. $this->xml_element("td",$attributes);
  13. $this->cell_content=&$this->add_child($content);
  14. }
  15.  
  16. function &cell_content()
  17. {
  18. return $this->cell_content;
  19. }
  20.  
  21. }
  22.  
  23. /* Header Cell */
  24.  
  25. class hcell extends cell
  26. {
  27. function hcell($content="",$attributes=array())
  28. {
  29. $this->cell($content,$attributes);
  30. $this->tag="th";
  31. }
  32.  
  33. }
  34.  
  35. /* Cell are chained into rows*/
  36.  
  37. class row extends xml_element
  38. {
  39. function row($attributes=array())
  40. {
  41. $this->xml_element("tr",$attributes);
  42. }
  43.  
  44. function &add_col($content="",$attributes=array())
  45. {
  46. $this->lastcell=&$this->add_child(new cell ($content,$attributes));
  47. return $this->lastcell;
  48. }
  49.  
  50. }
  51.  
  52. /* Rows are formed into table*/
  53.  
  54. class table extends xml_element
  55. {
  56. var $caption;
  57. function table($caption="",$attributes=array())
  58. {
  59. $this->xml_element("table",$attributes);
  60. if ($caption!="") $this->caption=&$this->add_child(new caption($caption));
  61. $this->lastrow=-1;
  62. }
  63.  
  64. function &new_row($attributes=array())
  65. {
  66. $this->lastrow=&$this->add_child(new row ($attributes));
  67. return $this->lastrow;
  68. }
  69.  
  70. function &add_row($row)
  71. {
  72. $this->lastrow=&$this->add_child($row);
  73. return $this->lastrow;
  74. }
  75.  
  76. function &add_col($content="",$attributes=array(),$id=-1)
  77. {
  78. if ($id==-1) $id=&$this->lastrow;
  79. if ($id==-1) $id=&$this->new_row();
  80. return $id->add_col($content,$attributes);
  81. }
  82.  
  83. function &get_cell($x=-1,$y=-1)
  84. {
  85. if ($x==-1) $x=$this->lastrow;
  86. if ($y==-1) {
  87.  
  88. $y=$this->get_child($x);
  89. $y=$y->lastcell;
  90. }
  91. $temp= $this->get_child($x);
  92. return $temp->get_child($y);
  93. }
  94.  
  95. function &get_row($x)
  96. {
  97. return $this->get_child($x);
  98. }
  99.  
  100. }

Documentation generated on Tue, 24 May 2005 03:59:28 -0400 by phpDocumentor 1.3.0RC3