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