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