Commit | Line | Data |
---|---|---|
cea5b93a | 1 | <?php |
880bcb60 RK |
2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, | |
4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
cea5b93a RK |
5 | |
6 | class ExtendedDocument extends DOMDocument { | |
7 | // ExtendedDocument PHP class | |
8 | // this extends the general PHP DOM Document class to simplify some usual constructs | |
9 | // | |
10 | // function __construct([$version], [$encoding]) | |
11 | // CONSTRUCTOR | |
12 | // construct a new DOM Document that uses our element definitions | |
13 | // | |
14014b8f RK |
14 | // static function initHTML5() |
15 | // initialize as an HTML5 document and return references to its basic elements. | |
16 | // returns an associative array with the following elements: 'html', 'head', 'title', 'body' | |
ae41c41b | 17 | // |
61cc8aa9 | 18 | // public function appendElement($name, [$value]) |
cea5b93a RK |
19 | // appends a DOMDocument::createElement() as a child of this document (see there for params) |
20 | // returns the new child | |
21 | // | |
61cc8aa9 | 22 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
23 | // appends a DOMDocument::createElement() with the given name as a child of this document, |
24 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
25 | // returns the new child | |
26 | // | |
61cc8aa9 | 27 | // public function appendLink($target, [$value]) |
cea5b93a RK |
28 | // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params) |
29 | // returns the new child | |
30 | // | |
61cc8aa9 | 31 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
32 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
33 | // returns the new child | |
34 | // | |
61cc8aa9 | 35 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
36 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
37 | // returns the new child | |
38 | // | |
61cc8aa9 | 39 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
40 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
41 | // returns an HTML <div> that is a child of the new child | |
42 | // | |
61cc8aa9 | 43 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
44 | // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params) |
45 | // returns the new child | |
46 | // | |
61cc8aa9 | 47 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
48 | // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params) |
49 | // returns the new child | |
50 | // | |
61cc8aa9 | 51 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
52 | // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params) |
53 | // returns the new child | |
54 | // | |
ea32f7e5 RK |
55 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
56 | // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params) | |
57 | // returns the new child | |
58 | // | |
61cc8aa9 | 59 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
60 | // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params) |
61 | // returns the new child | |
62 | // | |
61cc8aa9 | 63 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
64 | // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params) |
65 | // returns the new child | |
66 | // | |
61cc8aa9 | 67 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
68 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params) |
69 | // returns the new child | |
70 | // | |
61cc8aa9 | 71 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
72 | // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params) |
73 | // returns the new child | |
74 | // | |
61cc8aa9 | 75 | // public function appendInputSubmit($value) |
ae41c41b RK |
76 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params) |
77 | // returns the new child | |
78 | // | |
61cc8aa9 | 79 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
80 | // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params) |
81 | // returns the new child | |
82 | // | |
61cc8aa9 | 83 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
84 | // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params) |
85 | // returns the new child | |
86 | // | |
61cc8aa9 | 87 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
88 | // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params) |
89 | // returns the new child | |
90 | // | |
61cc8aa9 | 91 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
92 | // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params) |
93 | // returns the new child | |
94 | // | |
61cc8aa9 | 95 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
96 | // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params) |
97 | // returns the new child | |
98 | // | |
61cc8aa9 | 99 | // public function appendText($text) |
cea5b93a RK |
100 | // appends a DOMDocument::createTextNode() as a child of this document (see there for params) |
101 | // returns the new child | |
102 | // | |
6638efd5 RK |
103 | // public function appendEntity($name) |
104 | // appends a DOMDocument::createEntityReference() as a child of this document (see there for params) | |
105 | // returns the new child | |
106 | // | |
61cc8aa9 | 107 | // public function appendComment($comment_data) |
cadc5980 RK |
108 | // appends a DOMDocument::createComment() as a child of this document (see there for params) |
109 | // returns the new child | |
110 | // | |
61cc8aa9 | 111 | // public function appendHTMLMarkup($htmldata, [$parentNode]) |
ae41c41b RK |
112 | // appends a representation of the HTML data as children of the given parent node, by default this document |
113 | // NO return value! | |
114 | // | |
61cc8aa9 | 115 | // public function appendXMLMarkup($xmldata, [$parentNode]) |
ae41c41b | 116 | // appends a representation of the XML data as children of the given parent node, by default this document |
cea5b93a RK |
117 | // NO return value! |
118 | // | |
61cc8aa9 | 119 | // public function appendJSElement($jsdata) |
cea5b93a RK |
120 | // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params) |
121 | // NO return value! | |
122 | // | |
ea32f7e5 RK |
123 | // public function appendJSFile($jsURL) |
124 | // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params) | |
125 | // returns the new child | |
126 | // | |
61cc8aa9 | 127 | // public function createElementLink($target, [$value]) |
cea5b93a RK |
128 | // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value |
129 | // | |
61cc8aa9 | 130 | // public function createElementImage($src, [$alt_text]) |
53510e9e RK |
131 | // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default) |
132 | // | |
61cc8aa9 | 133 | // public function createElementForm($action, $method, $name) |
ae41c41b RK |
134 | // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form> |
135 | // with the given action, method, and name | |
136 | // | |
61cc8aa9 | 137 | // public function createElementInputHidden($name, $value) |
ae41c41b RK |
138 | // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value |
139 | // | |
61cc8aa9 | 140 | // public function createElementInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
141 | // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size, |
142 | // and optionally id and value | |
143 | // | |
61cc8aa9 | 144 | // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
145 | // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size, |
146 | // and optionally id and value | |
147 | // | |
ea32f7e5 RK |
148 | // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value]) |
149 | // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size, | |
150 | // and optionally id and value | |
151 | // | |
61cc8aa9 | 152 | // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
153 | // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size, |
154 | // and optionally id and value | |
155 | // | |
61cc8aa9 | 156 | // public function createElementInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
157 | // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and |
158 | // checked state | |
159 | // | |
61cc8aa9 | 160 | // public function createElementInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
161 | // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and |
162 | // checked state | |
163 | // | |
61cc8aa9 | 164 | // public function createElementInputFile($name, $id, $accept) |
4bb9d784 RK |
165 | // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept |
166 | // | |
61cc8aa9 | 167 | // public function createElementInputSubmit($value) |
1109f526 RK |
168 | // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label |
169 | // | |
61cc8aa9 | 170 | // public function createElementButton($value, $onclick = null) |
1109f526 | 171 | // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute |
ae41c41b | 172 | // |
61cc8aa9 | 173 | // public function createElementTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
174 | // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows, |
175 | // and optionally id and value | |
176 | // | |
61cc8aa9 | 177 | // public function createElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
178 | // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id, |
179 | // array of options (key => description) and key of the by-default selected entry | |
180 | // | |
61cc8aa9 | 181 | // public function createElementOption($key, $desc, [$selected]) |
bf91764c RK |
182 | // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content) |
183 | // and optionally bool that tells if the entry is selected | |
184 | // | |
61cc8aa9 | 185 | // public function createElementLabel($for_id, $value) |
ae41c41b | 186 | // returns an ExtendedElement that is an HTML <label> with the given 'for' and value |
cea5b93a | 187 | // |
61cc8aa9 | 188 | // public function createElementJS($jsdata) |
cea5b93a | 189 | // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside |
c1666e91 | 190 | // |
ea32f7e5 RK |
191 | // public function createElementJSFile($jsURL) |
192 | // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL | |
cea5b93a RK |
193 | |
194 | function __construct($version = '1.0', $encoding = 'utf-8') { | |
195 | // make sure the default DOMDocument constructor runs | |
196 | parent::__construct($version, $encoding); | |
197 | $this->registerNodeClass('DOMElement', 'ExtendedElement'); | |
bf91764c | 198 | $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment'); |
cea5b93a RK |
199 | } |
200 | ||
14014b8f RK |
201 | static function initHTML5() { |
202 | $doc = new ExtendedDocument(); | |
203 | $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly. | |
204 | ||
205 | // Created basic HTML document structure. | |
206 | $root = $doc->getElementsByTagName('html')->item(0); | |
207 | $head = $root->appendElement('head'); | |
208 | $title = $head->appendElement('title'); | |
209 | $body = $root->appendElement('body'); | |
210 | ||
211 | return array('document' => $doc, | |
212 | 'html' => $root, | |
213 | 'head' => $head, | |
214 | 'title' => $title, | |
215 | 'body' => $body); | |
216 | } | |
217 | ||
61cc8aa9 | 218 | public function appendElement($name, $value = '') { |
a8816f43 | 219 | return $this->appendChild($this->createElement($name, $value)); |
cea5b93a | 220 | } |
61cc8aa9 | 221 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 222 | $aelem = $this->appendChild($this->createElement($name)); |
ae41c41b RK |
223 | $aelem->appendXMLMarkup($xmldata); |
224 | //$aelem->appendChild($this->createXMLFragment($xmldata)); | |
cea5b93a RK |
225 | return $aelem; |
226 | } | |
61cc8aa9 | 227 | public function appendLink($target, $value = '') { |
cea5b93a RK |
228 | return $this->appendChild($this->createElementLink($target, $value)); |
229 | } | |
61cc8aa9 | 230 | public function appendImage($src, $alt_text = '') { |
4aa31782 RK |
231 | return $this->appendChild($this->createElementImage($src, $alt_text)); |
232 | } | |
61cc8aa9 | 233 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
234 | return $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
235 | } | |
61cc8aa9 | 236 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 237 | $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
238 | return $formelem->appendElement('div'); |
239 | } | |
61cc8aa9 | 240 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
241 | return $this->appendChild($this->createElementInputHidden($name, $value)); |
242 | } | |
61cc8aa9 | 243 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
244 | return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); |
245 | } | |
61cc8aa9 | 246 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
247 | return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
248 | } | |
ea32f7e5 RK |
249 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
250 | return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
251 | } | |
61cc8aa9 | 252 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 RK |
253 | return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
254 | } | |
61cc8aa9 | 255 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
256 | return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked)); |
257 | } | |
61cc8aa9 | 258 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
259 | return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked)); |
260 | } | |
61cc8aa9 | 261 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
262 | return $this->appendChild($this->createElementInputFile($name, $id, $accept)); |
263 | } | |
61cc8aa9 | 264 | public function appendInputSubmit($value) { |
ae41c41b RK |
265 | return $this->appendChild($this->createElementInputSubmit($value)); |
266 | } | |
61cc8aa9 | 267 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
268 | return $this->appendChild($this->createElementButton($value, $onclick)); |
269 | } | |
61cc8aa9 | 270 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
271 | return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value)); |
272 | } | |
61cc8aa9 | 273 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
274 | return $this->appendChild($this->createElementSelect($name, $id, $options, $default)); |
275 | } | |
61cc8aa9 | 276 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
277 | return $this->appendChild($this->createElementOption($key, $desc, $selected)); |
278 | } | |
61cc8aa9 | 279 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
280 | return $this->appendChild($this->createElementLabel($for_id, $value)); |
281 | } | |
61cc8aa9 | 282 | public function appendText($text) { |
cea5b93a RK |
283 | return $this->appendChild($this->createTextNode($text)); |
284 | } | |
6638efd5 RK |
285 | public function appendEntity($name) { |
286 | return $this->appendChild($this->createEntityReference($name)); | |
287 | } | |
61cc8aa9 | 288 | public function appendComment($comment_data) { |
cadc5980 RK |
289 | return $this->appendChild($this->createComment($comment_data)); |
290 | } | |
61cc8aa9 | 291 | public function appendJSElement($jsdata) { |
cea5b93a RK |
292 | $this->appendChild($this->createElementJS($jsdata)); |
293 | } | |
ea32f7e5 RK |
294 | public function appendJSFile($jsdata) { |
295 | return $this->appendChild($this->createElementJSFile($jsdata)); | |
296 | } | |
cea5b93a | 297 | |
61cc8aa9 | 298 | public function appendHTMLMarkup($htmldata, $parentNode = null) { |
ae41c41b RK |
299 | if (is_null($parentNode)) { $parentNode =& $this; } |
300 | // XXX: just a workaround for now! | |
301 | $parentNode->appendChild($this->createCDATASection($htmldata)); | |
302 | } | |
303 | ||
61cc8aa9 | 304 | public function appendXMLMarkup($xmldata, $parentNode = null) { |
ae41c41b RK |
305 | if (is_null($parentNode)) { $parentNode =& $this; } |
306 | $tmpdoc = new ExtendedDocument; | |
307 | $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n"; | |
308 | $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n"; | |
309 | $tmpxml .= '<root>'.$xmldata.'</root>'; | |
310 | $tmpdoc->loadXML($tmpxml); | |
311 | foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) { | |
312 | $parentNode->appendChild($this->importNode($child, true)); | |
313 | } | |
cea5b93a RK |
314 | } |
315 | ||
61cc8aa9 | 316 | public function createElement($name, $value = '') { |
a8816f43 RK |
317 | // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that. |
318 | $aelem = parent::createElement($name); | |
319 | $aelem->appendText($value); | |
320 | return $aelem; | |
321 | } | |
322 | ||
61cc8aa9 | 323 | public function createElementLink($target, $value = '') { |
a8816f43 | 324 | $link = $this->createElement('a', $value); |
bf91764c | 325 | $link->setAttribute('href', $target); // XXX: take care of & etc. in links |
cea5b93a RK |
326 | return $link; |
327 | } | |
328 | ||
61cc8aa9 | 329 | public function createElementImage($src, $alt_text = '') { |
319cfe8d RK |
330 | $img = $this->createElement('img'); |
331 | $img->setAttribute('src', $src); | |
332 | $img->setAttribute('alt', $alt_text); | |
333 | return $img; | |
4aa31782 RK |
334 | } |
335 | ||
61cc8aa9 | 336 | public function createElementForm($action, $method, $name, $id = null) { |
ae41c41b RK |
337 | $formelem = $this->createElement('form'); |
338 | $formelem->setAttribute('action', $action); | |
339 | $formelem->setAttribute('method', $method); | |
340 | $formelem->setAttribute('name', $name); | |
b8d16837 | 341 | $formelem->setAttribute('id', $id); |
ae41c41b RK |
342 | return $formelem; |
343 | } | |
344 | ||
61cc8aa9 | 345 | public function createElementInputHidden($name, $value) { |
ae41c41b RK |
346 | $hidden = $this->createElement('input'); |
347 | $hidden->setAttribute('type', 'hidden'); | |
348 | $hidden->setAttribute('name', $name); | |
349 | $hidden->setAttribute('value', $value); | |
350 | return $hidden; | |
351 | } | |
352 | ||
61cc8aa9 | 353 | public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
354 | $txfield = $this->createElement('input'); |
355 | $txfield->setAttribute('type', 'text'); | |
356 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
357 | $txfield->setAttribute('name', $name); | |
358 | $txfield->setAttribute('maxlength', $maxlength); | |
359 | $txfield->setAttribute('size', $size); | |
360 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
361 | return $txfield; | |
362 | } | |
363 | ||
61cc8aa9 | 364 | public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
365 | $txfield = $this->createElement('input'); |
366 | $txfield->setAttribute('type', 'number'); | |
367 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
368 | $txfield->setAttribute('name', $name); | |
369 | $txfield->setAttribute('maxlength', $maxlength); | |
370 | $txfield->setAttribute('size', $size); | |
371 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
372 | return $txfield; | |
373 | } | |
374 | ||
ea32f7e5 RK |
375 | public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
376 | $txfield = $this->createElement('input'); | |
377 | $txfield->setAttribute('type', 'email'); | |
378 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
379 | $txfield->setAttribute('name', $name); | |
380 | $txfield->setAttribute('maxlength', $maxlength); | |
381 | $txfield->setAttribute('size', $size); | |
382 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
383 | return $txfield; | |
384 | } | |
385 | ||
61cc8aa9 | 386 | public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
319cfe8d RK |
387 | $pwfield = $this->createElement('input'); |
388 | $pwfield->setAttribute('type', 'password'); | |
389 | if (!is_null($id)) { $pwfield->setAttribute('id', $id); } | |
390 | $pwfield->setAttribute('name', $name); | |
391 | $pwfield->setAttribute('maxlength', $maxlength); | |
392 | $pwfield->setAttribute('size', $size); | |
393 | if (!is_null($value)) { $pwfield->setAttribute('value', $value); } | |
394 | return $pwfield; | |
645a7eb6 RK |
395 | } |
396 | ||
61cc8aa9 | 397 | public function createElementInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
398 | $radio = $this->createElement('input'); |
399 | $radio->setAttribute('type', 'radio'); | |
400 | $radio->setAttribute('name', $name); | |
4bb9d784 | 401 | if (!is_null($id)) { $radio->setAttribute('id', $id); } |
ae41c41b RK |
402 | $radio->setAttribute('value', $value); |
403 | if ($checked) { $radio->setAttribute('checked', ''); } | |
404 | return $radio; | |
405 | } | |
406 | ||
61cc8aa9 | 407 | public function createElementInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
408 | $cbox = $this->createElement('input'); |
409 | $cbox->setAttribute('type', 'checkbox'); | |
410 | $cbox->setAttribute('name', $name); | |
4bb9d784 | 411 | if (!is_null($id)) { $cbox->setAttribute('id', $id); } |
ae41c41b RK |
412 | $cbox->setAttribute('value', $value); |
413 | if ($checked) { $cbox->setAttribute('checked', ''); } | |
414 | return $cbox; | |
415 | } | |
416 | ||
61cc8aa9 | 417 | public function createElementInputFile($name, $id, $accept) { |
4bb9d784 RK |
418 | $fileinput = $this->createElement('input'); |
419 | $fileinput->setAttribute('type', 'file'); | |
420 | $fileinput->setAttribute('name', $name); | |
421 | if (!is_null($id)) { $fileinput->setAttribute('id', $id); } | |
422 | $fileinput->setAttribute('accept', $accept); | |
423 | return $fileinput; | |
424 | } | |
425 | ||
61cc8aa9 | 426 | public function createElementInputSubmit($value) { |
ae41c41b RK |
427 | $submitbtn = $this->createElement('input'); |
428 | $submitbtn->setAttribute('type', 'submit'); | |
429 | $submitbtn->setAttribute('value', $value); | |
430 | return $submitbtn; | |
431 | } | |
432 | ||
61cc8aa9 | 433 | public function createElementButton($value, $onclick = null) { |
1109f526 RK |
434 | $btn = $this->createElement('input'); |
435 | $btn->setAttribute('type', 'button'); | |
436 | $btn->setAttribute('value', $value); | |
437 | if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); } | |
438 | return $btn; | |
439 | } | |
440 | ||
61cc8aa9 | 441 | public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
442 | $txtarea = $this->createElement('textarea', $value); |
443 | $txtarea->setAttribute('name', $name); | |
444 | $txtarea->setAttribute('cols', $columns); | |
445 | $txtarea->setAttribute('rows', $rows); | |
446 | if (!is_null($id)) { $txtarea->setAttribute('id', $id); } | |
447 | return $txtarea; | |
448 | } | |
449 | ||
61cc8aa9 | 450 | public function createElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
451 | $select = $this->createElement('select'); |
452 | $select->setAttribute('name', $name); | |
453 | if (!is_null($id)) { $select->setAttribute('id', $id); } | |
454 | foreach ($options as $key => $desc) { | |
455 | $select->appendElementOption($key, $desc, ($key == $default)); | |
456 | } | |
457 | return $select; | |
458 | } | |
459 | ||
61cc8aa9 | 460 | public function createElementOption($key, $desc, $selected = false) { |
bf91764c RK |
461 | $option = $this->createElement('option', $desc); |
462 | $option->setAttribute('value', $key); | |
463 | if ($selected) { $option->setAttribute('selected', ''); } | |
464 | return $option; | |
465 | } | |
466 | ||
61cc8aa9 | 467 | public function createElementLabel($for_id, $value) { |
ae41c41b RK |
468 | $label = $this->createElement('label', $value); |
469 | $label->setAttribute('for', $for_id); | |
470 | return $label; | |
cea5b93a RK |
471 | } |
472 | ||
61cc8aa9 | 473 | public function createElementJS($jsdata) { |
cea5b93a | 474 | $jselem = $this->createElement('script'); |
ea32f7e5 | 475 | // Note: type can/should be left out for HTML5. |
cea5b93a RK |
476 | $jselem->setAttribute('type', 'text/javascript'); |
477 | $jselem->appendChild($this->createCDATASection($jsdata)); | |
478 | return $jselem; | |
479 | } | |
c1666e91 | 480 | |
ea32f7e5 RK |
481 | public function createElementJSFile($jsURL) { |
482 | $jselem = $this->createElement('script'); | |
483 | // Note: type can/should be left out for HTML5. | |
484 | $jselem->setAttribute('type', 'text/javascript'); | |
485 | $jselem->setAttribute('src', $jsURL); | |
486 | return $jselem; | |
487 | } | |
cea5b93a RK |
488 | } |
489 | ||
490 | class ExtendedElement extends DOMElement { | |
491 | // ExtendedElement PHP class | |
492 | // this extends the general PHP DOM Element class to simplify some usual constructs | |
493 | // | |
61cc8aa9 | 494 | // public function appendElement($name, [$value]) |
cea5b93a RK |
495 | // appends a DOMDocument::createElement() as a child of this element (see there for params) |
496 | // returns the new child | |
497 | // | |
61cc8aa9 | 498 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
499 | // appends a DOMDocument::createElement() with the given name as a child of this element, |
500 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
501 | // returns the new child | |
502 | // | |
61cc8aa9 | 503 | // public function appendLink($target, [$value]) |
cea5b93a RK |
504 | // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params) |
505 | // returns the new child | |
506 | // | |
61cc8aa9 | 507 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
508 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
509 | // returns the new child | |
510 | // | |
61cc8aa9 | 511 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
512 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
513 | // returns the new child | |
514 | // | |
61cc8aa9 | 515 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
516 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
517 | // returns an HTML <div> that is a child of the new child | |
518 | // | |
61cc8aa9 | 519 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
520 | // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params) |
521 | // returns the new child | |
522 | // | |
61cc8aa9 | 523 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
524 | // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) |
525 | // returns the new child | |
526 | // | |
61cc8aa9 | 527 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
528 | // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) |
529 | // returns the new child | |
530 | // | |
ea32f7e5 RK |
531 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
532 | // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params) | |
533 | // returns the new child | |
534 | // | |
61cc8aa9 | 535 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
536 | // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params) |
537 | // returns the new child | |
538 | // | |
61cc8aa9 | 539 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
540 | // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params) |
541 | // returns the new child | |
542 | // | |
61cc8aa9 | 543 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
544 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params) |
545 | // returns the new child | |
546 | // | |
61cc8aa9 | 547 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
548 | // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params) |
549 | // returns the new child | |
550 | // | |
61cc8aa9 | 551 | // public function appendInputSubmit($value) |
ae41c41b RK |
552 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params) |
553 | // returns the new child | |
554 | // | |
61cc8aa9 | 555 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
556 | // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params) |
557 | // returns the new child | |
558 | // | |
61cc8aa9 | 559 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
560 | // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params) |
561 | // returns the new child | |
562 | // | |
61cc8aa9 | 563 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
564 | // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params) |
565 | // returns the new child | |
566 | // | |
61cc8aa9 | 567 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
568 | // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params) |
569 | // returns the new child | |
570 | // | |
61cc8aa9 | 571 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
572 | // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params) |
573 | // returns the new child | |
574 | // | |
61cc8aa9 | 575 | // public function appendText($text) |
cea5b93a RK |
576 | // appends a DOMDocument::createTextNode() as a child of this element (see there for params) |
577 | // returns the new child | |
578 | // | |
6638efd5 RK |
579 | // public function appendEntity($name) |
580 | // appends a DOMDocument::createEntityReference() as a child of this element (see there for params) | |
581 | // returns the new child | |
582 | // | |
61cc8aa9 | 583 | // public function appendComment($comment_data) |
cadc5980 RK |
584 | // appends a DOMDocument::createComment() as a child of this element (see there for params) |
585 | // returns the new child | |
586 | // | |
61cc8aa9 | 587 | // public function appendHTMLMarkup($htmldata) |
ae41c41b RK |
588 | // appends a representation of the HTML data as children of this element |
589 | // NO return value! | |
590 | // | |
61cc8aa9 | 591 | // public function appendXMLMarkup($xmldata) |
ae41c41b | 592 | // appends a representation of the XML data as children of this element |
cea5b93a RK |
593 | // NO return value! |
594 | // | |
61cc8aa9 | 595 | // public function appendJSElement($jsdata) |
cea5b93a RK |
596 | // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params) |
597 | // NO return value! | |
c1666e91 | 598 | // |
0bbc241e RK |
599 | // public function appendJSFile($jsURL) |
600 | // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params) | |
ea32f7e5 | 601 | // returns the new child |
cea5b93a | 602 | |
61cc8aa9 | 603 | public function appendElement($name, $value = '') { |
a8816f43 | 604 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
cea5b93a | 605 | } |
61cc8aa9 | 606 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 607 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
ae41c41b | 608 | $aelem->appendXMLMarkup($xmldata); |
cea5b93a RK |
609 | return $aelem; |
610 | } | |
61cc8aa9 | 611 | public function appendLink($target, $value = '') { |
cea5b93a RK |
612 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value)); |
613 | } | |
61cc8aa9 | 614 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
615 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
616 | } | |
61cc8aa9 | 617 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
618 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
619 | } | |
61cc8aa9 | 620 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 621 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
622 | return $formelem->appendElement('div'); |
623 | } | |
61cc8aa9 | 624 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
625 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
626 | } | |
61cc8aa9 | 627 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
628 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
629 | } | |
61cc8aa9 | 630 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
631 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
632 | } | |
ea32f7e5 RK |
633 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
634 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
635 | } | |
61cc8aa9 | 636 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 RK |
637 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
638 | } | |
61cc8aa9 | 639 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
640 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
641 | } | |
61cc8aa9 | 642 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
643 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
644 | } | |
61cc8aa9 | 645 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
646 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
647 | } | |
61cc8aa9 | 648 | public function appendInputSubmit($value) { |
ae41c41b RK |
649 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
650 | } | |
61cc8aa9 | 651 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
652 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
653 | } | |
61cc8aa9 | 654 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
655 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
656 | } | |
61cc8aa9 | 657 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
658 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default)); |
659 | } | |
61cc8aa9 | 660 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
661 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
662 | } | |
61cc8aa9 | 663 | public function appendLabel($for_id, $value) { |
bf91764c RK |
664 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
665 | } | |
61cc8aa9 | 666 | public function appendText($text) { |
bf91764c RK |
667 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
668 | } | |
6638efd5 RK |
669 | public function appendEntity($name) { |
670 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
671 | } | |
61cc8aa9 | 672 | public function appendComment($comment_data) { |
cadc5980 RK |
673 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
674 | } | |
61cc8aa9 | 675 | public function appendHTMLMarkup($htmldata) { |
bf91764c RK |
676 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
677 | } | |
61cc8aa9 | 678 | public function appendXMLMarkup($xmldata) { |
bf91764c RK |
679 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
680 | } | |
61cc8aa9 | 681 | public function appendJSElement($jsdata) { |
bf91764c RK |
682 | $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
683 | } | |
ea32f7e5 RK |
684 | public function appendJSFile($jsdata) { |
685 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata)); | |
686 | } | |
bf91764c RK |
687 | } |
688 | ||
689 | class ExtendedDocumentFragment extends DOMDocumentFragment { | |
690 | // ExtendedDocumentFragment PHP class | |
691 | // this extends the general PHP DOM Document Fragment class to simplify some usual constructs | |
692 | // | |
61cc8aa9 | 693 | // public function appendElement($name, [$value]) |
bf91764c RK |
694 | // appends a DOMDocument::createElement() as a child of this fragment (see there for params) |
695 | // returns the new child | |
696 | // | |
61cc8aa9 | 697 | // public function appendElementXML($name, $xmldata) |
bf91764c RK |
698 | // appends a DOMDocument::createElement() with the given name as a child of this fragment, |
699 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
700 | // returns the new child | |
701 | // | |
61cc8aa9 | 702 | // public function appendLink($target, [$value]) |
bf91764c RK |
703 | // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params) |
704 | // returns the new child | |
705 | // | |
61cc8aa9 | 706 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
707 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
708 | // returns the new child | |
709 | // | |
61cc8aa9 | 710 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
711 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
712 | // returns the new child | |
713 | // | |
61cc8aa9 | 714 | // public function appendFormDiv($action, $method, $name, [$id]) |
bf91764c RK |
715 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
716 | // returns an HTML <div> that is a child of the new child | |
717 | // | |
61cc8aa9 | 718 | // public function appendInputHidden($name, $value) |
bf91764c RK |
719 | // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params) |
720 | // returns the new child | |
721 | // | |
61cc8aa9 | 722 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
bf91764c RK |
723 | // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) |
724 | // returns the new child | |
725 | // | |
61cc8aa9 | 726 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
727 | // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) |
728 | // returns the new child | |
729 | // | |
ea32f7e5 RK |
730 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
731 | // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params) | |
732 | // returns the new child | |
733 | // | |
61cc8aa9 | 734 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
735 | // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params) |
736 | // returns the new child | |
737 | // | |
61cc8aa9 | 738 | // public function appendInputRadio($name, $id, $value, $checked) |
bf91764c RK |
739 | // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params) |
740 | // returns the new child | |
741 | // | |
61cc8aa9 | 742 | // public function appendInputCheckbox($name, $id, $value, $checked) |
bf91764c RK |
743 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params) |
744 | // returns the new child | |
745 | // | |
61cc8aa9 | 746 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
747 | // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params) |
748 | // returns the new child | |
749 | // | |
61cc8aa9 | 750 | // public function appendInputSubmit($value) |
bf91764c RK |
751 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params) |
752 | // returns the new child | |
753 | // | |
61cc8aa9 | 754 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
755 | // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params) |
756 | // returns the new child | |
757 | // | |
61cc8aa9 | 758 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
759 | // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params) |
760 | // returns the new child | |
761 | // | |
61cc8aa9 | 762 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
763 | // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params) |
764 | // returns the new child | |
765 | // | |
61cc8aa9 | 766 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
767 | // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params) |
768 | // returns the new child | |
769 | // | |
61cc8aa9 | 770 | // public function appendLabel($for_id, $value) |
bf91764c RK |
771 | // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params) |
772 | // returns the new child | |
773 | // | |
61cc8aa9 | 774 | // public function appendText($text) |
bf91764c RK |
775 | // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params) |
776 | // returns the new child | |
777 | // | |
6638efd5 RK |
778 | // public function appendEntity($name) |
779 | // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params) | |
780 | // returns the new child | |
781 | // | |
61cc8aa9 | 782 | // public function appendComment($comment_data) |
cadc5980 RK |
783 | // appends a DOMDocument::createComment() as a child of this fragment (see there for params) |
784 | // returns the new child | |
785 | // | |
61cc8aa9 | 786 | // public function appendHTMLMarkup($htmldata) |
bf91764c RK |
787 | // appends a representation of the HTML data as children of this fragment |
788 | // NO return value! | |
789 | // | |
61cc8aa9 | 790 | // public function appendXMLMarkup($xmldata) |
bf91764c RK |
791 | // appends a representation of the XML data as children of this fragment |
792 | // NO return value! | |
793 | // | |
61cc8aa9 | 794 | // public function appendJSElement($jsdata) |
bf91764c RK |
795 | // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params) |
796 | // NO return value! | |
c1666e91 | 797 | // |
0bbc241e RK |
798 | // public function appendJSFile($jsURL) |
799 | // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params) | |
ea32f7e5 | 800 | // returns the new child |
bf91764c | 801 | |
61cc8aa9 | 802 | public function appendElement($name, $value = '') { |
a8816f43 | 803 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
bf91764c | 804 | } |
61cc8aa9 | 805 | public function appendElementXML($name, $xmldata) { |
bf91764c RK |
806 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
807 | $aelem->appendXMLMarkup($xmldata); | |
808 | return $aelem; | |
809 | } | |
61cc8aa9 | 810 | public function appendLink($target, $value = '') { |
bf91764c RK |
811 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value)); |
812 | } | |
61cc8aa9 | 813 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
814 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
815 | } | |
61cc8aa9 | 816 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
817 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
818 | } | |
61cc8aa9 | 819 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 820 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
bf91764c RK |
821 | return $formelem->appendElement('div'); |
822 | } | |
61cc8aa9 | 823 | public function appendInputHidden($name, $value) { |
bf91764c RK |
824 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
825 | } | |
61cc8aa9 | 826 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
bf91764c | 827 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
645a7eb6 | 828 | } |
61cc8aa9 | 829 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
830 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
831 | } | |
ea32f7e5 RK |
832 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
833 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
834 | } | |
61cc8aa9 | 835 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 | 836 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
bf91764c | 837 | } |
61cc8aa9 | 838 | public function appendInputRadio($name, $id, $value, $checked) { |
bf91764c RK |
839 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
840 | } | |
61cc8aa9 | 841 | public function appendInputCheckbox($name, $id, $value, $checked) { |
bf91764c RK |
842 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
843 | } | |
61cc8aa9 | 844 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
845 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
846 | } | |
61cc8aa9 | 847 | public function appendInputSubmit($value) { |
bf91764c RK |
848 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
849 | } | |
61cc8aa9 | 850 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
851 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
852 | } | |
61cc8aa9 | 853 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
854 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
855 | } | |
61cc8aa9 | 856 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
857 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default)); |
858 | } | |
61cc8aa9 | 859 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
860 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
861 | } | |
61cc8aa9 | 862 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
863 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
864 | } | |
61cc8aa9 | 865 | public function appendText($text) { |
cea5b93a RK |
866 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
867 | } | |
6638efd5 RK |
868 | public function appendEntity($name) { |
869 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
870 | } | |
61cc8aa9 | 871 | public function appendComment($comment_data) { |
cadc5980 RK |
872 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
873 | } | |
61cc8aa9 | 874 | public function appendHTMLMarkup($htmldata) { |
ae41c41b RK |
875 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
876 | } | |
61cc8aa9 | 877 | public function appendXMLMarkup($xmldata) { |
ae41c41b | 878 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
cea5b93a | 879 | } |
61cc8aa9 | 880 | public function appendJSElement($jsdata) { |
cea5b93a RK |
881 | $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
882 | } | |
ea32f7e5 RK |
883 | public function appendJSFile($jsdata) { |
884 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata)); | |
885 | } | |
cea5b93a RK |
886 | } |
887 | ?> |