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