X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=classes%2Fdocument.php-class;h=d3dca7d7e66553df777c4160ab97b633f685553a;hp=64acdbcbb798509278f96ad8c288480f22822e94;hb=34bf6915dfc529bfb3408069ab7c62bbc218f461;hpb=f925e4a1b0d0fac984c82d1aa4fe3480bf207f5c diff --git a/classes/document.php-class b/classes/document.php-class index 64acdbc..d3dca7d 100755 --- a/classes/document.php-class +++ b/classes/document.php-class @@ -137,6 +137,11 @@ class ExtendedDocument extends DOMDocument { // appends a DOMDocument::createComment() as a child of this document (see there for params) // returns the new child // + // public function appendClonedElement($dom_element, [$deep]) + // appends a clone of the given DOMElement as a child of this document + // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) + // returns the new child + // // public 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! @@ -254,7 +259,7 @@ class ExtendedDocument extends DOMDocument { static function initHTML5($doc = null) { if (is_null($doc)) { $doc = new ExtendedDocument(); } - $doc->loadHTML(''); // this seems to be the only way to get the DOCTYPE set properly. + $doc->loadHTML(''); // this seems to be the only way to get the DOCTYPE set properly. // Created basic HTML document structure. $root = $doc->getElementsByTagName('html')->item(0); @@ -363,11 +368,14 @@ class ExtendedDocument extends DOMDocument { public function appendComment($comment_data) { return $this->appendChild($this->createComment($comment_data)); } + public function appendClonedElement($dom_element, $deep = true) { + return $this->appendChild($dom_element->cloneNode($deep)); + } public function appendJSElement($jsdata) { - $this->appendChild($this->createElementJS($jsdata)); + return $this->appendChild($this->createElementJS($jsdata)); } - public function appendJSFile($jsdata, $defer = false, $async = false) { - return $this->appendChild($this->createElementJSFile($jsdata, $defer, $async)); + public function appendJSFile($jsURL, $defer = false, $async = false) { + return $this->appendChild($this->createElementJSFile($jsURL, $defer, $async)); } public function appendHTMLMarkup($htmldata, $parentNode = null) { @@ -761,6 +769,11 @@ class ExtendedElement extends DOMElement { // appends a DOMDocument::createComment() as a child of this element (see there for params) // returns the new child // + // public function appendClonedElement($dom_element, [$deep]) + // appends a clone of the given DOMElement as a child of this element + // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) + // returns the new child + // // public function appendHTMLMarkup($htmldata) // appends a representation of the HTML data as children of this element // NO return value! @@ -771,7 +784,7 @@ class ExtendedElement extends DOMElement { // // public function appendJSElement($jsdata) // appends an ExtendedDocument::createElementJS() as a child of this element (see there for params) - // NO return value! + // returns the new child // // public function appendJSFile($jsURL, [$defer], [$async]) // appends an ExtendedDocument::createElementJSFile() as a child of this element (see there for params) @@ -880,6 +893,9 @@ class ExtendedElement extends DOMElement { public function appendComment($comment_data) { return $this->appendChild($this->ownerDocument->createComment($comment_data)); } + public function appendClonedElement($dom_element, $deep = true) { + return $this->appendChild($dom_element->cloneNode($deep)); + } public function appendHTMLMarkup($htmldata) { $this->ownerDocument->appendHTMLMarkup($htmldata, $this); } @@ -887,10 +903,10 @@ class ExtendedElement extends DOMElement { $this->ownerDocument->appendXMLMarkup($xmldata, $this); } public function appendJSElement($jsdata) { - $this->appendChild($this->ownerDocument->createElementJS($jsdata)); + return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); } - public function appendJSFile($jsdata, $defer = false, $async = false) { - return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async)); + public function appendJSFile($jsURL, $defer = false, $async = false) { + return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); } public function setClass($classname) { $this->setAttribute('class', $classname); @@ -1031,6 +1047,11 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends a DOMDocument::createComment() as a child of this fragment (see there for params) // returns the new child // + // public function appendClonedElement($dom_element, [$deep]) + // appends a clone of the given DOMElement as a child of this fragment + // the boolean $deep specifies if the children are cloned as well (defaults to TRUE) + // returns the new child + // // public function appendHTMLMarkup($htmldata) // appends a representation of the HTML data as children of this fragment // NO return value! @@ -1041,7 +1062,7 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // // public function appendJSElement($jsdata) // appends an ExtendedDocument::createElementJS() as a child of this fragment (see there for params) - // NO return value! + // returns the new child // // public function appendJSFile($jsURL, [$defer], [$async]) // appends an ExtendedDocument::createElementJSFile() as a child of this fragment (see there for params) @@ -1140,6 +1161,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { public function appendComment($comment_data) { return $this->appendChild($this->ownerDocument->createComment($comment_data)); } + public function appendClonedElement($dom_element, $deep = true) { + return $this->appendChild($dom_element->cloneNode($deep)); + } public function appendHTMLMarkup($htmldata) { $this->ownerDocument->appendHTMLMarkup($htmldata, $this); } @@ -1147,10 +1171,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { $this->ownerDocument->appendXMLMarkup($xmldata, $this); } public function appendJSElement($jsdata) { - $this->appendChild($this->ownerDocument->createElementJS($jsdata)); + return $this->appendChild($this->ownerDocument->createElementJS($jsdata)); } - public function appendJSFile($jsdata, $defer = false, $async = false) { - return $this->appendChild($this->ownerDocument->createElementJSFile($jsdata, $defer, $async)); + public function appendJSFile($jsURL, $defer = false, $async = false) { + return $this->appendChild($this->ownerDocument->createElementJSFile($jsURL, $defer, $async)); } } ?>