add code for datetime-local input elements
[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 //
d7403a92
RK
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.
22 //
61cc8aa9 23 // public function appendElement($name, [$value])
cea5b93a
RK
24 // appends a DOMDocument::createElement() as a child of this document (see there for params)
25 // returns the new child
26 //
61cc8aa9 27 // public function appendElementXML($name, $xmldata)
cea5b93a
RK
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
31 //
b3cc0fef 32 // public function appendLink($target, [$value], [$title])
cea5b93a
RK
33 // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
34 // returns the new child
35 //
61cc8aa9 36 // public function appendImage($src, [$alt_text])
53510e9e
RK
37 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
38 // returns the new child
39 //
61cc8aa9 40 // public function appendForm($action, $method, $name, [$id])
b8d16837
RK
41 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
42 // returns the new child
43 //
61cc8aa9 44 // public function appendFormDiv($action, $method, $name, [$id])
ae41c41b
RK
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
47 //
61cc8aa9 48 // public function appendInputHidden($name, $value)
ae41c41b
RK
49 // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
50 // returns the new child
51 //
61cc8aa9 52 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
ae41c41b
RK
53 // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
54 // returns the new child
55 //
f925e4a1
RK
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
59 //
61cc8aa9 60 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
61 // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
62 // returns the new child
63 //
f925e4a1
RK
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
67 //
6f794328
RK
68 // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
69 // appends an ExtendedDocument::createElementInputSearch() as a child of this document (see there for params)
70 // returns the new child
71 //
f925e4a1
RK
72 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
73 // appends an ExtendedDocument::createElementInputUrl() as a child of this document (see there for params)
74 // returns the new child
75 //
ea32f7e5
RK
76 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
77 // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params)
78 // returns the new child
79 //
f925e4a1
RK
80 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
81 // appends an ExtendedDocument::createElementInputTel() as a child of this document (see there for params)
82 // returns the new child
83 //
84 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
85 // appends an ExtendedDocument::createElementInputDate() as a child of this document (see there for params)
86 // returns the new child
87 //
88 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
89 // appends an ExtendedDocument::createElementInputTime() as a child of this document (see there for params)
90 // returns the new child
91 //
177ee3d6
RK
92 // public function appendInputDateTime($name, [$id], [$min], [$max], [$value])
93 // appends an ExtendedDocument::createElementInputDateTime() as a child of this document (see there for params)
94 // returns the new child
95 //
f925e4a1
RK
96 // public function appendInputColor($name, [$id], [$value])
97 // appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params)
645a7eb6
RK
98 // returns the new child
99 //
61cc8aa9 100 // public function appendInputRadio($name, $id, $value, $checked)
ae41c41b
RK
101 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
102 // returns the new child
103 //
61cc8aa9 104 // public function appendInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
105 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
106 // returns the new child
107 //
61cc8aa9 108 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
109 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
110 // returns the new child
111 //
61cc8aa9 112 // public function appendInputSubmit($value)
ae41c41b
RK
113 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
114 // returns the new child
115 //
61cc8aa9 116 // public function appendButton($value, $onclick = null)
1109f526
RK
117 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
118 // returns the new child
119 //
61cc8aa9 120 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
121 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
122 // returns the new child
123 //
69409ddb 124 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
bf91764c
RK
125 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
126 // returns the new child
127 //
61cc8aa9 128 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
129 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
130 // returns the new child
131 //
61cc8aa9 132 // public function appendLabel($for_id, $value)
ae41c41b
RK
133 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
134 // returns the new child
135 //
c79be4c2
RK
136 // public function appendElementDatalist([$id], [$options])
137 // appends an ExtendedDocument::createElementDatalist() as a child of this document (see there for params)
138 // returns the new child
139 //
61cc8aa9 140 // public function appendText($text)
cea5b93a
RK
141 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
142 // returns the new child
143 //
71771b0c
RK
144 // public function appendLinebreak()
145 // appends a <br> as a child of this document
146 // returns the new child
147 //
6638efd5
RK
148 // public function appendEntity($name)
149 // appends a DOMDocument::createEntityReference() as a child of this document (see there for params)
150 // returns the new child
151 //
61cc8aa9 152 // public function appendComment($comment_data)
cadc5980
RK
153 // appends a DOMDocument::createComment() as a child of this document (see there for params)
154 // returns the new child
155 //
3d4db013
RK
156 // public function appendClonedElement($dom_element, [$deep])
157 // appends a clone of the given DOMElement as a child of this document
158 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
159 // returns the new child
160 //
61cc8aa9 161 // public function appendHTMLMarkup($htmldata, [$parentNode])
ae41c41b
RK
162 // appends a representation of the HTML data as children of the given parent node, by default this document
163 // NO return value!
164 //
61cc8aa9 165 // public function appendXMLMarkup($xmldata, [$parentNode])
ae41c41b 166 // appends a representation of the XML data as children of the given parent node, by default this document
cea5b93a
RK
167 // NO return value!
168 //
acaa2daa
RK
169 // public function appendStyleElement($styledata)
170 // appends an ExtendedDocument::createElementStyle() as a child of this document (see there for params)
171 // returns the new child
172 //
61cc8aa9 173 // public function appendJSElement($jsdata)
cea5b93a 174 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
acaa2daa 175 // returns the new child
cea5b93a 176 //
8afa2e61 177 // public function appendJSFile($jsURL, [$defer], [$async])
ea32f7e5
RK
178 // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params)
179 // returns the new child
180 //
b3cc0fef
RK
181 // public function createElementLink($target, [$value], [$title])
182 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value as well as (optional) title attribute
cea5b93a 183 //
61cc8aa9 184 // public function createElementImage($src, [$alt_text])
b3cc0fef 185 // returns an ExtendedElement that is an HTML <img> with the given src and alt attributes (set to '' by default)
53510e9e 186 //
61cc8aa9 187 // public function createElementForm($action, $method, $name)
cb2420c6 188 // returns an ExtendedElement that is an HTML <form> with the given action, method, and name
ae41c41b 189 //
61cc8aa9 190 // public function createElementInputHidden($name, $value)
ae41c41b
RK
191 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
192 //
61cc8aa9 193 // public function createElementInputText($name, $maxlength, $size, [$id], [$value])
ae41c41b
RK
194 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
195 // and optionally id and value
196 //
f925e4a1
RK
197 // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
198 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
199 // and optionally id and value
200 //
61cc8aa9 201 // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
202 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
203 // and optionally id and value
204 //
f925e4a1
RK
205 // public function createElementInputRange($name, $id, $min, $max, [$step], [$value])
206 // returns an ExtendedElement that is an HTML <input> of type 'range' with the given name, id, min, max,
207 // and optionally step and value
208 //
209 // public function createElementInputUrl($name, $maxlength, $size, [$id], [$value])
210 // returns an ExtendedElement that is an HTML <input> of type 'url' with the given name, maxlength, size,
211 // and optionally id and value
212 //
6f794328
RK
213 // public function createElementInputSearch($name, $maxlength, $size, [$id], [$value])
214 // returns an ExtendedElement that is an HTML <input> of type 'search' with the given name, maxlength, size,
215 // and optionally id and value
216 //
ea32f7e5
RK
217 // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value])
218 // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size,
219 // and optionally id and value
220 //
f925e4a1
RK
221 // public function createElementInputTel($name, $maxlength, $size, [$id], [$value])
222 // returns an ExtendedElement that is an HTML <input> of type 'tel' with the given name, maxlength, size,
223 // and optionally id and value
224 //
225 // public function createElementInputDate($name, [$id], [$min], [$max], [$value])
226 // returns an ExtendedElement that is an HTML <input> of type 'date' with the given name,
227 // and optionally id, min, max, and value
228 //
229 // public function createElementInputTime($name, [$id], [$min], [$max], [$value])
230 // returns an ExtendedElement that is an HTML <input> of type 'time' with the given name,
231 // and optionally id, min, max, and value
232 //
177ee3d6
RK
233 // public function createElementInputDateTime($name, [$id], [$min], [$max], [$value])
234 // returns an ExtendedElement that is an HTML <input> of type 'datetime-local' with the given name,
235 // and optionally id, min, max, and value
236 //
f925e4a1
RK
237 // public function createElementInputColor($name, [$id], [$value])
238 // returns an ExtendedElement that is an HTML <input> of type 'color' with the given name,
645a7eb6
RK
239 // and optionally id and value
240 //
61cc8aa9 241 // public function createElementInputRadio($name, $id, $value, $checked)
ae41c41b
RK
242 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
243 // checked state
244 //
61cc8aa9 245 // public function createElementInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
246 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
247 // checked state
248 //
61cc8aa9 249 // public function createElementInputFile($name, $id, $accept)
4bb9d784
RK
250 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
251 //
61cc8aa9 252 // public function createElementInputSubmit($value)
1109f526
RK
253 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
254 //
61cc8aa9 255 // public function createElementButton($value, $onclick = null)
1109f526 256 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
ae41c41b 257 //
61cc8aa9 258 // public function createElementTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
259 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
260 // and optionally id and value
261 //
69409ddb 262 // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch])
bf91764c 263 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
69409ddb 264 // array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true)
bf91764c 265 //
61cc8aa9 266 // public function createElementOption($key, $desc, [$selected])
bf91764c
RK
267 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
268 // and optionally bool that tells if the entry is selected
269 //
61cc8aa9 270 // public function createElementLabel($for_id, $value)
ae41c41b 271 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
cea5b93a 272 //
c79be4c2
RK
273 // public function createElementDatalist([$id], [$options])
274 // returns an ExtendedElement that is an HTML <datalist> with optionally the given id and array of options (key => description)
275 //
acaa2daa
RK
276 // public function createElementStyle($styledata)
277 // returns an ExtendedElement that is an HTML <style> of CSS type with the style data inside
278 //
61cc8aa9 279 // public function createElementJS($jsdata)
cea5b93a 280 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
c1666e91 281 //
8afa2e61 282 // public function createElementJSFile($jsURL, [$defer], [$async])
ea32f7e5 283 // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL
8afa2e61 284 // $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
285
286 function __construct($version = '1.0', $encoding = 'utf-8') {
287 // make sure the default DOMDocument constructor runs
288 parent::__construct($version, $encoding);
289 $this->registerNodeClass('DOMElement', 'ExtendedElement');
bf91764c 290 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
cea5b93a
RK
291 }
292
b841a92b
RK
293 static function initHTML5($doc = null) {
294 if (is_null($doc)) { $doc = new ExtendedDocument(); }
0fe05664 295 $doc->loadHTML5('<?xml version="1.0" encoding="utf-8"?>'."\n".'<!DOCTYPE html>'."\n".'<html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
14014b8f
RK
296
297 // Created basic HTML document structure.
298 $root = $doc->getElementsByTagName('html')->item(0);
299 $head = $root->appendElement('head');
300 $title = $head->appendElement('title');
301 $body = $root->appendElement('body');
302
303 return array('document' => $doc,
304 'html' => $root,
305 'head' => $head,
306 'title' => $title,
307 'body' => $body);
308 }
309
d7403a92
RK
310 public function loadHTML5($source) {
311 // Do our own handling of DOMDocument error reporting so we can ignore "unknown tags" which are usually fine in HTML5.
312 libxml_use_internal_errors(true);
0fe05664 313 if (!preg_match('/^\s*<\?xml /', $source)) {
d7403a92
RK
314 // Add an XML declaration to force DOMDocument into UTF-8 mode.
315 $source = '<?xml version="1.0" encoding="utf-8"?>'."\n".$source;
316 }
317 $result = $this->loadHTML($source);
0fe05664
RK
318 // Set encoding directly a,d remove any processing node that isn't the first node
319 $this->encoding = 'utf-8';
320 foreach ($this->childNodes as $i => $child) {
321 if ($i && $child->nodeType == XML_PI_NODE) {
322 $this->removeChild($child);
323 }
324 }
d7403a92
RK
325 // Handle DOMDocument loading errors, throw away warnings on unknown tags as HTML5 allows all kinds.
326 $errseverity = array(LIBXML_ERR_WARNING => 'Warning', LIBXML_ERR_ERROR => 'Error', LIBXML_ERR_FATAL => 'Fatal');
327 foreach (libxml_get_errors() as $error) {
328 // $error is a libXMLError, see https://www.php.net/manual/en/class.libxmlerror.php
329 // See http://www.xmlsoft.org/html/libxml-xmlerror.html#xmlParserErrors for error numbers
330 if ($error->code != 801) { // XML_HTML_UNKNOWN_TAG gets no output, should not exist for HTML5.
331 trigger_error($errseverity[$error->level].' loading HTML5: '.$error->message.' (code '.$error->code.'), line: '.$error->line, E_USER_WARNING);
332 }
333 }
334 libxml_clear_errors();
335 libxml_use_internal_errors(false);
336 return $result;
337 }
338
61cc8aa9 339 public function appendElement($name, $value = '') {
a8816f43 340 return $this->appendChild($this->createElement($name, $value));
cea5b93a 341 }
61cc8aa9 342 public function appendElementXML($name, $xmldata) {
cea5b93a 343 $aelem = $this->appendChild($this->createElement($name));
ae41c41b
RK
344 $aelem->appendXMLMarkup($xmldata);
345 //$aelem->appendChild($this->createXMLFragment($xmldata));
cea5b93a
RK
346 return $aelem;
347 }
b3cc0fef
RK
348 public function appendLink($target, $value = '', $title = null) {
349 return $this->appendChild($this->createElementLink($target, $value, $title));
cea5b93a 350 }
61cc8aa9 351 public function appendImage($src, $alt_text = '') {
4aa31782
RK
352 return $this->appendChild($this->createElementImage($src, $alt_text));
353 }
61cc8aa9 354 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
355 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
356 }
61cc8aa9 357 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 358 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
ae41c41b
RK
359 return $formelem->appendElement('div');
360 }
61cc8aa9 361 public function appendInputHidden($name, $value) {
ae41c41b
RK
362 return $this->appendChild($this->createElementInputHidden($name, $value));
363 }
61cc8aa9 364 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
365 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
366 }
f925e4a1
RK
367 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
368 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
369 }
61cc8aa9 370 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
371 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
372 }
f925e4a1
RK
373 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
374 return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value));
375 }
6f794328
RK
376 public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
377 return $this->appendChild($this->createElementInputSearch($name, $maxlength, $size, $id, $value));
378 }
f925e4a1
RK
379 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
380 return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value));
381 }
ea32f7e5
RK
382 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
383 return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value));
384 }
f925e4a1
RK
385 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
386 return $this->appendChild($this->createElementInputTel($name, $maxlength, $size, $id, $value));
387 }
388 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
389 return $this->appendChild($this->createElementInputDate($name, $id, $min, $max, $value));
390 }
391 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
392 return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value));
393 }
177ee3d6
RK
394 public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) {
395 return $this->appendChild($this->createElementInputDateTime($name, $id, $min, $max, $value));
396 }
f925e4a1
RK
397 public function appendInputColor($name, $id = null, $value = null) {
398 return $this->appendChild($this->createElementInputColor($name, $id, $value));
645a7eb6 399 }
61cc8aa9 400 public function appendInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
401 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
402 }
61cc8aa9 403 public function appendInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
404 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
405 }
61cc8aa9 406 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
407 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
408 }
61cc8aa9 409 public function appendInputSubmit($value) {
ae41c41b
RK
410 return $this->appendChild($this->createElementInputSubmit($value));
411 }
61cc8aa9 412 public function appendButton($value, $onclick = null) {
1109f526
RK
413 return $this->appendChild($this->createElementButton($value, $onclick));
414 }
61cc8aa9 415 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
416 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
417 }
69409ddb
RK
418 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
419 return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch));
bf91764c 420 }
61cc8aa9 421 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
422 return $this->appendChild($this->createElementOption($key, $desc, $selected));
423 }
61cc8aa9 424 public function appendLabel($for_id, $value) {
ae41c41b
RK
425 return $this->appendChild($this->createElementLabel($for_id, $value));
426 }
c79be4c2
RK
427 public function appendElementDatalist($id = null, $options = array()) {
428 return $this->appendChild($this->createElementDatalist($id, $options));
429 }
61cc8aa9 430 public function appendText($text) {
cea5b93a
RK
431 return $this->appendChild($this->createTextNode($text));
432 }
71771b0c
RK
433 public function appendLinebreak() {
434 return $this->appendChild($this->createElement('br'));
435 }
6638efd5
RK
436 public function appendEntity($name) {
437 return $this->appendChild($this->createEntityReference($name));
438 }
61cc8aa9 439 public function appendComment($comment_data) {
cadc5980
RK
440 return $this->appendChild($this->createComment($comment_data));
441 }
3d4db013
RK
442 public function appendClonedElement($dom_element, $deep = true) {
443 return $this->appendChild($dom_element->cloneNode($deep));
444 }
acaa2daa
RK
445 public function appendStyleElement($styledata) {
446 return $this->appendChild($this->createElementStyle($styledata));
447 }
61cc8aa9 448 public function appendJSElement($jsdata) {
3d4db013 449 return $this->appendChild($this->createElementJS($jsdata));
cea5b93a 450 }
1a4ee0f0
RK
451 public function appendJSFile($jsURL, $defer = false, $async = false) {
452 return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async));
ea32f7e5 453 }
cea5b93a 454
61cc8aa9 455 public function appendHTMLMarkup($htmldata, $parentNode = null) {
ae41c41b 456 if (is_null($parentNode)) { $parentNode =& $this; }
d7403a92 457 // Use loadHTML5() to parse and turn the markup into proper HTML.
a9a5a68a
RK
458 $tmpdoc = new ExtendedDocument;
459 // The XML line is needed to tell the parser that we need UTF-8 parsing.
0fe05664 460 $tmpdoc->loadHTML5('<?xml version="1.0" encoding="utf-8"?>'."\n".'<!DOCTYPE html>'."\n".'<html><body>'.$htmldata.'</body></html>');
a9a5a68a
RK
461 foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) {
462 $parentNode->appendChild($this->importNode($child, true));
463 }
ae41c41b
RK
464 }
465
61cc8aa9 466 public function appendXMLMarkup($xmldata, $parentNode = null) {
ae41c41b
RK
467 if (is_null($parentNode)) { $parentNode =& $this; }
468 $tmpdoc = new ExtendedDocument;
469 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
470 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
471 $tmpxml .= '<root>'.$xmldata.'</root>';
472 $tmpdoc->loadXML($tmpxml);
473 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
474 $parentNode->appendChild($this->importNode($child, true));
475 }
cea5b93a
RK
476 }
477
61cc8aa9 478 public function createElement($name, $value = '') {
a8816f43
RK
479 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
480 $aelem = parent::createElement($name);
5ae00086 481 if (strlen($value ?? '')) { $aelem->appendText($value); }
a8816f43
RK
482 return $aelem;
483 }
484
b3cc0fef 485 public function createElementLink($target, $value = '', $title = null) {
a8816f43 486 $link = $this->createElement('a', $value);
bf91764c 487 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
b3cc0fef 488 if (!is_null($title)) { $link->setAttribute('title', $title); }
cea5b93a
RK
489 return $link;
490 }
491
61cc8aa9 492 public function createElementImage($src, $alt_text = '') {
319cfe8d
RK
493 $img = $this->createElement('img');
494 $img->setAttribute('src', $src);
495 $img->setAttribute('alt', $alt_text);
496 return $img;
4aa31782
RK
497 }
498
61cc8aa9 499 public function createElementForm($action, $method, $name, $id = null) {
ae41c41b
RK
500 $formelem = $this->createElement('form');
501 $formelem->setAttribute('action', $action);
502 $formelem->setAttribute('method', $method);
503 $formelem->setAttribute('name', $name);
b3cc0fef 504 if (!is_null($id)) { $formelem->setAttribute('id', $id); }
ae41c41b
RK
505 return $formelem;
506 }
507
61cc8aa9 508 public function createElementInputHidden($name, $value) {
ae41c41b
RK
509 $hidden = $this->createElement('input');
510 $hidden->setAttribute('type', 'hidden');
511 $hidden->setAttribute('name', $name);
512 $hidden->setAttribute('value', $value);
513 return $hidden;
514 }
515
61cc8aa9 516 public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
517 $txfield = $this->createElement('input');
518 $txfield->setAttribute('type', 'text');
519 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
520 $txfield->setAttribute('name', $name);
521 $txfield->setAttribute('maxlength', $maxlength);
522 $txfield->setAttribute('size', $size);
523 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
524 return $txfield;
525 }
526
61cc8aa9 527 public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
319cfe8d
RK
528 $pwfield = $this->createElement('input');
529 $pwfield->setAttribute('type', 'password');
530 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
531 $pwfield->setAttribute('name', $name);
532 $pwfield->setAttribute('maxlength', $maxlength);
533 $pwfield->setAttribute('size', $size);
534 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
535 return $pwfield;
645a7eb6
RK
536 }
537
f925e4a1
RK
538 public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
539 $numfield = $this->createElement('input');
540 $numfield->setAttribute('type', 'number');
541 if (!is_null($id)) { $numfield->setAttribute('id', $id); }
542 $numfield->setAttribute('name', $name);
543 $numfield->setAttribute('maxlength', $maxlength);
544 $numfield->setAttribute('size', $size);
545 if (!is_null($value)) { $numfield->setAttribute('value', $value); }
546 return $numfield;
547 }
548
549 public function createElementInputRange($name, $id, $min, $max, $step = null, $value = null) {
550 $rgfield = $this->createElement('input');
551 $rgfield->setAttribute('type', 'range');
552 if (!is_null($id)) { $rgfield->setAttribute('id', $id); }
553 $rgfield->setAttribute('name', $name);
554 if (!is_null($min)) { $rgfield->setAttribute('min', $min); }
555 if (!is_null($max)) { $rgfield->setAttribute('max', $max); }
556 if (!is_null($step)) { $rgfield->setAttribute('step', $step); }
557 if (!is_null($value)) { $rgfield->setAttribute('value', $value); }
558 return $rgfield;
559 }
560
6f794328
RK
561 public function createElementInputSearch($name, $maxlength, $size, $id = null, $value = null) {
562 $urlfield = $this->createElement('input');
563 $urlfield->setAttribute('type', 'search');
564 if (!is_null($id)) { $urlfield->setAttribute('id', $id); }
565 $urlfield->setAttribute('name', $name);
566 $urlfield->setAttribute('maxlength', $maxlength);
567 $urlfield->setAttribute('size', $size);
568 if (!is_null($value)) { $urlfield->setAttribute('value', $value); }
569 return $urlfield;
570 }
571
f925e4a1
RK
572 public function createElementInputUrl($name, $maxlength, $size, $id = null, $value = null) {
573 $urlfield = $this->createElement('input');
574 $urlfield->setAttribute('type', 'url');
575 if (!is_null($id)) { $urlfield->setAttribute('id', $id); }
576 $urlfield->setAttribute('name', $name);
577 $urlfield->setAttribute('maxlength', $maxlength);
578 $urlfield->setAttribute('size', $size);
579 if (!is_null($value)) { $urlfield->setAttribute('value', $value); }
580 return $urlfield;
581 }
582
583 public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
584 $mailfield = $this->createElement('input');
585 $mailfield->setAttribute('type', 'email');
586 if (!is_null($id)) { $mailfield->setAttribute('id', $id); }
587 $mailfield->setAttribute('name', $name);
588 $mailfield->setAttribute('maxlength', $maxlength);
589 $mailfield->setAttribute('size', $size);
590 if (!is_null($value)) { $mailfield->setAttribute('value', $value); }
591 return $mailfield;
592 }
593
594 public function createElementInputTel($name, $maxlength, $size, $id = null, $value = null) {
595 $telfield = $this->createElement('input');
596 $telfield->setAttribute('type', 'tel');
597 if (!is_null($id)) { $telfield->setAttribute('id', $id); }
598 $telfield->setAttribute('name', $name);
599 $telfield->setAttribute('maxlength', $maxlength);
600 $telfield->setAttribute('size', $size);
601 if (!is_null($value)) { $telfield->setAttribute('value', $value); }
602 return $telfield;
603 }
604
605 public function createElementInputDate($name, $id = null, $min = null, $max = null, $value = null) {
b5897591
RK
606 $dtfield = $this->createElement('input');
607 $dtfield->setAttribute('type', 'date');
608 if (!is_null($id)) { $dtfield->setAttribute('id', $id); }
609 $dtfield->setAttribute('name', $name);
610 if (!is_null($min)) { $dtfield->setAttribute('min', $min); }
611 if (!is_null($max)) { $dtfield->setAttribute('max', $max); }
612 if (!is_null($value)) { $dtfield->setAttribute('value', $value); }
613 return $dtfield;
f925e4a1
RK
614 }
615
616 public function createElementInputTime($name, $id = null, $min = null, $max = null, $value = null) {
b5897591
RK
617 $timefield = $this->createElement('input');
618 $timefield->setAttribute('type', 'time');
619 if (!is_null($id)) { $timefield->setAttribute('id', $id); }
620 $timefield->setAttribute('name', $name);
621 if (!is_null($min)) { $timefield->setAttribute('min', $min); }
622 if (!is_null($max)) { $timefield->setAttribute('max', $max); }
623 if (!is_null($value)) { $timefield->setAttribute('value', $value); }
624 return $timefield;
f925e4a1
RK
625 }
626
177ee3d6
RK
627 public function createElementInputDateTime($name, $id = null, $min = null, $max = null, $value = null) {
628 $dtfield = $this->createElement('input');
629 $dtfield->setAttribute('type', 'datetime-local');
630 if (!is_null($id)) { $dtfield->setAttribute('id', $id); }
631 $dtfield->setAttribute('name', $name);
632 if (!is_null($min)) { $dtfield->setAttribute('min', $min); }
633 if (!is_null($max)) { $dtfield->setAttribute('max', $max); }
634 if (!is_null($value)) { $dtfield->setAttribute('value', str_replace(' ', 'T', $value, 1)); }
635 return $dtfield;
636 }
637
f925e4a1
RK
638 public function createElementInputColor($name, $id = null, $value = null) {
639 $colfield = $this->createElement('input');
640 $colfield->setAttribute('type', 'color');
641 if (!is_null($id)) { $colfield->setAttribute('id', $id); }
642 $colfield->setAttribute('name', $name);
643 if (!is_null($value)) { $colfield->setAttribute('value', $value); }
644 return $colfield;
645 }
646
61cc8aa9 647 public function createElementInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
648 $radio = $this->createElement('input');
649 $radio->setAttribute('type', 'radio');
650 $radio->setAttribute('name', $name);
4bb9d784 651 if (!is_null($id)) { $radio->setAttribute('id', $id); }
ae41c41b
RK
652 $radio->setAttribute('value', $value);
653 if ($checked) { $radio->setAttribute('checked', ''); }
654 return $radio;
655 }
656
61cc8aa9 657 public function createElementInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
658 $cbox = $this->createElement('input');
659 $cbox->setAttribute('type', 'checkbox');
660 $cbox->setAttribute('name', $name);
4bb9d784 661 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
ae41c41b
RK
662 $cbox->setAttribute('value', $value);
663 if ($checked) { $cbox->setAttribute('checked', ''); }
664 return $cbox;
665 }
666
61cc8aa9 667 public function createElementInputFile($name, $id, $accept) {
4bb9d784
RK
668 $fileinput = $this->createElement('input');
669 $fileinput->setAttribute('type', 'file');
670 $fileinput->setAttribute('name', $name);
671 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
672 $fileinput->setAttribute('accept', $accept);
673 return $fileinput;
674 }
675
61cc8aa9 676 public function createElementInputSubmit($value) {
ae41c41b
RK
677 $submitbtn = $this->createElement('input');
678 $submitbtn->setAttribute('type', 'submit');
679 $submitbtn->setAttribute('value', $value);
680 return $submitbtn;
681 }
682
61cc8aa9 683 public function createElementButton($value, $onclick = null) {
1109f526
RK
684 $btn = $this->createElement('input');
685 $btn->setAttribute('type', 'button');
686 $btn->setAttribute('value', $value);
687 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
688 return $btn;
689 }
690
61cc8aa9 691 public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
692 $txtarea = $this->createElement('textarea', $value);
693 $txtarea->setAttribute('name', $name);
694 $txtarea->setAttribute('cols', $columns);
695 $txtarea->setAttribute('rows', $rows);
696 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
697 return $txtarea;
698 }
699
69409ddb 700 public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
bf91764c
RK
701 $select = $this->createElement('select');
702 $select->setAttribute('name', $name);
703 if (!is_null($id)) { $select->setAttribute('id', $id); }
704 foreach ($options as $key => $desc) {
69409ddb 705 $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default));
bf91764c
RK
706 }
707 return $select;
708 }
709
61cc8aa9 710 public function createElementOption($key, $desc, $selected = false) {
bf91764c 711 $option = $this->createElement('option', $desc);
b79cf811 712 if (is_numeric($key) || is_string($key)) {
c79be4c2
RK
713 $option->setAttribute('value', $key);
714 }
b79cf811
RK
715 if ($selected) {
716 $option->setAttribute('selected', '');
717 }
bf91764c
RK
718 return $option;
719 }
720
61cc8aa9 721 public function createElementLabel($for_id, $value) {
ae41c41b
RK
722 $label = $this->createElement('label', $value);
723 $label->setAttribute('for', $for_id);
724 return $label;
cea5b93a
RK
725 }
726
c79be4c2
RK
727 public function createElementDatalist($id = null, $options = array()) {
728 $select = $this->createElement('datalist');
729 if (!is_null($id)) { $select->setAttribute('id', $id); }
730 foreach ($options as $key => $desc) {
731 $select->appendElementOption($key, $desc);
732 }
733 return $select;
734 }
735
acaa2daa
RK
736 public function createElementStyle($styledata) {
737 $style_elem = $this->createElement('style');
738 // Note: type can/should be left out for HTML5.
739 $style_elem->setAttribute('type', 'text/css');
740 $style_elem->appendChild($this->createCDATASection($styledata));
741 return $style_elem;
742 }
743
61cc8aa9 744 public function createElementJS($jsdata) {
cea5b93a 745 $jselem = $this->createElement('script');
ea32f7e5 746 // Note: type can/should be left out for HTML5.
cea5b93a
RK
747 $jselem->setAttribute('type', 'text/javascript');
748 $jselem->appendChild($this->createCDATASection($jsdata));
749 return $jselem;
750 }
c1666e91 751
8afa2e61 752 public function createElementJSFile($jsURL, $defer = false, $async = false) {
ea32f7e5
RK
753 $jselem = $this->createElement('script');
754 // Note: type can/should be left out for HTML5.
755 $jselem->setAttribute('type', 'text/javascript');
8afa2e61
RK
756 if ($defer) {
757 $jselem->setAttribute('defer', '');
758 }
759 if ($async) {
760 $jselem->setAttribute('async', '');
761 }
ea32f7e5
RK
762 $jselem->setAttribute('src', $jsURL);
763 return $jselem;
764 }
cea5b93a
RK
765}
766
767class ExtendedElement extends DOMElement {
768 // ExtendedElement PHP class
769 // this extends the general PHP DOM Element class to simplify some usual constructs
770 //
61cc8aa9 771 // public function appendElement($name, [$value])
cea5b93a
RK
772 // appends a DOMDocument::createElement() as a child of this element (see there for params)
773 // returns the new child
774 //
61cc8aa9 775 // public function appendElementXML($name, $xmldata)
cea5b93a
RK
776 // appends a DOMDocument::createElement() with the given name as a child of this element,
777 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
778 // returns the new child
779 //
b3cc0fef 780 // public function appendLink($target, [$value], [$title])
cea5b93a
RK
781 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
782 // returns the new child
783 //
61cc8aa9 784 // public function appendImage($src, [$alt_text])
53510e9e
RK
785 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
786 // returns the new child
787 //
61cc8aa9 788 // public function appendForm($action, $method, $name, [$id])
b8d16837
RK
789 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
790 // returns the new child
791 //
61cc8aa9 792 // public function appendFormDiv($action, $method, $name, [$id])
ae41c41b
RK
793 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
794 // returns an HTML <div> that is a child of the new child
795 //
61cc8aa9 796 // public function appendInputHidden($name, $value)
ae41c41b
RK
797 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
798 // returns the new child
799 //
61cc8aa9 800 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
ae41c41b
RK
801 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
802 // returns the new child
803 //
f925e4a1
RK
804 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
805 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
806 // returns the new child
807 //
61cc8aa9 808 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
809 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
810 // returns the new child
811 //
f925e4a1
RK
812 // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
813 // appends an ExtendedDocument::createElementInputRange() as a child of this element (see there for params)
814 // returns the new child
815 //
6f794328
RK
816 // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
817 // appends an ExtendedDocument::createElementInputSearch() as a child of this element (see there for params)
818 // returns the new child
819 //
f925e4a1
RK
820 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
821 // appends an ExtendedDocument::createElementInputUrl() as a child of this element (see there for params)
822 // returns the new child
823 //
ea32f7e5
RK
824 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
825 // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params)
826 // returns the new child
827 //
f925e4a1
RK
828 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
829 // appends an ExtendedDocument::createElementInputTel() as a child of this element (see there for params)
830 // returns the new child
831 //
832 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
833 // appends an ExtendedDocument::createElementInputDate() as a child of this element (see there for params)
834 // returns the new child
835 //
836 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
837 // appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params)
645a7eb6
RK
838 // returns the new child
839 //
177ee3d6
RK
840 // public function appendInputDateTime($name, [$id], [$min], [$max], [$value])
841 // appends an ExtendedDocument::createElementInputDateTime() as a child of this element (see there for params)
842 // returns the new child
843 //
f925e4a1
RK
844 // public function appendInputColor($name, [$id], [$value])
845 // appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params)
846 //
61cc8aa9 847 // public function appendInputRadio($name, $id, $value, $checked)
ae41c41b
RK
848 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
849 // returns the new child
850 //
61cc8aa9 851 // public function appendInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
852 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
853 // returns the new child
854 //
61cc8aa9 855 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
856 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
857 // returns the new child
858 //
61cc8aa9 859 // public function appendInputSubmit($value)
ae41c41b
RK
860 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
861 // returns the new child
862 //
61cc8aa9 863 // public function appendButton($value, $onclick = null)
1109f526
RK
864 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
865 // returns the new child
866 //
61cc8aa9 867 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
868 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
869 // returns the new child
870 //
69409ddb 871 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
bf91764c
RK
872 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
873 // returns the new child
874 //
61cc8aa9 875 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
876 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
877 // returns the new child
878 //
61cc8aa9 879 // public function appendLabel($for_id, $value)
ae41c41b
RK
880 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
881 // returns the new child
882 //
c79be4c2
RK
883 // public function appendElementDatalist([$id], [$options])
884 // appends an ExtendedDocument::createElementDatalist() as a child of this element (see there for params)
885 // returns the new child
886 //
61cc8aa9 887 // public function appendText($text)
cea5b93a
RK
888 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
889 // returns the new child
890 //
71771b0c
RK
891 // public function appendLinebreak()
892 // appends a <br> as a child of this element
893 // returns the new child
894 //
6638efd5
RK
895 // public function appendEntity($name)
896 // appends a DOMDocument::createEntityReference() as a child of this element (see there for params)
897 // returns the new child
898 //
61cc8aa9 899 // public function appendComment($comment_data)
cadc5980
RK
900 // appends a DOMDocument::createComment() as a child of this element (see there for params)
901 // returns the new child
902 //
3d4db013
RK
903 // public function appendClonedElement($dom_element, [$deep])
904 // appends a clone of the given DOMElement as a child of this element
905 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
906 // returns the new child
907 //
61cc8aa9 908 // public function appendHTMLMarkup($htmldata)
ae41c41b
RK
909 // appends a representation of the HTML data as children of this element
910 // NO return value!
911 //
61cc8aa9 912 // public function appendXMLMarkup($xmldata)
ae41c41b 913 // appends a representation of the XML data as children of this element
cea5b93a
RK
914 // NO return value!
915 //
acaa2daa
RK
916 // public function appendStyleElement($styledata)
917 // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
918 // returns the new child
919 //
61cc8aa9 920 // public function appendJSElement($jsdata)
cea5b93a 921 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
3d4db013 922 // returns the new child
c1666e91 923 //
8afa2e61 924 // public function appendJSFile($jsURL, [$defer], [$async])
0bbc241e 925 // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
ea32f7e5 926 // returns the new child
f887cdcb
RK
927 //
928 // public function setClass($classname)
929 // sets the 'class' attribute of the element to the given classname value
930 //
931 // public function addClass($classname)
932 // adds the given classname value to the space-separated list in the 'class' attribute
933 // returns the value of the 'class' attribute
934 //
935 // public function setID($elem_id)
936 // sets the 'id' attribute of the element to the given elem_id value
cea5b93a 937
61cc8aa9 938 public function appendElement($name, $value = '') {
a8816f43 939 return $this->appendChild($this->ownerDocument->createElement($name, $value));
cea5b93a 940 }
61cc8aa9 941 public function appendElementXML($name, $xmldata) {
cea5b93a 942 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
ae41c41b 943 $aelem->appendXMLMarkup($xmldata);
cea5b93a
RK
944 return $aelem;
945 }
b3cc0fef
RK
946 public function appendLink($target, $value = '', $title = null) {
947 return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
cea5b93a 948 }
61cc8aa9 949 public function appendImage($src, $alt_text = '') {
53510e9e
RK
950 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
951 }
61cc8aa9 952 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
953 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
954 }
61cc8aa9 955 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 956 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
ae41c41b
RK
957 return $formelem->appendElement('div');
958 }
61cc8aa9 959 public function appendInputHidden($name, $value) {
ae41c41b
RK
960 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
961 }
61cc8aa9 962 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
963 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
964 }
f925e4a1
RK
965 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
966 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
967 }
61cc8aa9 968 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
969 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
970 }
f925e4a1
RK
971 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
972 return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
973 }
6f794328
RK
974 public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
975 return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value));
976 }
f925e4a1
RK
977 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
978 return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
979 }
ea32f7e5
RK
980 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
981 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
982 }
f925e4a1
RK
983 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
984 return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
985 }
986 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
987 return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
988 }
989 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
990 return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
991 }
177ee3d6
RK
992 public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) {
993 return $this->appendChild($this->ownerDocument->createElementInputDateTime($name, $id, $min, $max, $value));
994 }
f925e4a1
RK
995 public function appendInputColor($name, $id = null, $value = null) {
996 return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
645a7eb6 997 }
61cc8aa9 998 public function appendInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
999 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
1000 }
61cc8aa9 1001 public function appendInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
1002 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
1003 }
61cc8aa9 1004 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
1005 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
1006 }
61cc8aa9 1007 public function appendInputSubmit($value) {
ae41c41b
RK
1008 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
1009 }
61cc8aa9 1010 public function appendButton($value, $onclick = null) {
1109f526
RK
1011 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
1012 }
61cc8aa9 1013 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
1014 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
1015 }
69409ddb
RK
1016 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
1017 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
bf91764c 1018 }
61cc8aa9 1019 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
1020 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
1021 }
61cc8aa9 1022 public function appendLabel($for_id, $value) {
bf91764c
RK
1023 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
1024 }
c79be4c2
RK
1025 public function appendElementDatalist($id = null, $options = array()) {
1026 return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
1027 }
61cc8aa9 1028 public function appendText($text) {
c79be4c2 1029 return $this->appendChild($this->ownerDocument->createTextNode($text ?? ''));
bf91764c 1030 }
71771b0c
RK
1031 public function appendLinebreak() {
1032 return $this->appendChild($this->ownerDocument->createElement('br'));
1033 }
6638efd5
RK
1034 public function appendEntity($name) {
1035 return $this->appendChild($this->ownerDocument->createEntityReference($name));
1036 }
61cc8aa9 1037 public function appendComment($comment_data) {
cadc5980
RK
1038 return $this->appendChild($this->ownerDocument->createComment($comment_data));
1039 }
3d4db013
RK
1040 public function appendClonedElement($dom_element, $deep = true) {
1041 return $this->appendChild($dom_element->cloneNode($deep));
1042 }
61cc8aa9 1043 public function appendHTMLMarkup($htmldata) {
bf91764c
RK
1044 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
1045 }
61cc8aa9 1046 public function appendXMLMarkup($xmldata) {
bf91764c
RK
1047 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
1048 }
acaa2daa
RK
1049 public function appendStyleElement($styledata) {
1050 return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
1051 }
61cc8aa9 1052 public function appendJSElement($jsdata) {
3d4db013 1053 return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
bf91764c 1054 }
1a4ee0f0
RK
1055 public function appendJSFile($jsURL, $defer = false, $async = false) {
1056 return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));
ea32f7e5 1057 }
f887cdcb
RK
1058 public function setClass($classname) {
1059 $this->setAttribute('class', $classname);
1060 }
1061 public function addClass($classname) {
1062 $classval = $this->getAttribute('class');
1063 if (strlen($classval)) { $classval .= ' '; }
1064 $classval .= $classname;
1065 $this->setClass($classval);
1066 return $classval;
1067 }
1068 public function setID($elem_id) {
1069 $this->setAttribute('id', $elem_id);
1070 }
bf91764c
RK
1071}
1072
1073class ExtendedDocumentFragment extends DOMDocumentFragment {
1074 // ExtendedDocumentFragment PHP class
1075 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
1076 //
61cc8aa9 1077 // public function appendElement($name, [$value])
bf91764c
RK
1078 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
1079 // returns the new child
1080 //
61cc8aa9 1081 // public function appendElementXML($name, $xmldata)
bf91764c
RK
1082 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
1083 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
1084 // returns the new child
1085 //
b3cc0fef 1086 // public function appendLink($target, [$value], [$title])
bf91764c
RK
1087 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
1088 // returns the new child
1089 //
61cc8aa9 1090 // public function appendImage($src, [$alt_text])
53510e9e
RK
1091 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
1092 // returns the new child
1093 //
61cc8aa9 1094 // public function appendForm($action, $method, $name, [$id])
b8d16837
RK
1095 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
1096 // returns the new child
1097 //
61cc8aa9 1098 // public function appendFormDiv($action, $method, $name, [$id])
bf91764c
RK
1099 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
1100 // returns an HTML <div> that is a child of the new child
1101 //
61cc8aa9 1102 // public function appendInputHidden($name, $value)
bf91764c
RK
1103 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
1104 // returns the new child
1105 //
61cc8aa9 1106 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
bf91764c
RK
1107 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
1108 // returns the new child
1109 //
f925e4a1
RK
1110 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
1111 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
1112 // returns the new child
1113 //
61cc8aa9 1114 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
1115 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
1116 // returns the new child
1117 //
f925e4a1
RK
1118 // public function appendInputRange($name, $id, $min, $max, [$step], [$value])
1119 // appends an ExtendedDocument::createElementInputRange() as a child of this fragment (see there for params)
1120 // returns the new child
1121 //
6f794328
RK
1122 // public function appendInputSearch($name, $maxlength, $size, [$id], [$value])
1123 // appends an ExtendedDocument::createElementInputSearch() as a child of this fragment (see there for params)
1124 // returns the new child
1125 //
f925e4a1
RK
1126 // public function appendInputUrl($name, $maxlength, $size, [$id], [$value])
1127 // appends an ExtendedDocument::createElementInputUrl() as a child of this fragment (see there for params)
1128 // returns the new child
1129 //
ea32f7e5
RK
1130 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
1131 // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params)
1132 // returns the new child
1133 //
f925e4a1
RK
1134 // public function appendInputTel($name, $maxlength, $size, [$id], [$value])
1135 // appends an ExtendedDocument::createElementInputTel() as a child of this fragment (see there for params)
645a7eb6
RK
1136 // returns the new child
1137 //
f925e4a1
RK
1138 // public function appendInputDate($name, [$id], [$min], [$max], [$value])
1139 // appends an ExtendedDocument::createElementInputDate() as a child of this fragment (see there for params)
1140 // returns the new child
1141 //
1142 // public function appendInputTime($name, [$id], [$min], [$max], [$value])
1143 // appends an ExtendedDocument::createElementInputTime() as a child of this fragment (see there for params)
1144 // returns the new child
1145 //
177ee3d6
RK
1146 // public function appendInputDateTime($name, [$id], [$min], [$max], [$value])
1147 // appends an ExtendedDocument::createElementInputDateTime() as a child of this fragment (see there for params)
1148 // returns the new child
1149 //
f925e4a1
RK
1150 // public function appendInputColor($name, [$id], [$value])
1151 // appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params)
1152 //
61cc8aa9 1153 // public function appendInputRadio($name, $id, $value, $checked)
bf91764c
RK
1154 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
1155 // returns the new child
1156 //
61cc8aa9 1157 // public function appendInputCheckbox($name, $id, $value, $checked)
bf91764c
RK
1158 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
1159 // returns the new child
1160 //
61cc8aa9 1161 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
1162 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
1163 // returns the new child
1164 //
61cc8aa9 1165 // public function appendInputSubmit($value)
bf91764c
RK
1166 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
1167 // returns the new child
1168 //
61cc8aa9 1169 // public function appendButton($value, $onclick = null)
1109f526
RK
1170 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
1171 // returns the new child
1172 //
61cc8aa9 1173 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
1174 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
1175 // returns the new child
1176 //
69409ddb 1177 // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
bf91764c
RK
1178 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
1179 // returns the new child
1180 //
61cc8aa9 1181 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
1182 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
1183 // returns the new child
1184 //
61cc8aa9 1185 // public function appendLabel($for_id, $value)
bf91764c
RK
1186 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
1187 // returns the new child
1188 //
c79be4c2
RK
1189 // public function appendElementDatalist([$id], [$options])
1190 // appends an ExtendedDocument::createElementDatalist() as a child of this fragment (see there for params)
1191 // returns the new child
1192 //
61cc8aa9 1193 // public function appendText($text)
bf91764c
RK
1194 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
1195 // returns the new child
1196 //
71771b0c
RK
1197 // public function appendLinebreak()
1198 // appends a <br> as a child of this fragment
1199 // returns the new child
1200 //
6638efd5
RK
1201 // public function appendEntity($name)
1202 // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params)
1203 // returns the new child
1204 //
61cc8aa9 1205 // public function appendComment($comment_data)
cadc5980
RK
1206 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
1207 // returns the new child
1208 //
3d4db013
RK
1209 // public function appendClonedElement($dom_element, [$deep])
1210 // appends a clone of the given DOMElement as a child of this fragment
1211 // the boolean $deep specifies if the children are cloned as well (defaults to TRUE)
1212 // returns the new child
1213 //
61cc8aa9 1214 // public function appendHTMLMarkup($htmldata)
bf91764c
RK
1215 // appends a representation of the HTML data as children of this fragment
1216 // NO return value!
1217 //
61cc8aa9 1218 // public function appendXMLMarkup($xmldata)
bf91764c
RK
1219 // appends a representation of the XML data as children of this fragment
1220 // NO return value!
1221 //
acaa2daa
RK
1222 // public function appendStyleElement($styledata)
1223 // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params)
1224 // returns the new child
1225 //
61cc8aa9 1226 // public function appendJSElement($jsdata)
bf91764c 1227 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
3d4db013 1228 // returns the new child
c1666e91 1229 //
8afa2e61 1230 // public function appendJSFile($jsURL, [$defer], [$async])
0bbc241e 1231 // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params)
ea32f7e5 1232 // returns the new child
bf91764c 1233
61cc8aa9 1234 public function appendElement($name, $value = '') {
a8816f43 1235 return $this->appendChild($this->ownerDocument->createElement($name, $value));
bf91764c 1236 }
61cc8aa9 1237 public function appendElementXML($name, $xmldata) {
bf91764c
RK
1238 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
1239 $aelem->appendXMLMarkup($xmldata);
1240 return $aelem;
1241 }
b3cc0fef
RK
1242 public function appendLink($target, $value = '', $title = null) {
1243 return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title));
bf91764c 1244 }
61cc8aa9 1245 public function appendImage($src, $alt_text = '') {
53510e9e
RK
1246 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
1247 }
61cc8aa9 1248 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
1249 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
1250 }
61cc8aa9 1251 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 1252 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
bf91764c
RK
1253 return $formelem->appendElement('div');
1254 }
61cc8aa9 1255 public function appendInputHidden($name, $value) {
bf91764c
RK
1256 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
1257 }
61cc8aa9 1258 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
bf91764c 1259 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
645a7eb6 1260 }
f925e4a1
RK
1261 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
1262 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
1263 }
61cc8aa9 1264 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
1265 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
1266 }
f925e4a1
RK
1267 public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) {
1268 return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value));
1269 }
6f794328
RK
1270 public function appendInputSearch($name, $maxlength, $size, $id = null, $value = null) {
1271 return $this->appendChild($this->ownerDocument->createElementInputSearch($name, $maxlength, $size, $id, $value));
1272 }
f925e4a1
RK
1273 public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) {
1274 return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value));
1275 }
ea32f7e5
RK
1276 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
1277 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
1278 }
f925e4a1
RK
1279 public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) {
1280 return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value));
1281 }
1282 public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) {
1283 return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value));
1284 }
1285 public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) {
1286 return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value));
1287 }
177ee3d6
RK
1288 public function appendInputDateTime($name, $id = null, $min = null, $max = null, $value = null) {
1289 return $this->appendChild($this->ownerDocument->createElementInputDateTime($name, $id, $min, $max, $value));
1290 }
f925e4a1
RK
1291 public function appendInputColor($name, $id = null, $value = null) {
1292 return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value));
bf91764c 1293 }
61cc8aa9 1294 public function appendInputRadio($name, $id, $value, $checked) {
bf91764c
RK
1295 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
1296 }
61cc8aa9 1297 public function appendInputCheckbox($name, $id, $value, $checked) {
bf91764c
RK
1298 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
1299 }
61cc8aa9 1300 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
1301 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
1302 }
61cc8aa9 1303 public function appendInputSubmit($value) {
bf91764c
RK
1304 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
1305 }
61cc8aa9 1306 public function appendButton($value, $onclick = null) {
1109f526
RK
1307 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
1308 }
61cc8aa9 1309 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
1310 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
1311 }
69409ddb
RK
1312 public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
1313 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
bf91764c 1314 }
61cc8aa9 1315 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
1316 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
1317 }
61cc8aa9 1318 public function appendLabel($for_id, $value) {
ae41c41b
RK
1319 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
1320 }
c79be4c2
RK
1321 public function appendElementDatalist($id = null, $options = array()) {
1322 return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options));
1323 }
61cc8aa9 1324 public function appendText($text) {
cea5b93a
RK
1325 return $this->appendChild($this->ownerDocument->createTextNode($text));
1326 }
71771b0c
RK
1327 public function appendLinebreak() {
1328 return $this->appendChild($this->ownerDocument->createElement('br'));
1329 }
6638efd5
RK
1330 public function appendEntity($name) {
1331 return $this->appendChild($this->ownerDocument->createEntityReference($name));
1332 }
61cc8aa9 1333 public function appendComment($comment_data) {
cadc5980
RK
1334 return $this->appendChild($this->ownerDocument->createComment($comment_data));
1335 }
3d4db013
RK
1336 public function appendClonedElement($dom_element, $deep = true) {
1337 return $this->appendChild($dom_element->cloneNode($deep));
1338 }
61cc8aa9 1339 public function appendHTMLMarkup($htmldata) {
ae41c41b
RK
1340 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
1341 }
61cc8aa9 1342 public function appendXMLMarkup($xmldata) {
ae41c41b 1343 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
cea5b93a 1344 }
acaa2daa
RK
1345 public function appendStyleElement($styledata) {
1346 return $this->appendChild($this->ownerDocument->createElementStyle($styledata));
1347 }
61cc8aa9 1348 public function appendJSElement($jsdata) {
3d4db013 1349 return $this->appendChild($this->ownerDocument->createElementJS($jsdata));
cea5b93a 1350 }
1a4ee0f0
RK
1351 public function appendJSFile($jsURL, $defer = false, $async = false) {
1352 return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async));
ea32f7e5 1353 }
cea5b93a
RK
1354}
1355?>