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