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