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