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 | // | |
14014b8f RK |
30 | // static function initHTML5() |
31 | // initialize as an HTML5 document and return references to its basic elements. | |
32 | // returns an associative array with the following elements: 'html', 'head', 'title', 'body' | |
ae41c41b | 33 | // |
61cc8aa9 | 34 | // public function appendElement($name, [$value]) |
cea5b93a RK |
35 | // appends a DOMDocument::createElement() as a child of this document (see there for params) |
36 | // returns the new child | |
37 | // | |
61cc8aa9 | 38 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
39 | // appends a DOMDocument::createElement() with the given name as a child of this document, |
40 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
41 | // returns the new child | |
42 | // | |
61cc8aa9 | 43 | // public function appendLink($target, [$value]) |
cea5b93a RK |
44 | // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params) |
45 | // returns the new child | |
46 | // | |
61cc8aa9 | 47 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
48 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
49 | // returns the new child | |
50 | // | |
61cc8aa9 | 51 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
52 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
53 | // returns the new child | |
54 | // | |
61cc8aa9 | 55 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
56 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
57 | // returns an HTML <div> that is a child of the new child | |
58 | // | |
61cc8aa9 | 59 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
60 | // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params) |
61 | // returns the new child | |
62 | // | |
61cc8aa9 | 63 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
64 | // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params) |
65 | // returns the new child | |
66 | // | |
61cc8aa9 | 67 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
68 | // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params) |
69 | // returns the new child | |
70 | // | |
ea32f7e5 RK |
71 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
72 | // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params) | |
73 | // returns the new child | |
74 | // | |
61cc8aa9 | 75 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
76 | // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params) |
77 | // returns the new child | |
78 | // | |
61cc8aa9 | 79 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
80 | // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params) |
81 | // returns the new child | |
82 | // | |
61cc8aa9 | 83 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
84 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params) |
85 | // returns the new child | |
86 | // | |
61cc8aa9 | 87 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
88 | // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params) |
89 | // returns the new child | |
90 | // | |
61cc8aa9 | 91 | // public function appendInputSubmit($value) |
ae41c41b RK |
92 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params) |
93 | // returns the new child | |
94 | // | |
61cc8aa9 | 95 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
96 | // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params) |
97 | // returns the new child | |
98 | // | |
61cc8aa9 | 99 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
100 | // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params) |
101 | // returns the new child | |
102 | // | |
61cc8aa9 | 103 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
104 | // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params) |
105 | // returns the new child | |
106 | // | |
61cc8aa9 | 107 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
108 | // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params) |
109 | // returns the new child | |
110 | // | |
61cc8aa9 | 111 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
112 | // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params) |
113 | // returns the new child | |
114 | // | |
61cc8aa9 | 115 | // public function appendText($text) |
cea5b93a RK |
116 | // appends a DOMDocument::createTextNode() as a child of this document (see there for params) |
117 | // returns the new child | |
118 | // | |
6638efd5 RK |
119 | // public function appendEntity($name) |
120 | // appends a DOMDocument::createEntityReference() as a child of this document (see there for params) | |
121 | // returns the new child | |
122 | // | |
61cc8aa9 | 123 | // public function appendComment($comment_data) |
cadc5980 RK |
124 | // appends a DOMDocument::createComment() as a child of this document (see there for params) |
125 | // returns the new child | |
126 | // | |
61cc8aa9 | 127 | // public function appendHTMLMarkup($htmldata, [$parentNode]) |
ae41c41b RK |
128 | // appends a representation of the HTML data as children of the given parent node, by default this document |
129 | // NO return value! | |
130 | // | |
61cc8aa9 | 131 | // public function appendXMLMarkup($xmldata, [$parentNode]) |
ae41c41b | 132 | // appends a representation of the XML data as children of the given parent node, by default this document |
cea5b93a RK |
133 | // NO return value! |
134 | // | |
61cc8aa9 | 135 | // public function appendJSElement($jsdata) |
cea5b93a RK |
136 | // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params) |
137 | // NO return value! | |
138 | // | |
ea32f7e5 RK |
139 | // public function appendJSFile($jsURL) |
140 | // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params) | |
141 | // returns the new child | |
142 | // | |
61cc8aa9 | 143 | // public function appendCOMElement($module, $attributes) |
c1666e91 RK |
144 | // appends an ExtendedDocument::createCOMElement() as a child of this document (see there for params) |
145 | // returns the new child | |
146 | // | |
61cc8aa9 | 147 | // public function createElementLink($target, [$value]) |
cea5b93a RK |
148 | // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value |
149 | // | |
61cc8aa9 | 150 | // public function createElementImage($src, [$alt_text]) |
53510e9e RK |
151 | // returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default) |
152 | // | |
61cc8aa9 | 153 | // public function createElementForm($action, $method, $name) |
ae41c41b RK |
154 | // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form> |
155 | // with the given action, method, and name | |
156 | // | |
61cc8aa9 | 157 | // public function createElementInputHidden($name, $value) |
ae41c41b RK |
158 | // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value |
159 | // | |
61cc8aa9 | 160 | // public function createElementInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
161 | // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size, |
162 | // and optionally id and value | |
163 | // | |
61cc8aa9 | 164 | // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
165 | // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size, |
166 | // and optionally id and value | |
167 | // | |
ea32f7e5 RK |
168 | // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value]) |
169 | // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size, | |
170 | // and optionally id and value | |
171 | // | |
61cc8aa9 | 172 | // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
173 | // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size, |
174 | // and optionally id and value | |
175 | // | |
61cc8aa9 | 176 | // public function createElementInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
177 | // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and |
178 | // checked state | |
179 | // | |
61cc8aa9 | 180 | // public function createElementInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
181 | // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and |
182 | // checked state | |
183 | // | |
61cc8aa9 | 184 | // public function createElementInputFile($name, $id, $accept) |
4bb9d784 RK |
185 | // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept |
186 | // | |
61cc8aa9 | 187 | // public function createElementInputSubmit($value) |
1109f526 RK |
188 | // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label |
189 | // | |
61cc8aa9 | 190 | // public function createElementButton($value, $onclick = null) |
1109f526 | 191 | // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute |
ae41c41b | 192 | // |
61cc8aa9 | 193 | // public function createElementTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
194 | // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows, |
195 | // and optionally id and value | |
196 | // | |
61cc8aa9 | 197 | // public function createElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
198 | // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id, |
199 | // array of options (key => description) and key of the by-default selected entry | |
200 | // | |
61cc8aa9 | 201 | // public function createElementOption($key, $desc, [$selected]) |
bf91764c RK |
202 | // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content) |
203 | // and optionally bool that tells if the entry is selected | |
204 | // | |
61cc8aa9 | 205 | // public function createElementLabel($for_id, $value) |
ae41c41b | 206 | // returns an ExtendedElement that is an HTML <label> with the given 'for' and value |
cea5b93a | 207 | // |
61cc8aa9 | 208 | // public function createElementJS($jsdata) |
cea5b93a | 209 | // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside |
c1666e91 | 210 | // |
ea32f7e5 RK |
211 | // public function createElementJSFile($jsURL) |
212 | // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL | |
213 | // | |
61cc8aa9 | 214 | // public function createCOMElement($module, $attributes) |
c1666e91 RK |
215 | // returns an ExtendedElement that is in COM_NS namespace, with the given module as name and the |
216 | // given name=>value array as attributes | |
cea5b93a RK |
217 | |
218 | function __construct($version = '1.0', $encoding = 'utf-8') { | |
219 | // make sure the default DOMDocument constructor runs | |
220 | parent::__construct($version, $encoding); | |
221 | $this->registerNodeClass('DOMElement', 'ExtendedElement'); | |
bf91764c | 222 | $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment'); |
cea5b93a RK |
223 | } |
224 | ||
14014b8f RK |
225 | static function initHTML5() { |
226 | $doc = new ExtendedDocument(); | |
227 | $doc->loadHTML('<!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly. | |
228 | ||
229 | // Created basic HTML document structure. | |
230 | $root = $doc->getElementsByTagName('html')->item(0); | |
231 | $head = $root->appendElement('head'); | |
232 | $title = $head->appendElement('title'); | |
233 | $body = $root->appendElement('body'); | |
234 | ||
235 | return array('document' => $doc, | |
236 | 'html' => $root, | |
237 | 'head' => $head, | |
238 | 'title' => $title, | |
239 | 'body' => $body); | |
240 | } | |
241 | ||
61cc8aa9 | 242 | public function appendElement($name, $value = '') { |
a8816f43 | 243 | return $this->appendChild($this->createElement($name, $value)); |
cea5b93a | 244 | } |
61cc8aa9 | 245 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 246 | $aelem = $this->appendChild($this->createElement($name)); |
ae41c41b RK |
247 | $aelem->appendXMLMarkup($xmldata); |
248 | //$aelem->appendChild($this->createXMLFragment($xmldata)); | |
cea5b93a RK |
249 | return $aelem; |
250 | } | |
61cc8aa9 | 251 | public function appendLink($target, $value = '') { |
cea5b93a RK |
252 | return $this->appendChild($this->createElementLink($target, $value)); |
253 | } | |
61cc8aa9 | 254 | public function appendImage($src, $alt_text = '') { |
4aa31782 RK |
255 | return $this->appendChild($this->createElementImage($src, $alt_text)); |
256 | } | |
61cc8aa9 | 257 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
258 | return $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
259 | } | |
61cc8aa9 | 260 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 261 | $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
262 | return $formelem->appendElement('div'); |
263 | } | |
61cc8aa9 | 264 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
265 | return $this->appendChild($this->createElementInputHidden($name, $value)); |
266 | } | |
61cc8aa9 | 267 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
268 | return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); |
269 | } | |
61cc8aa9 | 270 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
271 | return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
272 | } | |
ea32f7e5 RK |
273 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
274 | return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
275 | } | |
61cc8aa9 | 276 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 RK |
277 | return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
278 | } | |
61cc8aa9 | 279 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
280 | return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked)); |
281 | } | |
61cc8aa9 | 282 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
283 | return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked)); |
284 | } | |
61cc8aa9 | 285 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
286 | return $this->appendChild($this->createElementInputFile($name, $id, $accept)); |
287 | } | |
61cc8aa9 | 288 | public function appendInputSubmit($value) { |
ae41c41b RK |
289 | return $this->appendChild($this->createElementInputSubmit($value)); |
290 | } | |
61cc8aa9 | 291 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
292 | return $this->appendChild($this->createElementButton($value, $onclick)); |
293 | } | |
61cc8aa9 | 294 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
295 | return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value)); |
296 | } | |
61cc8aa9 | 297 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
298 | return $this->appendChild($this->createElementSelect($name, $id, $options, $default)); |
299 | } | |
61cc8aa9 | 300 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
301 | return $this->appendChild($this->createElementOption($key, $desc, $selected)); |
302 | } | |
61cc8aa9 | 303 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
304 | return $this->appendChild($this->createElementLabel($for_id, $value)); |
305 | } | |
61cc8aa9 | 306 | public function appendText($text) { |
cea5b93a RK |
307 | return $this->appendChild($this->createTextNode($text)); |
308 | } | |
6638efd5 RK |
309 | public function appendEntity($name) { |
310 | return $this->appendChild($this->createEntityReference($name)); | |
311 | } | |
61cc8aa9 | 312 | public function appendComment($comment_data) { |
cadc5980 RK |
313 | return $this->appendChild($this->createComment($comment_data)); |
314 | } | |
61cc8aa9 | 315 | public function appendJSElement($jsdata) { |
cea5b93a RK |
316 | $this->appendChild($this->createElementJS($jsdata)); |
317 | } | |
ea32f7e5 RK |
318 | public function appendJSFile($jsdata) { |
319 | return $this->appendChild($this->createElementJSFile($jsdata)); | |
320 | } | |
61cc8aa9 | 321 | public function appendCOMElement($module, $attributes) { |
ea32f7e5 | 322 | return $this->appendChild($this->createCOMElement($module, $attributes)); |
c1666e91 | 323 | } |
cea5b93a | 324 | |
61cc8aa9 | 325 | public function appendHTMLMarkup($htmldata, $parentNode = null) { |
ae41c41b RK |
326 | if (is_null($parentNode)) { $parentNode =& $this; } |
327 | // XXX: just a workaround for now! | |
328 | $parentNode->appendChild($this->createCDATASection($htmldata)); | |
329 | } | |
330 | ||
61cc8aa9 | 331 | public function appendXMLMarkup($xmldata, $parentNode = null) { |
ae41c41b RK |
332 | if (is_null($parentNode)) { $parentNode =& $this; } |
333 | $tmpdoc = new ExtendedDocument; | |
334 | $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n"; | |
335 | $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n"; | |
336 | $tmpxml .= '<root>'.$xmldata.'</root>'; | |
337 | $tmpdoc->loadXML($tmpxml); | |
338 | foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) { | |
339 | $parentNode->appendChild($this->importNode($child, true)); | |
340 | } | |
cea5b93a RK |
341 | } |
342 | ||
61cc8aa9 | 343 | public function createElement($name, $value = '') { |
a8816f43 RK |
344 | // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that. |
345 | $aelem = parent::createElement($name); | |
346 | $aelem->appendText($value); | |
347 | return $aelem; | |
348 | } | |
349 | ||
61cc8aa9 | 350 | public function createElementLink($target, $value = '') { |
a8816f43 | 351 | $link = $this->createElement('a', $value); |
bf91764c | 352 | $link->setAttribute('href', $target); // XXX: take care of & etc. in links |
cea5b93a RK |
353 | return $link; |
354 | } | |
355 | ||
61cc8aa9 | 356 | public function createElementImage($src, $alt_text = '') { |
319cfe8d RK |
357 | $img = $this->createElement('img'); |
358 | $img->setAttribute('src', $src); | |
359 | $img->setAttribute('alt', $alt_text); | |
360 | return $img; | |
4aa31782 RK |
361 | } |
362 | ||
61cc8aa9 | 363 | public function createElementForm($action, $method, $name, $id = null) { |
ae41c41b RK |
364 | $formelem = $this->createElement('form'); |
365 | $formelem->setAttribute('action', $action); | |
366 | $formelem->setAttribute('method', $method); | |
367 | $formelem->setAttribute('name', $name); | |
b8d16837 | 368 | $formelem->setAttribute('id', $id); |
ae41c41b RK |
369 | return $formelem; |
370 | } | |
371 | ||
61cc8aa9 | 372 | public function createElementInputHidden($name, $value) { |
ae41c41b RK |
373 | $hidden = $this->createElement('input'); |
374 | $hidden->setAttribute('type', 'hidden'); | |
375 | $hidden->setAttribute('name', $name); | |
376 | $hidden->setAttribute('value', $value); | |
377 | return $hidden; | |
378 | } | |
379 | ||
61cc8aa9 | 380 | public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
381 | $txfield = $this->createElement('input'); |
382 | $txfield->setAttribute('type', 'text'); | |
383 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
384 | $txfield->setAttribute('name', $name); | |
385 | $txfield->setAttribute('maxlength', $maxlength); | |
386 | $txfield->setAttribute('size', $size); | |
387 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
388 | return $txfield; | |
389 | } | |
390 | ||
61cc8aa9 | 391 | public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
392 | $txfield = $this->createElement('input'); |
393 | $txfield->setAttribute('type', 'number'); | |
394 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
395 | $txfield->setAttribute('name', $name); | |
396 | $txfield->setAttribute('maxlength', $maxlength); | |
397 | $txfield->setAttribute('size', $size); | |
398 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
399 | return $txfield; | |
400 | } | |
401 | ||
ea32f7e5 RK |
402 | public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
403 | $txfield = $this->createElement('input'); | |
404 | $txfield->setAttribute('type', 'email'); | |
405 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
406 | $txfield->setAttribute('name', $name); | |
407 | $txfield->setAttribute('maxlength', $maxlength); | |
408 | $txfield->setAttribute('size', $size); | |
409 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
410 | return $txfield; | |
411 | } | |
412 | ||
61cc8aa9 | 413 | public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
319cfe8d RK |
414 | $pwfield = $this->createElement('input'); |
415 | $pwfield->setAttribute('type', 'password'); | |
416 | if (!is_null($id)) { $pwfield->setAttribute('id', $id); } | |
417 | $pwfield->setAttribute('name', $name); | |
418 | $pwfield->setAttribute('maxlength', $maxlength); | |
419 | $pwfield->setAttribute('size', $size); | |
420 | if (!is_null($value)) { $pwfield->setAttribute('value', $value); } | |
421 | return $pwfield; | |
645a7eb6 RK |
422 | } |
423 | ||
61cc8aa9 | 424 | public function createElementInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
425 | $radio = $this->createElement('input'); |
426 | $radio->setAttribute('type', 'radio'); | |
427 | $radio->setAttribute('name', $name); | |
4bb9d784 | 428 | if (!is_null($id)) { $radio->setAttribute('id', $id); } |
ae41c41b RK |
429 | $radio->setAttribute('value', $value); |
430 | if ($checked) { $radio->setAttribute('checked', ''); } | |
431 | return $radio; | |
432 | } | |
433 | ||
61cc8aa9 | 434 | public function createElementInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
435 | $cbox = $this->createElement('input'); |
436 | $cbox->setAttribute('type', 'checkbox'); | |
437 | $cbox->setAttribute('name', $name); | |
4bb9d784 | 438 | if (!is_null($id)) { $cbox->setAttribute('id', $id); } |
ae41c41b RK |
439 | $cbox->setAttribute('value', $value); |
440 | if ($checked) { $cbox->setAttribute('checked', ''); } | |
441 | return $cbox; | |
442 | } | |
443 | ||
61cc8aa9 | 444 | public function createElementInputFile($name, $id, $accept) { |
4bb9d784 RK |
445 | $fileinput = $this->createElement('input'); |
446 | $fileinput->setAttribute('type', 'file'); | |
447 | $fileinput->setAttribute('name', $name); | |
448 | if (!is_null($id)) { $fileinput->setAttribute('id', $id); } | |
449 | $fileinput->setAttribute('accept', $accept); | |
450 | return $fileinput; | |
451 | } | |
452 | ||
61cc8aa9 | 453 | public function createElementInputSubmit($value) { |
ae41c41b RK |
454 | $submitbtn = $this->createElement('input'); |
455 | $submitbtn->setAttribute('type', 'submit'); | |
456 | $submitbtn->setAttribute('value', $value); | |
457 | return $submitbtn; | |
458 | } | |
459 | ||
61cc8aa9 | 460 | public function createElementButton($value, $onclick = null) { |
1109f526 RK |
461 | $btn = $this->createElement('input'); |
462 | $btn->setAttribute('type', 'button'); | |
463 | $btn->setAttribute('value', $value); | |
464 | if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); } | |
465 | return $btn; | |
466 | } | |
467 | ||
61cc8aa9 | 468 | public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
469 | $txtarea = $this->createElement('textarea', $value); |
470 | $txtarea->setAttribute('name', $name); | |
471 | $txtarea->setAttribute('cols', $columns); | |
472 | $txtarea->setAttribute('rows', $rows); | |
473 | if (!is_null($id)) { $txtarea->setAttribute('id', $id); } | |
474 | return $txtarea; | |
475 | } | |
476 | ||
61cc8aa9 | 477 | public function createElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
478 | $select = $this->createElement('select'); |
479 | $select->setAttribute('name', $name); | |
480 | if (!is_null($id)) { $select->setAttribute('id', $id); } | |
481 | foreach ($options as $key => $desc) { | |
482 | $select->appendElementOption($key, $desc, ($key == $default)); | |
483 | } | |
484 | return $select; | |
485 | } | |
486 | ||
61cc8aa9 | 487 | public function createElementOption($key, $desc, $selected = false) { |
bf91764c RK |
488 | $option = $this->createElement('option', $desc); |
489 | $option->setAttribute('value', $key); | |
490 | if ($selected) { $option->setAttribute('selected', ''); } | |
491 | return $option; | |
492 | } | |
493 | ||
61cc8aa9 | 494 | public function createElementLabel($for_id, $value) { |
ae41c41b RK |
495 | $label = $this->createElement('label', $value); |
496 | $label->setAttribute('for', $for_id); | |
497 | return $label; | |
cea5b93a RK |
498 | } |
499 | ||
61cc8aa9 | 500 | public function createElementJS($jsdata) { |
cea5b93a | 501 | $jselem = $this->createElement('script'); |
ea32f7e5 | 502 | // Note: type can/should be left out for HTML5. |
cea5b93a RK |
503 | $jselem->setAttribute('type', 'text/javascript'); |
504 | $jselem->appendChild($this->createCDATASection($jsdata)); | |
505 | return $jselem; | |
506 | } | |
c1666e91 | 507 | |
ea32f7e5 RK |
508 | public function createElementJSFile($jsURL) { |
509 | $jselem = $this->createElement('script'); | |
510 | // Note: type can/should be left out for HTML5. | |
511 | $jselem->setAttribute('type', 'text/javascript'); | |
512 | $jselem->setAttribute('src', $jsURL); | |
513 | return $jselem; | |
514 | } | |
515 | ||
61cc8aa9 | 516 | public function createCOMElement($module, $attributes) { |
c1666e91 RK |
517 | $com_elem = $this->createElementNS(COM_NS, $module); |
518 | if (is_array($attributes) && count($attributes)) { | |
519 | foreach ($attributes as $name=>$value) { | |
520 | $com_elem->setAttribute($name, $value); | |
521 | } | |
522 | } | |
523 | return $com_elem; | |
524 | } | |
cea5b93a RK |
525 | } |
526 | ||
527 | class ExtendedElement extends DOMElement { | |
528 | // ExtendedElement PHP class | |
529 | // this extends the general PHP DOM Element class to simplify some usual constructs | |
530 | // | |
61cc8aa9 | 531 | // public function appendElement($name, [$value]) |
cea5b93a RK |
532 | // appends a DOMDocument::createElement() as a child of this element (see there for params) |
533 | // returns the new child | |
534 | // | |
61cc8aa9 | 535 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
536 | // appends a DOMDocument::createElement() with the given name as a child of this element, |
537 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
538 | // returns the new child | |
539 | // | |
61cc8aa9 | 540 | // public function appendLink($target, [$value]) |
cea5b93a RK |
541 | // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params) |
542 | // returns the new child | |
543 | // | |
61cc8aa9 | 544 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
545 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
546 | // returns the new child | |
547 | // | |
61cc8aa9 | 548 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
549 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
550 | // returns the new child | |
551 | // | |
61cc8aa9 | 552 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
553 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
554 | // returns an HTML <div> that is a child of the new child | |
555 | // | |
61cc8aa9 | 556 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
557 | // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params) |
558 | // returns the new child | |
559 | // | |
61cc8aa9 | 560 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
561 | // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) |
562 | // returns the new child | |
563 | // | |
61cc8aa9 | 564 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
565 | // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) |
566 | // returns the new child | |
567 | // | |
ea32f7e5 RK |
568 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
569 | // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params) | |
570 | // returns the new child | |
571 | // | |
61cc8aa9 | 572 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
573 | // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params) |
574 | // returns the new child | |
575 | // | |
61cc8aa9 | 576 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
577 | // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params) |
578 | // returns the new child | |
579 | // | |
61cc8aa9 | 580 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
581 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params) |
582 | // returns the new child | |
583 | // | |
61cc8aa9 | 584 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
585 | // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params) |
586 | // returns the new child | |
587 | // | |
61cc8aa9 | 588 | // public function appendInputSubmit($value) |
ae41c41b RK |
589 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params) |
590 | // returns the new child | |
591 | // | |
61cc8aa9 | 592 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
593 | // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params) |
594 | // returns the new child | |
595 | // | |
61cc8aa9 | 596 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
597 | // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params) |
598 | // returns the new child | |
599 | // | |
61cc8aa9 | 600 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
601 | // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params) |
602 | // returns the new child | |
603 | // | |
61cc8aa9 | 604 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
605 | // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params) |
606 | // returns the new child | |
607 | // | |
61cc8aa9 | 608 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
609 | // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params) |
610 | // returns the new child | |
611 | // | |
61cc8aa9 | 612 | // public function appendText($text) |
cea5b93a RK |
613 | // appends a DOMDocument::createTextNode() as a child of this element (see there for params) |
614 | // returns the new child | |
615 | // | |
6638efd5 RK |
616 | // public function appendEntity($name) |
617 | // appends a DOMDocument::createEntityReference() as a child of this element (see there for params) | |
618 | // returns the new child | |
619 | // | |
61cc8aa9 | 620 | // public function appendComment($comment_data) |
cadc5980 RK |
621 | // appends a DOMDocument::createComment() as a child of this element (see there for params) |
622 | // returns the new child | |
623 | // | |
61cc8aa9 | 624 | // public function appendHTMLMarkup($htmldata) |
ae41c41b RK |
625 | // appends a representation of the HTML data as children of this element |
626 | // NO return value! | |
627 | // | |
61cc8aa9 | 628 | // public function appendXMLMarkup($xmldata) |
ae41c41b | 629 | // appends a representation of the XML data as children of this element |
cea5b93a RK |
630 | // NO return value! |
631 | // | |
61cc8aa9 | 632 | // public function appendJSElement($jsdata) |
cea5b93a RK |
633 | // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params) |
634 | // NO return value! | |
c1666e91 | 635 | // |
61cc8aa9 | 636 | // public function appendCOMElement($module, $attributes) |
c1666e91 RK |
637 | // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params) |
638 | // returns the new child | |
ea32f7e5 RK |
639 | // |
640 | // public function appendCOMElement($module, $attributes) | |
641 | // appends an ExtendedDocument::createCOMElement() as a child of this element (see there for params) | |
642 | // returns the new child | |
cea5b93a | 643 | |
61cc8aa9 | 644 | public function appendElement($name, $value = '') { |
a8816f43 | 645 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
cea5b93a | 646 | } |
61cc8aa9 | 647 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 648 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
ae41c41b | 649 | $aelem->appendXMLMarkup($xmldata); |
cea5b93a RK |
650 | return $aelem; |
651 | } | |
61cc8aa9 | 652 | public function appendLink($target, $value = '') { |
cea5b93a RK |
653 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value)); |
654 | } | |
61cc8aa9 | 655 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
656 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
657 | } | |
61cc8aa9 | 658 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
659 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
660 | } | |
61cc8aa9 | 661 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 662 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
663 | return $formelem->appendElement('div'); |
664 | } | |
61cc8aa9 | 665 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
666 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
667 | } | |
61cc8aa9 | 668 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
669 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
670 | } | |
61cc8aa9 | 671 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
672 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
673 | } | |
ea32f7e5 RK |
674 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
675 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
676 | } | |
61cc8aa9 | 677 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 RK |
678 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
679 | } | |
61cc8aa9 | 680 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
681 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
682 | } | |
61cc8aa9 | 683 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
684 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
685 | } | |
61cc8aa9 | 686 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
687 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
688 | } | |
61cc8aa9 | 689 | public function appendInputSubmit($value) { |
ae41c41b RK |
690 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
691 | } | |
61cc8aa9 | 692 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
693 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
694 | } | |
61cc8aa9 | 695 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
696 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
697 | } | |
61cc8aa9 | 698 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
699 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default)); |
700 | } | |
61cc8aa9 | 701 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
702 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
703 | } | |
61cc8aa9 | 704 | public function appendLabel($for_id, $value) { |
bf91764c RK |
705 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
706 | } | |
61cc8aa9 | 707 | public function appendText($text) { |
bf91764c RK |
708 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
709 | } | |
6638efd5 RK |
710 | public function appendEntity($name) { |
711 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
712 | } | |
61cc8aa9 | 713 | public function appendComment($comment_data) { |
cadc5980 RK |
714 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
715 | } | |
61cc8aa9 | 716 | public function appendHTMLMarkup($htmldata) { |
bf91764c RK |
717 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
718 | } | |
61cc8aa9 | 719 | public function appendXMLMarkup($xmldata) { |
bf91764c RK |
720 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
721 | } | |
61cc8aa9 | 722 | public function appendJSElement($jsdata) { |
bf91764c RK |
723 | $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
724 | } | |
ea32f7e5 RK |
725 | public function appendJSFile($jsdata) { |
726 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata)); | |
727 | } | |
61cc8aa9 | 728 | public function appendCOMElement($module, $attributes) { |
ea32f7e5 | 729 | return $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes)); |
c1666e91 | 730 | } |
bf91764c RK |
731 | } |
732 | ||
733 | class ExtendedDocumentFragment extends DOMDocumentFragment { | |
734 | // ExtendedDocumentFragment PHP class | |
735 | // this extends the general PHP DOM Document Fragment class to simplify some usual constructs | |
736 | // | |
61cc8aa9 | 737 | // public function appendElement($name, [$value]) |
bf91764c RK |
738 | // appends a DOMDocument::createElement() as a child of this fragment (see there for params) |
739 | // returns the new child | |
740 | // | |
61cc8aa9 | 741 | // public function appendElementXML($name, $xmldata) |
bf91764c RK |
742 | // appends a DOMDocument::createElement() with the given name as a child of this fragment, |
743 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
744 | // returns the new child | |
745 | // | |
61cc8aa9 | 746 | // public function appendLink($target, [$value]) |
bf91764c RK |
747 | // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params) |
748 | // returns the new child | |
749 | // | |
61cc8aa9 | 750 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
751 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
752 | // returns the new child | |
753 | // | |
61cc8aa9 | 754 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
755 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
756 | // returns the new child | |
757 | // | |
61cc8aa9 | 758 | // public function appendFormDiv($action, $method, $name, [$id]) |
bf91764c RK |
759 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
760 | // returns an HTML <div> that is a child of the new child | |
761 | // | |
61cc8aa9 | 762 | // public function appendInputHidden($name, $value) |
bf91764c RK |
763 | // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params) |
764 | // returns the new child | |
765 | // | |
61cc8aa9 | 766 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
bf91764c RK |
767 | // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) |
768 | // returns the new child | |
769 | // | |
61cc8aa9 | 770 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
771 | // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) |
772 | // returns the new child | |
773 | // | |
ea32f7e5 RK |
774 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
775 | // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params) | |
776 | // returns the new child | |
777 | // | |
61cc8aa9 | 778 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
645a7eb6 RK |
779 | // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params) |
780 | // returns the new child | |
781 | // | |
61cc8aa9 | 782 | // public function appendInputRadio($name, $id, $value, $checked) |
bf91764c RK |
783 | // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params) |
784 | // returns the new child | |
785 | // | |
61cc8aa9 | 786 | // public function appendInputCheckbox($name, $id, $value, $checked) |
bf91764c RK |
787 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params) |
788 | // returns the new child | |
789 | // | |
61cc8aa9 | 790 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
791 | // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params) |
792 | // returns the new child | |
793 | // | |
61cc8aa9 | 794 | // public function appendInputSubmit($value) |
bf91764c RK |
795 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params) |
796 | // returns the new child | |
797 | // | |
61cc8aa9 | 798 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
799 | // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params) |
800 | // returns the new child | |
801 | // | |
61cc8aa9 | 802 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
803 | // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params) |
804 | // returns the new child | |
805 | // | |
61cc8aa9 | 806 | // public function appendElementSelect($name, [$id], [$options], [$default]) |
bf91764c RK |
807 | // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params) |
808 | // returns the new child | |
809 | // | |
61cc8aa9 | 810 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
811 | // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params) |
812 | // returns the new child | |
813 | // | |
61cc8aa9 | 814 | // public function appendLabel($for_id, $value) |
bf91764c RK |
815 | // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params) |
816 | // returns the new child | |
817 | // | |
61cc8aa9 | 818 | // public function appendText($text) |
bf91764c RK |
819 | // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params) |
820 | // returns the new child | |
821 | // | |
6638efd5 RK |
822 | // public function appendEntity($name) |
823 | // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params) | |
824 | // returns the new child | |
825 | // | |
61cc8aa9 | 826 | // public function appendComment($comment_data) |
cadc5980 RK |
827 | // appends a DOMDocument::createComment() as a child of this fragment (see there for params) |
828 | // returns the new child | |
829 | // | |
61cc8aa9 | 830 | // public function appendHTMLMarkup($htmldata) |
bf91764c RK |
831 | // appends a representation of the HTML data as children of this fragment |
832 | // NO return value! | |
833 | // | |
61cc8aa9 | 834 | // public function appendXMLMarkup($xmldata) |
bf91764c RK |
835 | // appends a representation of the XML data as children of this fragment |
836 | // NO return value! | |
837 | // | |
61cc8aa9 | 838 | // public function appendJSElement($jsdata) |
bf91764c RK |
839 | // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params) |
840 | // NO return value! | |
c1666e91 | 841 | // |
61cc8aa9 | 842 | // public function appendCOMElement($module, $attributes) |
c1666e91 RK |
843 | // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params) |
844 | // returns the new child | |
ea32f7e5 RK |
845 | // |
846 | // public function appendCOMElement($module, $attributes) | |
847 | // appends an ExtendedDocument::createCOMElement() as a child of this fragment (see there for params) | |
848 | // returns the new child | |
bf91764c | 849 | |
61cc8aa9 | 850 | public function appendElement($name, $value = '') { |
a8816f43 | 851 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
bf91764c | 852 | } |
61cc8aa9 | 853 | public function appendElementXML($name, $xmldata) { |
bf91764c RK |
854 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
855 | $aelem->appendXMLMarkup($xmldata); | |
856 | return $aelem; | |
857 | } | |
61cc8aa9 | 858 | public function appendLink($target, $value = '') { |
bf91764c RK |
859 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value)); |
860 | } | |
61cc8aa9 | 861 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
862 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
863 | } | |
61cc8aa9 | 864 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
865 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
866 | } | |
61cc8aa9 | 867 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 868 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
bf91764c RK |
869 | return $formelem->appendElement('div'); |
870 | } | |
61cc8aa9 | 871 | public function appendInputHidden($name, $value) { |
bf91764c RK |
872 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
873 | } | |
61cc8aa9 | 874 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
bf91764c | 875 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
645a7eb6 | 876 | } |
61cc8aa9 | 877 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
878 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
879 | } | |
ea32f7e5 RK |
880 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
881 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
882 | } | |
61cc8aa9 | 883 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
645a7eb6 | 884 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); |
bf91764c | 885 | } |
61cc8aa9 | 886 | public function appendInputRadio($name, $id, $value, $checked) { |
bf91764c RK |
887 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
888 | } | |
61cc8aa9 | 889 | public function appendInputCheckbox($name, $id, $value, $checked) { |
bf91764c RK |
890 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
891 | } | |
61cc8aa9 | 892 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
893 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
894 | } | |
61cc8aa9 | 895 | public function appendInputSubmit($value) { |
bf91764c RK |
896 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
897 | } | |
61cc8aa9 | 898 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
899 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
900 | } | |
61cc8aa9 | 901 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
902 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
903 | } | |
61cc8aa9 | 904 | public function appendElementSelect($name, $id = null, $options = array(), $default = null) { |
bf91764c RK |
905 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default)); |
906 | } | |
61cc8aa9 | 907 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
908 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
909 | } | |
61cc8aa9 | 910 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
911 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
912 | } | |
61cc8aa9 | 913 | public function appendText($text) { |
cea5b93a RK |
914 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
915 | } | |
6638efd5 RK |
916 | public function appendEntity($name) { |
917 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
918 | } | |
61cc8aa9 | 919 | public function appendComment($comment_data) { |
cadc5980 RK |
920 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
921 | } | |
61cc8aa9 | 922 | public function appendHTMLMarkup($htmldata) { |
ae41c41b RK |
923 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
924 | } | |
61cc8aa9 | 925 | public function appendXMLMarkup($xmldata) { |
ae41c41b | 926 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
cea5b93a | 927 | } |
61cc8aa9 | 928 | public function appendJSElement($jsdata) { |
cea5b93a RK |
929 | $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
930 | } | |
ea32f7e5 RK |
931 | public function appendJSFile($jsdata) { |
932 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata)); | |
933 | } | |
61cc8aa9 | 934 | public function appendCOMElement($module, $attributes) { |
ea32f7e5 | 935 | return $this->appendChild($this->ownerDocument->createCOMElement($module, $attributes)); |
c1666e91 | 936 | } |
cea5b93a RK |
937 | } |
938 | ?> |