require an exact match for the list entries
[php-utility-classes.git] / classes / document.php-class
CommitLineData
cea5b93a 1<?php
880bcb60
RK
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
cea5b93a
RK
5
6class ExtendedDocument extends DOMDocument {
7 // ExtendedDocument PHP class
8 // this extends the general PHP DOM Document class to simplify some usual constructs
9 //
10 // function __construct([$version], [$encoding])
11 // CONSTRUCTOR
12 // construct a new DOM Document that uses our element definitions
13 //
b841a92b 14 // static function initHTML5([$doc])
14014b8f 15 // initialize as an HTML5 document and return references to its basic elements.
b841a92b 16 // If a $doc is handed over (an ExtendedDocument or a derived class), load the content into that document.
14014b8f 17 // returns an associative array with the following elements: 'html', 'head', 'title', 'body'
ae41c41b 18 //
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 //
61cc8aa9 28 // public function appendLink($target, [$value])
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 //
61cc8aa9 52 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
53 // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
54 // returns the new child
55 //
ea32f7e5
RK
56 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
57 // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params)
58 // returns the new child
59 //
61cc8aa9 60 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
645a7eb6
RK
61 // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
62 // returns the new child
63 //
61cc8aa9 64 // public function appendInputRadio($name, $id, $value, $checked)
ae41c41b
RK
65 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
66 // returns the new child
67 //
61cc8aa9 68 // public function appendInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
69 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
70 // returns the new child
71 //
61cc8aa9 72 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
73 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
74 // returns the new child
75 //
61cc8aa9 76 // public function appendInputSubmit($value)
ae41c41b
RK
77 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
78 // returns the new child
79 //
61cc8aa9 80 // public function appendButton($value, $onclick = null)
1109f526
RK
81 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
82 // returns the new child
83 //
61cc8aa9 84 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
85 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
86 // returns the new child
87 //
61cc8aa9 88 // public function appendElementSelect($name, [$id], [$options], [$default])
bf91764c
RK
89 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
90 // returns the new child
91 //
61cc8aa9 92 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
93 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
94 // returns the new child
95 //
61cc8aa9 96 // public function appendLabel($for_id, $value)
ae41c41b
RK
97 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
98 // returns the new child
99 //
61cc8aa9 100 // public function appendText($text)
cea5b93a
RK
101 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
102 // returns the new child
103 //
6638efd5
RK
104 // public function appendEntity($name)
105 // appends a DOMDocument::createEntityReference() as a child of this document (see there for params)
106 // returns the new child
107 //
61cc8aa9 108 // public function appendComment($comment_data)
cadc5980
RK
109 // appends a DOMDocument::createComment() as a child of this document (see there for params)
110 // returns the new child
111 //
61cc8aa9 112 // public function appendHTMLMarkup($htmldata, [$parentNode])
ae41c41b
RK
113 // appends a representation of the HTML data as children of the given parent node, by default this document
114 // NO return value!
115 //
61cc8aa9 116 // public function appendXMLMarkup($xmldata, [$parentNode])
ae41c41b 117 // appends a representation of the XML data as children of the given parent node, by default this document
cea5b93a
RK
118 // NO return value!
119 //
61cc8aa9 120 // public function appendJSElement($jsdata)
cea5b93a
RK
121 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
122 // NO return value!
123 //
8afa2e61 124 // public function appendJSFile($jsURL, [$defer], [$async])
ea32f7e5
RK
125 // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params)
126 // returns the new child
127 //
61cc8aa9 128 // public function createElementLink($target, [$value])
cea5b93a
RK
129 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
130 //
61cc8aa9 131 // public function createElementImage($src, [$alt_text])
53510e9e
RK
132 // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
133 //
61cc8aa9 134 // public function createElementForm($action, $method, $name)
ae41c41b
RK
135 // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
136 // with the given action, method, and name
137 //
61cc8aa9 138 // public function createElementInputHidden($name, $value)
ae41c41b
RK
139 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
140 //
61cc8aa9 141 // public function createElementInputText($name, $maxlength, $size, [$id], [$value])
ae41c41b
RK
142 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
143 // and optionally id and value
144 //
61cc8aa9 145 // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
146 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
147 // and optionally id and value
148 //
ea32f7e5
RK
149 // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value])
150 // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size,
151 // and optionally id and value
152 //
61cc8aa9 153 // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
645a7eb6
RK
154 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
155 // and optionally id and value
156 //
61cc8aa9 157 // public function createElementInputRadio($name, $id, $value, $checked)
ae41c41b
RK
158 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
159 // checked state
160 //
61cc8aa9 161 // public function createElementInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
162 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
163 // checked state
164 //
61cc8aa9 165 // public function createElementInputFile($name, $id, $accept)
4bb9d784
RK
166 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
167 //
61cc8aa9 168 // public function createElementInputSubmit($value)
1109f526
RK
169 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
170 //
61cc8aa9 171 // public function createElementButton($value, $onclick = null)
1109f526 172 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
ae41c41b 173 //
61cc8aa9 174 // public function createElementTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
175 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
176 // and optionally id and value
177 //
61cc8aa9 178 // public function createElementSelect($name, [$id], [$options], [$default])
bf91764c
RK
179 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
180 // array of options (key => description) and key of the by-default selected entry
181 //
61cc8aa9 182 // public function createElementOption($key, $desc, [$selected])
bf91764c
RK
183 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
184 // and optionally bool that tells if the entry is selected
185 //
61cc8aa9 186 // public function createElementLabel($for_id, $value)
ae41c41b 187 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
cea5b93a 188 //
61cc8aa9 189 // public function createElementJS($jsdata)
cea5b93a 190 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
c1666e91 191 //
8afa2e61 192 // public function createElementJSFile($jsURL, [$defer], [$async])
ea32f7e5 193 // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL
8afa2e61 194 // $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
195
196 function __construct($version = '1.0', $encoding = 'utf-8') {
197 // make sure the default DOMDocument constructor runs
198 parent::__construct($version, $encoding);
199 $this->registerNodeClass('DOMElement', 'ExtendedElement');
bf91764c 200 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
cea5b93a
RK
201 }
202
b841a92b
RK
203 static function initHTML5($doc = null) {
204 if (is_null($doc)) { $doc = new ExtendedDocument(); }
14014b8f
RK
205 $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
206
207 // Created basic HTML document structure.
208 $root = $doc->getElementsByTagName('html')->item(0);
209 $head = $root->appendElement('head');
210 $title = $head->appendElement('title');
211 $body = $root->appendElement('body');
212
213 return array('document' => $doc,
214 'html' => $root,
215 'head' => $head,
216 'title' => $title,
217 'body' => $body);
218 }
219
61cc8aa9 220 public function appendElement($name, $value = '') {
a8816f43 221 return $this->appendChild($this->createElement($name, $value));
cea5b93a 222 }
61cc8aa9 223 public function appendElementXML($name, $xmldata) {
cea5b93a 224 $aelem = $this->appendChild($this->createElement($name));
ae41c41b
RK
225 $aelem->appendXMLMarkup($xmldata);
226 //$aelem->appendChild($this->createXMLFragment($xmldata));
cea5b93a
RK
227 return $aelem;
228 }
61cc8aa9 229 public function appendLink($target, $value = '') {
cea5b93a
RK
230 return $this->appendChild($this->createElementLink($target, $value));
231 }
61cc8aa9 232 public function appendImage($src, $alt_text = '') {
4aa31782
RK
233 return $this->appendChild($this->createElementImage($src, $alt_text));
234 }
61cc8aa9 235 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
236 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
237 }
61cc8aa9 238 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 239 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
ae41c41b
RK
240 return $formelem->appendElement('div');
241 }
61cc8aa9 242 public function appendInputHidden($name, $value) {
ae41c41b
RK
243 return $this->appendChild($this->createElementInputHidden($name, $value));
244 }
61cc8aa9 245 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
246 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
247 }
61cc8aa9 248 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
249 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
250 }
ea32f7e5
RK
251 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
252 return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value));
253 }
61cc8aa9 254 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
645a7eb6
RK
255 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
256 }
61cc8aa9 257 public function appendInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
258 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
259 }
61cc8aa9 260 public function appendInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
261 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
262 }
61cc8aa9 263 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
264 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
265 }
61cc8aa9 266 public function appendInputSubmit($value) {
ae41c41b
RK
267 return $this->appendChild($this->createElementInputSubmit($value));
268 }
61cc8aa9 269 public function appendButton($value, $onclick = null) {
1109f526
RK
270 return $this->appendChild($this->createElementButton($value, $onclick));
271 }
61cc8aa9 272 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
273 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
274 }
61cc8aa9 275 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
bf91764c
RK
276 return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
277 }
61cc8aa9 278 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
279 return $this->appendChild($this->createElementOption($key, $desc, $selected));
280 }
61cc8aa9 281 public function appendLabel($for_id, $value) {
ae41c41b
RK
282 return $this->appendChild($this->createElementLabel($for_id, $value));
283 }
61cc8aa9 284 public function appendText($text) {
cea5b93a
RK
285 return $this->appendChild($this->createTextNode($text));
286 }
6638efd5
RK
287 public function appendEntity($name) {
288 return $this->appendChild($this->createEntityReference($name));
289 }
61cc8aa9 290 public function appendComment($comment_data) {
cadc5980
RK
291 return $this->appendChild($this->createComment($comment_data));
292 }
61cc8aa9 293 public function appendJSElement($jsdata) {
cea5b93a
RK
294 $this->appendChild($this->createElementJS($jsdata));
295 }
8afa2e61
RK
296 public function appendJSFile($jsdata, $defer = false, $async = false) {
297 return $this->appendChild($this->createElementJSFile($jsdata, $defer, $async));
ea32f7e5 298 }
cea5b93a 299
61cc8aa9 300 public function appendHTMLMarkup($htmldata, $parentNode = null) {
ae41c41b 301 if (is_null($parentNode)) { $parentNode =& $this; }
a9a5a68a
RK
302 // Use loadHTML() to parse and turn the markup into proper HTML.
303 $tmpdoc = new ExtendedDocument;
304 // The XML line is needed to tell the parser that we need UTF-8 parsing.
305 $tmpdoc->loadHTML('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>');
306 foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) {
307 $parentNode->appendChild($this->importNode($child, true));
308 }
ae41c41b
RK
309 }
310
61cc8aa9 311 public function appendXMLMarkup($xmldata, $parentNode = null) {
ae41c41b
RK
312 if (is_null($parentNode)) { $parentNode =& $this; }
313 $tmpdoc = new ExtendedDocument;
314 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
315 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
316 $tmpxml .= '<root>'.$xmldata.'</root>';
317 $tmpdoc->loadXML($tmpxml);
318 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
319 $parentNode->appendChild($this->importNode($child, true));
320 }
cea5b93a
RK
321 }
322
61cc8aa9 323 public function createElement($name, $value = '') {
a8816f43
RK
324 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
325 $aelem = parent::createElement($name);
326 $aelem->appendText($value);
327 return $aelem;
328 }
329
61cc8aa9 330 public function createElementLink($target, $value = '') {
a8816f43 331 $link = $this->createElement('a', $value);
bf91764c 332 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
cea5b93a
RK
333 return $link;
334 }
335
61cc8aa9 336 public function createElementImage($src, $alt_text = '') {
319cfe8d
RK
337 $img = $this->createElement('img');
338 $img->setAttribute('src', $src);
339 $img->setAttribute('alt', $alt_text);
340 return $img;
4aa31782
RK
341 }
342
61cc8aa9 343 public function createElementForm($action, $method, $name, $id = null) {
ae41c41b
RK
344 $formelem = $this->createElement('form');
345 $formelem->setAttribute('action', $action);
346 $formelem->setAttribute('method', $method);
347 $formelem->setAttribute('name', $name);
b8d16837 348 $formelem->setAttribute('id', $id);
ae41c41b
RK
349 return $formelem;
350 }
351
61cc8aa9 352 public function createElementInputHidden($name, $value) {
ae41c41b
RK
353 $hidden = $this->createElement('input');
354 $hidden->setAttribute('type', 'hidden');
355 $hidden->setAttribute('name', $name);
356 $hidden->setAttribute('value', $value);
357 return $hidden;
358 }
359
61cc8aa9 360 public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
361 $txfield = $this->createElement('input');
362 $txfield->setAttribute('type', 'text');
363 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
364 $txfield->setAttribute('name', $name);
365 $txfield->setAttribute('maxlength', $maxlength);
366 $txfield->setAttribute('size', $size);
367 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
368 return $txfield;
369 }
370
61cc8aa9 371 public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
372 $txfield = $this->createElement('input');
373 $txfield->setAttribute('type', 'number');
374 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
375 $txfield->setAttribute('name', $name);
376 $txfield->setAttribute('maxlength', $maxlength);
377 $txfield->setAttribute('size', $size);
378 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
379 return $txfield;
380 }
381
ea32f7e5
RK
382 public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
383 $txfield = $this->createElement('input');
384 $txfield->setAttribute('type', 'email');
385 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
386 $txfield->setAttribute('name', $name);
387 $txfield->setAttribute('maxlength', $maxlength);
388 $txfield->setAttribute('size', $size);
389 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
390 return $txfield;
391 }
392
61cc8aa9 393 public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
319cfe8d
RK
394 $pwfield = $this->createElement('input');
395 $pwfield->setAttribute('type', 'password');
396 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
397 $pwfield->setAttribute('name', $name);
398 $pwfield->setAttribute('maxlength', $maxlength);
399 $pwfield->setAttribute('size', $size);
400 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
401 return $pwfield;
645a7eb6
RK
402 }
403
61cc8aa9 404 public function createElementInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
405 $radio = $this->createElement('input');
406 $radio->setAttribute('type', 'radio');
407 $radio->setAttribute('name', $name);
4bb9d784 408 if (!is_null($id)) { $radio->setAttribute('id', $id); }
ae41c41b
RK
409 $radio->setAttribute('value', $value);
410 if ($checked) { $radio->setAttribute('checked', ''); }
411 return $radio;
412 }
413
61cc8aa9 414 public function createElementInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
415 $cbox = $this->createElement('input');
416 $cbox->setAttribute('type', 'checkbox');
417 $cbox->setAttribute('name', $name);
4bb9d784 418 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
ae41c41b
RK
419 $cbox->setAttribute('value', $value);
420 if ($checked) { $cbox->setAttribute('checked', ''); }
421 return $cbox;
422 }
423
61cc8aa9 424 public function createElementInputFile($name, $id, $accept) {
4bb9d784
RK
425 $fileinput = $this->createElement('input');
426 $fileinput->setAttribute('type', 'file');
427 $fileinput->setAttribute('name', $name);
428 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
429 $fileinput->setAttribute('accept', $accept);
430 return $fileinput;
431 }
432
61cc8aa9 433 public function createElementInputSubmit($value) {
ae41c41b
RK
434 $submitbtn = $this->createElement('input');
435 $submitbtn->setAttribute('type', 'submit');
436 $submitbtn->setAttribute('value', $value);
437 return $submitbtn;
438 }
439
61cc8aa9 440 public function createElementButton($value, $onclick = null) {
1109f526
RK
441 $btn = $this->createElement('input');
442 $btn->setAttribute('type', 'button');
443 $btn->setAttribute('value', $value);
444 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
445 return $btn;
446 }
447
61cc8aa9 448 public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
449 $txtarea = $this->createElement('textarea', $value);
450 $txtarea->setAttribute('name', $name);
451 $txtarea->setAttribute('cols', $columns);
452 $txtarea->setAttribute('rows', $rows);
453 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
454 return $txtarea;
455 }
456
61cc8aa9 457 public function createElementSelect($name, $id = null, $options = array(), $default = null) {
bf91764c
RK
458 $select = $this->createElement('select');
459 $select->setAttribute('name', $name);
460 if (!is_null($id)) { $select->setAttribute('id', $id); }
461 foreach ($options as $key => $desc) {
f21250a5 462 $select->appendElementOption($key, $desc, ($key === $default));
bf91764c
RK
463 }
464 return $select;
465 }
466
61cc8aa9 467 public function createElementOption($key, $desc, $selected = false) {
bf91764c
RK
468 $option = $this->createElement('option', $desc);
469 $option->setAttribute('value', $key);
470 if ($selected) { $option->setAttribute('selected', ''); }
471 return $option;
472 }
473
61cc8aa9 474 public function createElementLabel($for_id, $value) {
ae41c41b
RK
475 $label = $this->createElement('label', $value);
476 $label->setAttribute('for', $for_id);
477 return $label;
cea5b93a
RK
478 }
479
61cc8aa9 480 public function createElementJS($jsdata) {
cea5b93a 481 $jselem = $this->createElement('script');
ea32f7e5 482 // Note: type can/should be left out for HTML5.
cea5b93a
RK
483 $jselem->setAttribute('type', 'text/javascript');
484 $jselem->appendChild($this->createCDATASection($jsdata));
485 return $jselem;
486 }
c1666e91 487
8afa2e61 488 public function createElementJSFile($jsURL, $defer = false, $async = false) {
ea32f7e5
RK
489 $jselem = $this->createElement('script');
490 // Note: type can/should be left out for HTML5.
491 $jselem->setAttribute('type', 'text/javascript');
8afa2e61
RK
492 if ($defer) {
493 $jselem->setAttribute('defer', '');
494 }
495 if ($async) {
496 $jselem->setAttribute('async', '');
497 }
ea32f7e5
RK
498 $jselem->setAttribute('src', $jsURL);
499 return $jselem;
500 }
cea5b93a
RK
501}
502
503class ExtendedElement extends DOMElement {
504 // ExtendedElement PHP class
505 // this extends the general PHP DOM Element class to simplify some usual constructs
506 //
61cc8aa9 507 // public function appendElement($name, [$value])
cea5b93a
RK
508 // appends a DOMDocument::createElement() as a child of this element (see there for params)
509 // returns the new child
510 //
61cc8aa9 511 // public function appendElementXML($name, $xmldata)
cea5b93a
RK
512 // appends a DOMDocument::createElement() with the given name as a child of this element,
513 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
514 // returns the new child
515 //
61cc8aa9 516 // public function appendLink($target, [$value])
cea5b93a
RK
517 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
518 // returns the new child
519 //
61cc8aa9 520 // public function appendImage($src, [$alt_text])
53510e9e
RK
521 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
522 // returns the new child
523 //
61cc8aa9 524 // public function appendForm($action, $method, $name, [$id])
b8d16837
RK
525 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
526 // returns the new child
527 //
61cc8aa9 528 // public function appendFormDiv($action, $method, $name, [$id])
ae41c41b
RK
529 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
530 // returns an HTML <div> that is a child of the new child
531 //
61cc8aa9 532 // public function appendInputHidden($name, $value)
ae41c41b
RK
533 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
534 // returns the new child
535 //
61cc8aa9 536 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
ae41c41b
RK
537 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
538 // returns the new child
539 //
61cc8aa9 540 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
541 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
542 // returns the new child
543 //
ea32f7e5
RK
544 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
545 // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params)
546 // returns the new child
547 //
61cc8aa9 548 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
645a7eb6
RK
549 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
550 // returns the new child
551 //
61cc8aa9 552 // public function appendInputRadio($name, $id, $value, $checked)
ae41c41b
RK
553 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
554 // returns the new child
555 //
61cc8aa9 556 // public function appendInputCheckbox($name, $id, $value, $checked)
ae41c41b
RK
557 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
558 // returns the new child
559 //
61cc8aa9 560 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
561 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
562 // returns the new child
563 //
61cc8aa9 564 // public function appendInputSubmit($value)
ae41c41b
RK
565 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
566 // returns the new child
567 //
61cc8aa9 568 // public function appendButton($value, $onclick = null)
1109f526
RK
569 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
570 // returns the new child
571 //
61cc8aa9 572 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
573 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
574 // returns the new child
575 //
61cc8aa9 576 // public function appendElementSelect($name, [$id], [$options], [$default])
bf91764c
RK
577 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
578 // returns the new child
579 //
61cc8aa9 580 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
581 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
582 // returns the new child
583 //
61cc8aa9 584 // public function appendLabel($for_id, $value)
ae41c41b
RK
585 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
586 // returns the new child
587 //
61cc8aa9 588 // public function appendText($text)
cea5b93a
RK
589 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
590 // returns the new child
591 //
6638efd5
RK
592 // public function appendEntity($name)
593 // appends a DOMDocument::createEntityReference() as a child of this element (see there for params)
594 // returns the new child
595 //
61cc8aa9 596 // public function appendComment($comment_data)
cadc5980
RK
597 // appends a DOMDocument::createComment() as a child of this element (see there for params)
598 // returns the new child
599 //
61cc8aa9 600 // public function appendHTMLMarkup($htmldata)
ae41c41b
RK
601 // appends a representation of the HTML data as children of this element
602 // NO return value!
603 //
61cc8aa9 604 // public function appendXMLMarkup($xmldata)
ae41c41b 605 // appends a representation of the XML data as children of this element
cea5b93a
RK
606 // NO return value!
607 //
61cc8aa9 608 // public function appendJSElement($jsdata)
cea5b93a
RK
609 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
610 // NO return value!
c1666e91 611 //
8afa2e61 612 // public function appendJSFile($jsURL, [$defer], [$async])
0bbc241e 613 // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
ea32f7e5 614 // returns the new child
cea5b93a 615
61cc8aa9 616 public function appendElement($name, $value = '') {
a8816f43 617 return $this->appendChild($this->ownerDocument->createElement($name, $value));
cea5b93a 618 }
61cc8aa9 619 public function appendElementXML($name, $xmldata) {
cea5b93a 620 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
ae41c41b 621 $aelem->appendXMLMarkup($xmldata);
cea5b93a
RK
622 return $aelem;
623 }
61cc8aa9 624 public function appendLink($target, $value = '') {
cea5b93a
RK
625 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
626 }
61cc8aa9 627 public function appendImage($src, $alt_text = '') {
53510e9e
RK
628 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
629 }
61cc8aa9 630 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
631 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
632 }
61cc8aa9 633 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 634 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
ae41c41b
RK
635 return $formelem->appendElement('div');
636 }
61cc8aa9 637 public function appendInputHidden($name, $value) {
ae41c41b
RK
638 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
639 }
61cc8aa9 640 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
ae41c41b
RK
641 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
642 }
61cc8aa9 643 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
644 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
645 }
ea32f7e5
RK
646 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
647 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
648 }
61cc8aa9 649 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
645a7eb6
RK
650 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
651 }
61cc8aa9 652 public function appendInputRadio($name, $id, $value, $checked) {
ae41c41b
RK
653 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
654 }
61cc8aa9 655 public function appendInputCheckbox($name, $id, $value, $checked) {
ae41c41b
RK
656 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
657 }
61cc8aa9 658 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
659 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
660 }
61cc8aa9 661 public function appendInputSubmit($value) {
ae41c41b
RK
662 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
663 }
61cc8aa9 664 public function appendButton($value, $onclick = null) {
1109f526
RK
665 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
666 }
61cc8aa9 667 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
668 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
669 }
61cc8aa9 670 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
bf91764c
RK
671 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
672 }
61cc8aa9 673 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
674 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
675 }
61cc8aa9 676 public function appendLabel($for_id, $value) {
bf91764c
RK
677 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
678 }
61cc8aa9 679 public function appendText($text) {
bf91764c
RK
680 return $this->appendChild($this->ownerDocument->createTextNode($text));
681 }
6638efd5
RK
682 public function appendEntity($name) {
683 return $this->appendChild($this->ownerDocument->createEntityReference($name));
684 }
61cc8aa9 685 public function appendComment($comment_data) {
cadc5980
RK
686 return $this->appendChild($this->ownerDocument->createComment($comment_data));
687 }
61cc8aa9 688 public function appendHTMLMarkup($htmldata) {
bf91764c
RK
689 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
690 }
61cc8aa9 691 public function appendXMLMarkup($xmldata) {
bf91764c
RK
692 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
693 }
61cc8aa9 694 public function appendJSElement($jsdata) {
bf91764c
RK
695 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
696 }
8afa2e61
RK
697 public function appendJSFile($jsdata, $defer = false, $async = false) {
698 return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
ea32f7e5 699 }
bf91764c
RK
700}
701
702class ExtendedDocumentFragment extends DOMDocumentFragment {
703 // ExtendedDocumentFragment PHP class
704 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
705 //
61cc8aa9 706 // public function appendElement($name, [$value])
bf91764c
RK
707 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
708 // returns the new child
709 //
61cc8aa9 710 // public function appendElementXML($name, $xmldata)
bf91764c
RK
711 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
712 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
713 // returns the new child
714 //
61cc8aa9 715 // public function appendLink($target, [$value])
bf91764c
RK
716 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
717 // returns the new child
718 //
61cc8aa9 719 // public function appendImage($src, [$alt_text])
53510e9e
RK
720 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
721 // returns the new child
722 //
61cc8aa9 723 // public function appendForm($action, $method, $name, [$id])
b8d16837
RK
724 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
725 // returns the new child
726 //
61cc8aa9 727 // public function appendFormDiv($action, $method, $name, [$id])
bf91764c
RK
728 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
729 // returns an HTML <div> that is a child of the new child
730 //
61cc8aa9 731 // public function appendInputHidden($name, $value)
bf91764c
RK
732 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
733 // returns the new child
734 //
61cc8aa9 735 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
bf91764c
RK
736 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
737 // returns the new child
738 //
61cc8aa9 739 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
262e0bbb
RK
740 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
741 // returns the new child
742 //
ea32f7e5
RK
743 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
744 // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params)
745 // returns the new child
746 //
61cc8aa9 747 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
645a7eb6
RK
748 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
749 // returns the new child
750 //
61cc8aa9 751 // public function appendInputRadio($name, $id, $value, $checked)
bf91764c
RK
752 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
753 // returns the new child
754 //
61cc8aa9 755 // public function appendInputCheckbox($name, $id, $value, $checked)
bf91764c
RK
756 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
757 // returns the new child
758 //
61cc8aa9 759 // public function appendInputFile($name, $id, $accept)
4bb9d784
RK
760 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
761 // returns the new child
762 //
61cc8aa9 763 // public function appendInputSubmit($value)
bf91764c
RK
764 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
765 // returns the new child
766 //
61cc8aa9 767 // public function appendButton($value, $onclick = null)
1109f526
RK
768 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
769 // returns the new child
770 //
61cc8aa9 771 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
bf91764c
RK
772 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
773 // returns the new child
774 //
61cc8aa9 775 // public function appendElementSelect($name, [$id], [$options], [$default])
bf91764c
RK
776 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
777 // returns the new child
778 //
61cc8aa9 779 // public function appendElementOption($key, $desc, [$selected])
bf91764c
RK
780 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
781 // returns the new child
782 //
61cc8aa9 783 // public function appendLabel($for_id, $value)
bf91764c
RK
784 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
785 // returns the new child
786 //
61cc8aa9 787 // public function appendText($text)
bf91764c
RK
788 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
789 // returns the new child
790 //
6638efd5
RK
791 // public function appendEntity($name)
792 // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params)
793 // returns the new child
794 //
61cc8aa9 795 // public function appendComment($comment_data)
cadc5980
RK
796 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
797 // returns the new child
798 //
61cc8aa9 799 // public function appendHTMLMarkup($htmldata)
bf91764c
RK
800 // appends a representation of the HTML data as children of this fragment
801 // NO return value!
802 //
61cc8aa9 803 // public function appendXMLMarkup($xmldata)
bf91764c
RK
804 // appends a representation of the XML data as children of this fragment
805 // NO return value!
806 //
61cc8aa9 807 // public function appendJSElement($jsdata)
bf91764c
RK
808 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
809 // NO return value!
c1666e91 810 //
8afa2e61 811 // public function appendJSFile($jsURL, [$defer], [$async])
0bbc241e 812 // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params)
ea32f7e5 813 // returns the new child
bf91764c 814
61cc8aa9 815 public function appendElement($name, $value = '') {
a8816f43 816 return $this->appendChild($this->ownerDocument->createElement($name, $value));
bf91764c 817 }
61cc8aa9 818 public function appendElementXML($name, $xmldata) {
bf91764c
RK
819 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
820 $aelem->appendXMLMarkup($xmldata);
821 return $aelem;
822 }
61cc8aa9 823 public function appendLink($target, $value = '') {
bf91764c
RK
824 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
825 }
61cc8aa9 826 public function appendImage($src, $alt_text = '') {
53510e9e
RK
827 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
828 }
61cc8aa9 829 public function appendForm($action, $method, $name, $id = null) {
b8d16837
RK
830 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
831 }
61cc8aa9 832 public function appendFormDiv($action, $method, $name, $id = null) {
b8d16837 833 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
bf91764c
RK
834 return $formelem->appendElement('div');
835 }
61cc8aa9 836 public function appendInputHidden($name, $value) {
bf91764c
RK
837 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
838 }
61cc8aa9 839 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
bf91764c 840 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
645a7eb6 841 }
61cc8aa9 842 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
262e0bbb
RK
843 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
844 }
ea32f7e5
RK
845 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
846 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
847 }
61cc8aa9 848 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
645a7eb6 849 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
bf91764c 850 }
61cc8aa9 851 public function appendInputRadio($name, $id, $value, $checked) {
bf91764c
RK
852 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
853 }
61cc8aa9 854 public function appendInputCheckbox($name, $id, $value, $checked) {
bf91764c
RK
855 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
856 }
61cc8aa9 857 public function appendInputFile($name, $id, $accept) {
4bb9d784
RK
858 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
859 }
61cc8aa9 860 public function appendInputSubmit($value) {
bf91764c
RK
861 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
862 }
61cc8aa9 863 public function appendButton($value, $onclick = null) {
1109f526
RK
864 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
865 }
61cc8aa9 866 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
bf91764c
RK
867 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
868 }
61cc8aa9 869 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
bf91764c
RK
870 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
871 }
61cc8aa9 872 public function appendElementOption($key, $desc, $selected = false) {
bf91764c
RK
873 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
874 }
61cc8aa9 875 public function appendLabel($for_id, $value) {
ae41c41b
RK
876 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
877 }
61cc8aa9 878 public function appendText($text) {
cea5b93a
RK
879 return $this->appendChild($this->ownerDocument->createTextNode($text));
880 }
6638efd5
RK
881 public function appendEntity($name) {
882 return $this->appendChild($this->ownerDocument->createEntityReference($name));
883 }
61cc8aa9 884 public function appendComment($comment_data) {
cadc5980
RK
885 return $this->appendChild($this->ownerDocument->createComment($comment_data));
886 }
61cc8aa9 887 public function appendHTMLMarkup($htmldata) {
ae41c41b
RK
888 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
889 }
61cc8aa9 890 public function appendXMLMarkup($xmldata) {
ae41c41b 891 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
cea5b93a 892 }
61cc8aa9 893 public function appendJSElement($jsdata) {
cea5b93a
RK
894 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
895 }
8afa2e61
RK
896 public function appendJSFile($jsdata, $defer = false, $async = false) {
897 return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
ea32f7e5 898 }
cea5b93a
RK
899}
900?>