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