2 /* ***** BEGIN LICENSE BLOCK *****
4 * The contents of this file are subject to Austrian copyright reegulations
5 * ("Urheberrecht"); you may not use this file except in compliance with
7 * This contents and any derived work, if it gets distributed in any way,
8 * is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
9 * either express or implied.
11 * The Original Code is KaiRo's extended DOM document classes.
13 * The Initial Developer of the Original Code is
14 * KaiRo - Robert Kaiser.
15 * Portions created by the Initial Developer are Copyright (C) 2010
16 * the Initial Developer. All Rights Reserved.
18 * Contributor(s): Robert Kaiser <kairo@kairo.at>
20 * ***** END LICENSE BLOCK ***** */
22 class ExtendedDocument extends DOMDocument {
23 // ExtendedDocument PHP class
24 // this extends the general PHP DOM Document class to simplify some usual constructs
26 // function __construct([$version], [$encoding])
28 // construct a new DOM Document that uses our element definitions
31 // the default XML header
33 // private $xhtmldtype
34 // the XHTML doctype to use by default
36 // function appendElement($name, [$value])
37 // appends a DOMDocument::createElement() as a child of this document (see there for params)
38 // returns the new child
40 // function appendElementXML($name, $xmldata)
41 // appends a DOMDocument::createElement() with the given name as a child of this document,
42 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
43 // returns the new child
45 // function appendLink($target, [$value])
46 // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
47 // returns the new child
49 // function appendImage($src, [$alt_text])
50 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
51 // returns the new child
53 // function appendForm($action, $method, $name, [$id])
54 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
55 // returns the new child
57 // function appendFormDiv($action, $method, $name, [$id])
58 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
59 // returns an HTML <div> that is a child of the new child
61 // function appendInputHidden($name, $value)
62 // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
63 // returns the new child
65 // function appendInputText($name, $maxlength, $size, [$id], [$value])
66 // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
67 // returns the new child
69 // function appendInputNumber($name, $maxlength, $size, [$id], [$value])
70 // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
71 // returns the new child
73 // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
74 // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
75 // returns the new child
77 // function appendInputRadio($name, $id, $value, $checked)
78 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
79 // returns the new child
81 // function appendInputCheckbox($name, $id, $value, $checked)
82 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
83 // returns the new child
85 // function appendInputFile($name, $id, $accept)
86 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
87 // returns the new child
89 // function appendInputSubmit($value)
90 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
91 // returns the new child
93 // function appendButton($value, $onclick = null)
94 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
95 // returns the new child
97 // function appendTextArea($name, $columns, $rows, [$id], [$value])
98 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
99 // returns the new child
101 // function appendElementSelect($name, [$id], [$options], [$default])
102 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
103 // returns the new child
105 // function appendElementOption($key, $desc, [$selected])
106 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
107 // returns the new child
109 // function appendLabel($for_id, $value)
110 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
111 // returns the new child
113 // function appendText($text)
114 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
115 // returns the new child
117 // function appendComment($comment_data)
118 // appends a DOMDocument::createComment() as a child of this document (see there for params)
119 // returns the new child
121 // function appendHTMLMarkup($htmldata, [$parentNode])
122 // appends a representation of the HTML data as children of the given parent node, by default this document
125 // function appendXMLMarkup($xmldata, [$parentNode])
126 // appends a representation of the XML data as children of the given parent node, by default this document
129 // function appendJSElement($jsdata)
130 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
133 // function appendCOMElement($module, $attributes)
134 // appends an ExtendedDocument::createCOMElement() as a child of this document (see there for params)
135 // returns the new child
137 // function createElementLink($target, [$value])
138 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
140 // function createElementImage($src, [$alt_text])
141 // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
143 // function createElementForm($action, $method, $name)
144 // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
145 // with the given action, method, and name
147 // function createElementInputHidden($name, $value)
148 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
150 // function createElementInputText($name, $maxlength, $size, [$id], [$value])
151 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
152 // and optionally id and value
154 // function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
155 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
156 // and optionally id and value
158 // function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
159 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
160 // and optionally id and value
162 // function createElementInputRadio($name, $id, $value, $checked)
163 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
166 // function createElementInputCheckbox($name, $id, $value, $checked)
167 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
170 // function createElementInputFile($name, $id, $accept)
171 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
173 // function createElementInputSubmit($value)
174 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
176 // function createElementButton($value, $onclick = null)
177 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
179 // function createElementTextArea($name, $columns, $rows, [$id], [$value])
180 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
181 // and optionally id and value
183 // function createElementSelect($name, [$id], [$options], [$default])
184 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
185 // array of options (key => description) and key of the by-default selected entry
187 // function createElementOption($key, $desc, [$selected])
188 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
189 // and optionally bool that tells if the entry is selected
191 // function createElementLabel($for_id, $value)
192 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
194 // function createElementJS($jsdata)
195 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
197 // function createCOMElement($module, $attributes)
198 // returns an ExtendedElement that is in COM_NS namespace, with the given module as name and the
199 // given name=>value array as attributes
201 function __construct($version = '1.0', $encoding = 'utf-8') {
202 // make sure the default DOMDocument constructor runs
203 parent::__construct($version, $encoding);
204 $this->registerNodeClass('DOMElement', 'ExtendedElement');
205 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
208 function appendElement($name, $value = '') {
209 return $this->appendChild($this->createElement($name, $value));
211 function appendElementXML($name, $xmldata) {
212 $aelem = $this->appendChild($this->createElement($name));
213 $aelem->appendXMLMarkup($xmldata);
214 //$aelem->appendChild($this->createXMLFragment($xmldata));
217 function appendLink($target, $value = '') {
218 return $this->appendChild($this->createElementLink($target, $value));
220 function appendImage($src, $alt_text = '') {
221 return $this->appendChild($this->createElementImage($src, $alt_text));
223 function appendForm($action, $method, $name, $id = null) {
224 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
226 function appendFormDiv($action, $method, $name, $id = null) {
227 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
228 return $formelem->appendElement('div');
230 function appendInputHidden($name, $value) {
231 return $this->appendChild($this->createElementInputHidden($name, $value));
233 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
234 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
236 function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
237 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
239 function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
240 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
242 function appendInputRadio($name, $id, $value, $checked) {
243 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
245 function appendInputCheckbox($name, $id, $value, $checked) {
246 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
248 function appendInputFile($name, $id, $accept) {
249 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
251 function appendInputSubmit($value) {
252 return $this->appendChild($this->createElementInputSubmit($value));
254 function appendButton($value, $onclick = null) {
255 return $this->appendChild($this->createElementButton($value, $onclick));
257 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
258 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
260 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
261 return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
263 function appendElementOption($key, $desc, $selected = false) {
264 return $this->appendChild($this->createElementOption($key, $desc, $selected));
266 function appendLabel($for_id, $value) {
267 return $this->appendChild($this->createElementLabel($for_id, $value));
269 function appendText($text) {
270 return $this->appendChild($this->createTextNode($text));
272 function appendComment($comment_data) {
273 return $this->appendChild($this->createComment($comment_data));
275 function appendJSElement($jsdata) {
276 $this->appendChild($this->createElementJS($jsdata));
278 function appendCOMElement($module, $attributes) {
279 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
282 function appendHTMLMarkup($htmldata, $parentNode = null) {
283 if (is_null($parentNode)) { $parentNode =& $this; }
284 // XXX: just a workaround for now!
285 $parentNode->appendChild($this->createCDATASection($htmldata));
288 function appendXMLMarkup($xmldata, $parentNode = null) {
289 if (is_null($parentNode)) { $parentNode =& $this; }
290 $tmpdoc = new ExtendedDocument;
291 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
292 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
293 $tmpxml .= '<root>'.$xmldata.'</root>';
294 $tmpdoc->loadXML($tmpxml);
295 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
296 $parentNode->appendChild($this->importNode($child, true));
300 function createElement($name, $value = '') {
301 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
302 $aelem = parent::createElement($name);
303 $aelem->appendText($value);
307 function createElementLink($target, $value = '') {
308 $link = $this->createElement('a', $value);
309 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
313 function createElementImage($src, $alt_text = '') {
314 $img = $this->createElement('img');
315 $img->setAttribute('src', $src);
316 $img->setAttribute('alt', $alt_text);
320 function createElementForm($action, $method, $name, $id = null) {
321 $formelem = $this->createElement('form');
322 $formelem->setAttribute('action', $action);
323 $formelem->setAttribute('method', $method);
324 $formelem->setAttribute('name', $name);
325 $formelem->setAttribute('id', $id);
329 function createElementInputHidden($name, $value) {
330 $hidden = $this->createElement('input');
331 $hidden->setAttribute('type', 'hidden');
332 $hidden->setAttribute('name', $name);
333 $hidden->setAttribute('value', $value);
337 function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
338 $txfield = $this->createElement('input');
339 $txfield->setAttribute('type', 'text');
340 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
341 $txfield->setAttribute('name', $name);
342 $txfield->setAttribute('maxlength', $maxlength);
343 $txfield->setAttribute('size', $size);
344 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
348 function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
349 $txfield = $this->createElement('input');
350 $txfield->setAttribute('type', 'number');
351 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
352 $txfield->setAttribute('name', $name);
353 $txfield->setAttribute('maxlength', $maxlength);
354 $txfield->setAttribute('size', $size);
355 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
359 function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
360 $pwfield = $this->createElement('input');
361 $pwfield->setAttribute('type', 'password');
362 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
363 $pwfield->setAttribute('name', $name);
364 $pwfield->setAttribute('maxlength', $maxlength);
365 $pwfield->setAttribute('size', $size);
366 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
370 function createElementInputRadio($name, $id, $value, $checked) {
371 $radio = $this->createElement('input');
372 $radio->setAttribute('type', 'radio');
373 $radio->setAttribute('name', $name);
374 if (!is_null($id)) { $radio->setAttribute('id', $id); }
375 $radio->setAttribute('value', $value);
376 if ($checked) { $radio->setAttribute('checked', ''); }
380 function createElementInputCheckbox($name, $id, $value, $checked) {
381 $cbox = $this->createElement('input');
382 $cbox->setAttribute('type', 'checkbox');
383 $cbox->setAttribute('name', $name);
384 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
385 $cbox->setAttribute('value', $value);
386 if ($checked) { $cbox->setAttribute('checked', ''); }
390 function createElementInputFile($name, $id, $accept) {
391 $fileinput = $this->createElement('input');
392 $fileinput->setAttribute('type', 'file');
393 $fileinput->setAttribute('name', $name);
394 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
395 $fileinput->setAttribute('accept', $accept);
399 function createElementInputSubmit($value) {
400 $submitbtn = $this->createElement('input');
401 $submitbtn->setAttribute('type', 'submit');
402 $submitbtn->setAttribute('value', $value);
406 function createElementButton($value, $onclick = null) {
407 $btn = $this->createElement('input');
408 $btn->setAttribute('type', 'button');
409 $btn->setAttribute('value', $value);
410 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
414 function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
415 $txtarea = $this->createElement('textarea', $value);
416 $txtarea->setAttribute('name', $name);
417 $txtarea->setAttribute('cols', $columns);
418 $txtarea->setAttribute('rows', $rows);
419 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
423 function createElementSelect($name, $id = null, $options = array(), $default = null) {
424 $select = $this->createElement('select');
425 $select->setAttribute('name', $name);
426 if (!is_null($id)) { $select->setAttribute('id', $id); }
427 foreach ($options as $key => $desc) {
428 $select->appendElementOption($key, $desc, ($key == $default));
433 function createElementOption($key, $desc, $selected = false) {
434 $option = $this->createElement('option', $desc);
435 $option->setAttribute('value', $key);
436 if ($selected) { $option->setAttribute('selected', ''); }
440 function createElementLabel($for_id, $value) {
441 $label = $this->createElement('label', $value);
442 $label->setAttribute('for', $for_id);
446 function createElementJS($jsdata) {
447 $jselem = $this->createElement('script');
448 $jselem->setAttribute('type', 'text/javascript');
449 $jselem->appendChild($this->createCDATASection($jsdata));
453 function createCOMElement($module, $attributes) {
454 $com_elem = $this->createElementNS(COM_NS, $module);
455 if (is_array($attributes) && count($attributes)) {
456 foreach ($attributes as $name=>$value) {
457 $com_elem->setAttribute($name, $value);
464 class ExtendedElement extends DOMElement {
465 // ExtendedElement PHP class
466 // this extends the general PHP DOM Element class to simplify some usual constructs
468 // function appendElement($name, [$value])
469 // appends a DOMDocument::createElement() as a child of this element (see there for params)
470 // returns the new child
472 // function appendElementXML($name, $xmldata)
473 // appends a DOMDocument::createElement() with the given name as a child of this element,
474 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
475 // returns the new child
477 // function appendLink($target, [$value])
478 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
479 // returns the new child
481 // function appendImage($src, [$alt_text])
482 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
483 // returns the new child
485 // function appendForm($action, $method, $name, [$id])
486 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
487 // returns the new child
489 // function appendFormDiv($action, $method, $name, [$id])
490 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
491 // returns an HTML <div> that is a child of the new child
493 // function appendInputHidden($name, $value)
494 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
495 // returns the new child
497 // function appendInputText($name, $maxlength, $size, [$id], [$value])
498 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
499 // returns the new child
501 // function appendInputNumber($name, $maxlength, $size, [$id], [$value])
502 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
503 // returns the new child
505 // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
506 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
507 // returns the new child
509 // function appendInputRadio($name, $id, $value, $checked)
510 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
511 // returns the new child
513 // function appendInputCheckbox($name, $id, $value, $checked)
514 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
515 // returns the new child
517 // function appendInputFile($name, $id, $accept)
518 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
519 // returns the new child
521 // function appendInputSubmit($value)
522 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
523 // returns the new child
525 // function appendButton($value, $onclick = null)
526 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
527 // returns the new child
529 // function appendTextArea($name, $columns, $rows, [$id], [$value])
530 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
531 // returns the new child
533 // function appendElementSelect($name, [$id], [$options], [$default])
534 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
535 // returns the new child
537 // function appendElementOption($key, $desc, [$selected])
538 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
539 // returns the new child
541 // function appendLabel($for_id, $value)
542 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
543 // returns the new child
545 // function appendText($text)
546 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
547 // returns the new child
549 // function appendComment($comment_data)
550 // appends a DOMDocument::createComment() as a child of this element (see there for params)
551 // returns the new child
553 // function appendHTMLMarkup($htmldata)
554 // appends a representation of the HTML data as children of this element
557 // function appendXMLMarkup($xmldata)
558 // appends a representation of the XML data as children of this element
561 // function appendJSElement($jsdata)
562 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
565 // function appendCOMElement($module, $attributes)
566 // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params)
567 // returns the new child
569 function appendElement($name, $value = '') {
570 return $this->appendChild($this->ownerDocument->createElement($name, $value));
572 function appendElementXML($name, $xmldata) {
573 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
574 $aelem->appendXMLMarkup($xmldata);
577 function appendLink($target, $value = '') {
578 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
580 function appendImage($src, $alt_text = '') {
581 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
583 function appendForm($action, $method, $name, $id = null) {
584 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
586 function appendFormDiv($action, $method, $name, $id = null) {
587 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
588 return $formelem->appendElement('div');
590 function appendInputHidden($name, $value) {
591 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
593 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
594 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
596 function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
597 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
599 function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
600 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
602 function appendInputRadio($name, $id, $value, $checked) {
603 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
605 function appendInputCheckbox($name, $id, $value, $checked) {
606 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
608 function appendInputFile($name, $id, $accept) {
609 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
611 function appendInputSubmit($value) {
612 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
614 function appendButton($value, $onclick = null) {
615 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
617 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
618 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
620 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
621 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
623 function appendElementOption($key, $desc, $selected = false) {
624 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
626 function appendLabel($for_id, $value) {
627 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
629 function appendText($text) {
630 return $this->appendChild($this->ownerDocument->createTextNode($text));
632 function appendComment($comment_data) {
633 return $this->appendChild($this->ownerDocument->createComment($comment_data));
635 function appendHTMLMarkup($htmldata) {
636 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
638 function appendXMLMarkup($xmldata) {
639 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
641 function appendJSElement($jsdata) {
642 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
644 function appendCOMElement($module, $attributes) {
645 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
649 class ExtendedDocumentFragment extends DOMDocumentFragment {
650 // ExtendedDocumentFragment PHP class
651 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
653 // function appendElement($name, [$value])
654 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
655 // returns the new child
657 // function appendElementXML($name, $xmldata)
658 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
659 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
660 // returns the new child
662 // function appendLink($target, [$value])
663 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
664 // returns the new child
666 // function appendImage($src, [$alt_text])
667 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
668 // returns the new child
670 // function appendForm($action, $method, $name, [$id])
671 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
672 // returns the new child
674 // function appendFormDiv($action, $method, $name, [$id])
675 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
676 // returns an HTML <div> that is a child of the new child
678 // function appendInputHidden($name, $value)
679 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
680 // returns the new child
682 // function appendInputText($name, $maxlength, $size, [$id], [$value])
683 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
684 // returns the new child
686 // function appendInputNumber($name, $maxlength, $size, [$id], [$value])
687 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
688 // returns the new child
690 // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
691 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
692 // returns the new child
694 // function appendInputRadio($name, $id, $value, $checked)
695 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
696 // returns the new child
698 // function appendInputCheckbox($name, $id, $value, $checked)
699 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
700 // returns the new child
702 // function appendInputFile($name, $id, $accept)
703 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
704 // returns the new child
706 // function appendInputSubmit($value)
707 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
708 // returns the new child
710 // function appendButton($value, $onclick = null)
711 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
712 // returns the new child
714 // function appendTextArea($name, $columns, $rows, [$id], [$value])
715 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
716 // returns the new child
718 // function appendElementSelect($name, [$id], [$options], [$default])
719 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
720 // returns the new child
722 // function appendElementOption($key, $desc, [$selected])
723 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
724 // returns the new child
726 // function appendLabel($for_id, $value)
727 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
728 // returns the new child
730 // function appendText($text)
731 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
732 // returns the new child
734 // function appendComment($comment_data)
735 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
736 // returns the new child
738 // function appendHTMLMarkup($htmldata)
739 // appends a representation of the HTML data as children of this fragment
742 // function appendXMLMarkup($xmldata)
743 // appends a representation of the XML data as children of this fragment
746 // function appendJSElement($jsdata)
747 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
750 // function appendCOMElement($module, $attributes)
751 // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params)
752 // returns the new child
754 function appendElement($name, $value = '') {
755 return $this->appendChild($this->ownerDocument->createElement($name, $value));
757 function appendElementXML($name, $xmldata) {
758 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
759 $aelem->appendXMLMarkup($xmldata);
762 function appendLink($target, $value = '') {
763 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
765 function appendImage($src, $alt_text = '') {
766 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
768 function appendForm($action, $method, $name, $id = null) {
769 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
771 function appendFormDiv($action, $method, $name, $id = null) {
772 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
773 return $formelem->appendElement('div');
775 function appendInputHidden($name, $value) {
776 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
778 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
779 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
781 function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
782 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
784 function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
785 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
787 function appendInputRadio($name, $id, $value, $checked) {
788 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
790 function appendInputCheckbox($name, $id, $value, $checked) {
791 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
793 function appendInputFile($name, $id, $accept) {
794 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
796 function appendInputSubmit($value) {
797 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
799 function appendButton($value, $onclick = null) {
800 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
802 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
803 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
805 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
806 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
808 function appendElementOption($key, $desc, $selected = false) {
809 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
811 function appendLabel($for_id, $value) {
812 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
814 function appendText($text) {
815 return $this->appendChild($this->ownerDocument->createTextNode($text));
817 function appendComment($comment_data) {
818 return $this->appendChild($this->ownerDocument->createComment($comment_data));
820 function appendHTMLMarkup($htmldata) {
821 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
823 function appendXMLMarkup($xmldata) {
824 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
826 function appendJSElement($jsdata) {
827 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
829 function appendCOMElement($module, $attributes) {
830 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));