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