Commit | Line | Data |
---|---|---|
cea5b93a | 1 | <?php |
880bcb60 RK |
2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, | |
4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
cea5b93a RK |
5 | |
6 | class ExtendedDocument extends DOMDocument { | |
7 | // ExtendedDocument PHP class | |
8 | // this extends the general PHP DOM Document class to simplify some usual constructs | |
9 | // | |
10 | // function __construct([$version], [$encoding]) | |
11 | // CONSTRUCTOR | |
12 | // construct a new DOM Document that uses our element definitions | |
13 | // | |
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 | // | |
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 | |
71 | // | |
ea32f7e5 RK |
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 | |
75 | // | |
f925e4a1 RK |
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 | |
79 | // | |
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 | |
83 | // | |
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 | |
87 | // | |
88 | // public function appendInputColor($name, [$id], [$value]) | |
89 | // appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params) | |
645a7eb6 RK |
90 | // returns the new child |
91 | // | |
61cc8aa9 | 92 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
93 | // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params) |
94 | // returns the new child | |
95 | // | |
61cc8aa9 | 96 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
97 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params) |
98 | // returns the new child | |
99 | // | |
61cc8aa9 | 100 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
101 | // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params) |
102 | // returns the new child | |
103 | // | |
61cc8aa9 | 104 | // public function appendInputSubmit($value) |
ae41c41b RK |
105 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params) |
106 | // returns the new child | |
107 | // | |
61cc8aa9 | 108 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
109 | // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params) |
110 | // returns the new child | |
111 | // | |
61cc8aa9 | 112 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
113 | // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params) |
114 | // returns the new child | |
115 | // | |
69409ddb | 116 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
117 | // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params) |
118 | // returns the new child | |
119 | // | |
61cc8aa9 | 120 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
121 | // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params) |
122 | // returns the new child | |
123 | // | |
61cc8aa9 | 124 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
125 | // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params) |
126 | // returns the new child | |
127 | // | |
c79be4c2 RK |
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 | |
131 | // | |
61cc8aa9 | 132 | // public function appendText($text) |
cea5b93a RK |
133 | // appends a DOMDocument::createTextNode() as a child of this document (see there for params) |
134 | // returns the new child | |
135 | // | |
71771b0c RK |
136 | // public function appendLinebreak() |
137 | // appends a <br> as a child of this document | |
138 | // returns the new child | |
139 | // | |
6638efd5 RK |
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 | |
143 | // | |
61cc8aa9 | 144 | // public function appendComment($comment_data) |
cadc5980 RK |
145 | // appends a DOMDocument::createComment() as a child of this document (see there for params) |
146 | // returns the new child | |
147 | // | |
3d4db013 RK |
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 | |
152 | // | |
61cc8aa9 | 153 | // public function appendHTMLMarkup($htmldata, [$parentNode]) |
ae41c41b RK |
154 | // appends a representation of the HTML data as children of the given parent node, by default this document |
155 | // NO return value! | |
156 | // | |
61cc8aa9 | 157 | // public function appendXMLMarkup($xmldata, [$parentNode]) |
ae41c41b | 158 | // appends a representation of the XML data as children of the given parent node, by default this document |
cea5b93a RK |
159 | // NO return value! |
160 | // | |
acaa2daa RK |
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 | |
164 | // | |
61cc8aa9 | 165 | // public function appendJSElement($jsdata) |
cea5b93a | 166 | // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params) |
acaa2daa | 167 | // returns the new child |
cea5b93a | 168 | // |
8afa2e61 | 169 | // public function appendJSFile($jsURL, [$defer], [$async]) |
ea32f7e5 RK |
170 | // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params) |
171 | // returns the new child | |
172 | // | |
b3cc0fef RK |
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 | |
cea5b93a | 175 | // |
61cc8aa9 | 176 | // public function createElementImage($src, [$alt_text]) |
b3cc0fef | 177 | // returns an ExtendedElement that is an HTML <img> with the given src and alt attributes (set to '' by default) |
53510e9e | 178 | // |
61cc8aa9 | 179 | // public function createElementForm($action, $method, $name) |
cb2420c6 | 180 | // returns an ExtendedElement that is an HTML <form> with the given action, method, and name |
ae41c41b | 181 | // |
61cc8aa9 | 182 | // public function createElementInputHidden($name, $value) |
ae41c41b RK |
183 | // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value |
184 | // | |
61cc8aa9 | 185 | // public function createElementInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
186 | // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size, |
187 | // and optionally id and value | |
188 | // | |
f925e4a1 RK |
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 | |
192 | // | |
61cc8aa9 | 193 | // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
194 | // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size, |
195 | // and optionally id and value | |
196 | // | |
f925e4a1 RK |
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 | |
200 | // | |
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 | |
204 | // | |
ea32f7e5 RK |
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 | |
208 | // | |
f925e4a1 RK |
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 | |
212 | // | |
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 | |
216 | // | |
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 | |
220 | // | |
221 | // public function createElementInputColor($name, [$id], [$value]) | |
222 | // returns an ExtendedElement that is an HTML <input> of type 'color' with the given name, | |
645a7eb6 RK |
223 | // and optionally id and value |
224 | // | |
61cc8aa9 | 225 | // public function createElementInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
226 | // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and |
227 | // checked state | |
228 | // | |
61cc8aa9 | 229 | // public function createElementInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
230 | // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and |
231 | // checked state | |
232 | // | |
61cc8aa9 | 233 | // public function createElementInputFile($name, $id, $accept) |
4bb9d784 RK |
234 | // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept |
235 | // | |
61cc8aa9 | 236 | // public function createElementInputSubmit($value) |
1109f526 RK |
237 | // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label |
238 | // | |
61cc8aa9 | 239 | // public function createElementButton($value, $onclick = null) |
1109f526 | 240 | // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute |
ae41c41b | 241 | // |
61cc8aa9 | 242 | // public function createElementTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
243 | // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows, |
244 | // and optionally id and value | |
245 | // | |
69409ddb | 246 | // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c | 247 | // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id, |
69409ddb | 248 | // array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true) |
bf91764c | 249 | // |
61cc8aa9 | 250 | // public function createElementOption($key, $desc, [$selected]) |
bf91764c RK |
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 | |
253 | // | |
61cc8aa9 | 254 | // public function createElementLabel($for_id, $value) |
ae41c41b | 255 | // returns an ExtendedElement that is an HTML <label> with the given 'for' and value |
cea5b93a | 256 | // |
c79be4c2 RK |
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) | |
259 | // | |
acaa2daa RK |
260 | // public function createElementStyle($styledata) |
261 | // returns an ExtendedElement that is an HTML <style> of CSS type with the style data inside | |
262 | // | |
61cc8aa9 | 263 | // public function createElementJS($jsdata) |
cea5b93a | 264 | // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside |
c1666e91 | 265 | // |
8afa2e61 | 266 | // public function createElementJSFile($jsURL, [$defer], [$async]) |
ea32f7e5 | 267 | // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL |
8afa2e61 | 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. |
cea5b93a RK |
269 | |
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'); | |
bf91764c | 274 | $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment'); |
cea5b93a RK |
275 | } |
276 | ||
b841a92b RK |
277 | static function initHTML5($doc = null) { |
278 | if (is_null($doc)) { $doc = new ExtendedDocument(); } | |
d7403a92 | 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. |
14014b8f RK |
280 | |
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'); | |
286 | ||
287 | return array('document' => $doc, | |
288 | 'html' => $root, | |
289 | 'head' => $head, | |
290 | 'title' => $title, | |
291 | 'body' => $body); | |
292 | } | |
293 | ||
d7403a92 RK |
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; | |
300 | } | |
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); | |
309 | } | |
310 | } | |
311 | libxml_clear_errors(); | |
312 | libxml_use_internal_errors(false); | |
313 | return $result; | |
314 | } | |
315 | ||
61cc8aa9 | 316 | public function appendElement($name, $value = '') { |
a8816f43 | 317 | return $this->appendChild($this->createElement($name, $value)); |
cea5b93a | 318 | } |
61cc8aa9 | 319 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 320 | $aelem = $this->appendChild($this->createElement($name)); |
ae41c41b RK |
321 | $aelem->appendXMLMarkup($xmldata); |
322 | //$aelem->appendChild($this->createXMLFragment($xmldata)); | |
cea5b93a RK |
323 | return $aelem; |
324 | } | |
b3cc0fef RK |
325 | public function appendLink($target, $value = '', $title = null) { |
326 | return $this->appendChild($this->createElementLink($target, $value, $title)); | |
cea5b93a | 327 | } |
61cc8aa9 | 328 | public function appendImage($src, $alt_text = '') { |
4aa31782 RK |
329 | return $this->appendChild($this->createElementImage($src, $alt_text)); |
330 | } | |
61cc8aa9 | 331 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
332 | return $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
333 | } | |
61cc8aa9 | 334 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 335 | $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
336 | return $formelem->appendElement('div'); |
337 | } | |
61cc8aa9 | 338 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
339 | return $this->appendChild($this->createElementInputHidden($name, $value)); |
340 | } | |
61cc8aa9 | 341 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
342 | return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); |
343 | } | |
f925e4a1 RK |
344 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
345 | return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
346 | } | |
61cc8aa9 | 347 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
348 | return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
349 | } | |
f925e4a1 RK |
350 | public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { |
351 | return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value)); | |
352 | } | |
353 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
354 | return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
355 | } | |
ea32f7e5 RK |
356 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
357 | return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
358 | } | |
f925e4a1 RK |
359 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
360 | return $this->appendChild($this->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
361 | } | |
362 | public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
363 | return $this->appendChild($this->createElementInputDate($name, $id, $min, $max, $value)); | |
364 | } | |
365 | public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
366 | return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value)); | |
367 | } | |
368 | public function appendInputColor($name, $id = null, $value = null) { | |
369 | return $this->appendChild($this->createElementInputColor($name, $id, $value)); | |
645a7eb6 | 370 | } |
61cc8aa9 | 371 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
372 | return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked)); |
373 | } | |
61cc8aa9 | 374 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
375 | return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked)); |
376 | } | |
61cc8aa9 | 377 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
378 | return $this->appendChild($this->createElementInputFile($name, $id, $accept)); |
379 | } | |
61cc8aa9 | 380 | public function appendInputSubmit($value) { |
ae41c41b RK |
381 | return $this->appendChild($this->createElementInputSubmit($value)); |
382 | } | |
61cc8aa9 | 383 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
384 | return $this->appendChild($this->createElementButton($value, $onclick)); |
385 | } | |
61cc8aa9 | 386 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
387 | return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value)); |
388 | } | |
69409ddb RK |
389 | public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
390 | return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch)); | |
bf91764c | 391 | } |
61cc8aa9 | 392 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
393 | return $this->appendChild($this->createElementOption($key, $desc, $selected)); |
394 | } | |
61cc8aa9 | 395 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
396 | return $this->appendChild($this->createElementLabel($for_id, $value)); |
397 | } | |
c79be4c2 RK |
398 | public function appendElementDatalist($id = null, $options = array()) { |
399 | return $this->appendChild($this->createElementDatalist($id, $options)); | |
400 | } | |
61cc8aa9 | 401 | public function appendText($text) { |
cea5b93a RK |
402 | return $this->appendChild($this->createTextNode($text)); |
403 | } | |
71771b0c RK |
404 | public function appendLinebreak() { |
405 | return $this->appendChild($this->createElement('br')); | |
406 | } | |
6638efd5 RK |
407 | public function appendEntity($name) { |
408 | return $this->appendChild($this->createEntityReference($name)); | |
409 | } | |
61cc8aa9 | 410 | public function appendComment($comment_data) { |
cadc5980 RK |
411 | return $this->appendChild($this->createComment($comment_data)); |
412 | } | |
3d4db013 RK |
413 | public function appendClonedElement($dom_element, $deep = true) { |
414 | return $this->appendChild($dom_element->cloneNode($deep)); | |
415 | } | |
acaa2daa RK |
416 | public function appendStyleElement($styledata) { |
417 | return $this->appendChild($this->createElementStyle($styledata)); | |
418 | } | |
61cc8aa9 | 419 | public function appendJSElement($jsdata) { |
3d4db013 | 420 | return $this->appendChild($this->createElementJS($jsdata)); |
cea5b93a | 421 | } |
1a4ee0f0 RK |
422 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
423 | return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 424 | } |
cea5b93a | 425 | |
61cc8aa9 | 426 | public function appendHTMLMarkup($htmldata, $parentNode = null) { |
ae41c41b | 427 | if (is_null($parentNode)) { $parentNode =& $this; } |
d7403a92 | 428 | // Use loadHTML5() to parse and turn the markup into proper HTML. |
a9a5a68a RK |
429 | $tmpdoc = new ExtendedDocument; |
430 | // The XML line is needed to tell the parser that we need UTF-8 parsing. | |
d7403a92 | 431 | $tmpdoc->loadHTML5('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>'); |
a9a5a68a RK |
432 | foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) { |
433 | $parentNode->appendChild($this->importNode($child, true)); | |
434 | } | |
ae41c41b RK |
435 | } |
436 | ||
61cc8aa9 | 437 | public function appendXMLMarkup($xmldata, $parentNode = null) { |
ae41c41b RK |
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)); | |
446 | } | |
cea5b93a RK |
447 | } |
448 | ||
61cc8aa9 | 449 | public function createElement($name, $value = '') { |
a8816f43 RK |
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); | |
5ae00086 | 452 | if (strlen($value ?? '')) { $aelem->appendText($value); } |
a8816f43 RK |
453 | return $aelem; |
454 | } | |
455 | ||
b3cc0fef | 456 | public function createElementLink($target, $value = '', $title = null) { |
a8816f43 | 457 | $link = $this->createElement('a', $value); |
bf91764c | 458 | $link->setAttribute('href', $target); // XXX: take care of & etc. in links |
b3cc0fef | 459 | if (!is_null($title)) { $link->setAttribute('title', $title); } |
cea5b93a RK |
460 | return $link; |
461 | } | |
462 | ||
61cc8aa9 | 463 | public function createElementImage($src, $alt_text = '') { |
319cfe8d RK |
464 | $img = $this->createElement('img'); |
465 | $img->setAttribute('src', $src); | |
466 | $img->setAttribute('alt', $alt_text); | |
467 | return $img; | |
4aa31782 RK |
468 | } |
469 | ||
61cc8aa9 | 470 | public function createElementForm($action, $method, $name, $id = null) { |
ae41c41b RK |
471 | $formelem = $this->createElement('form'); |
472 | $formelem->setAttribute('action', $action); | |
473 | $formelem->setAttribute('method', $method); | |
474 | $formelem->setAttribute('name', $name); | |
b3cc0fef | 475 | if (!is_null($id)) { $formelem->setAttribute('id', $id); } |
ae41c41b RK |
476 | return $formelem; |
477 | } | |
478 | ||
61cc8aa9 | 479 | public function createElementInputHidden($name, $value) { |
ae41c41b RK |
480 | $hidden = $this->createElement('input'); |
481 | $hidden->setAttribute('type', 'hidden'); | |
482 | $hidden->setAttribute('name', $name); | |
483 | $hidden->setAttribute('value', $value); | |
484 | return $hidden; | |
485 | } | |
486 | ||
61cc8aa9 | 487 | public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
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); } | |
495 | return $txfield; | |
496 | } | |
497 | ||
61cc8aa9 | 498 | public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
319cfe8d RK |
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); } | |
506 | return $pwfield; | |
645a7eb6 RK |
507 | } |
508 | ||
f925e4a1 RK |
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); } | |
517 | return $numfield; | |
518 | } | |
519 | ||
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); } | |
529 | return $rgfield; | |
530 | } | |
531 | ||
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); } | |
540 | return $urlfield; | |
541 | } | |
542 | ||
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); } | |
551 | return $mailfield; | |
552 | } | |
553 | ||
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); } | |
562 | return $telfield; | |
563 | } | |
564 | ||
565 | public function createElementInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
b5897591 RK |
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); } | |
573 | return $dtfield; | |
f925e4a1 RK |
574 | } |
575 | ||
576 | public function createElementInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
b5897591 RK |
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); } | |
584 | return $timefield; | |
f925e4a1 RK |
585 | } |
586 | ||
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); } | |
593 | return $colfield; | |
594 | } | |
595 | ||
61cc8aa9 | 596 | public function createElementInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
597 | $radio = $this->createElement('input'); |
598 | $radio->setAttribute('type', 'radio'); | |
599 | $radio->setAttribute('name', $name); | |
4bb9d784 | 600 | if (!is_null($id)) { $radio->setAttribute('id', $id); } |
ae41c41b RK |
601 | $radio->setAttribute('value', $value); |
602 | if ($checked) { $radio->setAttribute('checked', ''); } | |
603 | return $radio; | |
604 | } | |
605 | ||
61cc8aa9 | 606 | public function createElementInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
607 | $cbox = $this->createElement('input'); |
608 | $cbox->setAttribute('type', 'checkbox'); | |
609 | $cbox->setAttribute('name', $name); | |
4bb9d784 | 610 | if (!is_null($id)) { $cbox->setAttribute('id', $id); } |
ae41c41b RK |
611 | $cbox->setAttribute('value', $value); |
612 | if ($checked) { $cbox->setAttribute('checked', ''); } | |
613 | return $cbox; | |
614 | } | |
615 | ||
61cc8aa9 | 616 | public function createElementInputFile($name, $id, $accept) { |
4bb9d784 RK |
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); | |
622 | return $fileinput; | |
623 | } | |
624 | ||
61cc8aa9 | 625 | public function createElementInputSubmit($value) { |
ae41c41b RK |
626 | $submitbtn = $this->createElement('input'); |
627 | $submitbtn->setAttribute('type', 'submit'); | |
628 | $submitbtn->setAttribute('value', $value); | |
629 | return $submitbtn; | |
630 | } | |
631 | ||
61cc8aa9 | 632 | public function createElementButton($value, $onclick = null) { |
1109f526 RK |
633 | $btn = $this->createElement('input'); |
634 | $btn->setAttribute('type', 'button'); | |
635 | $btn->setAttribute('value', $value); | |
636 | if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); } | |
637 | return $btn; | |
638 | } | |
639 | ||
61cc8aa9 | 640 | public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
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); } | |
646 | return $txtarea; | |
647 | } | |
648 | ||
69409ddb | 649 | public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
bf91764c RK |
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) { | |
69409ddb | 654 | $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default)); |
bf91764c RK |
655 | } |
656 | return $select; | |
657 | } | |
658 | ||
61cc8aa9 | 659 | public function createElementOption($key, $desc, $selected = false) { |
bf91764c | 660 | $option = $this->createElement('option', $desc); |
c79be4c2 RK |
661 | if ($key) { |
662 | $option->setAttribute('value', $key); | |
663 | } | |
bf91764c RK |
664 | if ($selected) { $option->setAttribute('selected', ''); } |
665 | return $option; | |
666 | } | |
667 | ||
61cc8aa9 | 668 | public function createElementLabel($for_id, $value) { |
ae41c41b RK |
669 | $label = $this->createElement('label', $value); |
670 | $label->setAttribute('for', $for_id); | |
671 | return $label; | |
cea5b93a RK |
672 | } |
673 | ||
c79be4c2 RK |
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); | |
679 | } | |
680 | return $select; | |
681 | } | |
682 | ||
acaa2daa RK |
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)); | |
688 | return $style_elem; | |
689 | } | |
690 | ||
61cc8aa9 | 691 | public function createElementJS($jsdata) { |
cea5b93a | 692 | $jselem = $this->createElement('script'); |
ea32f7e5 | 693 | // Note: type can/should be left out for HTML5. |
cea5b93a RK |
694 | $jselem->setAttribute('type', 'text/javascript'); |
695 | $jselem->appendChild($this->createCDATASection($jsdata)); | |
696 | return $jselem; | |
697 | } | |
c1666e91 | 698 | |
8afa2e61 | 699 | public function createElementJSFile($jsURL, $defer = false, $async = false) { |
ea32f7e5 RK |
700 | $jselem = $this->createElement('script'); |
701 | // Note: type can/should be left out for HTML5. | |
702 | $jselem->setAttribute('type', 'text/javascript'); | |
8afa2e61 RK |
703 | if ($defer) { |
704 | $jselem->setAttribute('defer', ''); | |
705 | } | |
706 | if ($async) { | |
707 | $jselem->setAttribute('async', ''); | |
708 | } | |
ea32f7e5 RK |
709 | $jselem->setAttribute('src', $jsURL); |
710 | return $jselem; | |
711 | } | |
cea5b93a RK |
712 | } |
713 | ||
714 | class ExtendedElement extends DOMElement { | |
715 | // ExtendedElement PHP class | |
716 | // this extends the general PHP DOM Element class to simplify some usual constructs | |
717 | // | |
61cc8aa9 | 718 | // public function appendElement($name, [$value]) |
cea5b93a RK |
719 | // appends a DOMDocument::createElement() as a child of this element (see there for params) |
720 | // returns the new child | |
721 | // | |
61cc8aa9 | 722 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
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 | |
726 | // | |
b3cc0fef | 727 | // public function appendLink($target, [$value], [$title]) |
cea5b93a RK |
728 | // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params) |
729 | // returns the new child | |
730 | // | |
61cc8aa9 | 731 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
732 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
733 | // returns the new child | |
734 | // | |
61cc8aa9 | 735 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
736 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
737 | // returns the new child | |
738 | // | |
61cc8aa9 | 739 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
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 | |
742 | // | |
61cc8aa9 | 743 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
744 | // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params) |
745 | // returns the new child | |
746 | // | |
61cc8aa9 | 747 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
748 | // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) |
749 | // returns the new child | |
750 | // | |
f925e4a1 RK |
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 | |
754 | // | |
61cc8aa9 | 755 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
756 | // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) |
757 | // returns the new child | |
758 | // | |
f925e4a1 RK |
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 | |
762 | // | |
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 | |
766 | // | |
ea32f7e5 RK |
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 | |
770 | // | |
f925e4a1 RK |
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 | |
774 | // | |
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 | |
778 | // | |
779 | // public function appendInputTime($name, [$id], [$min], [$max], [$value]) | |
780 | // appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params) | |
645a7eb6 RK |
781 | // returns the new child |
782 | // | |
f925e4a1 RK |
783 | // public function appendInputColor($name, [$id], [$value]) |
784 | // appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params) | |
785 | // | |
61cc8aa9 | 786 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
787 | // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params) |
788 | // returns the new child | |
789 | // | |
61cc8aa9 | 790 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
791 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params) |
792 | // returns the new child | |
793 | // | |
61cc8aa9 | 794 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
795 | // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params) |
796 | // returns the new child | |
797 | // | |
61cc8aa9 | 798 | // public function appendInputSubmit($value) |
ae41c41b RK |
799 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params) |
800 | // returns the new child | |
801 | // | |
61cc8aa9 | 802 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
803 | // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params) |
804 | // returns the new child | |
805 | // | |
61cc8aa9 | 806 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
807 | // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params) |
808 | // returns the new child | |
809 | // | |
69409ddb | 810 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
811 | // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params) |
812 | // returns the new child | |
813 | // | |
61cc8aa9 | 814 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
815 | // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params) |
816 | // returns the new child | |
817 | // | |
61cc8aa9 | 818 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
819 | // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params) |
820 | // returns the new child | |
821 | // | |
c79be4c2 RK |
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 | |
825 | // | |
61cc8aa9 | 826 | // public function appendText($text) |
cea5b93a RK |
827 | // appends a DOMDocument::createTextNode() as a child of this element (see there for params) |
828 | // returns the new child | |
829 | // | |
71771b0c RK |
830 | // public function appendLinebreak() |
831 | // appends a <br> as a child of this element | |
832 | // returns the new child | |
833 | // | |
6638efd5 RK |
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 | |
837 | // | |
61cc8aa9 | 838 | // public function appendComment($comment_data) |
cadc5980 RK |
839 | // appends a DOMDocument::createComment() as a child of this element (see there for params) |
840 | // returns the new child | |
841 | // | |
3d4db013 RK |
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 | |
846 | // | |
61cc8aa9 | 847 | // public function appendHTMLMarkup($htmldata) |
ae41c41b RK |
848 | // appends a representation of the HTML data as children of this element |
849 | // NO return value! | |
850 | // | |
61cc8aa9 | 851 | // public function appendXMLMarkup($xmldata) |
ae41c41b | 852 | // appends a representation of the XML data as children of this element |
cea5b93a RK |
853 | // NO return value! |
854 | // | |
acaa2daa RK |
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 | |
858 | // | |
61cc8aa9 | 859 | // public function appendJSElement($jsdata) |
cea5b93a | 860 | // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params) |
3d4db013 | 861 | // returns the new child |
c1666e91 | 862 | // |
8afa2e61 | 863 | // public function appendJSFile($jsURL, [$defer], [$async]) |
0bbc241e | 864 | // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params) |
ea32f7e5 | 865 | // returns the new child |
f887cdcb RK |
866 | // |
867 | // public function setClass($classname) | |
868 | // sets the 'class' attribute of the element to the given classname value | |
869 | // | |
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 | |
873 | // | |
874 | // public function setID($elem_id) | |
875 | // sets the 'id' attribute of the element to the given elem_id value | |
cea5b93a | 876 | |
61cc8aa9 | 877 | public function appendElement($name, $value = '') { |
a8816f43 | 878 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
cea5b93a | 879 | } |
61cc8aa9 | 880 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 881 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
ae41c41b | 882 | $aelem->appendXMLMarkup($xmldata); |
cea5b93a RK |
883 | return $aelem; |
884 | } | |
b3cc0fef RK |
885 | public function appendLink($target, $value = '', $title = null) { |
886 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title)); | |
cea5b93a | 887 | } |
61cc8aa9 | 888 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
889 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
890 | } | |
61cc8aa9 | 891 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
892 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
893 | } | |
61cc8aa9 | 894 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 895 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
896 | return $formelem->appendElement('div'); |
897 | } | |
61cc8aa9 | 898 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
899 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
900 | } | |
61cc8aa9 | 901 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
902 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
903 | } | |
f925e4a1 RK |
904 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
905 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
906 | } | |
61cc8aa9 | 907 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
908 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
909 | } | |
f925e4a1 RK |
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)); | |
912 | } | |
913 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
914 | return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
915 | } | |
ea32f7e5 RK |
916 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
917 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
918 | } | |
f925e4a1 RK |
919 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
920 | return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
921 | } | |
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)); | |
924 | } | |
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)); | |
927 | } | |
928 | public function appendInputColor($name, $id = null, $value = null) { | |
929 | return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); | |
645a7eb6 | 930 | } |
61cc8aa9 | 931 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
932 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
933 | } | |
61cc8aa9 | 934 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
935 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
936 | } | |
61cc8aa9 | 937 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
938 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
939 | } | |
61cc8aa9 | 940 | public function appendInputSubmit($value) { |
ae41c41b RK |
941 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
942 | } | |
61cc8aa9 | 943 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
944 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
945 | } | |
61cc8aa9 | 946 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
947 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
948 | } | |
69409ddb RK |
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)); | |
bf91764c | 951 | } |
61cc8aa9 | 952 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
953 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
954 | } | |
61cc8aa9 | 955 | public function appendLabel($for_id, $value) { |
bf91764c RK |
956 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
957 | } | |
c79be4c2 RK |
958 | public function appendElementDatalist($id = null, $options = array()) { |
959 | return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options)); | |
960 | } | |
61cc8aa9 | 961 | public function appendText($text) { |
c79be4c2 | 962 | return $this->appendChild($this->ownerDocument->createTextNode($text ?? '')); |
bf91764c | 963 | } |
71771b0c RK |
964 | public function appendLinebreak() { |
965 | return $this->appendChild($this->ownerDocument->createElement('br')); | |
966 | } | |
6638efd5 RK |
967 | public function appendEntity($name) { |
968 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
969 | } | |
61cc8aa9 | 970 | public function appendComment($comment_data) { |
cadc5980 RK |
971 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
972 | } | |
3d4db013 RK |
973 | public function appendClonedElement($dom_element, $deep = true) { |
974 | return $this->appendChild($dom_element->cloneNode($deep)); | |
975 | } | |
61cc8aa9 | 976 | public function appendHTMLMarkup($htmldata) { |
bf91764c RK |
977 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
978 | } | |
61cc8aa9 | 979 | public function appendXMLMarkup($xmldata) { |
bf91764c RK |
980 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
981 | } | |
acaa2daa RK |
982 | public function appendStyleElement($styledata) { |
983 | return $this->appendChild($this->ownerDocument->createElementStyle($styledata)); | |
984 | } | |
61cc8aa9 | 985 | public function appendJSElement($jsdata) { |
3d4db013 | 986 | return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
bf91764c | 987 | } |
1a4ee0f0 RK |
988 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
989 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 990 | } |
f887cdcb RK |
991 | public function setClass($classname) { |
992 | $this->setAttribute('class', $classname); | |
993 | } | |
994 | public function addClass($classname) { | |
995 | $classval = $this->getAttribute('class'); | |
996 | if (strlen($classval)) { $classval .= ' '; } | |
997 | $classval .= $classname; | |
998 | $this->setClass($classval); | |
999 | return $classval; | |
1000 | } | |
1001 | public function setID($elem_id) { | |
1002 | $this->setAttribute('id', $elem_id); | |
1003 | } | |
bf91764c RK |
1004 | } |
1005 | ||
1006 | class ExtendedDocumentFragment extends DOMDocumentFragment { | |
1007 | // ExtendedDocumentFragment PHP class | |
1008 | // this extends the general PHP DOM Document Fragment class to simplify some usual constructs | |
1009 | // | |
61cc8aa9 | 1010 | // public function appendElement($name, [$value]) |
bf91764c RK |
1011 | // appends a DOMDocument::createElement() as a child of this fragment (see there for params) |
1012 | // returns the new child | |
1013 | // | |
61cc8aa9 | 1014 | // public function appendElementXML($name, $xmldata) |
bf91764c RK |
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 | |
1018 | // | |
b3cc0fef | 1019 | // public function appendLink($target, [$value], [$title]) |
bf91764c RK |
1020 | // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params) |
1021 | // returns the new child | |
1022 | // | |
61cc8aa9 | 1023 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
1024 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
1025 | // returns the new child | |
1026 | // | |
61cc8aa9 | 1027 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
1028 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
1029 | // returns the new child | |
1030 | // | |
61cc8aa9 | 1031 | // public function appendFormDiv($action, $method, $name, [$id]) |
bf91764c RK |
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 | |
1034 | // | |
61cc8aa9 | 1035 | // public function appendInputHidden($name, $value) |
bf91764c RK |
1036 | // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params) |
1037 | // returns the new child | |
1038 | // | |
61cc8aa9 | 1039 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
bf91764c RK |
1040 | // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) |
1041 | // returns the new child | |
1042 | // | |
f925e4a1 RK |
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 | |
1046 | // | |
61cc8aa9 | 1047 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
1048 | // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) |
1049 | // returns the new child | |
1050 | // | |
f925e4a1 RK |
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 | |
1054 | // | |
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 | |
1058 | // | |
ea32f7e5 RK |
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 | |
1062 | // | |
f925e4a1 RK |
1063 | // public function appendInputTel($name, $maxlength, $size, [$id], [$value]) |
1064 | // appends an ExtendedDocument::createElementInputTel() as a child of this fragment (see there for params) | |
645a7eb6 RK |
1065 | // returns the new child |
1066 | // | |
f925e4a1 RK |
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 | |
1070 | // | |
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 | |
1074 | // | |
1075 | // public function appendInputColor($name, [$id], [$value]) | |
1076 | // appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params) | |
1077 | // | |
61cc8aa9 | 1078 | // public function appendInputRadio($name, $id, $value, $checked) |
bf91764c RK |
1079 | // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params) |
1080 | // returns the new child | |
1081 | // | |
61cc8aa9 | 1082 | // public function appendInputCheckbox($name, $id, $value, $checked) |
bf91764c RK |
1083 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params) |
1084 | // returns the new child | |
1085 | // | |
61cc8aa9 | 1086 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
1087 | // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params) |
1088 | // returns the new child | |
1089 | // | |
61cc8aa9 | 1090 | // public function appendInputSubmit($value) |
bf91764c RK |
1091 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params) |
1092 | // returns the new child | |
1093 | // | |
61cc8aa9 | 1094 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
1095 | // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params) |
1096 | // returns the new child | |
1097 | // | |
61cc8aa9 | 1098 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
1099 | // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params) |
1100 | // returns the new child | |
1101 | // | |
69409ddb | 1102 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
1103 | // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params) |
1104 | // returns the new child | |
1105 | // | |
61cc8aa9 | 1106 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
1107 | // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params) |
1108 | // returns the new child | |
1109 | // | |
61cc8aa9 | 1110 | // public function appendLabel($for_id, $value) |
bf91764c RK |
1111 | // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params) |
1112 | // returns the new child | |
1113 | // | |
c79be4c2 RK |
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 | |
1117 | // | |
61cc8aa9 | 1118 | // public function appendText($text) |
bf91764c RK |
1119 | // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params) |
1120 | // returns the new child | |
1121 | // | |
71771b0c RK |
1122 | // public function appendLinebreak() |
1123 | // appends a <br> as a child of this fragment | |
1124 | // returns the new child | |
1125 | // | |
6638efd5 RK |
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 | |
1129 | // | |
61cc8aa9 | 1130 | // public function appendComment($comment_data) |
cadc5980 RK |
1131 | // appends a DOMDocument::createComment() as a child of this fragment (see there for params) |
1132 | // returns the new child | |
1133 | // | |
3d4db013 RK |
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 | |
1138 | // | |
61cc8aa9 | 1139 | // public function appendHTMLMarkup($htmldata) |
bf91764c RK |
1140 | // appends a representation of the HTML data as children of this fragment |
1141 | // NO return value! | |
1142 | // | |
61cc8aa9 | 1143 | // public function appendXMLMarkup($xmldata) |
bf91764c RK |
1144 | // appends a representation of the XML data as children of this fragment |
1145 | // NO return value! | |
1146 | // | |
acaa2daa RK |
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 | |
1150 | // | |
61cc8aa9 | 1151 | // public function appendJSElement($jsdata) |
bf91764c | 1152 | // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params) |
3d4db013 | 1153 | // returns the new child |
c1666e91 | 1154 | // |
8afa2e61 | 1155 | // public function appendJSFile($jsURL, [$defer], [$async]) |
0bbc241e | 1156 | // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params) |
ea32f7e5 | 1157 | // returns the new child |
bf91764c | 1158 | |
61cc8aa9 | 1159 | public function appendElement($name, $value = '') { |
a8816f43 | 1160 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
bf91764c | 1161 | } |
61cc8aa9 | 1162 | public function appendElementXML($name, $xmldata) { |
bf91764c RK |
1163 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
1164 | $aelem->appendXMLMarkup($xmldata); | |
1165 | return $aelem; | |
1166 | } | |
b3cc0fef RK |
1167 | public function appendLink($target, $value = '', $title = null) { |
1168 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title)); | |
bf91764c | 1169 | } |
61cc8aa9 | 1170 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
1171 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
1172 | } | |
61cc8aa9 | 1173 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
1174 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
1175 | } | |
61cc8aa9 | 1176 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 1177 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
bf91764c RK |
1178 | return $formelem->appendElement('div'); |
1179 | } | |
61cc8aa9 | 1180 | public function appendInputHidden($name, $value) { |
bf91764c RK |
1181 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
1182 | } | |
61cc8aa9 | 1183 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
bf91764c | 1184 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
645a7eb6 | 1185 | } |
f925e4a1 RK |
1186 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
1187 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
1188 | } | |
61cc8aa9 | 1189 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
1190 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
1191 | } | |
f925e4a1 RK |
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)); | |
1194 | } | |
1195 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
1196 | return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
1197 | } | |
ea32f7e5 RK |
1198 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
1199 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
1200 | } | |
f925e4a1 RK |
1201 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
1202 | return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
1203 | } | |
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)); | |
1206 | } | |
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)); | |
1209 | } | |
1210 | public function appendInputColor($name, $id = null, $value = null) { | |
1211 | return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); | |
bf91764c | 1212 | } |
61cc8aa9 | 1213 | public function appendInputRadio($name, $id, $value, $checked) { |
bf91764c RK |
1214 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
1215 | } | |
61cc8aa9 | 1216 | public function appendInputCheckbox($name, $id, $value, $checked) { |
bf91764c RK |
1217 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
1218 | } | |
61cc8aa9 | 1219 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
1220 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
1221 | } | |
61cc8aa9 | 1222 | public function appendInputSubmit($value) { |
bf91764c RK |
1223 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
1224 | } | |
61cc8aa9 | 1225 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
1226 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
1227 | } | |
61cc8aa9 | 1228 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
1229 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
1230 | } | |
69409ddb RK |
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)); | |
bf91764c | 1233 | } |
61cc8aa9 | 1234 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
1235 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
1236 | } | |
61cc8aa9 | 1237 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
1238 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
1239 | } | |
c79be4c2 RK |
1240 | public function appendElementDatalist($id = null, $options = array()) { |
1241 | return $this->appendChild($this->ownerDocument->createElementDatalist($id, $options)); | |
1242 | } | |
61cc8aa9 | 1243 | public function appendText($text) { |
cea5b93a RK |
1244 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
1245 | } | |
71771b0c RK |
1246 | public function appendLinebreak() { |
1247 | return $this->appendChild($this->ownerDocument->createElement('br')); | |
1248 | } | |
6638efd5 RK |
1249 | public function appendEntity($name) { |
1250 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
1251 | } | |
61cc8aa9 | 1252 | public function appendComment($comment_data) { |
cadc5980 RK |
1253 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
1254 | } | |
3d4db013 RK |
1255 | public function appendClonedElement($dom_element, $deep = true) { |
1256 | return $this->appendChild($dom_element->cloneNode($deep)); | |
1257 | } | |
61cc8aa9 | 1258 | public function appendHTMLMarkup($htmldata) { |
ae41c41b RK |
1259 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
1260 | } | |
61cc8aa9 | 1261 | public function appendXMLMarkup($xmldata) { |
ae41c41b | 1262 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
cea5b93a | 1263 | } |
acaa2daa RK |
1264 | public function appendStyleElement($styledata) { |
1265 | return $this->appendChild($this->ownerDocument->createElementStyle($styledata)); | |
1266 | } | |
61cc8aa9 | 1267 | public function appendJSElement($jsdata) { |
3d4db013 | 1268 | return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
cea5b93a | 1269 | } |
1a4ee0f0 RK |
1270 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
1271 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 1272 | } |
cea5b93a RK |
1273 | } |
1274 | ?> |