add appendComment() methods so we can add comments in an easy fashion
[php-utility-classes.git] / include / cbsm / util / document.php-class
index e641d23c56364fec3610153d65803280cf03c726..8f6c6cff7916bbf3a4de2682ed1a2fcd61a48720 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
@@ -90,6 +94,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 +117,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
@@ -172,6 +183,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');
@@ -206,6 +220,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 +254,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);
@@ -358,6 +382,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
@@ -402,6 +430,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 +461,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');
@@ -463,6 +498,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 +532,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
@@ -538,6 +580,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 +611,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');
@@ -599,6 +648,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);
   }