1.dom = new DOMDocument('1.0'); } 8. else $this->dom = new DOMDocument($ver); 9. } 10. 11.# Elements 12. public function p($children) { 13. $element = $this->dom->createElement('p'); 14. foreach ($children as $child) 15. $element->appendChild($child); 16. # No unset, short function. 17. return $element; 18. } 19. public function tr($children) { 20. $element = $this->dom->createElement('tr'); 21. foreach ($children as $child) 22. $element->appendChild($child); 23. # No unset, short function. 24. return $element; 25. } 26. public function td($children) { 27. $element = $this->dom->createElement('td'); 28. foreach ($children as $child) 29. $element->appendChild($child); 30. # No unset, short function. 31. return $element; 32. } 33. public function label($children) { 34. $element = $this->dom->createElement('label'); 35. foreach ($children as $child) 36. $element->appendChild($child); 37. # No unset, short function. 38. return $element; 39. } 40. public function br($children) { 41. $element = $this->dom->createElement('br'); 42. foreach ($children as $child) 43. $element->appendChild($child); 44. # No unset, short function. 45. return $element; 46. } 47. public function input($children) { 48. $element = $this->dom->createElement('input'); 49. foreach ($children as $child) 50. $element->appendChild($child); 51. # No unset, short function. 52. return $element; 53. } 54. public function input_attr($attr,$children) { 55. $input= $this->dom->createDocumentFragment(); 56. if ($input->appendXML('') === false) 57. die("Code error, bad arguments internally."); 58. $tmp = $this->dom->createElement('tmp'); 59. $tmp->appendChild($input); 60. $element = $this->dom->createElement('input'); 61. foreach($tmp->firstChild->attributes as $value) 62. $element->setAttribute($value->nodeName,$value->value); 63. foreach ($children as $child) 64. $element->appendChild($child); 65. # No unset, short function. 66. return $element; 67. } 68. public function span($children) { 69. $element = $this->dom->createElement('span'); 70. foreach ($children as $child) 71. $element->appendChild($child); 72. # No unset, short function. 73. return $element; 74. } 75. public function div($children) { 76. $element = $this->dom->createElement('div'); 77. foreach ($children as $child) 78. $element->appendChild($child); 79. # No unset, short function. 80. return $element; 81. } 82. 83.# Attributes 84. public function _class($value) { 85. $attribute = $this->dom->createAttribute('class'); 86. $attribute->appendChild( 87. $this->dom->createTextNode($value)); 88. return $attribute; 89. } 90. public function valign($value) { 91. $attribute = $this->dom->createAttribute('valign'); 92. $attribute->appendChild( 93. $this->dom->createTextNode($value)); 94. return $attribute; 95. } 96. public function type($value) { 97. $attribute = $this->dom->createAttribute('type'); 98. $attribute->appendChild( 99. $this->dom->createTextNode($value)); 100. return $attribute; 101. } 102. public function size($value) { 103. $attribute = $this->dom->createAttribute('size'); 104. $attribute->appendChild( 105. $this->dom->createTextNode($value)); 106. return $attribute; 107. } 108. public function name($value) { 109. $attribute = $this->dom->createAttribute('name'); 110. $attribute->appendChild( 111. $this->dom->createTextNode($value)); 112. return $attribute; 113. } 114. public function id($value) { 115. $attribute = $this->dom->createAttribute('id'); 116. $attribute->appendChild( 117. $this->dom->createTextNode($value)); 118. return $attribute; 119. } 120. public function _for($value) { 121. $attribute = $this->dom->createAttribute('for'); 122. $attribute->appendChild( 123. $this->dom->createTextNode($value)); 124. return $attribute; 125. } 126. public function value($value) { 127. $attribute = $this->dom->createAttribute('value'); 128. $attribute->appendChild( 129. $this->dom->createTextNode($value)); 130. return $attribute; 131. } 132. public function checked($value) { 133. $attribute = $this->dom->createAttribute('checked'); 134. $attribute->appendChild( 135. $this->dom->createTextNode($value)); 136. return $attribute; 137. } 138. public function _default($value) { 139. $attribute = $this->dom->createAttribute('value'); 140. $attribute->appendChild( 141. $this->dom->createTextNode($value)); 142. return $attribute; 143. } 144. 145.#Text 146. public function text($value) { 147. return $this->dom->createTextNode($value); 148. } 149. 150. } 151. 152.$cgi = new cgi(''); 153.$label="myin"; 154.$name="Example input."; 155.$value="Wrong Syntax"; 156.$desc="Not useful at this time." 157. $cgi->dom->appendChild($cgi->tr(array( 158. $cgi->td(array( 159. $cgi->valign('top'), 160. $cgi->label(array( 161. $cgi->_for($label), 162. $cgi->text( 163. $label.':'))), 164. $cgi->br(array( 165. $cgi->_class('nobr'))), 166. )),$cgi->td(array( 167. $cgi->input_attr('',array( 168. $cgi->type('checkbox'), 169. $cgi->size($this->size), 170. $cgi->name($this->name), 171. $cgi->id($this->label), 172. $cgi->_class('checkfield'), 173. $cgi->value($value) 174. )), 175. $cgi->br(array( 176. $cgi->_class('nobr'))), 177. $cgi->text($this->desc), 178. $cgi->br(array()), 179. $cgi->br(array()) 180. )) 181. ))); 182.echo $cgi->dom->saveHTML();