diff -r bd595ad770fc -r 1c2f13fd785c web/enmi/Zend/Feed/Reader/Extension/EntryAbstract.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/enmi/Zend/Feed/Reader/Extension/EntryAbstract.php Thu Jan 20 19:30:54 2011 +0100 @@ -0,0 +1,200 @@ +_entry = $entry; + $this->_entryKey = $entryKey; + $this->_domDocument = $entry->ownerDocument; + + if ($type !== null) { + $this->_data['type'] = $type; + } else { + $this->_data['type'] = Zend_Feed_Reader::detectType($entry->ownerDocument, true); + } + // set the XPath query prefix for the entry being queried + if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_10 + || $this->getType() == Zend_Feed_Reader::TYPE_RSS_090 + ) { + $this->setXpathPrefix('//rss:item[' . ($this->_entryKey+1) . ']'); + } elseif ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 + || $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03 + ) { + $this->setXpathPrefix('//atom:entry[' . ($this->_entryKey+1) . ']'); + } else { + $this->setXpathPrefix('//item[' . ($this->_entryKey+1) . ']'); + } + } + + /** + * Get the DOM + * + * @return DOMDocument + */ + public function getDomDocument() + { + return $this->_domDocument; + } + + /** + * Get the Entry's encoding + * + * @return string + */ + public function getEncoding() + { + $assumed = $this->getDomDocument()->encoding; + return $assumed; + } + + /** + * Get the entry type + * + * @return string + */ + public function getType() + { + return $this->_data['type']; + } + + /** + * Set the XPath query + * + * @param DOMXPath $xpath + * @return Zend_Feed_Reader_Extension_EntryAbstract + */ + public function setXpath(DOMXPath $xpath) + { + $this->_xpath = $xpath; + $this->_registerNamespaces(); + return $this; + } + + /** + * Get the XPath query object + * + * @return DOMXPath + */ + public function getXpath() + { + if (!$this->_xpath) { + $this->setXpath(new DOMXPath($this->getDomDocument())); + } + return $this->_xpath; + } + + /** + * Serialize the entry to an array + * + * @return array + */ + public function toArray() + { + return $this->_data; + } + + /** + * Get the XPath prefix + * + * @return string + */ + public function getXpathPrefix() + { + return $this->_xpathPrefix; + } + + /** + * Set the XPath prefix + * + * @param string $prefix + * @return Zend_Feed_Reader_Extension_EntryAbstract + */ + public function setXpathPrefix($prefix) + { + $this->_xpathPrefix = $prefix; + return $this; + } + + /** + * Register XML namespaces + * + * @return void + */ + protected abstract function _registerNamespaces(); +}