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