Chris@0: get('Atom\Feed'); Chris@0: $atomFeed->setDomDocument($dom); Chris@0: $atomFeed->setType($this->data['type']); Chris@0: $atomFeed->setXpath($this->xpath); Chris@0: $this->extensions['Atom\\Feed'] = $atomFeed; Chris@0: Chris@0: $atomFeed = $manager->get('DublinCore\Feed'); Chris@0: $atomFeed->setDomDocument($dom); Chris@0: $atomFeed->setType($this->data['type']); Chris@0: $atomFeed->setXpath($this->xpath); Chris@0: $this->extensions['DublinCore\\Feed'] = $atomFeed; Chris@0: Chris@0: foreach ($this->extensions as $extension) { Chris@0: $extension->setXpathPrefix('/atom:feed'); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get a single author Chris@0: * Chris@0: * @param int $index Chris@0: * @return string|null Chris@0: */ Chris@0: public function getAuthor($index = 0) Chris@0: { Chris@0: $authors = $this->getAuthors(); Chris@0: Chris@0: if (isset($authors[$index])) { Chris@0: return $authors[$index]; Chris@0: } Chris@0: Chris@0: return; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get an array with feed authors Chris@0: * Chris@0: * @return array Chris@0: */ Chris@0: public function getAuthors() Chris@0: { Chris@0: if (array_key_exists('authors', $this->data)) { Chris@0: return $this->data['authors']; Chris@0: } Chris@0: Chris@0: $authors = $this->getExtension('Atom')->getAuthors(); Chris@0: Chris@0: $this->data['authors'] = $authors; Chris@0: Chris@0: return $this->data['authors']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the copyright entry Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getCopyright() Chris@0: { Chris@0: if (array_key_exists('copyright', $this->data)) { Chris@0: return $this->data['copyright']; Chris@0: } Chris@0: Chris@0: $copyright = $this->getExtension('Atom')->getCopyright(); Chris@0: Chris@12: if (! $copyright) { Chris@0: $copyright = null; Chris@0: } Chris@0: Chris@0: $this->data['copyright'] = $copyright; Chris@0: Chris@0: return $this->data['copyright']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed creation date Chris@0: * Chris@12: * @return \DateTime|null Chris@0: */ Chris@0: public function getDateCreated() Chris@0: { Chris@0: if (array_key_exists('datecreated', $this->data)) { Chris@0: return $this->data['datecreated']; Chris@0: } Chris@0: Chris@0: $dateCreated = $this->getExtension('Atom')->getDateCreated(); Chris@0: Chris@12: if (! $dateCreated) { Chris@0: $dateCreated = null; Chris@0: } Chris@0: Chris@0: $this->data['datecreated'] = $dateCreated; Chris@0: Chris@0: return $this->data['datecreated']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed modification date Chris@0: * Chris@12: * @return \DateTime|null Chris@0: */ Chris@0: public function getDateModified() Chris@0: { Chris@0: if (array_key_exists('datemodified', $this->data)) { Chris@0: return $this->data['datemodified']; Chris@0: } Chris@0: Chris@0: $dateModified = $this->getExtension('Atom')->getDateModified(); Chris@0: Chris@12: if (! $dateModified) { Chris@0: $dateModified = null; Chris@0: } Chris@0: Chris@0: $this->data['datemodified'] = $dateModified; Chris@0: Chris@0: return $this->data['datemodified']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed lastBuild date. This is not implemented in Atom. Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getLastBuildDate() Chris@0: { Chris@0: return; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed description Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getDescription() Chris@0: { Chris@0: if (array_key_exists('description', $this->data)) { Chris@0: return $this->data['description']; Chris@0: } Chris@0: Chris@0: $description = $this->getExtension('Atom')->getDescription(); Chris@0: Chris@12: if (! $description) { Chris@0: $description = null; Chris@0: } Chris@0: Chris@0: $this->data['description'] = $description; Chris@0: Chris@0: return $this->data['description']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed generator entry Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getGenerator() Chris@0: { Chris@0: if (array_key_exists('generator', $this->data)) { Chris@0: return $this->data['generator']; Chris@0: } Chris@0: Chris@0: $generator = $this->getExtension('Atom')->getGenerator(); Chris@0: Chris@0: $this->data['generator'] = $generator; Chris@0: Chris@0: return $this->data['generator']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed ID Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getId() Chris@0: { Chris@0: if (array_key_exists('id', $this->data)) { Chris@0: return $this->data['id']; Chris@0: } Chris@0: Chris@0: $id = $this->getExtension('Atom')->getId(); Chris@0: Chris@0: $this->data['id'] = $id; Chris@0: Chris@0: return $this->data['id']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed language Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getLanguage() Chris@0: { Chris@0: if (array_key_exists('language', $this->data)) { Chris@0: return $this->data['language']; Chris@0: } Chris@0: Chris@0: $language = $this->getExtension('Atom')->getLanguage(); Chris@0: Chris@12: if (! $language) { Chris@0: $language = $this->xpath->evaluate('string(//@xml:lang[1])'); Chris@0: } Chris@0: Chris@12: if (! $language) { Chris@0: $language = null; Chris@0: } Chris@0: Chris@0: $this->data['language'] = $language; Chris@0: Chris@0: return $this->data['language']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get a link to the source website Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getBaseUrl() Chris@0: { Chris@0: if (array_key_exists('baseUrl', $this->data)) { Chris@0: return $this->data['baseUrl']; Chris@0: } Chris@0: Chris@0: $baseUrl = $this->getExtension('Atom')->getBaseUrl(); Chris@0: Chris@0: $this->data['baseUrl'] = $baseUrl; Chris@0: Chris@0: return $this->data['baseUrl']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get a link to the source website Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getLink() Chris@0: { Chris@0: if (array_key_exists('link', $this->data)) { Chris@0: return $this->data['link']; Chris@0: } Chris@0: Chris@0: $link = $this->getExtension('Atom')->getLink(); Chris@0: Chris@0: $this->data['link'] = $link; Chris@0: Chris@0: return $this->data['link']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get feed image data Chris@0: * Chris@0: * @return array|null Chris@0: */ Chris@0: public function getImage() Chris@0: { Chris@0: if (array_key_exists('image', $this->data)) { Chris@0: return $this->data['image']; Chris@0: } Chris@0: Chris@0: $link = $this->getExtension('Atom')->getImage(); Chris@0: Chris@0: $this->data['image'] = $link; Chris@0: Chris@0: return $this->data['image']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get a link to the feed's XML Url Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getFeedLink() Chris@0: { Chris@0: if (array_key_exists('feedlink', $this->data)) { Chris@0: return $this->data['feedlink']; Chris@0: } Chris@0: Chris@0: $link = $this->getExtension('Atom')->getFeedLink(); Chris@0: Chris@0: if ($link === null || empty($link)) { Chris@0: $link = $this->getOriginalSourceUri(); Chris@0: } Chris@0: Chris@0: $this->data['feedlink'] = $link; Chris@0: Chris@0: return $this->data['feedlink']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get the feed title Chris@0: * Chris@0: * @return string|null Chris@0: */ Chris@0: public function getTitle() Chris@0: { Chris@0: if (array_key_exists('title', $this->data)) { Chris@0: return $this->data['title']; Chris@0: } Chris@0: Chris@0: $title = $this->getExtension('Atom')->getTitle(); Chris@0: Chris@0: $this->data['title'] = $title; Chris@0: Chris@0: return $this->data['title']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get an array of any supported Pusubhubbub endpoints Chris@0: * Chris@0: * @return array|null Chris@0: */ Chris@0: public function getHubs() Chris@0: { Chris@0: if (array_key_exists('hubs', $this->data)) { Chris@0: return $this->data['hubs']; Chris@0: } Chris@0: Chris@0: $hubs = $this->getExtension('Atom')->getHubs(); Chris@0: Chris@0: $this->data['hubs'] = $hubs; Chris@0: Chris@0: return $this->data['hubs']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Get all categories Chris@0: * Chris@0: * @return Reader\Collection\Category Chris@0: */ Chris@0: public function getCategories() Chris@0: { Chris@0: if (array_key_exists('categories', $this->data)) { Chris@0: return $this->data['categories']; Chris@0: } Chris@0: Chris@0: $categoryCollection = $this->getExtension('Atom')->getCategories(); Chris@0: Chris@0: if (count($categoryCollection) == 0) { Chris@0: $categoryCollection = $this->getExtension('DublinCore')->getCategories(); Chris@0: } Chris@0: Chris@0: $this->data['categories'] = $categoryCollection; Chris@0: Chris@0: return $this->data['categories']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Read all entries to the internal entries array Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: protected function indexEntries() Chris@0: { Chris@0: if ($this->getType() == Reader\Reader::TYPE_ATOM_10 || Chris@0: $this->getType() == Reader\Reader::TYPE_ATOM_03) { Chris@0: $entries = $this->xpath->evaluate('//atom:entry'); Chris@0: Chris@0: foreach ($entries as $index => $entry) { Chris@0: $this->entries[$index] = $entry; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Register the default namespaces for the current feed format Chris@0: * Chris@0: */ Chris@0: protected function registerNamespaces() Chris@0: { Chris@0: switch ($this->data['type']) { Chris@0: case Reader\Reader::TYPE_ATOM_03: Chris@0: $this->xpath->registerNamespace('atom', Reader\Reader::NAMESPACE_ATOM_03); Chris@0: break; Chris@0: case Reader\Reader::TYPE_ATOM_10: Chris@0: default: Chris@0: $this->xpath->registerNamespace('atom', Reader\Reader::NAMESPACE_ATOM_10); Chris@0: } Chris@0: } Chris@0: }