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/. */
6 class ExtendedDocument extends DOMDocument {
7 // ExtendedDocument PHP class
8 // this extends the general PHP DOM Document class to simplify some usual constructs
10 // function __construct([$version], [$encoding])
12 // construct a new DOM Document that uses our element definitions
14 // static function initHTML5([$doc])
15 // initialize as an HTML5 document and return references to its basic elements.
16 // If a $doc is handed over (an ExtendedDocument or a derived class), load the content into that document.
17 // returns an associative array with the following elements: 'html', 'head', 'title', 'body'
19 // public function loadHTML5($source) {
20 // A version of loadHTML() - see DOMDocument documentation - that is made for loading HTML5 and not emitting warnings/errors for unknown elements.
21 // returns true on success, false otherwise, just like loadHTML5.
23 // public function appendElement($name, [$value])
24 // appends a DOMDocument::createElement() as a child of this document (see there for params)
25 // returns the new child
27 // public function appendElementXML($name, $xmldata)
28 // appends a DOMDocument::createElement() with the given name as a child of this document,
29 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
30 // returns the new child
32 // public function appendLink($target, [$value], [$title])
33 // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
34 // returns the new child
36 // public function appendImage($src, [$alt_text])
37 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
38 // returns the new child
40 // public function appendForm($action, $method, $name, [$id])
41 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
42 // returns the new child
44 // public function appendFormDiv($action, $method, $name, [$id])
45 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
46 // returns an HTML <div> that is a child of the new child
48 // public function appendInputHidden($name, $value)
49 // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
50 // returns the new child
52 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
53 // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
54 // returns the new child
56 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
57 // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
58 // returns the new child
60 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
61 // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
62 // returns the new child
64 // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
65 // appends an ExtendedDocument::createElementInputRange() as a child of this document (see there for params)
66 // returns the new child
68 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
69 // appends an ExtendedDocument::createElementInputUrl() as a child of this document (see there for params)
70 // returns the new child
72 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
73 // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params)
74 // returns the new child
76 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
77 // appends an ExtendedDocument::createElementInputTel() as a child of this document (see there for params)
78 // returns the new child
80 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
81 // appends an ExtendedDocument::createElementInputDate() as a child of this document (see there for params)
82 // returns the new child
84 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
85 // appends an ExtendedDocument::createElementInputTime() as a child of this document (see there for params)
86 // returns the new child
88 // public function appendInputColor($name, [$id], [$value])
89 // appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params)
90 // returns the new child
92 // public function appendInputRadio($name, $id, $value, $checked)
93 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
94 // returns the new child
96 // public function appendInputCheckbox($name, $id, $value, $checked)
97 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
98 // returns the new child
100 // public function appendInputFile($name, $id, $accept)
101 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
102 // returns the new child
104 // public function appendInputSubmit($value)
105 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
106 // returns the new child
108 // public function appendButton($value, $onclick = null)
109 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
110 // returns the new child
112 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
113 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
114 // returns the new child
116 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
117 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
118 // returns the new child
120 // public function appendElementOption($key, $desc, [$selected])
121 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
122 // returns the new child
124 // public function appendLabel($for_id, $value)
125 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
126 // returns the new child
128 // public function appendElementDatalist([$id], [$options])
129 // appends an ExtendedDocument::createElementDatalist() as a child of this document (see there for params)
130 // returns the new child
132 // public function appendText($text)
133 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
134 // returns the new child
136 // public function appendLinebreak()
137 // appends a <br> as a child of this document
138 // returns the new child
140 // public function appendEntity($name)
141 // appends a DOMDocument::createEntityReference() as a child of this document (see there for params)
142 // returns the new child
144 // public function appendComment($comment_data)
145 // appends a DOMDocument::createComment() as a child of this document (see there for params)
146 // returns the new child
148 // public function appendClonedElement($dom_element, [$deep])
149 // appends a clone of the given DOMElement as a child of this document
150 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
151 // returns the new child
153 // public function appendHTMLMarkup($htmldata, [$parentNode])
154 // appends a representation of the HTML data as children of the given parent node, by default this document
157 // public function appendXMLMarkup($xmldata, [$parentNode])
158 // appends a representation of the XML data as children of the given parent node, by default this document
161 // public function appendStyleElement($styledata)
162 // appends an ExtendedDocument::createElementStyle() as a child of this document (see there for params)
163 // returns the new child
165 // public function appendJSElement($jsdata)
166 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
167 // returns the new child
169 // public function appendJSFile($jsURL, [$defer], [$async])
170 // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params)
171 // returns the new child
173 // public function createElementLink($target, [$value], [$title])
174 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value as well as (optional) title attribute
176 // public function createElementImage($src, [$alt_text])
177 // returns an ExtendedElement that is an HTML <img> with the given src and alt attributes (set to '' by default)
179 // public function createElementForm($action, $method, $name)
180 // returns an ExtendedElement that is an HTML <form> with the given action, method, and name
182 // public function createElementInputHidden($name, $value)
183 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
185 // public function createElementInputText($name, $maxlength, $size, [$id], [$value])
186 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
187 // and optionally id and value
189 // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
190 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
191 // and optionally id and value
193 // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
194 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
195 // and optionally id and value
197 // public function createElementInputRange($name, $id, $min, $max, [$step], [$value])
198 // returns an ExtendedElement that is an HTML <input> of type 'range' with the given name, id, min, max,
199 // and optionally step and value
201 // public function createElementInputUrl($name, $maxlength, $size, [$id], [$value])
202 // returns an ExtendedElement that is an HTML <input> of type 'url' with the given name, maxlength, size,
203 // and optionally id and value
205 // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value])
206 // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size,
207 // and optionally id and value
209 // public function createElementInputTel($name, $maxlength, $size, [$id], [$value])
210 // returns an ExtendedElement that is an HTML <input> of type 'tel' with the given name, maxlength, size,
211 // and optionally id and value
213 // public function createElementInputDate($name, [$id], [$min], [$max], [$value])
214 // returns an ExtendedElement that is an HTML <input> of type 'date' with the given name,
215 // and optionally id, min, max, and value
217 // public function createElementInputTime($name, [$id], [$min], [$max], [$value])
218 // returns an ExtendedElement that is an HTML <input> of type 'time' with the given name,
219 // and optionally id, min, max, and value
221 // public function createElementInputColor($name, [$id], [$value])
222 // returns an ExtendedElement that is an HTML <input> of type 'color' with the given name,
223 // and optionally id and value
225 // public function createElementInputRadio($name, $id, $value, $checked)
226 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
229 // public function createElementInputCheckbox($name, $id, $value, $checked)
230 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
233 // public function createElementInputFile($name, $id, $accept)
234 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
236 // public function createElementInputSubmit($value)
237 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
239 // public function createElementButton($value, $onclick = null)
240 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
242 // public function createElementTextArea($name, $columns, $rows, [$id], [$value])
243 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
244 // and optionally id and value
246 // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch])
247 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
248 // array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true)
250 // public function createElementOption($key, $desc, [$selected])
251 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
252 // and optionally bool that tells if the entry is selected
254 // public function createElementLabel($for_id, $value)
255 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
257 // public function createElementDatalist([$id], [$options])
258 // returns an ExtendedElement that is an HTML <datalist> with optionally the given id and array of options (key => description)
260 // public function createElementStyle($styledata)
261 // returns an ExtendedElement that is an HTML <style> of CSS type with the style data inside
263 // public function createElementJS($jsdata)
264 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
266 // public function createElementJSFile($jsURL, [$defer], [$async])
267 // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL
268 // $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.
270 function __construct($version = '1.0', $encoding = 'utf-8') {
271 // make sure the default DOMDocument constructor runs
272 parent::__construct($version, $encoding);
273 $this->registerNodeClass('DOMElement', 'ExtendedElement');
274 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
277 static function initHTML5($doc = null) {
278 if (is_null($doc)) { $doc = new ExtendedDocument(); }
279 $doc->loadHTML5('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
281 // Created basic HTML document structure.
282 $root = $doc->getElementsByTagName('html')->item(0);
283 $head = $root->appendElement('head');
284 $title = $head->appendElement('title');
285 $body = $root->appendElement('body');
287 return array('document' => $doc,
294 public function loadHTML5($source) {
295 // Do our own handling of DOMDocument error reporting so we can ignore "unknown tags" which are usually fine in HTML5.
296 libxml_use_internal_errors(true);
297 if (!preg_match('/^\s*<?xml /', $source)) {
298 // Add an XML declaration to force DOMDocument into UTF-8 mode.
299 $source = '<?xml version="1.0" encoding="utf-8"?>'."\n".$source;
301 $result = $this->loadHTML($source);
302 // Handle DOMDocument loading errors, throw away warnings on unknown tags as HTML5 allows all kinds.
303 $errseverity = array(LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal');
304 foreach (libxml_get_errors() as $error) {
305 // $error is a libXMLError, see https://www.php.net/manual/en/class.libxmlerror.php
306 // See http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors for error numbers
307 if ($error->code != 801) { // XML_HTML_UNKNOWN_TAG gets no output, should not exist for HTML5.
308 trigger_error($errseverity[$error->level].' loading HTML5: '.$error->message.' (code '.$error->code.'), line: '.$error->line, E_USER_WARNING);
311 libxml_clear_errors();
312 libxml_use_internal_errors(false);
316 public function appendElement($name, $value = '') {
317 return $this->appendChild($this->createElement($name, $value));
319 public function appendElementXML($name, $xmldata) {
320 $aelem = $this->appendChild($this->createElement($name));
321 $aelem->appendXMLMarkup($xmldata);
322 //$aelem->appendChild($this->createXMLFragment($xmldata));
325 public function appendLink($target, $value = '', $title = null) {
326 return $this->appendChild($this->createElementLink($target, $value, $title));
328 public function appendImage($src, $alt_text = '') {
329 return $this->appendChild($this->createElementImage($src, $alt_text));
331 public function appendForm($action, $method, $name, $id = null) {
332 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
334 public function appendFormDiv($action, $method, $name, $id = null) {
335 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
336 return $formelem->appendElement('div');
338 public function appendInputHidden($name, $value) {
339 return $this->appendChild($this->createElementInputHidden($name, $value));
341 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
342 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
344 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
345 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
347 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
348 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
350 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
351 return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value));
353 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
354 return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value));
356 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
357 return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value));
359 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
360 return $this->appendChild($this->createElementInputTel($name, $maxlength, $size, $id, $value));
362 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
363 return $this->appendChild($this->createElementInputDate($name, $id, $min, $max, $value));
365 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
366 return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value));
368 public function appendInputColor($name, $id = null, $value = null) {
369 return $this->appendChild($this->createElementInputColor($name, $id, $value));
371 public function appendInputRadio($name, $id, $value, $checked) {
372 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
374 public function appendInputCheckbox($name, $id, $value, $checked) {
375 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
377 public function appendInputFile($name, $id, $accept) {
378 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
380 public function appendInputSubmit($value) {
381 return $this->appendChild($this->createElementInputSubmit($value));
383 public function appendButton($value, $onclick = null) {
384 return $this->appendChild($this->createElementButton($value, $onclick));
386 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
387 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
389 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
390 return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch));
392 public function appendElementOption($key, $desc, $selected = false) {
393 return $this->appendChild($this->createElementOption($key, $desc, $selected));
395 public function appendLabel($for_id, $value) {
396 return $this->appendChild($this->createElementLabel($for_id, $value));
398 public function appendElementDatalist($id = null, $options = array()) {
399 return $this->appendChild($this->createElementDatalist($id, $options));
401 public function appendText($text) {
402 return $this->appendChild($this->createTextNode($text));
404 public function appendLinebreak() {
405 return $this->appendChild($this->createElement('br'));
407 public function appendEntity($name) {
408 return $this->appendChild($this->createEntityReference($name));
410 public function appendComment($comment_data) {
411 return $this->appendChild($this->createComment($comment_data));
413 public function appendClonedElement($dom_element, $deep = true) {
414 return $this->appendChild($dom_element->cloneNode($deep));
416 public function appendStyleElement($styledata) {
417 return $this->appendChild($this->createElementStyle($styledata));
419 public function appendJSElement($jsdata) {
420 return $this->appendChild($this->createElementJS($jsdata));
422 public function appendJSFile($jsURL, $defer = false, $async = false) {
423 return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async));
426 public function appendHTMLMarkup($htmldata, $parentNode = null) {
427 if (is_null($parentNode)) { $parentNode =& $this; }
428 // Use loadHTML5() to parse and turn the markup into proper HTML.
429 $tmpdoc = new ExtendedDocument;
430 // The XML line is needed to tell the parser that we need UTF-8 parsing.
431 $tmpdoc->loadHTML5('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>');
432 foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) {
433 $parentNode->appendChild($this->importNode($child, true));
437 public function appendXMLMarkup($xmldata, $parentNode = null) {
438 if (is_null($parentNode)) { $parentNode =& $this; }
439 $tmpdoc = new ExtendedDocument;
440 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
441 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
442 $tmpxml .= '<root>'.$xmldata.'</root>';
443 $tmpdoc->loadXML($tmpxml);
444 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
445 $parentNode->appendChild($this->importNode($child, true));
449 public function createElement($name, $value = '') {
450 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
451 $aelem = parent::createElement($name);
452 if (strlen($value ?? '')) { $aelem->appendText($value); }
456 public function createElementLink($target, $value = '', $title = null) {
457 $link = $this->createElement('a', $value);
458 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
459 if (!is_null($title)) { $link->setAttribute('title', $title); }
463 public function createElementImage($src, $alt_text = '') {
464 $img = $this->createElement('img');
465 $img->setAttribute('src', $src);
466 $img->setAttribute('alt', $alt_text);
470 public function createElementForm($action, $method, $name, $id = null) {
471 $formelem = $this->createElement('form');
472 $formelem->setAttribute('action', $action);
473 $formelem->setAttribute('method', $method);
474 $formelem->setAttribute('name', $name);
475 if (!is_null($id)) { $formelem->setAttribute('id', $id); }
479 public function createElementInputHidden($name, $value) {
480 $hidden = $this->createElement('input');
481 $hidden->setAttribute('type', 'hidden');
482 $hidden->setAttribute('name', $name);
483 $hidden->setAttribute('value', $value);
487 public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
488 $txfield = $this->createElement('input');
489 $txfield->setAttribute('type', 'text');
490 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
491 $txfield->setAttribute('name', $name);
492 $txfield->setAttribute('maxlength', $maxlength);
493 $txfield->setAttribute('size', $size);
494 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
498 public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
499 $pwfield = $this->createElement('input');
500 $pwfield->setAttribute('type', 'password');
501 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
502 $pwfield->setAttribute('name', $name);
503 $pwfield->setAttribute('maxlength', $maxlength);
504 $pwfield->setAttribute('size', $size);
505 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
509 public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
510 $numfield = $this->createElement('input');
511 $numfield->setAttribute('type', 'number');
512 if (!is_null($id)) { $numfield->setAttribute('id', $id); }
513 $numfield->setAttribute('name', $name);
514 $numfield->setAttribute('maxlength', $maxlength);
515 $numfield->setAttribute('size', $size);
516 if (!is_null($value)) { $numfield->setAttribute('value', $value); }
520 public function createElementInputRange($name, $id, $min, $max, $step = null, $value = null) {
521 $rgfield = $this->createElement('input');
522 $rgfield->setAttribute('type', 'range');
523 if (!is_null($id)) { $rgfield->setAttribute('id', $id); }
524 $rgfield->setAttribute('name', $name);
525 if (!is_null($min)) { $rgfield->setAttribute('min', $min); }
526 if (!is_null($max)) { $rgfield->setAttribute('max', $max); }
527 if (!is_null($step)) { $rgfield->setAttribute('step', $step); }
528 if (!is_null($value)) { $rgfield->setAttribute('value', $value); }
532 public function createElementInputUrl($name, $maxlength, $size, $id = null, $value = null) {
533 $urlfield = $this->createElement('input');
534 $urlfield->setAttribute('type', 'url');
535 if (!is_null($id)) { $urlfield->setAttribute('id', $id); }
536 $urlfield->setAttribute('name', $name);
537 $urlfield->setAttribute('maxlength', $maxlength);
538 $urlfield->setAttribute('size', $size);
539 if (!is_null($value)) { $urlfield->setAttribute('value', $value); }
543 public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
544 $mailfield = $this->createElement('input');
545 $mailfield->setAttribute('type', 'email');
546 if (!is_null($id)) { $mailfield->setAttribute('id', $id); }
547 $mailfield->setAttribute('name', $name);
548 $mailfield->setAttribute('maxlength', $maxlength);
549 $mailfield->setAttribute('size', $size);
550 if (!is_null($value)) { $mailfield->setAttribute('value', $value); }
554 public function createElementInputTel($name, $maxlength, $size, $id = null, $value = null) {
555 $telfield = $this->createElement('input');
556 $telfield->setAttribute('type', 'tel');
557 if (!is_null($id)) { $telfield->setAttribute('id', $id); }
558 $telfield->setAttribute('name', $name);
559 $telfield->setAttribute('maxlength', $maxlength);
560 $telfield->setAttribute('size', $size);
561 if (!is_null($value)) { $telfield->setAttribute('value', $value); }
565 public function createElementInputDate($name, $id = null, $min = null, $max = null, $value = null) {
566 $dtfield = $this->createElement('input');
567 $dtfield->setAttribute('type', 'date');
568 if (!is_null($id)) { $dtfield->setAttribute('id', $id); }
569 $dtfield->setAttribute('name', $name);
570 if (!is_null($min)) { $dtfield->setAttribute('min', $min); }
571 if (!is_null($max)) { $dtfield->setAttribute('max', $max); }
572 if (!is_null($value)) { $dtfield->setAttribute('value', $value); }
576 public function createElementInputTime($name, $id = null, $min = null, $max = null, $value = null) {
577 $timefield = $this->createElement('input');
578 $timefield->setAttribute('type', 'time');
579 if (!is_null($id)) { $timefield->setAttribute('id', $id); }
580 $timefield->setAttribute('name', $name);
581 if (!is_null($min)) { $timefield->setAttribute('min', $min); }
582 if (!is_null($max)) { $timefield->setAttribute('max', $max); }
583 if (!is_null($value)) { $timefield->setAttribute('value', $value); }
587 public function createElementInputColor($name, $id = null, $value = null) {
588 $colfield = $this->createElement('input');
589 $colfield->setAttribute('type', 'color');
590 if (!is_null($id)) { $colfield->setAttribute('id', $id); }
591 $colfield->setAttribute('name', $name);
592 if (!is_null($value)) { $colfield->setAttribute('value', $value); }
596 public function createElementInputRadio($name, $id, $value, $checked) {
597 $radio = $this->createElement('input');
598 $radio->setAttribute('type', 'radio');
599 $radio->setAttribute('name', $name);
600 if (!is_null($id)) { $radio->setAttribute('id', $id); }
601 $radio->setAttribute('value', $value);
602 if ($checked) { $radio->setAttribute('checked', ''); }
606 public function createElementInputCheckbox($name, $id, $value, $checked) {
607 $cbox = $this->createElement('input');
608 $cbox->setAttribute('type', 'checkbox');
609 $cbox->setAttribute('name', $name);
610 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
611 $cbox->setAttribute('value', $value);
612 if ($checked) { $cbox->setAttribute('checked', ''); }
616 public function createElementInputFile($name, $id, $accept) {
617 $fileinput = $this->createElement('input');
618 $fileinput->setAttribute('type', 'file');
619 $fileinput->setAttribute('name', $name);
620 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
621 $fileinput->setAttribute('accept', $accept);
625 public function createElementInputSubmit($value) {
626 $submitbtn = $this->createElement('input');
627 $submitbtn->setAttribute('type', 'submit');
628 $submitbtn->setAttribute('value', $value);
632 public function createElementButton($value, $onclick = null) {
633 $btn = $this->createElement('input');
634 $btn->setAttribute('type', 'button');
635 $btn->setAttribute('value', $value);
636 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
640 public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
641 $txtarea = $this->createElement('textarea', $value);
642 $txtarea->setAttribute('name', $name);
643 $txtarea->setAttribute('cols', $columns);
644 $txtarea->setAttribute('rows', $rows);
645 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
649 public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
650 $select = $this->createElement('select');
651 $select->setAttribute('name', $name);
652 if (!is_null($id)) { $select->setAttribute('id', $id); }
653 foreach ($options as $key => $desc) {
654 $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default));
659 public function createElementOption($key, $desc, $selected = false) {
660 $option = $this->createElement('option', $desc);
662 $option->setAttribute('value', $key);
664 if ($selected) { $option->setAttribute('selected', ''); }
668 public function createElementLabel($for_id, $value) {
669 $label = $this->createElement('label', $value);
670 $label->setAttribute('for', $for_id);
674 public function createElementDatalist($id = null, $options = array()) {
675 $select = $this->createElement('datalist');
676 if (!is_null($id)) { $select->setAttribute('id', $id); }
677 foreach ($options as $key => $desc) {
678 $select->appendElementOption($key, $desc);
683 public function createElementStyle($styledata) {
684 $style_elem = $this->createElement('style');
685 // Note: type can/should be left out for HTML5.
686 $style_elem->setAttribute('type', 'text/css');
687 $style_elem->appendChild($this->createCDATASection($styledata));
691 public function createElementJS($jsdata) {
692 $jselem = $this->createElement('script');
693 // Note: type can/should be left out for HTML5.
694 $jselem->setAttribute('type', 'text/javascript');
695 $jselem->appendChild($this->createCDATASection($jsdata));
699 public function createElementJSFile($jsURL, $defer = false, $async = false) {
700 $jselem = $this->createElement('script');
701 // Note: type can/should be left out for HTML5.
702 $jselem->setAttribute('type', 'text/javascript');
704 $jselem->setAttribute('defer', '');
707 $jselem->setAttribute('async', '');
709 $jselem->setAttribute('src', $jsURL);
714 class ExtendedElement extends DOMElement {
715 // ExtendedElement PHP class
716 // this extends the general PHP DOM Element class to simplify some usual constructs
718 // public function appendElement($name, [$value])
719 // appends a DOMDocument::createElement() as a child of this element (see there for params)
720 // returns the new child
722 // public function appendElementXML($name, $xmldata)
723 // appends a DOMDocument::createElement() with the given name as a child of this element,
724 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
725 // returns the new child
727 // public function appendLink($target, [$value], [$title])
728 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
729 // returns the new child
731 // public function appendImage($src, [$alt_text])
732 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
733 // returns the new child
735 // public function appendForm($action, $method, $name, [$id])
736 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
737 // returns the new child
739 // public function appendFormDiv($action, $method, $name, [$id])
740 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
741 // returns an HTML <div> that is a child of the new child
743 // public function appendInputHidden($name, $value)
744 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
745 // returns the new child
747 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
748 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
749 // returns the new child
751 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
752 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
753 // returns the new child
755 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
756 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
757 // returns the new child
759 // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
760 // appends an ExtendedDocument::createElementInputRange() as a child of this element (see there for params)
761 // returns the new child
763 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
764 // appends an ExtendedDocument::createElementInputUrl() as a child of this element (see there for params)
765 // returns the new child
767 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
768 // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params)
769 // returns the new child
771 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
772 // appends an ExtendedDocument::createElementInputTel() as a child of this element (see there for params)
773 // returns the new child
775 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
776 // appends an ExtendedDocument::createElementInputDate() as a child of this element (see there for params)
777 // returns the new child
779 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
780 // appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params)
781 // returns the new child
783 // public function appendInputColor($name, [$id], [$value])
784 // appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params)
786 // public function appendInputRadio($name, $id, $value, $checked)
787 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
788 // returns the new child
790 // public function appendInputCheckbox($name, $id, $value, $checked)
791 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
792 // returns the new child
794 // public function appendInputFile($name, $id, $accept)
795 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
796 // returns the new child
798 // public function appendInputSubmit($value)
799 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
800 // returns the new child
802 // public function appendButton($value, $onclick = null)
803 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
804 // returns the new child
806 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
807 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
808 // returns the new child
810 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
811 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
812 // returns the new child
814 // public function appendElementOption($key, $desc, [$selected])
815 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
816 // returns the new child
818 // public function appendLabel($for_id, $value)
819 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
820 // returns the new child
822 // public function appendElementDatalist([$id], [$options])
823 // appends an ExtendedDocument::createElementDatalist() as a child of this element (see there for params)
824 // returns the new child
826 // public function appendText($text)
827 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
828 // returns the new child
830 // public function appendLinebreak()
831 // appends a <br> as a child of this element
832 // returns the new child
834 // public function appendEntity($name)
835 // appends a DOMDocument::createEntityReference() as a child of this element (see there for params)
836 // returns the new child
838 // public function appendComment($comment_data)
839 // appends a DOMDocument::createComment() as a child of this element (see there for params)
840 // returns the new child
842 // public function appendClonedElement($dom_element, [$deep])
843 // appends a clone of the given DOMElement as a child of this element
844 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
845 // returns the new child
847 // public function appendHTMLMarkup($htmldata)
848 // appends a representation of the HTML data as children of this element
851 // public function appendXMLMarkup($xmldata)
852 // appends a representation of the XML data as children of this element
855 // public function appendStyleElement($styledata)
856 // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
857 // returns the new child
859 // public function appendJSElement($jsdata)
860 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
861 // returns the new child
863 // public function appendJSFile($jsURL, [$defer], [$async])
864 // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
865 // returns the new child
867 // public function setClass($classname)
868 // sets the 'class' attribute of the element to the given classname value
870 // public function addClass($classname)
871 // adds the given classname value to the space-separated list in the 'class' attribute
872 // returns the value of the 'class' attribute
874 // public function setID($elem_id)
875 // sets the 'id' attribute of the element to the given elem_id value
877 public function appendElement($name, $value = '') {
878 return $this->appendChild($this->ownerDocument->createElement($name, $value));
880 public function appendElementXML($name, $xmldata) {
881 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
882 $aelem->appendXMLMarkup($xmldata);
885 public function appendLink($target, $value = '', $title = null) {
886 return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
888 public function appendImage($src, $alt_text = '') {
889 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
891 public function appendForm($action, $method, $name, $id = null) {
892 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
894 public function appendFormDiv($action, $method, $name, $id = null) {
895 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
896 return $formelem->appendElement('div');
898 public function appendInputHidden($name, $value) {
899 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
901 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
902 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
904 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
905 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
907 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
908 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
910 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
911 return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
913 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
914 return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
916 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
917 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
919 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
920 return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
922 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
923 return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
925 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
926 return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
928 public function appendInputColor($name, $id = null, $value = null) {
929 return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
931 public function appendInputRadio($name, $id, $value, $checked) {
932 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
934 public function appendInputCheckbox($name, $id, $value, $checked) {
935 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
937 public function appendInputFile($name, $id, $accept) {
938 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
940 public function appendInputSubmit($value) {
941 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
943 public function appendButton($value, $onclick = null) {
944 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
946 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
947 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
949 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
950 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
952 public function appendElementOption($key, $desc, $selected = false) {
953 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
955 public function appendLabel($for_id, $value) {
956 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
958 public function appendElementDatalist($id = null, $options = array()) {
959 return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
961 public function appendText($text) {
962 return $this->appendChild($this->ownerDocument->createTextNode($text ?? ''));
964 public function appendLinebreak() {
965 return $this->appendChild($this->ownerDocument->createElement('br'));
967 public function appendEntity($name) {
968 return $this->appendChild($this->ownerDocument->createEntityReference($name));
970 public function appendComment($comment_data) {
971 return $this->appendChild($this->ownerDocument->createComment($comment_data));
973 public function appendClonedElement($dom_element, $deep = true) {
974 return $this->appendChild($dom_element->cloneNode($deep));
976 public function appendHTMLMarkup($htmldata) {
977 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
979 public function appendXMLMarkup($xmldata) {
980 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
982 public function appendStyleElement($styledata) {
983 return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
985 public function appendJSElement($jsdata) {
986 return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
988 public function appendJSFile($jsURL, $defer = false, $async = false) {
989 return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));
991 public function setClass($classname) {
992 $this->setAttribute('class', $classname);
994 public function addClass($classname) {
995 $classval = $this->getAttribute('class');
996 if (strlen($classval)) { $classval .= ' '; }
997 $classval .= $classname;
998 $this->setClass($classval);
1001 public function setID($elem_id) {
1002 $this->setAttribute('id', $elem_id);
1006 class ExtendedDocumentFragment extends DOMDocumentFragment {
1007 // ExtendedDocumentFragment PHP class
1008 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
1010 // public function appendElement($name, [$value])
1011 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
1012 // returns the new child
1014 // public function appendElementXML($name, $xmldata)
1015 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
1016 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
1017 // returns the new child
1019 // public function appendLink($target, [$value], [$title])
1020 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
1021 // returns the new child
1023 // public function appendImage($src, [$alt_text])
1024 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
1025 // returns the new child
1027 // public function appendForm($action, $method, $name, [$id])
1028 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
1029 // returns the new child
1031 // public function appendFormDiv($action, $method, $name, [$id])
1032 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
1033 // returns an HTML <div> that is a child of the new child
1035 // public function appendInputHidden($name, $value)
1036 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
1037 // returns the new child
1039 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
1040 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
1041 // returns the new child
1043 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
1044 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
1045 // returns the new child
1047 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
1048 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
1049 // returns the new child
1051 // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
1052 // appends an ExtendedDocument::createElementInputRange() as a child of this fragment (see there for params)
1053 // returns the new child
1055 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
1056 // appends an ExtendedDocument::createElementInputUrl() as a child of this fragment (see there for params)
1057 // returns the new child
1059 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
1060 // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params)
1061 // returns the new child
1063 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
1064 // appends an ExtendedDocument::createElementInputTel() as a child of this fragment (see there for params)
1065 // returns the new child
1067 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
1068 // appends an ExtendedDocument::createElementInputDate() as a child of this fragment (see there for params)
1069 // returns the new child
1071 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
1072 // appends an ExtendedDocument::createElementInputTime() as a child of this fragment (see there for params)
1073 // returns the new child
1075 // public function appendInputColor($name, [$id], [$value])
1076 // appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params)
1078 // public function appendInputRadio($name, $id, $value, $checked)
1079 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
1080 // returns the new child
1082 // public function appendInputCheckbox($name, $id, $value, $checked)
1083 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
1084 // returns the new child
1086 // public function appendInputFile($name, $id, $accept)
1087 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
1088 // returns the new child
1090 // public function appendInputSubmit($value)
1091 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
1092 // returns the new child
1094 // public function appendButton($value, $onclick = null)
1095 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
1096 // returns the new child
1098 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
1099 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
1100 // returns the new child
1102 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
1103 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
1104 // returns the new child
1106 // public function appendElementOption($key, $desc, [$selected])
1107 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
1108 // returns the new child
1110 // public function appendLabel($for_id, $value)
1111 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
1112 // returns the new child
1114 // public function appendElementDatalist([$id], [$options])
1115 // appends an ExtendedDocument::createElementDatalist() as a child of this fragment (see there for params)
1116 // returns the new child
1118 // public function appendText($text)
1119 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
1120 // returns the new child
1122 // public function appendLinebreak()
1123 // appends a <br> as a child of this fragment
1124 // returns the new child
1126 // public function appendEntity($name)
1127 // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params)
1128 // returns the new child
1130 // public function appendComment($comment_data)
1131 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
1132 // returns the new child
1134 // public function appendClonedElement($dom_element, [$deep])
1135 // appends a clone of the given DOMElement as a child of this fragment
1136 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
1137 // returns the new child
1139 // public function appendHTMLMarkup($htmldata)
1140 // appends a representation of the HTML data as children of this fragment
1143 // public function appendXMLMarkup($xmldata)
1144 // appends a representation of the XML data as children of this fragment
1147 // public function appendStyleElement($styledata)
1148 // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
1149 // returns the new child
1151 // public function appendJSElement($jsdata)
1152 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
1153 // returns the new child
1155 // public function appendJSFile($jsURL, [$defer], [$async])
1156 // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params)
1157 // returns the new child
1159 public function appendElement($name, $value = '') {
1160 return $this->appendChild($this->ownerDocument->createElement($name, $value));
1162 public function appendElementXML($name, $xmldata) {
1163 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
1164 $aelem->appendXMLMarkup($xmldata);
1167 public function appendLink($target, $value = '', $title = null) {
1168 return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
1170 public function appendImage($src, $alt_text = '') {
1171 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
1173 public function appendForm($action, $method, $name, $id = null) {
1174 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
1176 public function appendFormDiv($action, $method, $name, $id = null) {
1177 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
1178 return $formelem->appendElement('div');
1180 public function appendInputHidden($name, $value) {
1181 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
1183 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
1184 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
1186 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
1187 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
1189 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
1190 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
1192 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
1193 return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
1195 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
1196 return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
1198 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
1199 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
1201 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
1202 return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
1204 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
1205 return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
1207 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
1208 return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
1210 public function appendInputColor($name, $id = null, $value = null) {
1211 return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
1213 public function appendInputRadio($name, $id, $value, $checked) {
1214 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
1216 public function appendInputCheckbox($name, $id, $value, $checked) {
1217 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
1219 public function appendInputFile($name, $id, $accept) {
1220 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
1222 public function appendInputSubmit($value) {
1223 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
1225 public function appendButton($value, $onclick = null) {
1226 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
1228 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
1229 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
1231 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
1232 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
1234 public function appendElementOption($key, $desc, $selected = false) {
1235 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
1237 public function appendLabel($for_id, $value) {
1238 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
1240 public function appendElementDatalist($id = null, $options = array()) {
1241 return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
1243 public function appendText($text) {
1244 return $this->appendChild($this->ownerDocument->createTextNode($text));
1246 public function appendLinebreak() {
1247 return $this->appendChild($this->ownerDocument->createElement('br'));
1249 public function appendEntity($name) {
1250 return $this->appendChild($this->ownerDocument->createEntityReference($name));
1252 public function appendComment($comment_data) {
1253 return $this->appendChild($this->ownerDocument->createComment($comment_data));
1255 public function appendClonedElement($dom_element, $deep = true) {
1256 return $this->appendChild($dom_element->cloneNode($deep));
1258 public function appendHTMLMarkup($htmldata) {
1259 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
1261 public function appendXMLMarkup($xmldata) {
1262 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
1264 public function appendStyleElement($styledata) {
1265 return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
1267 public function appendJSElement($jsdata) {
1268 return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
1270 public function appendJSFile($jsURL, $defer = false, $async = false) {
1271 return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));