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