// CONSTRUCTOR
// construct a new DOM Document that uses our element definitions
//
+ // private $xmheader
+ // the default XML header
+ //
+ // private $xhtmldtype
+ // the XHTML doctype to use by default
+ //
// function appendElement($name, [$value])
// appends a DOMDocument::createElement() as a child of this document (see there for params)
// returns the new child
// appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
// returns the new child
//
+ // function appendFormDiv($action, $method, $name)
+ // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params)
+ // returns an HTML <div> that is a child of the new child
+ //
+ // function appendInputHidden($name, $value)
+ // appends an ExtendedDocument::createElementInputHidden() as a child of this document (see there for params)
+ // returns the new child
+ //
+ // function appendInputText($name, $maxlength, $size, [$id], [$value])
+ // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
+ // returns the new child
+ //
+ // function appendInputRadio($name, $id, $value, $checked)
+ // appends an ExtendedDocument::createElementInputRadio() as a child of this document (see there for params)
+ // returns the new child
+ //
+ // function appendInputCheckbox($name, $id, $value, $checked)
+ // appends an ExtendedDocument::createElementInputCheckbox() as a child of this document (see there for params)
+ // returns the new child
+ //
+ // function appendInputSubmit($value)
+ // appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
+ // returns the new child
+ //
+ // function appendLabel($for_id, $value)
+ // appends an ExtendedDocument::createElementLabel() as a child of this document (see there for params)
+ // returns the new child
+ //
// function appendText($text)
// appends a DOMDocument::createTextNode() as a child of this document (see there for params)
// returns the new child
//
- // function appendRawMarkup($markupdata)
- // appends an ExtendedDocument::createElementRawMarkup() as a child of this document (see there for params)
+ // function appendHTMLMarkup($htmldata, [$parentNode])
+ // appends a representation of the HTML data as children of the given parent node, by default this document
+ // NO return value!
+ //
+ // function appendXMLMarkup($xmldata, [$parentNode])
+ // appends a representation of the XML data as children of the given parent node, by default this document
// NO return value!
//
// function appendJSElement($jsdata)
// appends an ExtendedDocument::createElementJS() as a child of this document (see there for params)
// NO return value!
//
- // function createXMLFragment($xmldata)
- // returns a DOMDocumentFragment containing the DOM of the given XML data
- //
// function createElementLink($target, [$value])
// returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
//
- // function createElementRawMarkup($markupdata)
- // returns a DOMNode containing a representation of the given raw markup data
+ // function createElementForm($action, $method, $name)
+ // returns an ExtendedElement that is an HTML <div> that is a child of an HTML <form>
+ // with the given action, method, and name
+ //
+ // function createElementInputHidden($name, $value)
+ // returns an ExtendedElement that is an HTML <input> of type 'hidden' with the given name and value
+ //
+ // function createElementInputText($name, $maxlength, $size, [$id], [$value])
+ // returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
+ // and optionally id and value
+ //
+ // function createElementInputRadio($name, $id, $value, $checked)
+ // returns an ExtendedElement that is an HTML <input> of type 'radio' with the given name, id, value and
+ // checked state
+ //
+ // function createElementInputCheckbox($name, $id, $value, $checked)
+ // returns an ExtendedElement that is an HTML <input> of type 'checkbox' with the given name, id, value and
+ // checked state
+ //
+ // function createElementInputSubmit($value)
+ // returns an ExtendedElement that is an HTML <input> of type 'submit' with the given name and value
+ //
+ // function createElementLabel($for_id, $value)
+ // returns an ExtendedElement that is an HTML <label> with the given 'for' and value
//
// function createElementJS($jsdata)
// returns an ExtendedElement that is an HTML <script> of JavaScript type with the JS data inside
}
function appendElementXML($name, $xmldata) {
$aelem = $this->appendChild($this->createElement($name));
- $aelem->appendChild($this->createXMLFragment($xmldata));
+ $aelem->appendXMLMarkup($xmldata);
+ //$aelem->appendChild($this->createXMLFragment($xmldata));
return $aelem;
}
function appendLink($target, $value = '') {
return $this->appendChild($this->createElementLink($target, $value));
}
+ function appendFormDiv($action, $method, $name) {
+ $formelem = $this->appendChild($this->createElementForm($action, $method, $name));
+ return $formelem->appendElement('div');
+ }
+ function appendInputHidden($name, $value) {
+ return $this->appendChild($this->createElementInputHidden($name, $value));
+ }
+ function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
+ return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
+ }
+ function appendInputRadio($name, $id, $value, $checked) {
+ return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
+ }
+ function appendInputCheckbox($name, $id, $value, $checked) {
+ return $this->appendChild($this->createElementInputCheckbox($name, $id, $value, $checked));
+ }
+ function appendInputSubmit($value) {
+ return $this->appendChild($this->createElementInputSubmit($value));
+ }
+ function appendLabel($for_id, $value) {
+ return $this->appendChild($this->createElementLabel($for_id, $value));
+ }
function appendText($text) {
return $this->appendChild($this->createTextNode($text));
}
- function appendRawMarkup($markupdata) {
- $this->appendChild($this->createElementRawMarkup($markupdata));
- }
function appendJSElement($jsdata) {
$this->appendChild($this->createElementJS($jsdata));
}
- function createXMLFragment($xmldata) {
- $xmlfragment = $this->createDocumentFragment();
- $xmlfragment->appendXML($xmldata);
- return $xmlfragment;
+ function appendHTMLMarkup($htmldata, $parentNode = null) {
+ if (is_null($parentNode)) { $parentNode =& $this; }
+ // XXX: just a workaround for now!
+ $parentNode->appendChild($this->createCDATASection($htmldata));
+ }
+
+ function appendXMLMarkup($xmldata, $parentNode = null) {
+ if (is_null($parentNode)) { $parentNode =& $this; }
+ $tmpdoc = new ExtendedDocument;
+ $tmpxml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
+ $tmpxml .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'."\n";
+ $tmpxml .= '<root>'.$xmldata.'</root>';
+ $tmpdoc->loadXML($tmpxml);
+ foreach ($tmpdoc->getElementsByTagName('root')->item(0)->childNodes as $child) {
+ $parentNode->appendChild($this->importNode($child, true));
+ }
}
function createElementLink($target, $value = '') {
return $link;
}
- function createElementRawMarkup($markupdata) {
- // XXX: just a workaround for now!
- return $this->createCDATASection($markupdata);
+ function createElementForm($action, $method, $name) {
+ $formelem = $this->createElement('form');
+ $formelem->setAttribute('action', $action);
+ $formelem->setAttribute('method', $method);
+ $formelem->setAttribute('name', $name);
+ return $formelem;
+ }
+
+ function createElementInputHidden($name, $value) {
+ $hidden = $this->createElement('input');
+ $hidden->setAttribute('type', 'hidden');
+ $hidden->setAttribute('name', $name);
+ $hidden->setAttribute('value', $value);
+ return $hidden;
+ }
+
+ function createElementInputText($name, $maxlength, $size, $id = null, $value = null) {
+ $txfield = $this->createElement('input');
+ $txfield->setAttribute('type', 'text');
+ if (!is_null($id)) { $txfield->setAttribute('id', $id); }
+ $txfield->setAttribute('name', $name);
+ $txfield->setAttribute('maxlength', $maxlength);
+ $txfield->setAttribute('size', $size);
+ if (!is_null($value)) { $txfield->setAttribute('value', $value); }
+ return $txfield;
+ }
+
+ function createElementInputRadio($name, $id, $value, $checked) {
+ $radio = $this->createElement('input');
+ $radio->setAttribute('type', 'radio');
+ $radio->setAttribute('name', $name);
+ $radio->setAttribute('id', $id);
+ $radio->setAttribute('value', $value);
+ if ($checked) { $radio->setAttribute('checked', ''); }
+ return $radio;
+ }
+
+ function createElementInputCheckbox($name, $id, $value, $checked) {
+ $cbox = $this->createElement('input');
+ $cbox->setAttribute('type', 'checkbox');
+ $cbox->setAttribute('name', $name);
+ $cbox->setAttribute('id', $id);
+ $cbox->setAttribute('value', $value);
+ if ($checked) { $cbox->setAttribute('checked', ''); }
+ return $cbox;
+ }
+
+ function createElementInputSubmit($value) {
+ $submitbtn = $this->createElement('input');
+ $submitbtn->setAttribute('type', 'submit');
+ $submitbtn->setAttribute('value', $value);
+ return $submitbtn;
+ }
+
+ function createElementLabel($for_id, $value) {
+ $label = $this->createElement('label', $value);
+ $label->setAttribute('for', $for_id);
+ return $label;
}
function createElementJS($jsdata) {
// appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
// returns the new child
//
+ // function appendFormDiv($action, $method, $name)
+ // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params)
+ // returns an HTML <div> that is a child of the new child
+ //
+ // function appendInputHidden($name, $value)
+ // appends an ExtendedDocument::createElementInputHidden() as a child of this element (see there for params)
+ // returns the new child
+ //
+ // function appendInputText($name, $maxlength, $size, [$id], [$value])
+ // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
+ // returns the new child
+ //
+ // function appendInputRadio($name, $id, $value, $checked)
+ // appends an ExtendedDocument::createElementInputRadio() as a child of this element (see there for params)
+ // returns the new child
+ //
+ // function appendInputCheckbox($name, $id, $value, $checked)
+ // appends an ExtendedDocument::createElementInputCheckbox() as a child of this element (see there for params)
+ // returns the new child
+ //
+ // function appendInputSubmit($value)
+ // appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
+ // returns the new child
+ //
+ // function appendLabel($for_id, $value)
+ // appends an ExtendedDocument::createElementLabel() as a child of this element (see there for params)
+ // returns the new child
+ //
// function appendText($text)
// appends a DOMDocument::createTextNode() as a child of this element (see there for params)
// returns the new child
//
- // function appendRawMarkup($markupdata)
- // appends an ExtendedDocument::createElementRawMarkup() as a child of this element (see there for params)
+ // function appendHTMLMarkup($htmldata)
+ // appends a representation of the HTML data as children of this element
+ // NO return value!
+ //
+ // function appendXMLMarkup($xmldata)
+ // appends a representation of the XML data as children of this element
// NO return value!
//
// function appendJSElement($jsdata)
}
function appendElementXML($name, $xmldata) {
$aelem = $this->appendChild($this->ownerDocument->createElement($name));
- $aelem->appendChild($this->ownerDocument->createXMLFragment($xmldata));
+ $aelem->appendXMLMarkup($xmldata);
return $aelem;
}
function appendLink($target, $value = '') {
return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
}
+ function appendFormDiv($action, $method, $name) {
+ $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name));
+ return $formelem->appendElement('div');
+ }
+ function appendInputHidden($name, $value) {
+ return $this->appendChild($this->ownerDocument->createElementInputHidden($name, $value));
+ }
+ function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
+ return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
+ }
+ function appendInputRadio($name, $id, $value, $checked) {
+ return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
+ }
+ function appendInputCheckbox($name, $id, $value, $checked) {
+ return $this->appendChild($this->ownerDocument->createElementInputCheckbox($name, $id, $value, $checked));
+ }
+ function appendInputSubmit($value) {
+ return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
+ }
+ function appendLabel($for_id, $value) {
+ return $this->appendChild($this->ownerDocument->createElementLabel($for_id, $value));
+ }
function appendText($text) {
return $this->appendChild($this->ownerDocument->createTextNode($text));
}
- function appendRawMarkup($markupdata) {
- $this->appendChild($this->ownerDocument->createElementRawMarkup($markupdata));
+ function appendHTMLMarkup($htmldata) {
+ $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
+ }
+ function appendXMLMarkup($xmldata) {
+ $this->ownerDocument->appendXMLMarkup($xmldata, $this);
}
function appendJSElement($jsdata) {
$this->appendChild($this->ownerDocument->createElementJS($jsdata));