Chris@0: entry = $entry; Chris@0: $this->domDocument = $entry->ownerDocument; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the entry DOMElement Chris@0: * Chris@0: * @return DOMElement Chris@0: */ Chris@0: public function getEntryElement() Chris@0: { Chris@0: return $this->entry; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the entry key Chris@0: * Chris@0: * @param string $entryKey Chris@0: * @return AbstractEntry Chris@0: */ Chris@0: public function setEntryKey($entryKey) Chris@0: { Chris@0: $this->entryKey = $entryKey; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the DOM Chris@0: * Chris@0: * @return DOMDocument Chris@0: */ Chris@0: public function getDomDocument() Chris@0: { Chris@0: return $this->domDocument; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the Entry's encoding Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getEncoding() Chris@0: { Chris@0: $assumed = $this->getDomDocument()->encoding; Chris@0: return $assumed; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the entry type Chris@0: * Chris@0: * Has side effect of setting xpath prefix Chris@0: * Chris@0: * @param string $type Chris@0: * @return AbstractEntry Chris@0: */ Chris@0: public function setType($type) Chris@0: { Chris@0: if (null === $type) { Chris@0: $this->data['type'] = null; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: $this->data['type'] = $type; Chris@0: if ($type === Reader\Reader::TYPE_RSS_10 Chris@0: || $type === Reader\Reader::TYPE_RSS_090 Chris@0: ) { Chris@12: $this->setXpathPrefix('//rss:item[' . ((int)$this->entryKey + 1) . ']'); Chris@0: return $this; Chris@0: } Chris@0: Chris@0: if ($type === Reader\Reader::TYPE_ATOM_10 Chris@0: || $type === Reader\Reader::TYPE_ATOM_03 Chris@0: ) { Chris@12: $this->setXpathPrefix('//atom:entry[' . ((int)$this->entryKey + 1) . ']'); Chris@0: return $this; Chris@0: } Chris@0: Chris@12: $this->setXpathPrefix('//item[' . ((int)$this->entryKey + 1) . ']'); Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the entry type Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getType() Chris@0: { Chris@0: $type = $this->data['type']; Chris@0: if ($type === null) { Chris@0: $type = Reader\Reader::detectType($this->getEntryElement(), true); Chris@0: $this->setType($type); Chris@0: } Chris@0: Chris@0: return $type; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the XPath query Chris@0: * Chris@0: * @param DOMXPath $xpath Chris@0: * @return AbstractEntry Chris@0: */ Chris@0: public function setXpath(DOMXPath $xpath) Chris@0: { Chris@0: $this->xpath = $xpath; Chris@0: $this->registerNamespaces(); Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the XPath query object Chris@0: * Chris@0: * @return DOMXPath Chris@0: */ Chris@0: public function getXpath() Chris@0: { Chris@12: if (! $this->xpath) { Chris@0: $this->setXpath(new DOMXPath($this->getDomDocument())); Chris@0: } Chris@0: return $this->xpath; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Serialize the entry to an array Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function toArray() Chris@0: { Chris@0: return $this->data; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the XPath prefix Chris@0: * Chris@0: * @return string Chris@0: */ Chris@0: public function getXpathPrefix() Chris@0: { Chris@0: return $this->xpathPrefix; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Set the XPath prefix Chris@0: * Chris@0: * @param string $prefix Chris@0: * @return AbstractEntry Chris@0: */ Chris@0: public function setXpathPrefix($prefix) Chris@0: { Chris@0: $this->xpathPrefix = $prefix; Chris@0: return $this; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Register XML namespaces Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: abstract protected function registerNamespaces(); Chris@0: }