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
30 // static function initHTML5()
31 // initialize as an HTML5 document and return references to its basic elements.
32 // returns an associative array with the following elements: 'html', 'head', 'title', 'body'
34 // public function appendElement($name, [$value])
35 // appends a DOMDocument::createElement() as a child of this document (see there for params)
36 // returns the new child
38 // public function appendElementXML($name, $xmldata)
39 // appends a DOMDocument::createElement() with the given name as a child of this document,
40 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
41 // returns the new child
43 // public function appendLink($target, [$value])
44 // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
45 // returns the new child
47 // public function appendImage($src, [$alt_text])
48 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
49 // returns the new child
51 // public function appendForm($action, $method, $name, [$id])
52 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
53 // returns the new child
55 // public function appendFormDiv($action, $method, $name, [$id])
56 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
57 // returns an HTML <div> that is a child of the new child
59 // public function appendInputHidden($name, $value)
60 // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
61 // returns the new child
63 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
64 // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
65 // returns the new child
67 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
68 // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params)
69 // returns the new child
71 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
72 // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
73 // returns the new child
75 // public function appendInputRadio($name, $id, $value, $checked)
76 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
77 // returns the new child
79 // public function appendInputCheckbox($name, $id, $value, $checked)
80 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
81 // returns the new child
83 // public function appendInputFile($name, $id, $accept)
84 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
85 // returns the new child
87 // public function appendInputSubmit($value)
88 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
89 // returns the new child
91 // public function appendButton($value, $onclick = null)
92 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
93 // returns the new child
95 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
96 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
97 // returns the new child
99 // public function appendElementSelect($name, [$id], [$options], [$default])
100 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
101 // returns the new child
103 // public function appendElementOption($key, $desc, [$selected])
104 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
105 // returns the new child
107 // public function appendLabel($for_id, $value)
108 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
109 // returns the new child
111 // public function appendText($text)
112 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
113 // returns the new child
115 // public function appendComment($comment_data)
116 // appends a DOMDocument::createComment() as a child of this document (see there for params)
117 // returns the new child
119 // public function appendHTMLMarkup($htmldata, [$parentNode])
120 // appends a representation of the HTML data as children of the given parent node, by default this document
123 // public function appendXMLMarkup($xmldata, [$parentNode])
124 // appends a representation of the XML data as children of the given parent node, by default this document
127 // public function appendJSElement($jsdata)
128 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
131 // public function appendCOMElement($module, $attributes)
132 // appends an ExtendedDocument::createCOMElement() as a child of this document (see there for params)
133 // returns the new child
135 // public function createElementLink($target, [$value])
136 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
138 // public function createElementImage($src, [$alt_text])
139 // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
141 // public function createElementForm($action, $method, $name)
142 // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
143 // with the given action, method, and name
145 // public function createElementInputHidden($name, $value)
146 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
148 // public function createElementInputText($name, $maxlength, $size, [$id], [$value])
149 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
150 // and optionally id and value
152 // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
153 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
154 // and optionally id and value
156 // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
157 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
158 // and optionally id and value
160 // public function createElementInputRadio($name, $id, $value, $checked)
161 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
164 // public function createElementInputCheckbox($name, $id, $value, $checked)
165 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
168 // public function createElementInputFile($name, $id, $accept)
169 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
171 // public function createElementInputSubmit($value)
172 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
174 // public function createElementButton($value, $onclick = null)
175 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
177 // public function createElementTextArea($name, $columns, $rows, [$id], [$value])
178 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
179 // and optionally id and value
181 // public function createElementSelect($name, [$id], [$options], [$default])
182 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
183 // array of options (key => description) and key of the by-default selected entry
185 // public function createElementOption($key, $desc, [$selected])
186 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
187 // and optionally bool that tells if the entry is selected
189 // public function createElementLabel($for_id, $value)
190 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
192 // public function createElementJS($jsdata)
193 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
195 // public function createCOMElement($module, $attributes)
196 // returns an ExtendedElement that is in COM_NS namespace, with the given module as name and the
197 // given name=>value array as attributes
199 function __construct($version = '1.0', $encoding = 'utf-8') {
200 // make sure the default DOMDocument constructor runs
201 parent::__construct($version, $encoding);
202 $this->registerNodeClass('DOMElement', 'ExtendedElement');
203 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
206 static function initHTML5() {
207 $doc = new ExtendedDocument();
208 $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
210 // Created basic HTML document structure.
211 $root = $doc->getElementsByTagName('html')->item(0);
212 $head = $root->appendElement('head');
213 $title = $head->appendElement('title');
214 $body = $root->appendElement('body');
216 return array('document' => $doc,
223 public function appendElement($name, $value = '') {
224 return $this->appendChild($this->createElement($name, $value));
226 public function appendElementXML($name, $xmldata) {
227 $aelem = $this->appendChild($this->createElement($name));
228 $aelem->appendXMLMarkup($xmldata);
229 //$aelem->appendChild($this->createXMLFragment($xmldata));
232 public function appendLink($target, $value = '') {
233 return $this->appendChild($this->createElementLink($target, $value));
235 public function appendImage($src, $alt_text = '') {
236 return $this->appendChild($this->createElementImage($src, $alt_text));
238 public function appendForm($action, $method, $name, $id = null) {
239 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
241 public function appendFormDiv($action, $method, $name, $id = null) {
242 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
243 return $formelem->appendElement('div');
245 public function appendInputHidden($name, $value) {
246 return $this->appendChild($this->createElementInputHidden($name, $value));
248 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
249 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
251 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
252 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
254 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
255 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
257 public function appendInputRadio($name, $id, $value, $checked) {
258 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
260 public function appendInputCheckbox($name, $id, $value, $checked) {
261 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
263 public function appendInputFile($name, $id, $accept) {
264 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
266 public function appendInputSubmit($value) {
267 return $this->appendChild($this->createElementInputSubmit($value));
269 public function appendButton($value, $onclick = null) {
270 return $this->appendChild($this->createElementButton($value, $onclick));
272 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
273 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
275 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
276 return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
278 public function appendElementOption($key, $desc, $selected = false) {
279 return $this->appendChild($this->createElementOption($key, $desc, $selected));
281 public function appendLabel($for_id, $value) {
282 return $this->appendChild($this->createElementLabel($for_id, $value));
284 public function appendText($text) {
285 return $this->appendChild($this->createTextNode($text));
287 public function appendComment($comment_data) {
288 return $this->appendChild($this->createComment($comment_data));
290 public function appendJSElement($jsdata) {
291 $this->appendChild($this->createElementJS($jsdata));
293 public function appendCOMElement($module, $attributes) {
294 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
297 public function appendHTMLMarkup($htmldata, $parentNode = null) {
298 if (is_null($parentNode)) { $parentNode =& $this; }
299 // XXX: just a workaround for now!
300 $parentNode->appendChild($this->createCDATASection($htmldata));
303 public function appendXMLMarkup($xmldata, $parentNode = null) {
304 if (is_null($parentNode)) { $parentNode =& $this; }
305 $tmpdoc = new ExtendedDocument;
306 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
307 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
308 $tmpxml .= '<root>'.$xmldata.'</root>';
309 $tmpdoc->loadXML($tmpxml);
310 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
311 $parentNode->appendChild($this->importNode($child, true));
315 public function createElement($name, $value = '') {
316 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
317 $aelem = parent::createElement($name);
318 $aelem->appendText($value);
322 public function createElementLink($target, $value = '') {
323 $link = $this->createElement('a', $value);
324 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
328 public function createElementImage($src, $alt_text = '') {
329 $img = $this->createElement('img');
330 $img->setAttribute('src', $src);
331 $img->setAttribute('alt', $alt_text);
335 public function createElementForm($action, $method, $name, $id = null) {
336 $formelem = $this->createElement('form');
337 $formelem->setAttribute('action', $action);
338 $formelem->setAttribute('method', $method);
339 $formelem->setAttribute('name', $name);
340 $formelem->setAttribute('id', $id);
344 public function createElementInputHidden($name, $value) {
345 $hidden = $this->createElement('input');
346 $hidden->setAttribute('type', 'hidden');
347 $hidden->setAttribute('name', $name);
348 $hidden->setAttribute('value', $value);
352 public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
353 $txfield = $this->createElement('input');
354 $txfield->setAttribute('type', 'text');
355 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
356 $txfield->setAttribute('name', $name);
357 $txfield->setAttribute('maxlength', $maxlength);
358 $txfield->setAttribute('size', $size);
359 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
363 public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
364 $txfield = $this->createElement('input');
365 $txfield->setAttribute('type', 'number');
366 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
367 $txfield->setAttribute('name', $name);
368 $txfield->setAttribute('maxlength', $maxlength);
369 $txfield->setAttribute('size', $size);
370 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
374 public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
375 $pwfield = $this->createElement('input');
376 $pwfield->setAttribute('type', 'password');
377 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
378 $pwfield->setAttribute('name', $name);
379 $pwfield->setAttribute('maxlength', $maxlength);
380 $pwfield->setAttribute('size', $size);
381 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
385 public function createElementInputRadio($name, $id, $value, $checked) {
386 $radio = $this->createElement('input');
387 $radio->setAttribute('type', 'radio');
388 $radio->setAttribute('name', $name);
389 if (!is_null($id)) { $radio->setAttribute('id', $id); }
390 $radio->setAttribute('value', $value);
391 if ($checked) { $radio->setAttribute('checked', ''); }
395 public function createElementInputCheckbox($name, $id, $value, $checked) {
396 $cbox = $this->createElement('input');
397 $cbox->setAttribute('type', 'checkbox');
398 $cbox->setAttribute('name', $name);
399 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
400 $cbox->setAttribute('value', $value);
401 if ($checked) { $cbox->setAttribute('checked', ''); }
405 public function createElementInputFile($name, $id, $accept) {
406 $fileinput = $this->createElement('input');
407 $fileinput->setAttribute('type', 'file');
408 $fileinput->setAttribute('name', $name);
409 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
410 $fileinput->setAttribute('accept', $accept);
414 public function createElementInputSubmit($value) {
415 $submitbtn = $this->createElement('input');
416 $submitbtn->setAttribute('type', 'submit');
417 $submitbtn->setAttribute('value', $value);
421 public function createElementButton($value, $onclick = null) {
422 $btn = $this->createElement('input');
423 $btn->setAttribute('type', 'button');
424 $btn->setAttribute('value', $value);
425 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
429 public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
430 $txtarea = $this->createElement('textarea', $value);
431 $txtarea->setAttribute('name', $name);
432 $txtarea->setAttribute('cols', $columns);
433 $txtarea->setAttribute('rows', $rows);
434 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
438 public function createElementSelect($name, $id = null, $options = array(), $default = null) {
439 $select = $this->createElement('select');
440 $select->setAttribute('name', $name);
441 if (!is_null($id)) { $select->setAttribute('id', $id); }
442 foreach ($options as $key => $desc) {
443 $select->appendElementOption($key, $desc, ($key == $default));
448 public function createElementOption($key, $desc, $selected = false) {
449 $option = $this->createElement('option', $desc);
450 $option->setAttribute('value', $key);
451 if ($selected) { $option->setAttribute('selected', ''); }
455 public function createElementLabel($for_id, $value) {
456 $label = $this->createElement('label', $value);
457 $label->setAttribute('for', $for_id);
461 public function createElementJS($jsdata) {
462 $jselem = $this->createElement('script');
463 $jselem->setAttribute('type', 'text/javascript');
464 $jselem->appendChild($this->createCDATASection($jsdata));
468 public function createCOMElement($module, $attributes) {
469 $com_elem = $this->createElementNS(COM_NS, $module);
470 if (is_array($attributes) && count($attributes)) {
471 foreach ($attributes as $name=>$value) {
472 $com_elem->setAttribute($name, $value);
479 class ExtendedElement extends DOMElement {
480 // ExtendedElement PHP class
481 // this extends the general PHP DOM Element class to simplify some usual constructs
483 // public function appendElement($name, [$value])
484 // appends a DOMDocument::createElement() as a child of this element (see there for params)
485 // returns the new child
487 // public function appendElementXML($name, $xmldata)
488 // appends a DOMDocument::createElement() with the given name as a child of this element,
489 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
490 // returns the new child
492 // public function appendLink($target, [$value])
493 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
494 // returns the new child
496 // public function appendImage($src, [$alt_text])
497 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
498 // returns the new child
500 // public function appendForm($action, $method, $name, [$id])
501 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
502 // returns the new child
504 // public function appendFormDiv($action, $method, $name, [$id])
505 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
506 // returns an HTML <div> that is a child of the new child
508 // public function appendInputHidden($name, $value)
509 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
510 // returns the new child
512 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
513 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
514 // returns the new child
516 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
517 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
518 // returns the new child
520 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
521 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
522 // returns the new child
524 // public function appendInputRadio($name, $id, $value, $checked)
525 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
526 // returns the new child
528 // public function appendInputCheckbox($name, $id, $value, $checked)
529 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
530 // returns the new child
532 // public function appendInputFile($name, $id, $accept)
533 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
534 // returns the new child
536 // public function appendInputSubmit($value)
537 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
538 // returns the new child
540 // public function appendButton($value, $onclick = null)
541 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
542 // returns the new child
544 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
545 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
546 // returns the new child
548 // public function appendElementSelect($name, [$id], [$options], [$default])
549 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
550 // returns the new child
552 // public function appendElementOption($key, $desc, [$selected])
553 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
554 // returns the new child
556 // public function appendLabel($for_id, $value)
557 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
558 // returns the new child
560 // public function appendText($text)
561 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
562 // returns the new child
564 // public function appendComment($comment_data)
565 // appends a DOMDocument::createComment() as a child of this element (see there for params)
566 // returns the new child
568 // public function appendHTMLMarkup($htmldata)
569 // appends a representation of the HTML data as children of this element
572 // public function appendXMLMarkup($xmldata)
573 // appends a representation of the XML data as children of this element
576 // public function appendJSElement($jsdata)
577 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
580 // public function appendCOMElement($module, $attributes)
581 // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params)
582 // returns the new child
584 public function appendElement($name, $value = '') {
585 return $this->appendChild($this->ownerDocument->createElement($name, $value));
587 public function appendElementXML($name, $xmldata) {
588 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
589 $aelem->appendXMLMarkup($xmldata);
592 public function appendLink($target, $value = '') {
593 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
595 public function appendImage($src, $alt_text = '') {
596 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
598 public function appendForm($action, $method, $name, $id = null) {
599 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
601 public function appendFormDiv($action, $method, $name, $id = null) {
602 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
603 return $formelem->appendElement('div');
605 public function appendInputHidden($name, $value) {
606 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
608 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
609 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
611 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
612 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
614 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
615 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
617 public function appendInputRadio($name, $id, $value, $checked) {
618 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
620 public function appendInputCheckbox($name, $id, $value, $checked) {
621 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
623 public function appendInputFile($name, $id, $accept) {
624 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
626 public function appendInputSubmit($value) {
627 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
629 public function appendButton($value, $onclick = null) {
630 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
632 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
633 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
635 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
636 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
638 public function appendElementOption($key, $desc, $selected = false) {
639 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
641 public function appendLabel($for_id, $value) {
642 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
644 public function appendText($text) {
645 return $this->appendChild($this->ownerDocument->createTextNode($text));
647 public function appendComment($comment_data) {
648 return $this->appendChild($this->ownerDocument->createComment($comment_data));
650 public function appendHTMLMarkup($htmldata) {
651 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
653 public function appendXMLMarkup($xmldata) {
654 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
656 public function appendJSElement($jsdata) {
657 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
659 public function appendCOMElement($module, $attributes) {
660 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
664 class ExtendedDocumentFragment extends DOMDocumentFragment {
665 // ExtendedDocumentFragment PHP class
666 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
668 // public function appendElement($name, [$value])
669 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
670 // returns the new child
672 // public function appendElementXML($name, $xmldata)
673 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
674 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
675 // returns the new child
677 // public function appendLink($target, [$value])
678 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
679 // returns the new child
681 // public function appendImage($src, [$alt_text])
682 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
683 // returns the new child
685 // public function appendForm($action, $method, $name, [$id])
686 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
687 // returns the new child
689 // public function appendFormDiv($action, $method, $name, [$id])
690 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
691 // returns an HTML <div> that is a child of the new child
693 // public function appendInputHidden($name, $value)
694 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
695 // returns the new child
697 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
698 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
699 // returns the new child
701 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
702 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
703 // returns the new child
705 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
706 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
707 // returns the new child
709 // public function appendInputRadio($name, $id, $value, $checked)
710 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
711 // returns the new child
713 // public function appendInputCheckbox($name, $id, $value, $checked)
714 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
715 // returns the new child
717 // public function appendInputFile($name, $id, $accept)
718 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
719 // returns the new child
721 // public function appendInputSubmit($value)
722 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
723 // returns the new child
725 // public function appendButton($value, $onclick = null)
726 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
727 // returns the new child
729 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
730 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
731 // returns the new child
733 // public function appendElementSelect($name, [$id], [$options], [$default])
734 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
735 // returns the new child
737 // public function appendElementOption($key, $desc, [$selected])
738 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
739 // returns the new child
741 // public function appendLabel($for_id, $value)
742 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
743 // returns the new child
745 // public function appendText($text)
746 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
747 // returns the new child
749 // public function appendComment($comment_data)
750 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
751 // returns the new child
753 // public function appendHTMLMarkup($htmldata)
754 // appends a representation of the HTML data as children of this fragment
757 // public function appendXMLMarkup($xmldata)
758 // appends a representation of the XML data as children of this fragment
761 // public function appendJSElement($jsdata)
762 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
765 // public function appendCOMElement($module, $attributes)
766 // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params)
767 // returns the new child
769 public function appendElement($name, $value = '') {
770 return $this->appendChild($this->ownerDocument->createElement($name, $value));
772 public function appendElementXML($name, $xmldata) {
773 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
774 $aelem->appendXMLMarkup($xmldata);
777 public function appendLink($target, $value = '') {
778 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
780 public function appendImage($src, $alt_text = '') {
781 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
783 public function appendForm($action, $method, $name, $id = null) {
784 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
786 public function appendFormDiv($action, $method, $name, $id = null) {
787 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
788 return $formelem->appendElement('div');
790 public function appendInputHidden($name, $value) {
791 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
793 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
794 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
796 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
797 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
799 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
800 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
802 public function appendInputRadio($name, $id, $value, $checked) {
803 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
805 public function appendInputCheckbox($name, $id, $value, $checked) {
806 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
808 public function appendInputFile($name, $id, $accept) {
809 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
811 public function appendInputSubmit($value) {
812 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
814 public function appendButton($value, $onclick = null) {
815 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
817 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
818 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
820 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
821 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
823 public function appendElementOption($key, $desc, $selected = false) {
824 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
826 public function appendLabel($for_id, $value) {
827 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
829 public function appendText($text) {
830 return $this->appendChild($this->ownerDocument->createTextNode($text));
832 public function appendComment($comment_data) {
833 return $this->appendChild($this->ownerDocument->createComment($comment_data));
835 public function appendHTMLMarkup($htmldata) {
836 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
838 public function appendXMLMarkup($xmldata) {
839 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
841 public function appendJSElement($jsdata) {
842 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
844 public function appendCOMElement($module, $attributes) {
845 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));