add methods for password fields
[php-utility-classes.git] / include / cbsm / util / document.php-class
index e641d23c56364fec3610153d65803280cf03c726..a10041a9dc6c2b2e9cfaeb02b5816978e694f680 100755 (executable)
@@ -46,6 +46,10 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementLink() as a child of this document (see there for params)
   //     returns the new child
   //
+  // function appendImage($src, [$alt_text])
+  //   appends an ExtendedDocument::createElementImage() 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
@@ -58,6 +62,10 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params)
   //     returns the new child
   //
+  // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() 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
@@ -70,6 +78,10 @@ class ExtendedDocument extends DOMDocument {
   //   appends an ExtendedDocument::createElementInputSubmit() as a child of this document (see there for params)
   //     returns the new child
   //
+  // function appendButton($value, $onclick = null)
+  //   appends an ExtendedDocument::createElementButton() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // function appendTextArea($name, $columns, $rows, [$id], [$value])
   //   appends an ExtendedDocument::createElementTextArea() as a child of this document (see there for params)
   //     returns the new child
@@ -90,6 +102,10 @@ class ExtendedDocument extends DOMDocument {
   //   appends a DOMDocument::createTextNode() as a child of this document (see there for params)
   //     returns the new child
   //
+  // function appendComment($comment_data)
+  //   appends a DOMDocument::createComment() as a child of this document (see there for params)
+  //     returns the new child
+  //
   // 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!
@@ -109,6 +125,9 @@ class ExtendedDocument extends DOMDocument {
   // function createElementLink($target, [$value])
   //   returns an ExtendedElement that is an HTML <a> with the given target (href) and (optional) value
   //
+  // function createElementImage($src, [$alt_text])
+  //   returns an ExtendedElement that is an HTML <img> with the given (src) and alt attributes (set to '' by default)
+  //
   // 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
@@ -120,6 +139,10 @@ class ExtendedDocument extends DOMDocument {
   //   returns an ExtendedElement that is an HTML <input> of type 'text' with the given name, maxlength, size,
   //   and optionally id and value
   //
+  // function createElementInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   returns an ExtendedElement that is an HTML <input> of type 'password' 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
@@ -129,7 +152,10 @@ class ExtendedDocument extends DOMDocument {
   //   checked state
   //
   // function createElementInputSubmit($value)
-  //   returns an ExtendedElement that is an HTML <input> of type 'submit' with the given name and value
+  //   returns an ExtendedElement that is an HTML <input> of type 'submit' with the given value as label
+  //
+  // function createElementButton($value, $onclick = null)
+  //   returns an ExtendedElement that is an HTML button with the given value as label and optionally onclick attribute
   //
   // function createElementTextArea($name, $columns, $rows, [$id], [$value])
   //   returns an ExtendedElement that is an HTML <textarea> with the given name, columns, rows,
@@ -172,6 +198,9 @@ class ExtendedDocument extends DOMDocument {
   function appendLink($target, $value = '') {
     return $this->appendChild($this->createElementLink($target, $value));
   }
+  function appendImage($src, $alt_text = '') {
+    return $this->appendChild($this->createElementImage($src, $alt_text));
+  }
   function appendFormDiv($action, $method, $name) {
     $formelem = $this->appendChild($this->createElementForm($action, $method, $name));
     return $formelem->appendElement('div');
@@ -182,6 +211,9 @@ class ExtendedDocument extends DOMDocument {
   function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->createElementInputRadio($name, $id, $value, $checked));
   }
@@ -191,6 +223,9 @@ class ExtendedDocument extends DOMDocument {
   function appendInputSubmit($value) {
     return $this->appendChild($this->createElementInputSubmit($value));
   }
+  function appendButton($value, $onclick = null) {
+    return $this->appendChild($this->createElementButton($value, $onclick));
+  }
   function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->createElementTextArea($name, $columns, $rows, $id, $value));
   }
@@ -206,6 +241,9 @@ class ExtendedDocument extends DOMDocument {
   function appendText($text) {
     return $this->appendChild($this->createTextNode($text));
   }
+  function appendComment($comment_data) {
+    return $this->appendChild($this->createComment($comment_data));
+  }
   function appendJSElement($jsdata) {
     $this->appendChild($this->createElementJS($jsdata));
   }
@@ -237,6 +275,13 @@ class ExtendedDocument extends DOMDocument {
     return $link;
   }
 
+  function createElementImage($src, $alt_text = '') {
+    $link = $this->createElement('img');
+    $link->setAttribute('src', $src);
+    $link->setAttribute('alt', $alt_text);
+    return $link;
+  }
+
   function createElementForm($action, $method, $name) {
     $formelem = $this->createElement('form');
     $formelem->setAttribute('action', $action);
@@ -264,6 +309,17 @@ class ExtendedDocument extends DOMDocument {
     return $txfield;
   }
 
+  function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    $txfield = $this->createElement('input');
+    $txfield->setAttribute('type', 'password');
+    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');
@@ -291,6 +347,14 @@ class ExtendedDocument extends DOMDocument {
     return $submitbtn;
   }
 
+  function createElementButton($value, $onclick = null) {
+    $btn = $this->createElement('input');
+    $btn->setAttribute('type', 'button');
+    $btn->setAttribute('value', $value);
+    if (!is_null($onclick)) { $btn->setAttribute('onclick', $onclick); }
+    return $btn;
+  }
+
   function createElementTextArea($name, $columns, $rows, $id = null, $value = null) {
     $txtarea = $this->createElement('textarea', $value);
     $txtarea->setAttribute('name', $name);
@@ -358,6 +422,10 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementLink() as a child of this element (see there for params)
   //     returns the new child
   //
+  // function appendImage($src, [$alt_text])
+  //   appends an ExtendedDocument::createElementImage() 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 element (see there for params)
   //     returns an HTML <div> that is a child of the new child
@@ -370,6 +438,10 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params)
   //     returns the new child
   //
+  // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() 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
@@ -382,6 +454,10 @@ class ExtendedElement extends DOMElement {
   //   appends an ExtendedDocument::createElementInputSubmit() as a child of this element (see there for params)
   //     returns the new child
   //
+  // function appendButton($value, $onclick = null)
+  //   appends an ExtendedDocument::createElementButton() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // function appendTextArea($name, $columns, $rows, [$id], [$value])
   //   appends an ExtendedDocument::createElementTextArea() as a child of this element (see there for params)
   //     returns the new child
@@ -402,6 +478,10 @@ class ExtendedElement extends DOMElement {
   //   appends a DOMDocument::createTextNode() as a child of this element (see there for params)
   //     returns the new child
   //
+  // function appendComment($comment_data)
+  //   appends a DOMDocument::createComment() as a child of this element (see there for params)
+  //     returns the new child
+  //
   // function appendHTMLMarkup($htmldata)
   //   appends a representation of the HTML data as children of this element
   //     NO return value!
@@ -429,6 +509,9 @@ class ExtendedElement extends DOMElement {
   function appendLink($target, $value = '') {
     return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
   }
+  function appendImage($src, $alt_text = '') {
+    return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
+  }
   function appendFormDiv($action, $method, $name) {
     $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name));
     return $formelem->appendElement('div');
@@ -439,6 +522,9 @@ class ExtendedElement extends DOMElement {
   function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
   }
@@ -448,6 +534,9 @@ class ExtendedElement extends DOMElement {
   function appendInputSubmit($value) {
     return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
   }
+  function appendButton($value, $onclick = null) {
+    return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
+  }
   function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
   }
@@ -463,6 +552,9 @@ class ExtendedElement extends DOMElement {
   function appendText($text) {
     return $this->appendChild($this->ownerDocument->createTextNode($text));
   }
+  function appendComment($comment_data) {
+    return $this->appendChild($this->ownerDocument->createComment($comment_data));
+  }
   function appendHTMLMarkup($htmldata) {
     $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
   }
@@ -494,6 +586,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementLink() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // function appendImage($src, [$alt_text])
+  //   appends an ExtendedDocument::createElementImage() 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 fragment (see there for params)
   //     returns an HTML <div> that is a child of the new child
@@ -506,6 +602,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // function appendInputPassword($name, $maxlength, $size, [$id], [$value])
+  //   appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // function appendInputRadio($name, $id, $value, $checked)
   //   appends an ExtendedDocument::createElementInputRadio() as a child of this fragment (see there for params)
   //     returns the new child
@@ -518,6 +618,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends an ExtendedDocument::createElementInputSubmit() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // function appendButton($value, $onclick = null)
+  //   appends an ExtendedDocument::createElementButton() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // function appendTextArea($name, $columns, $rows, [$id], [$value])
   //   appends an ExtendedDocument::createElementTextArea() as a child of this fragment (see there for params)
   //     returns the new child
@@ -538,6 +642,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   //   appends a DOMDocument::createTextNode() as a child of this fragment (see there for params)
   //     returns the new child
   //
+  // function appendComment($comment_data)
+  //   appends a DOMDocument::createComment() as a child of this fragment (see there for params)
+  //     returns the new child
+  //
   // function appendHTMLMarkup($htmldata)
   //   appends a representation of the HTML data as children of this fragment
   //     NO return value!
@@ -565,6 +673,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   function appendLink($target, $value = '') {
     return $this->appendChild($this->ownerDocument->createElementLink($target, $value));
   }
+  function appendImage($src, $alt_text = '') {
+    return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text));
+  }
   function appendFormDiv($action, $method, $name) {
     $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name));
     return $formelem->appendElement('div');
@@ -575,6 +686,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   function appendInputText($name, $maxlength, $size, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value));
   }
+  function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) {
+    return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value));
+  }
   function appendInputRadio($name, $id, $value, $checked) {
     return $this->appendChild($this->ownerDocument->createElementInputRadio($name, $id, $value, $checked));
   }
@@ -584,6 +698,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   function appendInputSubmit($value) {
     return $this->appendChild($this->ownerDocument->createElementInputSubmit($value));
   }
+  function appendButton($value, $onclick = null) {
+    return $this->appendChild($this->ownerDocument->createElementButton($value, $onclick));
+  }
   function appendTextArea($name, $columns, $rows, $id = null, $value = null) {
     return $this->appendChild($this->ownerDocument->createElementTextArea($name, $columns, $rows, $id, $value));
   }
@@ -599,6 +716,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment {
   function appendText($text) {
     return $this->appendChild($this->ownerDocument->createTextNode($text));
   }
+  function appendComment($comment_data) {
+    return $this->appendChild($this->ownerDocument->createComment($comment_data));
+  }
   function appendHTMLMarkup($htmldata) {
     $this->ownerDocument->appendHTMLMarkup($htmldata, $this);
   }