// appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
// returns the new child
//
- // public function appendElementSelect($name, [$id], [$options], [$default])
+ // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
// appends an ExtendedDocument::createElementSelect() as a child of this document (see there for params)
// returns the new child
//
// appends a DOMDocument::createTextNode() as a child of this document (see there for params)
// returns the new child
//
+ // public function appendLinebreak()
+ // appends a <br> as a child of this document
+ // returns the new child
+ //
// public function appendEntity($name)
// appends a DOMDocument::createEntityReference() as a child of this document (see there for params)
// returns the new child
// returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
// and optionally id and value
//
- // public function createElementSelect($name, [$id], [$options], [$default])
+ // public function createElementSelect($name, [$id], [$options], [$default], [$strictmatch])
// returns an ExtendedElement that is an HTML <select> with the given name, and optionally id,
- // array of options (key => description) and key of the by-default selected entry
+ // array of options (key => description) and key of the by-default selected entry (matched including type when strictmatch is true)
//
// public function createElementOption($key, $desc, [$selected])
// returns an ExtendedElement that is an HTML <option> with the given key (value) and description (content)
public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
}
- public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
- return $this->appendChild($this->createElementSelect($name, $id, $options, $default));
+ public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+ return $this->appendChild($this->createElementSelect($name, $id, $options, $default, $strictmatch));
}
public function appendElementOption($key, $desc, $selected = false) {
return $this->appendChild($this->createElementOption($key, $desc, $selected));
public function appendText($text) {
return $this->appendChild($this->createTextNode($text));
}
+ public function appendLinebreak() {
+ return $this->appendChild($this->createElement('br'));
+ }
public function appendEntity($name) {
return $this->appendChild($this->createEntityReference($name));
}
}
public function createElementLink($target, $value = '') {
- $link = $this->createElement('a', $value);
+ $link = $this->createElement('a', (strlen($value) ? $value : $target));
$link->setAttribute('href', $target); // XXX: take care of & etc. in links
return $link;
}
return $txtarea;
}
- public function createElementSelect($name, $id = null, $options = array(), $default = null) {
+ public function createElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
$select = $this->createElement('select');
$select->setAttribute('name', $name);
if (!is_null($id)) { $select->setAttribute('id', $id); }
foreach ($options as $key => $desc) {
- $select->appendElementOption($key, $desc, ($key == $default));
+ $select->appendElementOption($key, $desc, $strictmatch ? ($key === $default) : ($key == $default));
}
return $select;
}
// appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
// returns the new child
//
- // public function appendElementSelect($name, [$id], [$options], [$default])
+ // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
// appends an ExtendedDocument::createElementSelect() as a child of this element (see there for params)
// returns the new child
//
// appends a DOMDocument::createTextNode() as a child of this element (see there for params)
// returns the new child
//
+ // public function appendLinebreak()
+ // appends a <br> as a child of this element
+ // returns the new child
+ //
// public function appendEntity($name)
// appends a DOMDocument::createEntityReference() as a child of this element (see there for params)
// returns the new child
// public function appendJSFile($jsURL, [$defer], [$async])
// appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params)
// returns the new child
+ //
+ // public function setClass($classname)
+ // sets the 'class' attribute of the element to the given classname value
+ //
+ // public function addClass($classname)
+ // adds the given classname value to the space-separated list in the 'class' attribute
+ // returns the value of the 'class' attribute
+ //
+ // public function setID($elem_id)
+ // sets the 'id' attribute of the element to the given elem_id value
public function appendElement($name, $value = '') {
return $this->appendChild($this->ownerDocument->createElement($name, $value));
public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
}
- public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
- return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
+ public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+ return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
}
public function appendElementOption($key, $desc, $selected = false) {
return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
public function appendText($text) {
return $this->appendChild($this->ownerDocument->createTextNode($text));
}
+ public function appendLinebreak() {
+ return $this->appendChild($this->ownerDocument->createElement('br'));
+ }
public function appendEntity($name) {
return $this->appendChild($this->ownerDocument->createEntityReference($name));
}
public function appendJSFile($jsdata, $defer = false, $async = false) {
return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async));
}
+ public function setClass($classname) {
+ $this->setAttribute('class', $classname);
+ }
+ public function addClass($classname) {
+ $classval = $this->getAttribute('class');
+ if (strlen($classval)) { $classval .= ' '; }
+ $classval .= $classname;
+ $this->setClass($classval);
+ return $classval;
+ }
+ public function setID($elem_id) {
+ $this->setAttribute('id', $elem_id);
+ }
}
class ExtendedDocumentFragment extends DOMDocumentFragment {
// appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
// returns the new child
//
- // public function appendElementSelect($name, [$id], [$options], [$default])
+ // public function appendElementSelect($name, [$id], [$options], [$default], [$strictmatch])
// appends an ExtendedDocument::createElementSelect() as a child of this fragment (see there for params)
// returns the new child
//
// appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
// returns the new child
//
+ // public function appendLinebreak()
+ // appends a <br> as a child of this fragment
+ // returns the new child
+ //
// public function appendEntity($name)
// appends a DOMDocument::createEntityReference() as a child of this fragment (see there for params)
// returns the new child
public function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
}
- public function appendElementSelect($name, $id = null, $options = array(), $default = null) {
- return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default));
+ public function appendElementSelect($name, $id = null, $options = array(), $default = null, $strictmatch = false) {
+ return $this->appendChild($this->ownerDocument->createElementSelect($name, $id, $options, $default, $strictmatch));
}
public function appendElementOption($key, $desc, $selected = false) {
return $this->appendChild($this->ownerDocument->createElementOption($key, $desc, $selected));
public function appendText($text) {
return $this->appendChild($this->ownerDocument->createTextNode($text));
}
+ public function appendLinebreak() {
+ return $this->appendChild($this->ownerDocument->createElement('br'));
+ }
public function appendEntity($name) {
return $this->appendChild($this->ownerDocument->createEntityReference($name));
}