Beispiel #1
0
 /**
  * Inserts $imageData as a child into $imageObject.
  *
  * Detects if $imageObject contains <office:binary-data/>. If this is the case, 
  * this element is replaced with the given $imageData. Otherwise, 
  * $imageData is added as a new child.
  * 
  * @param DOMElement $imageObject 
  * @param DOMElement $imageData 
  */
 protected function insertImageData($imageObject, $imageData)
 {
     $binaryDataElems = $imageObject->getElementsByTagNameNS(ezcDocumentOdt::NS_ODT_OFFICE, 'binary-data');
     if ($binaryDataElems->length === 1) {
         $imageObject->replaceChild($imageData, $binaryDataElems->item(0));
     } else {
         $imageObject->appendChild($imageData);
     }
 }
 /**
  *
  * @param string $titre
  */
 public function SetTitre($titre)
 {
     $set = $this->document->createTextNode($titre);
     $this->elementTitle->replaceChild($set, $this->textTitre);
     $this->textTitre = $set;
     // Si seulement cette fonction était implémenté...
     //$this->textTitre->replaceWholeText($titre);
 }
Beispiel #3
0
 /**
  * (PHP 5)<br/>
  * Replaces a child
  * @link http://php.net/manual/en/domnode.replacechild.php
  * @param DOMNode $newnode <p>
  * The new node. It must be a member of the target document, i.e.
  * created by one of the DOMDocument->createXXX() methods or imported in
  * the document by .
  * </p>
  * @param DOMNode $oldnode <p>
  * The old node.
  * </p>
  * @return DOMNode The old node or false if an error occur.
  */
 public function replaceChild(\DOMNode $newnode, \DOMNode $oldnode)
 {
     $newNode = parent::replaceChild($newnode, $oldnode);
     return $newNode;
 }
Beispiel #4
0
 /**
  * Replaces a directive.
  * 
  * @param HTTPd_DOMElement $newnode
  * @param HTTPd_DOMElement $oldnode
  * @return HTTPd_DOMElement
  */
 public function replaceChild(\DOMNode $newnode, \DOMNode $oldnode)
 {
     if ($newnode instanceof \DOMAttr || $oldnode instanceof \DOMAttr) {
         throw new \DOMException("Don't call Q\\HTTPd_DOMElement::" . __FUNCTION__ . "() to replace an attribute, use setAttribute() or setAttributeNode() instead.", DOM_HIERARCHY_REQUEST_ERR);
     }
     if ($this->firstChild === null) {
         throw new \DOMException("It's not possible to add children to {$this->nodeName} direcive.", DOM_HIERARCHY_REQUEST_ERR);
     }
     if (!$newnode instanceof HTTPd_DOMElement && !$newnode instanceof HTTPd_DOMComment && !$newnode instanceof \DOMText) {
         throw new \DOMException("You may only add Q\\HTTPd_DOMElement, Q\\HTTPd_DOMComment and DOMText nodes to a section, not a " . get_class($newnode) . ".", DOM_HIERARCHY_REQUEST_ERR);
     }
     return \DOMElement::replaceChild($newnode, $oldnode);
 }
 /**
  * Extends one item with the full content of the specified link
  *
  * @param Feed       $feed
  * @param DOMElement $domElement
  * @param bool       $useCache
  * @return int
  */
 private function extendItemAndGetChangedTime(Feed $feed, DOMElement $domElement, $useCache)
 {
     /** @var $contentNodes DOMElement[] */
     $contentNodes = array();
     $link = "";
     $time = 0;
     foreach ($domElement->childNodes as $child) {
         /** @var $child DOMElement */
         $name = $child->nodeName;
         $value = $child->nodeValue;
         if ($name == "link") {
             $link = $value;
             if ($link == "") {
                 $link = $child->getAttribute("href");
             }
         } else {
             if (in_array($name, $this->contentNames)) {
                 $contentNodes[] = $child;
             } else {
                 if (in_array($name, $this->timeNames)) {
                     $time = strtotime($value);
                 }
             }
         }
     }
     $filteredContent = $this->getFilteredContentOfUrl($feed, $link, $useCache, $time);
     foreach ($contentNodes as $contentNode) {
         // replace old with new content
         if ($filteredContent != "") {
             $newNode = $contentNode->ownerDocument->createElement($contentNode->nodeName);
             $newNode->setAttribute("type", "html");
             $textNode = $contentNode->ownerDocument->createTextNode($filteredContent);
             $newNode->appendChild($textNode);
             foreach ($contentNode->attributes as $attrName => $attrNode) {
                 @$newNode->setAttribute($attrName, $attrNode);
             }
             $domElement->replaceChild($newNode, $contentNode);
         } else {
             @($contentNode->nodeValue .= "\n\n<br /><br /><span style='font: #ff0000'>WARNING! Your Rss-Extender rules returned an empty string for link: " . $link . "</span>");
         }
     }
     return $time;
 }