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