add an appendButton method for adding buttons
[php-utility-classes.git] / include / cbsm / util / document.php-class
CommitLineData
cea5b93a
RK
1<?php
2/* ***** BEGIN LICENSE BLOCK *****
3 *
4 * The contents of this file are subject to Austrian copyright reegulations
5 * ("Urheberrecht"); you may not use this file except in compliance with
6 * those laws.
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.
10 *
11 * The Original Code is KaiRo's extended DOM document classes.
12 *
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.
17 *
18 * Contributor(s): Robert Kaiser <kairo@kairo.at>
19 *
20 * ***** END LICENSE BLOCK ***** */
21
22class ExtendedDocument extends DOMDocument {
23 // ExtendedDocument PHP class
24 // this extends the general PHP DOM Document class to simplify some usual constructs
25 //
26 // function __construct([$version], [$encoding])
27 // CONSTRUCTOR
28 // construct a new DOM Document that uses our element definitions
29 //
ae41c41b
RK
30 // private $xmheader
31 // the default XML header
32 //
33 // private $xhtmldtype
34 // the XHTML doctype to use by default
35 //
cea5b93a
RK
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
39 //
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
44 //
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
48 //
53510e9e
RK
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
52 //
ae41c41b
RK
53 // function appendFormDiv($action, $method, $name)
54 // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
55 // returns an HTML <div> that is a child of the new child
56 //
57 // function appendInputHidden($name, $value)
58 // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
59 // returns the new child
60 //
61 // function appendInputText($name, $maxlength, $size, [$id], [$value])
62 // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
63 // returns the new child
64 //
65 // function appendInputRadio($name, $id, $value, $checked)
66 // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
67 // returns the new child
68 //
69 // function appendInputCheckbox($name, $id, $value, $checked)
70 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
71 // returns the new child
72 //
73 // function appendInputSubmit($value)
74 // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
75 // returns the new child
76 //
1109f526
RK
77 // function appendButton($value, $onclick = null)
78 // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
79 // returns the new child
80 //
bf91764c
RK
81 // function appendTextArea($name, $columns, $rows, [$id], [$value])
82 // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
83 // returns the new child
84 //
85 // function appendElementSelect($name, [$id], [$options], [$default])
86 // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
87 // returns the new child
88 //
89 // function appendElementOption($key, $desc, [$selected])
90 // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params)
91 // returns the new child
92 //
ae41c41b
RK
93 // function appendLabel($for_id, $value)
94 // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
95 // returns the new child
96 //
cea5b93a
RK
97 // function appendText($text)
98 // appends a DOMDocument::createTextNode() as a child of this document (see there for params)
99 // returns the new child
100 //
cadc5980
RK
101 // function appendComment($comment_data)
102 // appends a DOMDocument::createComment() as a child of this document (see there for params)
103 // returns the new child
104 //
ae41c41b
RK
105 // function appendHTMLMarkup($htmldata, [$parentNode])
106 // appends a representation of the HTML data as children of the given parent node, by default this document
107 // NO return value!
108 //
109 // function appendXMLMarkup($xmldata, [$parentNode])
110 // appends a representation of the XML data as children of the given parent node, by default this document
cea5b93a
RK
111 // NO return value!
112 //
113 // function appendJSElement($jsdata)
114 // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
115 // NO return value!
116 //
c1666e91
RK
117 // function appendCOMElement($module, $attributes)
118 // appends an ExtendedDocument::createCOMElement() as a child of this document (see there for params)
119 // returns the new child
120 //
cea5b93a
RK
121 // function createElementLink($target, [$value])
122 // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
123 //
53510e9e
RK
124 // function createElementImage($src, [$alt_text])
125 // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
126 //
ae41c41b
RK
127 // function createElementForm($action, $method, $name)
128 // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
129 // with the given action, method, and name
130 //
131 // function createElementInputHidden($name, $value)
132 // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
133 //
134 // function createElementInputText($name, $maxlength, $size, [$id], [$value])
135 // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
136 // and optionally id and value
137 //
138 // function createElementInputRadio($name, $id, $value, $checked)
139 // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
140 // checked state
141 //
142 // function createElementInputCheckbox($name, $id, $value, $checked)
143 // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
144 // checked state
145 //
146 // function createElementInputSubmit($value)
1109f526
RK
147 // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
148 //
149 // function createElementButton($value, $onclick = null)
150 // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
ae41c41b 151 //
bf91764c
RK
152 // function createElementTextArea($name, $columns, $rows, [$id], [$value])
153 // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
154 // and optionally id and value
155 //
156 // function createElementSelect($name, [$id], [$options], [$default])
157 // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
158 // array of options (key => description) and key of the by-default selected entry
159 //
160 // function createElementOption($key, $desc, [$selected])
161 // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
162 // and optionally bool that tells if the entry is selected
163 //
ae41c41b
RK
164 // function createElementLabel($for_id, $value)
165 // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
cea5b93a
RK
166 //
167 // function createElementJS($jsdata)
168 // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
c1666e91
RK
169 //
170 // function createCOMElement($module, $attributes)
171 // returns an ExtendedElement that is in COM_NS namespace, with the given module as name and the
172 // given name=>value array as attributes
cea5b93a
RK
173
174 function __construct($version = '1.0', $encoding = 'utf-8') {
175 // make sure the default DOMDocument constructor runs
176 parent::__construct($version, $encoding);
177 $this->registerNodeClass('DOMElement', 'ExtendedElement');
bf91764c 178 $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment');
cea5b93a
RK
179 }
180
181 function appendElement($name, $value = '') {
182 return $this->appendChild($this->createElement($name, $value));
183 }
184 function appendElementXML($name, $xmldata) {
185 $aelem = $this->appendChild($this->createElement($name));
ae41c41b
RK
186 $aelem->appendXMLMarkup($xmldata);
187 //$aelem->appendChild($this->createXMLFragment($xmldata));
cea5b93a
RK
188 return $aelem;
189 }
190 function appendLink($target, $value = '') {
191 return $this->appendChild($this->createElementLink($target, $value));
192 }
4aa31782
RK
193 function appendImage($src, $alt_text = '') {
194 return $this->appendChild($this->createElementImage($src, $alt_text));
195 }
ae41c41b
RK
196 function appendFormDiv($action, $method, $name) {
197 $formelem = $this->appendChild($this->createElementForm($action, $method, $name));
198 return $formelem->appendElement('div');
199 }
200 function appendInputHidden($name, $value) {
201 return $this->appendChild($this->createElementInputHidden($name, $value));
202 }
203 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
204 return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
205 }
206 function appendInputRadio($name, $id, $value, $checked) {
207 return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
208 }
209 function appendInputCheckbox($name, $id, $value, $checked) {
210 return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
211 }
212 function appendInputSubmit($value) {
213 return $this->appendChild($this->createElementInputSubmit($value));
214 }
1109f526
RK
215 function appendButton($value, $onclick = null) {
216 return $this->appendChild($this->createElementButton($value, $onclick));
217 }
bf91764c
RK
218 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
219 return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
220 }
221 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
222 return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
223 }
224 function appendElementOption($key, $desc, $selected = false) {
225 return $this->appendChild($this->createElementOption($key, $desc, $selected));
226 }
ae41c41b
RK
227 function appendLabel($for_id, $value) {
228 return $this->appendChild($this->createElementLabel($for_id, $value));
229 }
cea5b93a
RK
230 function appendText($text) {
231 return $this->appendChild($this->createTextNode($text));
232 }
cadc5980
RK
233 function appendComment($comment_data) {
234 return $this->appendChild($this->createComment($comment_data));
235 }
cea5b93a
RK
236 function appendJSElement($jsdata) {
237 $this->appendChild($this->createElementJS($jsdata));
238 }
c1666e91
RK
239 function appendCOMElement($module, $attributes) {
240 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
241 }
cea5b93a 242
ae41c41b
RK
243 function appendHTMLMarkup($htmldata, $parentNode = null) {
244 if (is_null($parentNode)) { $parentNode =& $this; }
245 // XXX: just a workaround for now!
246 $parentNode->appendChild($this->createCDATASection($htmldata));
247 }
248
249 function appendXMLMarkup($xmldata, $parentNode = null) {
250 if (is_null($parentNode)) { $parentNode =& $this; }
251 $tmpdoc = new ExtendedDocument;
252 $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
253 $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
254 $tmpxml .= '<root>'.$xmldata.'</root>';
255 $tmpdoc->loadXML($tmpxml);
256 foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
257 $parentNode->appendChild($this->importNode($child, true));
258 }
cea5b93a
RK
259 }
260
261 function createElementLink($target, $value = '') {
262 $link = $this->createElement('a', $value);
bf91764c 263 $link->setAttribute('href', $target); // XXX: take care of & etc. in links
cea5b93a
RK
264 return $link;
265 }
266
4aa31782
RK
267 function createElementImage($src, $alt_text = '') {
268 $link = $this->createElement('img');
269 $link->setAttribute('src', $src);
270 $link->setAttribute('alt', $alt_text);
271 return $link;
272 }
273
ae41c41b
RK
274 function createElementForm($action, $method, $name) {
275 $formelem = $this->createElement('form');
276 $formelem->setAttribute('action', $action);
277 $formelem->setAttribute('method', $method);
278 $formelem->setAttribute('name', $name);
279 return $formelem;
280 }
281
282 function createElementInputHidden($name, $value) {
283 $hidden = $this->createElement('input');
284 $hidden->setAttribute('type', 'hidden');
285 $hidden->setAttribute('name', $name);
286 $hidden->setAttribute('value', $value);
287 return $hidden;
288 }
289
290 function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
291 $txfield = $this->createElement('input');
292 $txfield->setAttribute('type', 'text');
293 if (!is_null($id)) { $txfield->setAttribute('id', $id); }
294 $txfield->setAttribute('name', $name);
295 $txfield->setAttribute('maxlength', $maxlength);
296 $txfield->setAttribute('size', $size);
297 if (!is_null($value)) { $txfield->setAttribute('value', $value); }
298 return $txfield;
299 }
300
301 function createElementInputRadio($name, $id, $value, $checked) {
302 $radio = $this->createElement('input');
303 $radio->setAttribute('type', 'radio');
304 $radio->setAttribute('name', $name);
305 $radio->setAttribute('id', $id);
306 $radio->setAttribute('value', $value);
307 if ($checked) { $radio->setAttribute('checked', ''); }
308 return $radio;
309 }
310
311 function createElementInputCheckbox($name, $id, $value, $checked) {
312 $cbox = $this->createElement('input');
313 $cbox->setAttribute('type', 'checkbox');
314 $cbox->setAttribute('name', $name);
315 $cbox->setAttribute('id', $id);
316 $cbox->setAttribute('value', $value);
317 if ($checked) { $cbox->setAttribute('checked', ''); }
318 return $cbox;
319 }
320
321 function createElementInputSubmit($value) {
322 $submitbtn = $this->createElement('input');
323 $submitbtn->setAttribute('type', 'submit');
324 $submitbtn->setAttribute('value', $value);
325 return $submitbtn;
326 }
327
1109f526
RK
328 function createElementButton($value, $onclick = null) {
329 $btn = $this->createElement('input');
330 $btn->setAttribute('type', 'button');
331 $btn->setAttribute('value', $value);
332 if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
333 return $btn;
334 }
335
bf91764c
RK
336 function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
337 $txtarea = $this->createElement('textarea', $value);
338 $txtarea->setAttribute('name', $name);
339 $txtarea->setAttribute('cols', $columns);
340 $txtarea->setAttribute('rows', $rows);
341 if (!is_null($id)) { $txtarea->setAttribute('id', $id); }
342 return $txtarea;
343 }
344
345 function createElementSelect($name, $id = null, $options = array(), $default = null) {
346 $select = $this->createElement('select');
347 $select->setAttribute('name', $name);
348 if (!is_null($id)) { $select->setAttribute('id', $id); }
349 foreach ($options as $key => $desc) {
350 $select->appendElementOption($key, $desc, ($key == $default));
351 }
352 return $select;
353 }
354
355 function createElementOption($key, $desc, $selected = false) {
356 $option = $this->createElement('option', $desc);
357 $option->setAttribute('value', $key);
358 if ($selected) { $option->setAttribute('selected', ''); }
359 return $option;
360 }
361
ae41c41b
RK
362 function createElementLabel($for_id, $value) {
363 $label = $this->createElement('label', $value);
364 $label->setAttribute('for', $for_id);
365 return $label;
cea5b93a
RK
366 }
367
368 function createElementJS($jsdata) {
369 $jselem = $this->createElement('script');
370 $jselem->setAttribute('type', 'text/javascript');
371 $jselem->appendChild($this->createCDATASection($jsdata));
372 return $jselem;
373 }
c1666e91
RK
374
375 function createCOMElement($module, $attributes) {
376 $com_elem = $this->createElementNS(COM_NS, $module);
377 if (is_array($attributes) && count($attributes)) {
378 foreach ($attributes as $name=>$value) {
379 $com_elem->setAttribute($name, $value);
380 }
381 }
382 return $com_elem;
383 }
cea5b93a
RK
384}
385
386class ExtendedElement extends DOMElement {
387 // ExtendedElement PHP class
388 // this extends the general PHP DOM Element class to simplify some usual constructs
389 //
390 // function appendElement($name, [$value])
391 // appends a DOMDocument::createElement() as a child of this element (see there for params)
392 // returns the new child
393 //
394 // function appendElementXML($name, $xmldata)
395 // appends a DOMDocument::createElement() with the given name as a child of this element,
396 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
397 // returns the new child
398 //
399 // function appendLink($target, [$value])
400 // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
401 // returns the new child
402 //
53510e9e
RK
403 // function appendImage($src, [$alt_text])
404 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
405 // returns the new child
406 //
ae41c41b
RK
407 // function appendFormDiv($action, $method, $name)
408 // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
409 // returns an HTML <div> that is a child of the new child
410 //
411 // function appendInputHidden($name, $value)
412 // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
413 // returns the new child
414 //
415 // function appendInputText($name, $maxlength, $size, [$id], [$value])
416 // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
417 // returns the new child
418 //
419 // function appendInputRadio($name, $id, $value, $checked)
420 // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
421 // returns the new child
422 //
423 // function appendInputCheckbox($name, $id, $value, $checked)
424 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
425 // returns the new child
426 //
427 // function appendInputSubmit($value)
428 // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
429 // returns the new child
430 //
1109f526
RK
431 // function appendButton($value, $onclick = null)
432 // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
433 // returns the new child
434 //
bf91764c
RK
435 // function appendTextArea($name, $columns, $rows, [$id], [$value])
436 // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
437 // returns the new child
438 //
439 // function appendElementSelect($name, [$id], [$options], [$default])
440 // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
441 // returns the new child
442 //
443 // function appendElementOption($key, $desc, [$selected])
444 // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params)
445 // returns the new child
446 //
ae41c41b
RK
447 // function appendLabel($for_id, $value)
448 // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
449 // returns the new child
450 //
cea5b93a
RK
451 // function appendText($text)
452 // appends a DOMDocument::createTextNode() as a child of this element (see there for params)
453 // returns the new child
454 //
cadc5980
RK
455 // function appendComment($comment_data)
456 // appends a DOMDocument::createComment() as a child of this element (see there for params)
457 // returns the new child
458 //
ae41c41b
RK
459 // function appendHTMLMarkup($htmldata)
460 // appends a representation of the HTML data as children of this element
461 // NO return value!
462 //
463 // function appendXMLMarkup($xmldata)
464 // appends a representation of the XML data as children of this element
cea5b93a
RK
465 // NO return value!
466 //
467 // function appendJSElement($jsdata)
468 // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params)
469 // NO return value!
c1666e91
RK
470 //
471 // function appendCOMElement($module, $attributes)
472 // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params)
473 // returns the new child
cea5b93a
RK
474
475 function appendElement($name, $value = '') {
476 return $this->appendChild($this->ownerDocument->createElement($name, $value));
477 }
478 function appendElementXML($name, $xmldata) {
479 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
ae41c41b 480 $aelem->appendXMLMarkup($xmldata);
cea5b93a
RK
481 return $aelem;
482 }
483 function appendLink($target, $value = '') {
484 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
485 }
53510e9e
RK
486 function appendImage($src, $alt_text = '') {
487 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
488 }
ae41c41b
RK
489 function appendFormDiv($action, $method, $name) {
490 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name));
491 return $formelem->appendElement('div');
492 }
493 function appendInputHidden($name, $value) {
494 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
495 }
496 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
497 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
498 }
499 function appendInputRadio($name, $id, $value, $checked) {
500 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
501 }
502 function appendInputCheckbox($name, $id, $value, $checked) {
503 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
504 }
505 function appendInputSubmit($value) {
506 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
507 }
1109f526
RK
508 function appendButton($value, $onclick = null) {
509 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
510 }
bf91764c
RK
511 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
512 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
513 }
514 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
515 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
516 }
517 function appendElementOption($key, $desc, $selected = false) {
518 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
519 }
520 function appendLabel($for_id, $value) {
521 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
522 }
523 function appendText($text) {
524 return $this->appendChild($this->ownerDocument->createTextNode($text));
525 }
cadc5980
RK
526 function appendComment($comment_data) {
527 return $this->appendChild($this->ownerDocument->createComment($comment_data));
528 }
bf91764c
RK
529 function appendHTMLMarkup($htmldata) {
530 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
531 }
532 function appendXMLMarkup($xmldata) {
533 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
534 }
535 function appendJSElement($jsdata) {
536 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
537 }
c1666e91
RK
538 function appendCOMElement($module, $attributes) {
539 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
540 }
bf91764c
RK
541}
542
543class ExtendedDocumentFragment extends DOMDocumentFragment {
544 // ExtendedDocumentFragment PHP class
545 // this extends the general PHP DOM Document Fragment class to simplify some usual constructs
546 //
547 // function appendElement($name, [$value])
548 // appends a DOMDocument::createElement() as a child of this fragment (see there for params)
549 // returns the new child
550 //
551 // function appendElementXML($name, $xmldata)
552 // appends a DOMDocument::createElement() with the given name as a child of this fragment,
553 // with an ExtendedDocument::createXMLFragment() of the given XML data inside
554 // returns the new child
555 //
556 // function appendLink($target, [$value])
557 // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
558 // returns the new child
559 //
53510e9e
RK
560 // function appendImage($src, [$alt_text])
561 // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params)
562 // returns the new child
563 //
bf91764c
RK
564 // function appendFormDiv($action, $method, $name)
565 // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params)
566 // returns an HTML <div> that is a child of the new child
567 //
568 // function appendInputHidden($name, $value)
569 // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params)
570 // returns the new child
571 //
572 // function appendInputText($name, $maxlength, $size, [$id], [$value])
573 // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
574 // returns the new child
575 //
576 // function appendInputRadio($name, $id, $value, $checked)
577 // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
578 // returns the new child
579 //
580 // function appendInputCheckbox($name, $id, $value, $checked)
581 // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params)
582 // returns the new child
583 //
584 // function appendInputSubmit($value)
585 // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
586 // returns the new child
587 //
1109f526
RK
588 // function appendButton($value, $onclick = null)
589 // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
590 // returns the new child
591 //
bf91764c
RK
592 // function appendTextArea($name, $columns, $rows, [$id], [$value])
593 // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
594 // returns the new child
595 //
596 // function appendElementSelect($name, [$id], [$options], [$default])
597 // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
598 // returns the new child
599 //
600 // function appendElementOption($key, $desc, [$selected])
601 // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params)
602 // returns the new child
603 //
604 // function appendLabel($for_id, $value)
605 // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params)
606 // returns the new child
607 //
608 // function appendText($text)
609 // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
610 // returns the new child
611 //
cadc5980
RK
612 // function appendComment($comment_data)
613 // appends a DOMDocument::createComment() as a child of this fragment (see there for params)
614 // returns the new child
615 //
bf91764c
RK
616 // function appendHTMLMarkup($htmldata)
617 // appends a representation of the HTML data as children of this fragment
618 // NO return value!
619 //
620 // function appendXMLMarkup($xmldata)
621 // appends a representation of the XML data as children of this fragment
622 // NO return value!
623 //
624 // function appendJSElement($jsdata)
625 // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params)
626 // NO return value!
c1666e91
RK
627 //
628 // function appendCOMElement($module, $attributes)
629 // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params)
630 // returns the new child
bf91764c
RK
631
632 function appendElement($name, $value = '') {
633 return $this->appendChild($this->ownerDocument->createElement($name, $value));
634 }
635 function appendElementXML($name, $xmldata) {
636 $aelem = $this->appendChild($this->ownerDocument->createElement($name));
637 $aelem->appendXMLMarkup($xmldata);
638 return $aelem;
639 }
640 function appendLink($target, $value = '') {
641 return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
642 }
53510e9e
RK
643 function appendImage($src, $alt_text = '') {
644 return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
645 }
bf91764c
RK
646 function appendFormDiv($action, $method, $name) {
647 $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name));
648 return $formelem->appendElement('div');
649 }
650 function appendInputHidden($name, $value) {
651 return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
652 }
653 function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
654 return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
655 }
656 function appendInputRadio($name, $id, $value, $checked) {
657 return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
658 }
659 function appendInputCheckbox($name, $id, $value, $checked) {
660 return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
661 }
662 function appendInputSubmit($value) {
663 return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
664 }
1109f526
RK
665 function appendButton($value, $onclick = null) {
666 return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
667 }
bf91764c
RK
668 function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
669 return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
670 }
671 function appendElementSelect($name, $id = null, $options = array(), $default = null) {
672 return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
673 }
674 function appendElementOption($key, $desc, $selected = false) {
675 return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
676 }
ae41c41b
RK
677 function appendLabel($for_id, $value) {
678 return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
679 }
cea5b93a
RK
680 function appendText($text) {
681 return $this->appendChild($this->ownerDocument->createTextNode($text));
682 }
cadc5980
RK
683 function appendComment($comment_data) {
684 return $this->appendChild($this->ownerDocument->createComment($comment_data));
685 }
ae41c41b
RK
686 function appendHTMLMarkup($htmldata) {
687 $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
688 }
689 function appendXMLMarkup($xmldata) {
690 $this->ownerDocument->appendXMLMarkup($xmldata, $this);
cea5b93a
RK
691 }
692 function appendJSElement($jsdata) {
693 $this->appendChild($this->ownerDocument->createElementJS($jsdata));
694 }
c1666e91
RK
695 function appendCOMElement($module, $attributes) {
696 $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes));
697 }
cea5b93a
RK
698}
699?>