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 appendInputEmail($name, $maxlength, $size, [$id], [$value])
72 // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params)
73 // returns the new child
75 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
76 // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params)
77 // returns the new child
79 // public function appendInputRadio($name, $id, $value, $checked)
80 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
81 // returns the new child
83 // public function appendInputCheckbox($name, $id, $value, $checked)
84 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
85 // returns the new child
87 // public function appendInputFile($name, $id, $accept)
88 // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params)
89 // returns the new child
91 // public function appendInputSubmit($value)
92 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
93 // returns the new child
95 // public function appendButton($value, $onclick = null)
96 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
97 // returns the new child
99 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
100 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
101 // returns the new child
103 // public function appendElementSelect($name, [$id], [$options], [$default])
104 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
105 // returns the new child
107 // public function appendElementOption($key, $desc, [$selected])
108 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
109 // returns the new child
111 // public function appendLabel($for_id, $value)
112 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
113 // returns the new child
115 // public function appendText($text)
116 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
117 // returns the new child
119 // public function appendComment($comment_data)
120 // appends a DOMDocument::createComment() as a child of this document (see there for params)
121 // returns the new child
123 // public function appendHTMLMarkup($htmldata, [$parentNode])
124 // appends a representation of the HTML data as children of the given parent node, by default this document
127 // public function appendXMLMarkup($xmldata, [$parentNode])
128 // appends a representation of the XML data as children of the given parent node, by default this document
131 // public function appendJSElement($jsdata)
132 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
135 // public function appendJSFile($jsURL)
136 // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params)
137 // returns the new child
139 // public function appendCOMElement($module, $attributes)
140 // appends an ExtendedDocument::createCOMElement() as a child of this document (see there for params)
141 // returns the new child
143 // public function createElementLink($target, [$value])
144 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
146 // public function createElementImage($src, [$alt_text])
147 // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
149 // public function createElementForm($action, $method, $name)
150 // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
151 // with the given action, method, and name
153 // public function createElementInputHidden($name, $value)
154 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
156 // public function createElementInputText($name, $maxlength, $size, [$id], [$value])
157 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
158 // and optionally id and value
160 // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value])
161 // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size,
162 // and optionally id and value
164 // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value])
165 // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size,
166 // and optionally id and value
168 // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
169 // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size,
170 // and optionally id and value
172 // public function createElementInputRadio($name, $id, $value, $checked)
173 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
176 // public function createElementInputCheckbox($name, $id, $value, $checked)
177 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
180 // public function createElementInputFile($name, $id, $accept)
181 // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept
183 // public function createElementInputSubmit($value)
184 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
186 // public function createElementButton($value, $onclick = null)
187 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
189 // public function createElementTextArea($name, $columns, $rows, [$id], [$value])
190 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
191 // and optionally id and value
193 // public function createElementSelect($name, [$id], [$options], [$default])
194 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
195 // array of options (key => description) and key of the by-default selected entry
197 // public function createElementOption($key, $desc, [$selected])
198 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
199 // and optionally bool that tells if the entry is selected
201 // public function createElementLabel($for_id, $value)
202 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
204 // public function createElementJS($jsdata)
205 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
207 // public function createElementJSFile($jsURL)
208 // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL
210 // public function createCOMElement($module, $attributes)
211 // returns an ExtendedElement that is in COM_NS namespace, with the given module as name and the
212 // given name=>value array as attributes
214 function __construct($version = '1.0', $encoding = 'utf-8') {
215 // make sure the default DOMDocument constructor runs
216 parent::__construct($version, $encoding);
217 $this->registerNodeClass('DOMElement', 'ExtendedElement');
218 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
221 static function initHTML5() {
222 $doc = new ExtendedDocument();
223 $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly.
225 // Created basic HTML document structure.
226 $root = $doc->getElementsByTagName('html')->item(0);
227 $head = $root->appendElement('head');
228 $title = $head->appendElement('title');
229 $body = $root->appendElement('body');
231 return array('document' => $doc,
238 public function appendElement($name, $value = '') {
239 return $this->appendChild($this->createElement($name, $value));
241 public function appendElementXML($name, $xmldata) {
242 $aelem = $this->appendChild($this->createElement($name));
243 $aelem->appendXMLMarkup($xmldata);
244 //$aelem->appendChild($this->createXMLFragment($xmldata));
247 public function appendLink($target, $value = '') {
248 return $this->appendChild($this->createElementLink($target, $value));
250 public function appendImage($src, $alt_text = '') {
251 return $this->appendChild($this->createElementImage($src, $alt_text));
253 public function appendForm($action, $method, $name, $id = null) {
254 return $this->appendChild($this->createElementForm($action, $method, $name, $id));
256 public function appendFormDiv($action, $method, $name, $id = null) {
257 $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id));
258 return $formelem->appendElement('div');
260 public function appendInputHidden($name, $value) {
261 return $this->appendChild($this->createElementInputHidden($name, $value));
263 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
264 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
266 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
267 return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value));
269 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
270 return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value));
272 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
273 return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
275 public function appendInputRadio($name, $id, $value, $checked) {
276 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
278 public function appendInputCheckbox($name, $id, $value, $checked) {
279 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
281 public function appendInputFile($name, $id, $accept) {
282 return $this->appendChild($this->createElementInputFile($name, $id, $accept));
284 public function appendInputSubmit($value) {
285 return $this->appendChild($this->createElementInputSubmit($value));
287 public function appendButton($value, $onclick = null) {
288 return $this->appendChild($this->createElementButton($value, $onclick));
290 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
291 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
293 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
294 return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
296 public function appendElementOption($key, $desc, $selected = false) {
297 return $this->appendChild($this->createElementOption($key, $desc, $selected));
299 public function appendLabel($for_id, $value) {
300 return $this->appendChild($this->createElementLabel($for_id, $value));
302 public function appendText($text) {
303 return $this->appendChild($this->createTextNode($text));
305 public function appendComment($comment_data) {
306 return $this->appendChild($this->createComment($comment_data));
308 public function appendJSElement($jsdata) {
309 $this->appendChild($this->createElementJS($jsdata));
311 public function appendJSFile($jsdata) {
312 return $this->appendChild($this->createElementJSFile($jsdata));
314 public function appendCOMElement($module, $attributes) {
315 return $this->appendChild($this->createCOMElement($module, $attributes));
318 public function appendHTMLMarkup($htmldata, $parentNode = null) {
319 if (is_null($parentNode)) { $parentNode =& $this; }
320 // XXX: just a workaround for now!
321 $parentNode->appendChild($this->createCDATASection($htmldata));
324 public function appendXMLMarkup($xmldata, $parentNode = null) {
325 if (is_null($parentNode)) { $parentNode =& $this; }
326 $tmpdoc = new ExtendedDocument;
327 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
328 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
329 $tmpxml .= '<root>'.$xmldata.'</root>';
330 $tmpdoc->loadXML($tmpxml);
331 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
332 $parentNode->appendChild($this->importNode($child, true));
336 public function createElement($name, $value = '') {
337 // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that.
338 $aelem = parent::createElement($name);
339 $aelem->appendText($value);
343 public function createElementLink($target, $value = '') {
344 $link = $this->createElement('a', $value);
345 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
349 public function createElementImage($src, $alt_text = '') {
350 $img = $this->createElement('img');
351 $img->setAttribute('src', $src);
352 $img->setAttribute('alt', $alt_text);
356 public function createElementForm($action, $method, $name, $id = null) {
357 $formelem = $this->createElement('form');
358 $formelem->setAttribute('action', $action);
359 $formelem->setAttribute('method', $method);
360 $formelem->setAttribute('name', $name);
361 $formelem->setAttribute('id', $id);
365 public function createElementInputHidden($name, $value) {
366 $hidden = $this->createElement('input');
367 $hidden->setAttribute('type', 'hidden');
368 $hidden->setAttribute('name', $name);
369 $hidden->setAttribute('value', $value);
373 public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
374 $txfield = $this->createElement('input');
375 $txfield->setAttribute('type', 'text');
376 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
377 $txfield->setAttribute('name', $name);
378 $txfield->setAttribute('maxlength', $maxlength);
379 $txfield->setAttribute('size', $size);
380 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
384 public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) {
385 $txfield = $this->createElement('input');
386 $txfield->setAttribute('type', 'number');
387 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
388 $txfield->setAttribute('name', $name);
389 $txfield->setAttribute('maxlength', $maxlength);
390 $txfield->setAttribute('size', $size);
391 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
395 public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) {
396 $txfield = $this->createElement('input');
397 $txfield->setAttribute('type', 'email');
398 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
399 $txfield->setAttribute('name', $name);
400 $txfield->setAttribute('maxlength', $maxlength);
401 $txfield->setAttribute('size', $size);
402 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
406 public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
407 $pwfield = $this->createElement('input');
408 $pwfield->setAttribute('type', 'password');
409 if (!is_null($id)) { $pwfield->setAttribute('id', $id); }
410 $pwfield->setAttribute('name', $name);
411 $pwfield->setAttribute('maxlength', $maxlength);
412 $pwfield->setAttribute('size', $size);
413 if (!is_null($value)) { $pwfield->setAttribute('value', $value); }
417 public function createElementInputRadio($name, $id, $value, $checked) {
418 $radio = $this->createElement('input');
419 $radio->setAttribute('type', 'radio');
420 $radio->setAttribute('name', $name);
421 if (!is_null($id)) { $radio->setAttribute('id', $id); }
422 $radio->setAttribute('value', $value);
423 if ($checked) { $radio->setAttribute('checked', ''); }
427 public function createElementInputCheckbox($name, $id, $value, $checked) {
428 $cbox = $this->createElement('input');
429 $cbox->setAttribute('type', 'checkbox');
430 $cbox->setAttribute('name', $name);
431 if (!is_null($id)) { $cbox->setAttribute('id', $id); }
432 $cbox->setAttribute('value', $value);
433 if ($checked) { $cbox->setAttribute('checked', ''); }
437 public function createElementInputFile($name, $id, $accept) {
438 $fileinput = $this->createElement('input');
439 $fileinput->setAttribute('type', 'file');
440 $fileinput->setAttribute('name', $name);
441 if (!is_null($id)) { $fileinput->setAttribute('id', $id); }
442 $fileinput->setAttribute('accept', $accept);
446 public function createElementInputSubmit($value) {
447 $submitbtn = $this->createElement('input');
448 $submitbtn->setAttribute('type', 'submit');
449 $submitbtn->setAttribute('value', $value);
453 public function createElementButton($value, $onclick = null) {
454 $btn = $this->createElement('input');
455 $btn->setAttribute('type', 'button');
456 $btn->setAttribute('value', $value);
457 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
461 public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
462 $txtarea = $this->createElement('textarea', $value);
463 $txtarea->setAttribute('name', $name);
464 $txtarea->setAttribute('cols', $columns);
465 $txtarea->setAttribute('rows', $rows);
466 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
470 public function createElementSelect($name, $id = null, $options = array(), $default = null) {
471 $select = $this->createElement('select');
472 $select->setAttribute('name', $name);
473 if (!is_null($id)) { $select->setAttribute('id', $id); }
474 foreach ($options as $key => $desc) {
475 $select->appendElementOption($key, $desc, ($key == $default));
480 public function createElementOption($key, $desc, $selected = false) {
481 $option = $this->createElement('option', $desc);
482 $option->setAttribute('value', $key);
483 if ($selected) { $option->setAttribute('selected', ''); }
487 public function createElementLabel($for_id, $value) {
488 $label = $this->createElement('label', $value);
489 $label->setAttribute('for', $for_id);
493 public function createElementJS($jsdata) {
494 $jselem = $this->createElement('script');
495 // Note: type can/should be left out for HTML5.
496 $jselem->setAttribute('type', 'text/javascript');
497 $jselem->appendChild($this->createCDATASection($jsdata));
501 public function createElementJSFile($jsURL) {
502 $jselem = $this->createElement('script');
503 // Note: type can/should be left out for HTML5.
504 $jselem->setAttribute('type', 'text/javascript');
505 $jselem->setAttribute('src', $jsURL);
509 public function createCOMElement($module, $attributes) {
510 $com_elem = $this->createElementNS(COM_NS, $module);
511 if (is_array($attributes) && count($attributes)) {
512 foreach ($attributes as $name=>$value) {
513 $com_elem->setAttribute($name, $value);
520 class ExtendedElement extends DOMElement {
521 // ExtendedElement PHP class
522 // this extends the general PHP DOM Element class to simplify some usual constructs
524 // public function appendElement($name, [$value])
525 // appends a DOMDocument::createElement() as a child of this element (see there for params)
526 // returns the new child
528 // public function appendElementXML($name, $xmldata)
529 // appends a DOMDocument::createElement() with the given name as a child of this element,
530 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
531 // returns the new child
533 // public function appendLink($target, [$value])
534 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
535 // returns the new child
537 // public function appendImage($src, [$alt_text])
538 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
539 // returns the new child
541 // public function appendForm($action, $method, $name, [$id])
542 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
543 // returns the new child
545 // public function appendFormDiv($action, $method, $name, [$id])
546 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
547 // returns an HTML <div> that is a child of the new child
549 // public function appendInputHidden($name, $value)
550 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
551 // returns the new child
553 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
554 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
555 // returns the new child
557 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
558 // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params)
559 // returns the new child
561 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
562 // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params)
563 // returns the new child
565 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
566 // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params)
567 // returns the new child
569 // public function appendInputRadio($name, $id, $value, $checked)
570 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
571 // returns the new child
573 // public function appendInputCheckbox($name, $id, $value, $checked)
574 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
575 // returns the new child
577 // public function appendInputFile($name, $id, $accept)
578 // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params)
579 // returns the new child
581 // public function appendInputSubmit($value)
582 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
583 // returns the new child
585 // public function appendButton($value, $onclick = null)
586 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
587 // returns the new child
589 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
590 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
591 // returns the new child
593 // public function appendElementSelect($name, [$id], [$options], [$default])
594 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
595 // returns the new child
597 // public function appendElementOption($key, $desc, [$selected])
598 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
599 // returns the new child
601 // public function appendLabel($for_id, $value)
602 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
603 // returns the new child
605 // public function appendText($text)
606 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
607 // returns the new child
609 // public function appendComment($comment_data)
610 // appends a DOMDocument::createComment() as a child of this element (see there for params)
611 // returns the new child
613 // public function appendHTMLMarkup($htmldata)
614 // appends a representation of the HTML data as children of this element
617 // public function appendXMLMarkup($xmldata)
618 // appends a representation of the XML data as children of this element
621 // public function appendJSElement($jsdata)
622 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
625 // public function appendCOMElement($module, $attributes)
626 // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params)
627 // returns the new child
629 // public function appendCOMElement($module, $attributes)
630 // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params)
631 // returns the new child
633 public function appendElement($name, $value = '') {
634 return $this->appendChild($this->ownerDocument->createElement($name, $value));
636 public function appendElementXML($name, $xmldata) {
637 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
638 $aelem->appendXMLMarkup($xmldata);
641 public function appendLink($target, $value = '') {
642 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
644 public function appendImage($src, $alt_text = '') {
645 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
647 public function appendForm($action, $method, $name, $id = null) {
648 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
650 public function appendFormDiv($action, $method, $name, $id = null) {
651 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
652 return $formelem->appendElement('div');
654 public function appendInputHidden($name, $value) {
655 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
657 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
658 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
660 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
661 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
663 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
664 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
666 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
667 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
669 public function appendInputRadio($name, $id, $value, $checked) {
670 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
672 public function appendInputCheckbox($name, $id, $value, $checked) {
673 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
675 public function appendInputFile($name, $id, $accept) {
676 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
678 public function appendInputSubmit($value) {
679 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
681 public function appendButton($value, $onclick = null) {
682 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
684 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
685 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
687 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
688 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
690 public function appendElementOption($key, $desc, $selected = false) {
691 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
693 public function appendLabel($for_id, $value) {
694 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
696 public function appendText($text) {
697 return $this->appendChild($this->ownerDocument->createTextNode($text));
699 public function appendComment($comment_data) {
700 return $this->appendChild($this->ownerDocument->createComment($comment_data));
702 public function appendHTMLMarkup($htmldata) {
703 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
705 public function appendXMLMarkup($xmldata) {
706 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
708 public function appendJSElement($jsdata) {
709 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
711 public function appendJSFile($jsdata) {
712 return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata));
714 public function appendCOMElement($module, $attributes) {
715 return $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
719 class ExtendedDocumentFragment extends DOMDocumentFragment {
720 // ExtendedDocumentFragment PHP class
721 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
723 // public function appendElement($name, [$value])
724 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
725 // returns the new child
727 // public function appendElementXML($name, $xmldata)
728 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
729 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
730 // returns the new child
732 // public function appendLink($target, [$value])
733 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
734 // returns the new child
736 // public function appendImage($src, [$alt_text])
737 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
738 // returns the new child
740 // public function appendForm($action, $method, $name, [$id])
741 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
742 // returns the new child
744 // public function appendFormDiv($action, $method, $name, [$id])
745 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
746 // returns an HTML <div> that is a child of the new child
748 // public function appendInputHidden($name, $value)
749 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
750 // returns the new child
752 // public function appendInputText($name, $maxlength, $size, [$id], [$value])
753 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
754 // returns the new child
756 // public function appendInputNumber($name, $maxlength, $size, [$id], [$value])
757 // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params)
758 // returns the new child
760 // public function appendInputEmail($name, $maxlength, $size, [$id], [$value])
761 // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params)
762 // returns the new child
764 // public function appendInputPassword($name, $maxlength, $size, [$id], [$value])
765 // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
766 // returns the new child
768 // public function appendInputRadio($name, $id, $value, $checked)
769 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
770 // returns the new child
772 // public function appendInputCheckbox($name, $id, $value, $checked)
773 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
774 // returns the new child
776 // public function appendInputFile($name, $id, $accept)
777 // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params)
778 // returns the new child
780 // public function appendInputSubmit($value)
781 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
782 // returns the new child
784 // public function appendButton($value, $onclick = null)
785 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
786 // returns the new child
788 // public function appendTextArea($name, $columns, $rows, [$id], [$value])
789 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
790 // returns the new child
792 // public function appendElementSelect($name, [$id], [$options], [$default])
793 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
794 // returns the new child
796 // public function appendElementOption($key, $desc, [$selected])
797 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
798 // returns the new child
800 // public function appendLabel($for_id, $value)
801 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
802 // returns the new child
804 // public function appendText($text)
805 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
806 // returns the new child
808 // public function appendComment($comment_data)
809 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
810 // returns the new child
812 // public function appendHTMLMarkup($htmldata)
813 // appends a representation of the HTML data as children of this fragment
816 // public function appendXMLMarkup($xmldata)
817 // appends a representation of the XML data as children of this fragment
820 // public function appendJSElement($jsdata)
821 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
824 // public function appendCOMElement($module, $attributes)
825 // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params)
826 // returns the new child
828 // public function appendCOMElement($module, $attributes)
829 // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params)
830 // returns the new child
832 public function appendElement($name, $value = '') {
833 return $this->appendChild($this->ownerDocument->createElement($name, $value));
835 public function appendElementXML($name, $xmldata) {
836 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
837 $aelem->appendXMLMarkup($xmldata);
840 public function appendLink($target, $value = '') {
841 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
843 public function appendImage($src, $alt_text = '') {
844 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
846 public function appendForm($action, $method, $name, $id = null) {
847 return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
849 public function appendFormDiv($action, $method, $name, $id = null) {
850 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id));
851 return $formelem->appendElement('div');
853 public function appendInputHidden($name, $value) {
854 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
856 public function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
857 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
859 public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) {
860 return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value));
862 public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) {
863 return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value));
865 public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
866 return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
868 public function appendInputRadio($name, $id, $value, $checked) {
869 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
871 public function appendInputCheckbox($name, $id, $value, $checked) {
872 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
874 public function appendInputFile($name, $id, $accept) {
875 return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept));
877 public function appendInputSubmit($value) {
878 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
880 public function appendButton($value, $onclick = null) {
881 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
883 public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
884 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
886 public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
887 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
889 public function appendElementOption($key, $desc, $selected = false) {
890 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
892 public function appendLabel($for_id, $value) {
893 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
895 public function appendText($text) {
896 return $this->appendChild($this->ownerDocument->createTextNode($text));
898 public function appendComment($comment_data) {
899 return $this->appendChild($this->ownerDocument->createComment($comment_data));
901 public function appendHTMLMarkup($htmldata) {
902 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
904 public function appendXMLMarkup($xmldata) {
905 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
907 public function appendJSElement($jsdata) {
908 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
910 public function appendJSFile($jsdata) {
911 return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata));
913 public function appendCOMElement($module, $attributes) {
914 return $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));