Commit | Line | Data |
---|---|---|
cea5b93a | 1 | <?php |
880bcb60 RK |
2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, | |
4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ | |
cea5b93a RK |
5 | |
6 | class ExtendedDocument extends DOMDocument { | |
7 | // ExtendedDocument PHP class | |
8 | // this extends the general PHP DOM Document class to simplify some usual constructs | |
9 | // | |
10 | // function __construct([$version], [$encoding]) | |
11 | // CONSTRUCTOR | |
12 | // construct a new DOM Document that uses our element definitions | |
13 | // | |
b841a92b | 14 | // static function initHTML5([$doc]) |
14014b8f | 15 | // initialize as an HTML5 document and return references to its basic elements. |
b841a92b | 16 | // If a $doc is handed over (an ExtendedDocument or a derived class), load the content into that document. |
14014b8f | 17 | // returns an associative array with the following elements: 'html', 'head', 'title', 'body' |
ae41c41b | 18 | // |
61cc8aa9 | 19 | // public function appendElement($name, [$value]) |
cea5b93a RK |
20 | // appends a DOMDocument::createElement() as a child of this document (see there for params) |
21 | // returns the new child | |
22 | // | |
61cc8aa9 | 23 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
24 | // appends a DOMDocument::createElement() with the given name as a child of this document, |
25 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
26 | // returns the new child | |
27 | // | |
b3cc0fef | 28 | // public function appendLink($target, [$value], [$title]) |
cea5b93a RK |
29 | // appends an ExtendedDocument::createElementLink() as a child of this document (see there for params) |
30 | // returns the new child | |
31 | // | |
61cc8aa9 | 32 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
33 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
34 | // returns the new child | |
35 | // | |
61cc8aa9 | 36 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
37 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
38 | // returns the new child | |
39 | // | |
61cc8aa9 | 40 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
41 | // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) |
42 | // returns an HTML <div> that is a child of the new child | |
43 | // | |
61cc8aa9 | 44 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
45 | // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params) |
46 | // returns the new child | |
47 | // | |
61cc8aa9 | 48 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
49 | // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params) |
50 | // returns the new child | |
51 | // | |
f925e4a1 RK |
52 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
53 | // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params) | |
54 | // returns the new child | |
55 | // | |
61cc8aa9 | 56 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
57 | // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params) |
58 | // returns the new child | |
59 | // | |
f925e4a1 RK |
60 | // public function appendInputRange($name, $id, $min, $max, [$step], [$value]) |
61 | // appends an ExtendedDocument::createElementInputRange() as a child of this document (see there for params) | |
62 | // returns the new child | |
63 | // | |
64 | // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) | |
65 | // appends an ExtendedDocument::createElementInputUrl() as a child of this document (see there for params) | |
66 | // returns the new child | |
67 | // | |
ea32f7e5 RK |
68 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
69 | // appends an ExtendedDocument::createElementInputEmail() as a child of this document (see there for params) | |
70 | // returns the new child | |
71 | // | |
f925e4a1 RK |
72 | // public function appendInputTel($name, $maxlength, $size, [$id], [$value]) |
73 | // appends an ExtendedDocument::createElementInputTel() as a child of this document (see there for params) | |
74 | // returns the new child | |
75 | // | |
76 | // public function appendInputDate($name, [$id], [$min], [$max], [$value]) | |
77 | // appends an ExtendedDocument::createElementInputDate() as a child of this document (see there for params) | |
78 | // returns the new child | |
79 | // | |
80 | // public function appendInputTime($name, [$id], [$min], [$max], [$value]) | |
81 | // appends an ExtendedDocument::createElementInputTime() as a child of this document (see there for params) | |
82 | // returns the new child | |
83 | // | |
84 | // public function appendInputColor($name, [$id], [$value]) | |
85 | // appends an ExtendedDocument::createElementInputColor() as a child of this document (see there for params) | |
645a7eb6 RK |
86 | // returns the new child |
87 | // | |
61cc8aa9 | 88 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
89 | // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params) |
90 | // returns the new child | |
91 | // | |
61cc8aa9 | 92 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
93 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params) |
94 | // returns the new child | |
95 | // | |
61cc8aa9 | 96 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
97 | // appends an ExtendedDocument::createElementInputFile() as a child of this document (see there for params) |
98 | // returns the new child | |
99 | // | |
61cc8aa9 | 100 | // public function appendInputSubmit($value) |
ae41c41b RK |
101 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params) |
102 | // returns the new child | |
103 | // | |
61cc8aa9 | 104 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
105 | // appends an ExtendedDocument::createElementButton() as a child of this document (see there for params) |
106 | // returns the new child | |
107 | // | |
61cc8aa9 | 108 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
109 | // appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params) |
110 | // returns the new child | |
111 | // | |
69409ddb | 112 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
113 | // appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params) |
114 | // returns the new child | |
115 | // | |
61cc8aa9 | 116 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
117 | // appends an ExtendedDocument::createElementOption() as a child of this document (see there for params) |
118 | // returns the new child | |
119 | // | |
61cc8aa9 | 120 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
121 | // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params) |
122 | // returns the new child | |
123 | // | |
61cc8aa9 | 124 | // public function appendText($text) |
cea5b93a RK |
125 | // appends a DOMDocument::createTextNode() as a child of this document (see there for params) |
126 | // returns the new child | |
127 | // | |
71771b0c RK |
128 | // public function appendLinebreak() |
129 | // appends a <br> as a child of this document | |
130 | // returns the new child | |
131 | // | |
6638efd5 RK |
132 | // public function appendEntity($name) |
133 | // appends a DOMDocument::createEntityReference() as a child of this document (see there for params) | |
134 | // returns the new child | |
135 | // | |
61cc8aa9 | 136 | // public function appendComment($comment_data) |
cadc5980 RK |
137 | // appends a DOMDocument::createComment() as a child of this document (see there for params) |
138 | // returns the new child | |
139 | // | |
3d4db013 RK |
140 | // public function appendClonedElement($dom_element, [$deep]) |
141 | // appends a clone of the given DOMElement as a child of this document | |
142 | // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) | |
143 | // returns the new child | |
144 | // | |
61cc8aa9 | 145 | // public function appendHTMLMarkup($htmldata, [$parentNode]) |
ae41c41b RK |
146 | // appends a representation of the HTML data as children of the given parent node, by default this document |
147 | // NO return value! | |
148 | // | |
61cc8aa9 | 149 | // public function appendXMLMarkup($xmldata, [$parentNode]) |
ae41c41b | 150 | // appends a representation of the XML data as children of the given parent node, by default this document |
cea5b93a RK |
151 | // NO return value! |
152 | // | |
acaa2daa RK |
153 | // public function appendStyleElement($styledata) |
154 | // appends an ExtendedDocument::createElementStyle() as a child of this document (see there for params) | |
155 | // returns the new child | |
156 | // | |
61cc8aa9 | 157 | // public function appendJSElement($jsdata) |
cea5b93a | 158 | // appends an ExtendedDocument::createElementJS() as a child of this document (see there for params) |
acaa2daa | 159 | // returns the new child |
cea5b93a | 160 | // |
8afa2e61 | 161 | // public function appendJSFile($jsURL, [$defer], [$async]) |
ea32f7e5 RK |
162 | // appends an ExtendedDocument::createElementJSFile() as a child of this document (see there for params) |
163 | // returns the new child | |
164 | // | |
b3cc0fef RK |
165 | // public function createElementLink($target, [$value], [$title]) |
166 | // returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value as well as (optional) title attribute | |
cea5b93a | 167 | // |
61cc8aa9 | 168 | // public function createElementImage($src, [$alt_text]) |
b3cc0fef | 169 | // returns an ExtendedElement that is an HTML <img> with the given src and alt attributes (set to '' by default) |
53510e9e | 170 | // |
61cc8aa9 | 171 | // public function createElementForm($action, $method, $name) |
ae41c41b RK |
172 | // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form> |
173 | // with the given action, method, and name | |
174 | // | |
61cc8aa9 | 175 | // public function createElementInputHidden($name, $value) |
ae41c41b RK |
176 | // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value |
177 | // | |
61cc8aa9 | 178 | // public function createElementInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
179 | // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size, |
180 | // and optionally id and value | |
181 | // | |
f925e4a1 RK |
182 | // public function createElementInputPassword($name, $maxlength, $size, [$id], [$value]) |
183 | // returns an ExtendedElement that is an HTML <input> of type 'password' with the given name, maxlength, size, | |
184 | // and optionally id and value | |
185 | // | |
61cc8aa9 | 186 | // public function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
187 | // returns an ExtendedElement that is an HTML <input> of type 'number' with the given name, maxlength, size, |
188 | // and optionally id and value | |
189 | // | |
f925e4a1 RK |
190 | // public function createElementInputRange($name, $id, $min, $max, [$step], [$value]) |
191 | // returns an ExtendedElement that is an HTML <input> of type 'range' with the given name, id, min, max, | |
192 | // and optionally step and value | |
193 | // | |
194 | // public function createElementInputUrl($name, $maxlength, $size, [$id], [$value]) | |
195 | // returns an ExtendedElement that is an HTML <input> of type 'url' with the given name, maxlength, size, | |
196 | // and optionally id and value | |
197 | // | |
ea32f7e5 RK |
198 | // public function createElementInputEmail($name, $maxlength, $size, [$id], [$value]) |
199 | // returns an ExtendedElement that is an HTML <input> of type 'email' with the given name, maxlength, size, | |
200 | // and optionally id and value | |
201 | // | |
f925e4a1 RK |
202 | // public function createElementInputTel($name, $maxlength, $size, [$id], [$value]) |
203 | // returns an ExtendedElement that is an HTML <input> of type 'tel' with the given name, maxlength, size, | |
204 | // and optionally id and value | |
205 | // | |
206 | // public function createElementInputDate($name, [$id], [$min], [$max], [$value]) | |
207 | // returns an ExtendedElement that is an HTML <input> of type 'date' with the given name, | |
208 | // and optionally id, min, max, and value | |
209 | // | |
210 | // public function createElementInputTime($name, [$id], [$min], [$max], [$value]) | |
211 | // returns an ExtendedElement that is an HTML <input> of type 'time' with the given name, | |
212 | // and optionally id, min, max, and value | |
213 | // | |
214 | // public function createElementInputColor($name, [$id], [$value]) | |
215 | // returns an ExtendedElement that is an HTML <input> of type 'color' with the given name, | |
645a7eb6 RK |
216 | // and optionally id and value |
217 | // | |
61cc8aa9 | 218 | // public function createElementInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
219 | // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and |
220 | // checked state | |
221 | // | |
61cc8aa9 | 222 | // public function createElementInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
223 | // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and |
224 | // checked state | |
225 | // | |
61cc8aa9 | 226 | // public function createElementInputFile($name, $id, $accept) |
4bb9d784 RK |
227 | // returns an ExtendedElement that is an HTML <input> of type 'file' with the given name, id and accept |
228 | // | |
61cc8aa9 | 229 | // public function createElementInputSubmit($value) |
1109f526 RK |
230 | // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label |
231 | // | |
61cc8aa9 | 232 | // public function createElementButton($value, $onclick = null) |
1109f526 | 233 | // returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute |
ae41c41b | 234 | // |
61cc8aa9 | 235 | // public function createElementTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
236 | // returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows, |
237 | // and optionally id and value | |
238 | // | |
69409ddb | 239 | // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c | 240 | // returns an ExtendedElement that is an HTML <select> with the given name, and optionally id, |
69409ddb | 241 | // array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true) |
bf91764c | 242 | // |
61cc8aa9 | 243 | // public function createElementOption($key, $desc, [$selected]) |
bf91764c RK |
244 | // returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content) |
245 | // and optionally bool that tells if the entry is selected | |
246 | // | |
61cc8aa9 | 247 | // public function createElementLabel($for_id, $value) |
ae41c41b | 248 | // returns an ExtendedElement that is an HTML <label> with the given 'for' and value |
cea5b93a | 249 | // |
acaa2daa RK |
250 | // public function createElementStyle($styledata) |
251 | // returns an ExtendedElement that is an HTML <style> of CSS type with the style data inside | |
252 | // | |
61cc8aa9 | 253 | // public function createElementJS($jsdata) |
cea5b93a | 254 | // returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside |
c1666e91 | 255 | // |
8afa2e61 | 256 | // public function createElementJSFile($jsURL, [$defer], [$async]) |
ea32f7e5 | 257 | // returns an ExtendedElement that is an HTML <script> of JavaScript type linking to the file given by the URL |
8afa2e61 | 258 | // $defer and $async are boolean attributes that set if the script should be executed after parsing but before onload, and if it should be loaded asynchronously. |
cea5b93a RK |
259 | |
260 | function __construct($version = '1.0', $encoding = 'utf-8') { | |
261 | // make sure the default DOMDocument constructor runs | |
262 | parent::__construct($version, $encoding); | |
263 | $this->registerNodeClass('DOMElement', 'ExtendedElement'); | |
bf91764c | 264 | $this->registerNodeClass('DOMDocumentFragment', 'ExtendedDocumentFragment'); |
cea5b93a RK |
265 | } |
266 | ||
b841a92b RK |
267 | static function initHTML5($doc = null) { |
268 | if (is_null($doc)) { $doc = new ExtendedDocument(); } | |
1a4ee0f0 | 269 | $doc->loadHTML('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html></html>'); // this seems to be the only way to get the DOCTYPE set properly. |
14014b8f RK |
270 | |
271 | // Created basic HTML document structure. | |
272 | $root = $doc->getElementsByTagName('html')->item(0); | |
273 | $head = $root->appendElement('head'); | |
274 | $title = $head->appendElement('title'); | |
275 | $body = $root->appendElement('body'); | |
276 | ||
277 | return array('document' => $doc, | |
278 | 'html' => $root, | |
279 | 'head' => $head, | |
280 | 'title' => $title, | |
281 | 'body' => $body); | |
282 | } | |
283 | ||
61cc8aa9 | 284 | public function appendElement($name, $value = '') { |
a8816f43 | 285 | return $this->appendChild($this->createElement($name, $value)); |
cea5b93a | 286 | } |
61cc8aa9 | 287 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 288 | $aelem = $this->appendChild($this->createElement($name)); |
ae41c41b RK |
289 | $aelem->appendXMLMarkup($xmldata); |
290 | //$aelem->appendChild($this->createXMLFragment($xmldata)); | |
cea5b93a RK |
291 | return $aelem; |
292 | } | |
b3cc0fef RK |
293 | public function appendLink($target, $value = '', $title = null) { |
294 | return $this->appendChild($this->createElementLink($target, $value, $title)); | |
cea5b93a | 295 | } |
61cc8aa9 | 296 | public function appendImage($src, $alt_text = '') { |
4aa31782 RK |
297 | return $this->appendChild($this->createElementImage($src, $alt_text)); |
298 | } | |
61cc8aa9 | 299 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
300 | return $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
301 | } | |
61cc8aa9 | 302 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 303 | $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
304 | return $formelem->appendElement('div'); |
305 | } | |
61cc8aa9 | 306 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
307 | return $this->appendChild($this->createElementInputHidden($name, $value)); |
308 | } | |
61cc8aa9 | 309 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
310 | return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); |
311 | } | |
f925e4a1 RK |
312 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
313 | return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
314 | } | |
61cc8aa9 | 315 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
316 | return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
317 | } | |
f925e4a1 RK |
318 | public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { |
319 | return $this->appendChild($this->createElementInputRange($name, $id, $min, $max, $step, $value)); | |
320 | } | |
321 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
322 | return $this->appendChild($this->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
323 | } | |
ea32f7e5 RK |
324 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
325 | return $this->appendChild($this->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
326 | } | |
f925e4a1 RK |
327 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
328 | return $this->appendChild($this->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
329 | } | |
330 | public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
331 | return $this->appendChild($this->createElementInputDate($name, $id, $min, $max, $value)); | |
332 | } | |
333 | public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
334 | return $this->appendChild($this->createElementInputTime($name, $id, $min, $max, $value)); | |
335 | } | |
336 | public function appendInputColor($name, $id = null, $value = null) { | |
337 | return $this->appendChild($this->createElementInputColor($name, $id, $value)); | |
645a7eb6 | 338 | } |
61cc8aa9 | 339 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
340 | return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked)); |
341 | } | |
61cc8aa9 | 342 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
343 | return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked)); |
344 | } | |
61cc8aa9 | 345 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
346 | return $this->appendChild($this->createElementInputFile($name, $id, $accept)); |
347 | } | |
61cc8aa9 | 348 | public function appendInputSubmit($value) { |
ae41c41b RK |
349 | return $this->appendChild($this->createElementInputSubmit($value)); |
350 | } | |
61cc8aa9 | 351 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
352 | return $this->appendChild($this->createElementButton($value, $onclick)); |
353 | } | |
61cc8aa9 | 354 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
355 | return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value)); |
356 | } | |
69409ddb RK |
357 | public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
358 | return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch)); | |
bf91764c | 359 | } |
61cc8aa9 | 360 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
361 | return $this->appendChild($this->createElementOption($key, $desc, $selected)); |
362 | } | |
61cc8aa9 | 363 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
364 | return $this->appendChild($this->createElementLabel($for_id, $value)); |
365 | } | |
61cc8aa9 | 366 | public function appendText($text) { |
cea5b93a RK |
367 | return $this->appendChild($this->createTextNode($text)); |
368 | } | |
71771b0c RK |
369 | public function appendLinebreak() { |
370 | return $this->appendChild($this->createElement('br')); | |
371 | } | |
6638efd5 RK |
372 | public function appendEntity($name) { |
373 | return $this->appendChild($this->createEntityReference($name)); | |
374 | } | |
61cc8aa9 | 375 | public function appendComment($comment_data) { |
cadc5980 RK |
376 | return $this->appendChild($this->createComment($comment_data)); |
377 | } | |
3d4db013 RK |
378 | public function appendClonedElement($dom_element, $deep = true) { |
379 | return $this->appendChild($dom_element->cloneNode($deep)); | |
380 | } | |
acaa2daa RK |
381 | public function appendStyleElement($styledata) { |
382 | return $this->appendChild($this->createElementStyle($styledata)); | |
383 | } | |
61cc8aa9 | 384 | public function appendJSElement($jsdata) { |
3d4db013 | 385 | return $this->appendChild($this->createElementJS($jsdata)); |
cea5b93a | 386 | } |
1a4ee0f0 RK |
387 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
388 | return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 389 | } |
cea5b93a | 390 | |
61cc8aa9 | 391 | public function appendHTMLMarkup($htmldata, $parentNode = null) { |
ae41c41b | 392 | if (is_null($parentNode)) { $parentNode =& $this; } |
a9a5a68a RK |
393 | // Use loadHTML() to parse and turn the markup into proper HTML. |
394 | $tmpdoc = new ExtendedDocument; | |
395 | // The XML line is needed to tell the parser that we need UTF-8 parsing. | |
396 | $tmpdoc->loadHTML('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html><html><body>'.$htmldata.'</body></html>'); | |
397 | foreach ($tmpdoc->getElementsByTagName('body')->item(0)->childNodes as $child) { | |
398 | $parentNode->appendChild($this->importNode($child, true)); | |
399 | } | |
ae41c41b RK |
400 | } |
401 | ||
61cc8aa9 | 402 | public function appendXMLMarkup($xmldata, $parentNode = null) { |
ae41c41b RK |
403 | if (is_null($parentNode)) { $parentNode =& $this; } |
404 | $tmpdoc = new ExtendedDocument; | |
405 | $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n"; | |
406 | $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n"; | |
407 | $tmpxml .= '<root>'.$xmldata.'</root>'; | |
408 | $tmpdoc->loadXML($tmpxml); | |
409 | foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) { | |
410 | $parentNode->appendChild($this->importNode($child, true)); | |
411 | } | |
cea5b93a RK |
412 | } |
413 | ||
61cc8aa9 | 414 | public function createElement($name, $value = '') { |
a8816f43 RK |
415 | // Adding the $value in DOMDocument's createElement does NOT escape it, so override it and use appendText to support that. |
416 | $aelem = parent::createElement($name); | |
b3cc0fef | 417 | if (strlen($value)) { $aelem->appendText($value); } |
a8816f43 RK |
418 | return $aelem; |
419 | } | |
420 | ||
b3cc0fef | 421 | public function createElementLink($target, $value = '', $title = null) { |
a8816f43 | 422 | $link = $this->createElement('a', $value); |
bf91764c | 423 | $link->setAttribute('href', $target); // XXX: take care of & etc. in links |
b3cc0fef | 424 | if (!is_null($title)) { $link->setAttribute('title', $title); } |
cea5b93a RK |
425 | return $link; |
426 | } | |
427 | ||
61cc8aa9 | 428 | public function createElementImage($src, $alt_text = '') { |
319cfe8d RK |
429 | $img = $this->createElement('img'); |
430 | $img->setAttribute('src', $src); | |
431 | $img->setAttribute('alt', $alt_text); | |
432 | return $img; | |
4aa31782 RK |
433 | } |
434 | ||
61cc8aa9 | 435 | public function createElementForm($action, $method, $name, $id = null) { |
ae41c41b RK |
436 | $formelem = $this->createElement('form'); |
437 | $formelem->setAttribute('action', $action); | |
438 | $formelem->setAttribute('method', $method); | |
439 | $formelem->setAttribute('name', $name); | |
b3cc0fef | 440 | if (!is_null($id)) { $formelem->setAttribute('id', $id); } |
ae41c41b RK |
441 | return $formelem; |
442 | } | |
443 | ||
61cc8aa9 | 444 | public function createElementInputHidden($name, $value) { |
ae41c41b RK |
445 | $hidden = $this->createElement('input'); |
446 | $hidden->setAttribute('type', 'hidden'); | |
447 | $hidden->setAttribute('name', $name); | |
448 | $hidden->setAttribute('value', $value); | |
449 | return $hidden; | |
450 | } | |
451 | ||
61cc8aa9 | 452 | public function createElementInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
453 | $txfield = $this->createElement('input'); |
454 | $txfield->setAttribute('type', 'text'); | |
455 | if (!is_null($id)) { $txfield->setAttribute('id', $id); } | |
456 | $txfield->setAttribute('name', $name); | |
457 | $txfield->setAttribute('maxlength', $maxlength); | |
458 | $txfield->setAttribute('size', $size); | |
459 | if (!is_null($value)) { $txfield->setAttribute('value', $value); } | |
460 | return $txfield; | |
461 | } | |
462 | ||
61cc8aa9 | 463 | public function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
319cfe8d RK |
464 | $pwfield = $this->createElement('input'); |
465 | $pwfield->setAttribute('type', 'password'); | |
466 | if (!is_null($id)) { $pwfield->setAttribute('id', $id); } | |
467 | $pwfield->setAttribute('name', $name); | |
468 | $pwfield->setAttribute('maxlength', $maxlength); | |
469 | $pwfield->setAttribute('size', $size); | |
470 | if (!is_null($value)) { $pwfield->setAttribute('value', $value); } | |
471 | return $pwfield; | |
645a7eb6 RK |
472 | } |
473 | ||
f925e4a1 RK |
474 | public function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
475 | $numfield = $this->createElement('input'); | |
476 | $numfield->setAttribute('type', 'number'); | |
477 | if (!is_null($id)) { $numfield->setAttribute('id', $id); } | |
478 | $numfield->setAttribute('name', $name); | |
479 | $numfield->setAttribute('maxlength', $maxlength); | |
480 | $numfield->setAttribute('size', $size); | |
481 | if (!is_null($value)) { $numfield->setAttribute('value', $value); } | |
482 | return $numfield; | |
483 | } | |
484 | ||
485 | public function createElementInputRange($name, $id, $min, $max, $step = null, $value = null) { | |
486 | $rgfield = $this->createElement('input'); | |
487 | $rgfield->setAttribute('type', 'range'); | |
488 | if (!is_null($id)) { $rgfield->setAttribute('id', $id); } | |
489 | $rgfield->setAttribute('name', $name); | |
490 | if (!is_null($min)) { $rgfield->setAttribute('min', $min); } | |
491 | if (!is_null($max)) { $rgfield->setAttribute('max', $max); } | |
492 | if (!is_null($step)) { $rgfield->setAttribute('step', $step); } | |
493 | if (!is_null($value)) { $rgfield->setAttribute('value', $value); } | |
494 | return $rgfield; | |
495 | } | |
496 | ||
497 | public function createElementInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
498 | $urlfield = $this->createElement('input'); | |
499 | $urlfield->setAttribute('type', 'url'); | |
500 | if (!is_null($id)) { $urlfield->setAttribute('id', $id); } | |
501 | $urlfield->setAttribute('name', $name); | |
502 | $urlfield->setAttribute('maxlength', $maxlength); | |
503 | $urlfield->setAttribute('size', $size); | |
504 | if (!is_null($value)) { $urlfield->setAttribute('value', $value); } | |
505 | return $urlfield; | |
506 | } | |
507 | ||
508 | public function createElementInputEmail($name, $maxlength, $size, $id = null, $value = null) { | |
509 | $mailfield = $this->createElement('input'); | |
510 | $mailfield->setAttribute('type', 'email'); | |
511 | if (!is_null($id)) { $mailfield->setAttribute('id', $id); } | |
512 | $mailfield->setAttribute('name', $name); | |
513 | $mailfield->setAttribute('maxlength', $maxlength); | |
514 | $mailfield->setAttribute('size', $size); | |
515 | if (!is_null($value)) { $mailfield->setAttribute('value', $value); } | |
516 | return $mailfield; | |
517 | } | |
518 | ||
519 | public function createElementInputTel($name, $maxlength, $size, $id = null, $value = null) { | |
520 | $telfield = $this->createElement('input'); | |
521 | $telfield->setAttribute('type', 'tel'); | |
522 | if (!is_null($id)) { $telfield->setAttribute('id', $id); } | |
523 | $telfield->setAttribute('name', $name); | |
524 | $telfield->setAttribute('maxlength', $maxlength); | |
525 | $telfield->setAttribute('size', $size); | |
526 | if (!is_null($value)) { $telfield->setAttribute('value', $value); } | |
527 | return $telfield; | |
528 | } | |
529 | ||
530 | public function createElementInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
531 | $telfield = $this->createElement('input'); | |
532 | $telfield->setAttribute('type', 'date'); | |
533 | if (!is_null($id)) { $telfield->setAttribute('id', $id); } | |
534 | if (!is_null($min)) { $rgfield->setAttribute('min', $min); } | |
535 | if (!is_null($max)) { $rgfield->setAttribute('max', $max); } | |
536 | if (!is_null($value)) { $telfield->setAttribute('value', $value); } | |
537 | return $telfield; | |
538 | } | |
539 | ||
540 | public function createElementInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
541 | $telfield = $this->createElement('input'); | |
542 | $telfield->setAttribute('type', 'time'); | |
543 | if (!is_null($id)) { $telfield->setAttribute('id', $id); } | |
544 | if (!is_null($min)) { $rgfield->setAttribute('min', $min); } | |
545 | if (!is_null($max)) { $rgfield->setAttribute('max', $max); } | |
546 | if (!is_null($value)) { $telfield->setAttribute('value', $value); } | |
547 | return $telfield; | |
548 | } | |
549 | ||
550 | public function createElementInputColor($name, $id = null, $value = null) { | |
551 | $colfield = $this->createElement('input'); | |
552 | $colfield->setAttribute('type', 'color'); | |
553 | if (!is_null($id)) { $colfield->setAttribute('id', $id); } | |
554 | $colfield->setAttribute('name', $name); | |
555 | if (!is_null($value)) { $colfield->setAttribute('value', $value); } | |
556 | return $colfield; | |
557 | } | |
558 | ||
61cc8aa9 | 559 | public function createElementInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
560 | $radio = $this->createElement('input'); |
561 | $radio->setAttribute('type', 'radio'); | |
562 | $radio->setAttribute('name', $name); | |
4bb9d784 | 563 | if (!is_null($id)) { $radio->setAttribute('id', $id); } |
ae41c41b RK |
564 | $radio->setAttribute('value', $value); |
565 | if ($checked) { $radio->setAttribute('checked', ''); } | |
566 | return $radio; | |
567 | } | |
568 | ||
61cc8aa9 | 569 | public function createElementInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
570 | $cbox = $this->createElement('input'); |
571 | $cbox->setAttribute('type', 'checkbox'); | |
572 | $cbox->setAttribute('name', $name); | |
4bb9d784 | 573 | if (!is_null($id)) { $cbox->setAttribute('id', $id); } |
ae41c41b RK |
574 | $cbox->setAttribute('value', $value); |
575 | if ($checked) { $cbox->setAttribute('checked', ''); } | |
576 | return $cbox; | |
577 | } | |
578 | ||
61cc8aa9 | 579 | public function createElementInputFile($name, $id, $accept) { |
4bb9d784 RK |
580 | $fileinput = $this->createElement('input'); |
581 | $fileinput->setAttribute('type', 'file'); | |
582 | $fileinput->setAttribute('name', $name); | |
583 | if (!is_null($id)) { $fileinput->setAttribute('id', $id); } | |
584 | $fileinput->setAttribute('accept', $accept); | |
585 | return $fileinput; | |
586 | } | |
587 | ||
61cc8aa9 | 588 | public function createElementInputSubmit($value) { |
ae41c41b RK |
589 | $submitbtn = $this->createElement('input'); |
590 | $submitbtn->setAttribute('type', 'submit'); | |
591 | $submitbtn->setAttribute('value', $value); | |
592 | return $submitbtn; | |
593 | } | |
594 | ||
61cc8aa9 | 595 | public function createElementButton($value, $onclick = null) { |
1109f526 RK |
596 | $btn = $this->createElement('input'); |
597 | $btn->setAttribute('type', 'button'); | |
598 | $btn->setAttribute('value', $value); | |
599 | if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); } | |
600 | return $btn; | |
601 | } | |
602 | ||
61cc8aa9 | 603 | public function createElementTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
604 | $txtarea = $this->createElement('textarea', $value); |
605 | $txtarea->setAttribute('name', $name); | |
606 | $txtarea->setAttribute('cols', $columns); | |
607 | $txtarea->setAttribute('rows', $rows); | |
608 | if (!is_null($id)) { $txtarea->setAttribute('id', $id); } | |
609 | return $txtarea; | |
610 | } | |
611 | ||
69409ddb | 612 | public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
bf91764c RK |
613 | $select = $this->createElement('select'); |
614 | $select->setAttribute('name', $name); | |
615 | if (!is_null($id)) { $select->setAttribute('id', $id); } | |
616 | foreach ($options as $key => $desc) { | |
69409ddb | 617 | $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default)); |
bf91764c RK |
618 | } |
619 | return $select; | |
620 | } | |
621 | ||
61cc8aa9 | 622 | public function createElementOption($key, $desc, $selected = false) { |
bf91764c RK |
623 | $option = $this->createElement('option', $desc); |
624 | $option->setAttribute('value', $key); | |
625 | if ($selected) { $option->setAttribute('selected', ''); } | |
626 | return $option; | |
627 | } | |
628 | ||
61cc8aa9 | 629 | public function createElementLabel($for_id, $value) { |
ae41c41b RK |
630 | $label = $this->createElement('label', $value); |
631 | $label->setAttribute('for', $for_id); | |
632 | return $label; | |
cea5b93a RK |
633 | } |
634 | ||
acaa2daa RK |
635 | public function createElementStyle($styledata) { |
636 | $style_elem = $this->createElement('style'); | |
637 | // Note: type can/should be left out for HTML5. | |
638 | $style_elem->setAttribute('type', 'text/css'); | |
639 | $style_elem->appendChild($this->createCDATASection($styledata)); | |
640 | return $style_elem; | |
641 | } | |
642 | ||
61cc8aa9 | 643 | public function createElementJS($jsdata) { |
cea5b93a | 644 | $jselem = $this->createElement('script'); |
ea32f7e5 | 645 | // Note: type can/should be left out for HTML5. |
cea5b93a RK |
646 | $jselem->setAttribute('type', 'text/javascript'); |
647 | $jselem->appendChild($this->createCDATASection($jsdata)); | |
648 | return $jselem; | |
649 | } | |
c1666e91 | 650 | |
8afa2e61 | 651 | public function createElementJSFile($jsURL, $defer = false, $async = false) { |
ea32f7e5 RK |
652 | $jselem = $this->createElement('script'); |
653 | // Note: type can/should be left out for HTML5. | |
654 | $jselem->setAttribute('type', 'text/javascript'); | |
8afa2e61 RK |
655 | if ($defer) { |
656 | $jselem->setAttribute('defer', ''); | |
657 | } | |
658 | if ($async) { | |
659 | $jselem->setAttribute('async', ''); | |
660 | } | |
ea32f7e5 RK |
661 | $jselem->setAttribute('src', $jsURL); |
662 | return $jselem; | |
663 | } | |
cea5b93a RK |
664 | } |
665 | ||
666 | class ExtendedElement extends DOMElement { | |
667 | // ExtendedElement PHP class | |
668 | // this extends the general PHP DOM Element class to simplify some usual constructs | |
669 | // | |
61cc8aa9 | 670 | // public function appendElement($name, [$value]) |
cea5b93a RK |
671 | // appends a DOMDocument::createElement() as a child of this element (see there for params) |
672 | // returns the new child | |
673 | // | |
61cc8aa9 | 674 | // public function appendElementXML($name, $xmldata) |
cea5b93a RK |
675 | // appends a DOMDocument::createElement() with the given name as a child of this element, |
676 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
677 | // returns the new child | |
678 | // | |
b3cc0fef | 679 | // public function appendLink($target, [$value], [$title]) |
cea5b93a RK |
680 | // appends an ExtendedDocument::createElementLink() as a child of this element (see there for params) |
681 | // returns the new child | |
682 | // | |
61cc8aa9 | 683 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
684 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
685 | // returns the new child | |
686 | // | |
61cc8aa9 | 687 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
688 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
689 | // returns the new child | |
690 | // | |
61cc8aa9 | 691 | // public function appendFormDiv($action, $method, $name, [$id]) |
ae41c41b RK |
692 | // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) |
693 | // returns an HTML <div> that is a child of the new child | |
694 | // | |
61cc8aa9 | 695 | // public function appendInputHidden($name, $value) |
ae41c41b RK |
696 | // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params) |
697 | // returns the new child | |
698 | // | |
61cc8aa9 | 699 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
ae41c41b RK |
700 | // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) |
701 | // returns the new child | |
702 | // | |
f925e4a1 RK |
703 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
704 | // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params) | |
705 | // returns the new child | |
706 | // | |
61cc8aa9 | 707 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
708 | // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) |
709 | // returns the new child | |
710 | // | |
f925e4a1 RK |
711 | // public function appendInputRange($name, $id, $min, $max, [$step], [$value]) |
712 | // appends an ExtendedDocument::createElementInputRange() as a child of this element (see there for params) | |
713 | // returns the new child | |
714 | // | |
715 | // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) | |
716 | // appends an ExtendedDocument::createElementInputUrl() as a child of this element (see there for params) | |
717 | // returns the new child | |
718 | // | |
ea32f7e5 RK |
719 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
720 | // appends an ExtendedDocument::createElementInputEmail() as a child of this element (see there for params) | |
721 | // returns the new child | |
722 | // | |
f925e4a1 RK |
723 | // public function appendInputTel($name, $maxlength, $size, [$id], [$value]) |
724 | // appends an ExtendedDocument::createElementInputTel() as a child of this element (see there for params) | |
725 | // returns the new child | |
726 | // | |
727 | // public function appendInputDate($name, [$id], [$min], [$max], [$value]) | |
728 | // appends an ExtendedDocument::createElementInputDate() as a child of this element (see there for params) | |
729 | // returns the new child | |
730 | // | |
731 | // public function appendInputTime($name, [$id], [$min], [$max], [$value]) | |
732 | // appends an ExtendedDocument::createElementInputTime() as a child of this element (see there for params) | |
645a7eb6 RK |
733 | // returns the new child |
734 | // | |
f925e4a1 RK |
735 | // public function appendInputColor($name, [$id], [$value]) |
736 | // appends an ExtendedDocument::createElementInputColor() as a child of this element (see there for params) | |
737 | // | |
61cc8aa9 | 738 | // public function appendInputRadio($name, $id, $value, $checked) |
ae41c41b RK |
739 | // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params) |
740 | // returns the new child | |
741 | // | |
61cc8aa9 | 742 | // public function appendInputCheckbox($name, $id, $value, $checked) |
ae41c41b RK |
743 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params) |
744 | // returns the new child | |
745 | // | |
61cc8aa9 | 746 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
747 | // appends an ExtendedDocument::createElementInputFile() as a child of this element (see there for params) |
748 | // returns the new child | |
749 | // | |
61cc8aa9 | 750 | // public function appendInputSubmit($value) |
ae41c41b RK |
751 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params) |
752 | // returns the new child | |
753 | // | |
61cc8aa9 | 754 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
755 | // appends an ExtendedDocument::createElementButton() as a child of this element (see there for params) |
756 | // returns the new child | |
757 | // | |
61cc8aa9 | 758 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
759 | // appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params) |
760 | // returns the new child | |
761 | // | |
69409ddb | 762 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
763 | // appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params) |
764 | // returns the new child | |
765 | // | |
61cc8aa9 | 766 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
767 | // appends an ExtendedDocument::createElementOption() as a child of this element (see there for params) |
768 | // returns the new child | |
769 | // | |
61cc8aa9 | 770 | // public function appendLabel($for_id, $value) |
ae41c41b RK |
771 | // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params) |
772 | // returns the new child | |
773 | // | |
61cc8aa9 | 774 | // public function appendText($text) |
cea5b93a RK |
775 | // appends a DOMDocument::createTextNode() as a child of this element (see there for params) |
776 | // returns the new child | |
777 | // | |
71771b0c RK |
778 | // public function appendLinebreak() |
779 | // appends a <br> as a child of this element | |
780 | // returns the new child | |
781 | // | |
6638efd5 RK |
782 | // public function appendEntity($name) |
783 | // appends a DOMDocument::createEntityReference() as a child of this element (see there for params) | |
784 | // returns the new child | |
785 | // | |
61cc8aa9 | 786 | // public function appendComment($comment_data) |
cadc5980 RK |
787 | // appends a DOMDocument::createComment() as a child of this element (see there for params) |
788 | // returns the new child | |
789 | // | |
3d4db013 RK |
790 | // public function appendClonedElement($dom_element, [$deep]) |
791 | // appends a clone of the given DOMElement as a child of this element | |
792 | // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) | |
793 | // returns the new child | |
794 | // | |
61cc8aa9 | 795 | // public function appendHTMLMarkup($htmldata) |
ae41c41b RK |
796 | // appends a representation of the HTML data as children of this element |
797 | // NO return value! | |
798 | // | |
61cc8aa9 | 799 | // public function appendXMLMarkup($xmldata) |
ae41c41b | 800 | // appends a representation of the XML data as children of this element |
cea5b93a RK |
801 | // NO return value! |
802 | // | |
acaa2daa RK |
803 | // public function appendStyleElement($styledata) |
804 | // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params) | |
805 | // returns the new child | |
806 | // | |
61cc8aa9 | 807 | // public function appendJSElement($jsdata) |
cea5b93a | 808 | // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params) |
3d4db013 | 809 | // returns the new child |
c1666e91 | 810 | // |
8afa2e61 | 811 | // public function appendJSFile($jsURL, [$defer], [$async]) |
0bbc241e | 812 | // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params) |
ea32f7e5 | 813 | // returns the new child |
f887cdcb RK |
814 | // |
815 | // public function setClass($classname) | |
816 | // sets the 'class' attribute of the element to the given classname value | |
817 | // | |
818 | // public function addClass($classname) | |
819 | // adds the given classname value to the space-separated list in the 'class' attribute | |
820 | // returns the value of the 'class' attribute | |
821 | // | |
822 | // public function setID($elem_id) | |
823 | // sets the 'id' attribute of the element to the given elem_id value | |
cea5b93a | 824 | |
61cc8aa9 | 825 | public function appendElement($name, $value = '') { |
a8816f43 | 826 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
cea5b93a | 827 | } |
61cc8aa9 | 828 | public function appendElementXML($name, $xmldata) { |
cea5b93a | 829 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
ae41c41b | 830 | $aelem->appendXMLMarkup($xmldata); |
cea5b93a RK |
831 | return $aelem; |
832 | } | |
b3cc0fef RK |
833 | public function appendLink($target, $value = '', $title = null) { |
834 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title)); | |
cea5b93a | 835 | } |
61cc8aa9 | 836 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
837 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
838 | } | |
61cc8aa9 | 839 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
840 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
841 | } | |
61cc8aa9 | 842 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 843 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
ae41c41b RK |
844 | return $formelem->appendElement('div'); |
845 | } | |
61cc8aa9 | 846 | public function appendInputHidden($name, $value) { |
ae41c41b RK |
847 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
848 | } | |
61cc8aa9 | 849 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
ae41c41b RK |
850 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
851 | } | |
f925e4a1 RK |
852 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
853 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
854 | } | |
61cc8aa9 | 855 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
856 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
857 | } | |
f925e4a1 RK |
858 | public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { |
859 | return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value)); | |
860 | } | |
861 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
862 | return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
863 | } | |
ea32f7e5 RK |
864 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
865 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
866 | } | |
f925e4a1 RK |
867 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
868 | return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
869 | } | |
870 | public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
871 | return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value)); | |
872 | } | |
873 | public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
874 | return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value)); | |
875 | } | |
876 | public function appendInputColor($name, $id = null, $value = null) { | |
877 | return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); | |
645a7eb6 | 878 | } |
61cc8aa9 | 879 | public function appendInputRadio($name, $id, $value, $checked) { |
ae41c41b RK |
880 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
881 | } | |
61cc8aa9 | 882 | public function appendInputCheckbox($name, $id, $value, $checked) { |
ae41c41b RK |
883 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
884 | } | |
61cc8aa9 | 885 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
886 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
887 | } | |
61cc8aa9 | 888 | public function appendInputSubmit($value) { |
ae41c41b RK |
889 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
890 | } | |
61cc8aa9 | 891 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
892 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
893 | } | |
61cc8aa9 | 894 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
895 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
896 | } | |
69409ddb RK |
897 | public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
898 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch)); | |
bf91764c | 899 | } |
61cc8aa9 | 900 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
901 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
902 | } | |
61cc8aa9 | 903 | public function appendLabel($for_id, $value) { |
bf91764c RK |
904 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
905 | } | |
61cc8aa9 | 906 | public function appendText($text) { |
bf91764c RK |
907 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
908 | } | |
71771b0c RK |
909 | public function appendLinebreak() { |
910 | return $this->appendChild($this->ownerDocument->createElement('br')); | |
911 | } | |
6638efd5 RK |
912 | public function appendEntity($name) { |
913 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
914 | } | |
61cc8aa9 | 915 | public function appendComment($comment_data) { |
cadc5980 RK |
916 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
917 | } | |
3d4db013 RK |
918 | public function appendClonedElement($dom_element, $deep = true) { |
919 | return $this->appendChild($dom_element->cloneNode($deep)); | |
920 | } | |
61cc8aa9 | 921 | public function appendHTMLMarkup($htmldata) { |
bf91764c RK |
922 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
923 | } | |
61cc8aa9 | 924 | public function appendXMLMarkup($xmldata) { |
bf91764c RK |
925 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
926 | } | |
acaa2daa RK |
927 | public function appendStyleElement($styledata) { |
928 | return $this->appendChild($this->ownerDocument->createElementStyle($styledata)); | |
929 | } | |
61cc8aa9 | 930 | public function appendJSElement($jsdata) { |
3d4db013 | 931 | return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
bf91764c | 932 | } |
1a4ee0f0 RK |
933 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
934 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 935 | } |
f887cdcb RK |
936 | public function setClass($classname) { |
937 | $this->setAttribute('class', $classname); | |
938 | } | |
939 | public function addClass($classname) { | |
940 | $classval = $this->getAttribute('class'); | |
941 | if (strlen($classval)) { $classval .= ' '; } | |
942 | $classval .= $classname; | |
943 | $this->setClass($classval); | |
944 | return $classval; | |
945 | } | |
946 | public function setID($elem_id) { | |
947 | $this->setAttribute('id', $elem_id); | |
948 | } | |
bf91764c RK |
949 | } |
950 | ||
951 | class ExtendedDocumentFragment extends DOMDocumentFragment { | |
952 | // ExtendedDocumentFragment PHP class | |
953 | // this extends the general PHP DOM Document Fragment class to simplify some usual constructs | |
954 | // | |
61cc8aa9 | 955 | // public function appendElement($name, [$value]) |
bf91764c RK |
956 | // appends a DOMDocument::createElement() as a child of this fragment (see there for params) |
957 | // returns the new child | |
958 | // | |
61cc8aa9 | 959 | // public function appendElementXML($name, $xmldata) |
bf91764c RK |
960 | // appends a DOMDocument::createElement() with the given name as a child of this fragment, |
961 | // with an ExtendedDocument::createXMLFragment() of the given XML data inside | |
962 | // returns the new child | |
963 | // | |
b3cc0fef | 964 | // public function appendLink($target, [$value], [$title]) |
bf91764c RK |
965 | // appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params) |
966 | // returns the new child | |
967 | // | |
61cc8aa9 | 968 | // public function appendImage($src, [$alt_text]) |
53510e9e RK |
969 | // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) |
970 | // returns the new child | |
971 | // | |
61cc8aa9 | 972 | // public function appendForm($action, $method, $name, [$id]) |
b8d16837 RK |
973 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
974 | // returns the new child | |
975 | // | |
61cc8aa9 | 976 | // public function appendFormDiv($action, $method, $name, [$id]) |
bf91764c RK |
977 | // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) |
978 | // returns an HTML <div> that is a child of the new child | |
979 | // | |
61cc8aa9 | 980 | // public function appendInputHidden($name, $value) |
bf91764c RK |
981 | // appends an ExtendedDocument::createElementInputHidden() as a child of this fragment (see there for params) |
982 | // returns the new child | |
983 | // | |
61cc8aa9 | 984 | // public function appendInputText($name, $maxlength, $size, [$id], [$value]) |
bf91764c RK |
985 | // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) |
986 | // returns the new child | |
987 | // | |
f925e4a1 RK |
988 | // public function appendInputPassword($name, $maxlength, $size, [$id], [$value]) |
989 | // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params) | |
990 | // returns the new child | |
991 | // | |
61cc8aa9 | 992 | // public function appendInputNumber($name, $maxlength, $size, [$id], [$value]) |
262e0bbb RK |
993 | // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) |
994 | // returns the new child | |
995 | // | |
f925e4a1 RK |
996 | // public function appendInputRange($name, $id, $min, $max, [$step], [$value]) |
997 | // appends an ExtendedDocument::createElementInputRange() as a child of this fragment (see there for params) | |
998 | // returns the new child | |
999 | // | |
1000 | // public function appendInputUrl($name, $maxlength, $size, [$id], [$value]) | |
1001 | // appends an ExtendedDocument::createElementInputUrl() as a child of this fragment (see there for params) | |
1002 | // returns the new child | |
1003 | // | |
ea32f7e5 RK |
1004 | // public function appendInputEmail($name, $maxlength, $size, [$id], [$value]) |
1005 | // appends an ExtendedDocument::createElementInputEmail() as a child of this fragment (see there for params) | |
1006 | // returns the new child | |
1007 | // | |
f925e4a1 RK |
1008 | // public function appendInputTel($name, $maxlength, $size, [$id], [$value]) |
1009 | // appends an ExtendedDocument::createElementInputTel() as a child of this fragment (see there for params) | |
645a7eb6 RK |
1010 | // returns the new child |
1011 | // | |
f925e4a1 RK |
1012 | // public function appendInputDate($name, [$id], [$min], [$max], [$value]) |
1013 | // appends an ExtendedDocument::createElementInputDate() as a child of this fragment (see there for params) | |
1014 | // returns the new child | |
1015 | // | |
1016 | // public function appendInputTime($name, [$id], [$min], [$max], [$value]) | |
1017 | // appends an ExtendedDocument::createElementInputTime() as a child of this fragment (see there for params) | |
1018 | // returns the new child | |
1019 | // | |
1020 | // public function appendInputColor($name, [$id], [$value]) | |
1021 | // appends an ExtendedDocument::createElementInputColor() as a child of this fragment (see there for params) | |
1022 | // | |
61cc8aa9 | 1023 | // public function appendInputRadio($name, $id, $value, $checked) |
bf91764c RK |
1024 | // appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params) |
1025 | // returns the new child | |
1026 | // | |
61cc8aa9 | 1027 | // public function appendInputCheckbox($name, $id, $value, $checked) |
bf91764c RK |
1028 | // appends an ExtendedDocument::createElementInputCheckbox() as a child of this fragment (see there for params) |
1029 | // returns the new child | |
1030 | // | |
61cc8aa9 | 1031 | // public function appendInputFile($name, $id, $accept) |
4bb9d784 RK |
1032 | // appends an ExtendedDocument::createElementInputFile() as a child of this fragment (see there for params) |
1033 | // returns the new child | |
1034 | // | |
61cc8aa9 | 1035 | // public function appendInputSubmit($value) |
bf91764c RK |
1036 | // appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params) |
1037 | // returns the new child | |
1038 | // | |
61cc8aa9 | 1039 | // public function appendButton($value, $onclick = null) |
1109f526 RK |
1040 | // appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params) |
1041 | // returns the new child | |
1042 | // | |
61cc8aa9 | 1043 | // public function appendTextArea($name, $columns, $rows, [$id], [$value]) |
bf91764c RK |
1044 | // appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params) |
1045 | // returns the new child | |
1046 | // | |
69409ddb | 1047 | // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch]) |
bf91764c RK |
1048 | // appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params) |
1049 | // returns the new child | |
1050 | // | |
61cc8aa9 | 1051 | // public function appendElementOption($key, $desc, [$selected]) |
bf91764c RK |
1052 | // appends an ExtendedDocument::createElementOption() as a child of this fragment (see there for params) |
1053 | // returns the new child | |
1054 | // | |
61cc8aa9 | 1055 | // public function appendLabel($for_id, $value) |
bf91764c RK |
1056 | // appends an ExtendedDocument::createElementLabel() as a child of this fragment (see there for params) |
1057 | // returns the new child | |
1058 | // | |
61cc8aa9 | 1059 | // public function appendText($text) |
bf91764c RK |
1060 | // appends a DOMDocument::createTextNode() as a child of this fragment (see there for params) |
1061 | // returns the new child | |
1062 | // | |
71771b0c RK |
1063 | // public function appendLinebreak() |
1064 | // appends a <br> as a child of this fragment | |
1065 | // returns the new child | |
1066 | // | |
6638efd5 RK |
1067 | // public function appendEntity($name) |
1068 | // appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params) | |
1069 | // returns the new child | |
1070 | // | |
61cc8aa9 | 1071 | // public function appendComment($comment_data) |
cadc5980 RK |
1072 | // appends a DOMDocument::createComment() as a child of this fragment (see there for params) |
1073 | // returns the new child | |
1074 | // | |
3d4db013 RK |
1075 | // public function appendClonedElement($dom_element, [$deep]) |
1076 | // appends a clone of the given DOMElement as a child of this fragment | |
1077 | // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) | |
1078 | // returns the new child | |
1079 | // | |
61cc8aa9 | 1080 | // public function appendHTMLMarkup($htmldata) |
bf91764c RK |
1081 | // appends a representation of the HTML data as children of this fragment |
1082 | // NO return value! | |
1083 | // | |
61cc8aa9 | 1084 | // public function appendXMLMarkup($xmldata) |
bf91764c RK |
1085 | // appends a representation of the XML data as children of this fragment |
1086 | // NO return value! | |
1087 | // | |
acaa2daa RK |
1088 | // public function appendStyleElement($styledata) |
1089 | // appends an ExtendedDocument::createElementStyle() as a child of this element (see there for params) | |
1090 | // returns the new child | |
1091 | // | |
61cc8aa9 | 1092 | // public function appendJSElement($jsdata) |
bf91764c | 1093 | // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params) |
3d4db013 | 1094 | // returns the new child |
c1666e91 | 1095 | // |
8afa2e61 | 1096 | // public function appendJSFile($jsURL, [$defer], [$async]) |
0bbc241e | 1097 | // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params) |
ea32f7e5 | 1098 | // returns the new child |
bf91764c | 1099 | |
61cc8aa9 | 1100 | public function appendElement($name, $value = '') { |
a8816f43 | 1101 | return $this->appendChild($this->ownerDocument->createElement($name, $value)); |
bf91764c | 1102 | } |
61cc8aa9 | 1103 | public function appendElementXML($name, $xmldata) { |
bf91764c RK |
1104 | $aelem = $this->appendChild($this->ownerDocument->createElement($name)); |
1105 | $aelem->appendXMLMarkup($xmldata); | |
1106 | return $aelem; | |
1107 | } | |
b3cc0fef RK |
1108 | public function appendLink($target, $value = '', $title = null) { |
1109 | return $this->appendChild($this->ownerDocument->createElementLink($target, $value, $title)); | |
bf91764c | 1110 | } |
61cc8aa9 | 1111 | public function appendImage($src, $alt_text = '') { |
53510e9e RK |
1112 | return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); |
1113 | } | |
61cc8aa9 | 1114 | public function appendForm($action, $method, $name, $id = null) { |
b8d16837 RK |
1115 | return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
1116 | } | |
61cc8aa9 | 1117 | public function appendFormDiv($action, $method, $name, $id = null) { |
b8d16837 | 1118 | $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); |
bf91764c RK |
1119 | return $formelem->appendElement('div'); |
1120 | } | |
61cc8aa9 | 1121 | public function appendInputHidden($name, $value) { |
bf91764c RK |
1122 | return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value)); |
1123 | } | |
61cc8aa9 | 1124 | public function appendInputText($name, $maxlength, $size, $id = null, $value = null) { |
bf91764c | 1125 | return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); |
645a7eb6 | 1126 | } |
f925e4a1 RK |
1127 | public function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { |
1128 | return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); | |
1129 | } | |
61cc8aa9 | 1130 | public function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { |
262e0bbb RK |
1131 | return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); |
1132 | } | |
f925e4a1 RK |
1133 | public function appendInputRange($name, $id, $min, $max, $step = null, $value = null) { |
1134 | return $this->appendChild($this->ownerDocument->createElementInputRange($name, $id, $min, $max, $step, $value)); | |
1135 | } | |
1136 | public function appendInputUrl($name, $maxlength, $size, $id = null, $value = null) { | |
1137 | return $this->appendChild($this->ownerDocument->createElementInputUrl($name, $maxlength, $size, $id, $value)); | |
1138 | } | |
ea32f7e5 RK |
1139 | public function appendInputEmail($name, $maxlength, $size, $id = null, $value = null) { |
1140 | return $this->appendChild($this->ownerDocument->createElementInputEmail($name, $maxlength, $size, $id, $value)); | |
1141 | } | |
f925e4a1 RK |
1142 | public function appendInputTel($name, $maxlength, $size, $id = null, $value = null) { |
1143 | return $this->appendChild($this->ownerDocument->createElementInputTel($name, $maxlength, $size, $id, $value)); | |
1144 | } | |
1145 | public function appendInputDate($name, $id = null, $min = null, $max = null, $value = null) { | |
1146 | return $this->appendChild($this->ownerDocument->createElementInputDate($name, $id, $min, $max, $value)); | |
1147 | } | |
1148 | public function appendInputTime($name, $id = null, $min = null, $max = null, $value = null) { | |
1149 | return $this->appendChild($this->ownerDocument->createElementInputTime($name, $id, $min, $max, $value)); | |
1150 | } | |
1151 | public function appendInputColor($name, $id = null, $value = null) { | |
1152 | return $this->appendChild($this->ownerDocument->createElementInputColor($name, $id, $value)); | |
bf91764c | 1153 | } |
61cc8aa9 | 1154 | public function appendInputRadio($name, $id, $value, $checked) { |
bf91764c RK |
1155 | return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked)); |
1156 | } | |
61cc8aa9 | 1157 | public function appendInputCheckbox($name, $id, $value, $checked) { |
bf91764c RK |
1158 | return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked)); |
1159 | } | |
61cc8aa9 | 1160 | public function appendInputFile($name, $id, $accept) { |
4bb9d784 RK |
1161 | return $this->appendChild($this->ownerDocument->createElementInputFile($name, $id, $accept)); |
1162 | } | |
61cc8aa9 | 1163 | public function appendInputSubmit($value) { |
bf91764c RK |
1164 | return $this->appendChild($this->ownerDocument->createElementInputSubmit($value)); |
1165 | } | |
61cc8aa9 | 1166 | public function appendButton($value, $onclick = null) { |
1109f526 RK |
1167 | return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick)); |
1168 | } | |
61cc8aa9 | 1169 | public function appendTextArea($name, $columns, $rows, $id = null, $value = null) { |
bf91764c RK |
1170 | return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value)); |
1171 | } | |
69409ddb RK |
1172 | public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) { |
1173 | return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch)); | |
bf91764c | 1174 | } |
61cc8aa9 | 1175 | public function appendElementOption($key, $desc, $selected = false) { |
bf91764c RK |
1176 | return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected)); |
1177 | } | |
61cc8aa9 | 1178 | public function appendLabel($for_id, $value) { |
ae41c41b RK |
1179 | return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value)); |
1180 | } | |
61cc8aa9 | 1181 | public function appendText($text) { |
cea5b93a RK |
1182 | return $this->appendChild($this->ownerDocument->createTextNode($text)); |
1183 | } | |
71771b0c RK |
1184 | public function appendLinebreak() { |
1185 | return $this->appendChild($this->ownerDocument->createElement('br')); | |
1186 | } | |
6638efd5 RK |
1187 | public function appendEntity($name) { |
1188 | return $this->appendChild($this->ownerDocument->createEntityReference($name)); | |
1189 | } | |
61cc8aa9 | 1190 | public function appendComment($comment_data) { |
cadc5980 RK |
1191 | return $this->appendChild($this->ownerDocument->createComment($comment_data)); |
1192 | } | |
3d4db013 RK |
1193 | public function appendClonedElement($dom_element, $deep = true) { |
1194 | return $this->appendChild($dom_element->cloneNode($deep)); | |
1195 | } | |
61cc8aa9 | 1196 | public function appendHTMLMarkup($htmldata) { |
ae41c41b RK |
1197 | $this->ownerDocument->appendHTMLMarkup($htmldata, $this); |
1198 | } | |
61cc8aa9 | 1199 | public function appendXMLMarkup($xmldata) { |
ae41c41b | 1200 | $this->ownerDocument->appendXMLMarkup($xmldata, $this); |
cea5b93a | 1201 | } |
acaa2daa RK |
1202 | public function appendStyleElement($styledata) { |
1203 | return $this->appendChild($this->ownerDocument->createElementStyle($styledata)); | |
1204 | } | |
61cc8aa9 | 1205 | public function appendJSElement($jsdata) { |
3d4db013 | 1206 | return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); |
cea5b93a | 1207 | } |
1a4ee0f0 RK |
1208 | public function appendJSFile($jsURL, $defer = false, $async = false) { |
1209 | return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); | |
ea32f7e5 | 1210 | } |
cea5b93a RK |
1211 | } |
1212 | ?> |