import v1.1.0_RC2 | 2009-09-20
This commit is contained in:
357
libs/Zend/Feed/Reader/Entry/Atom.php
Normal file
357
libs/Zend/Feed/Reader/Entry/Atom.php
Normal file
@ -0,0 +1,357 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Atom.php 16966 2009-07-22 15:22:18Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_EntryInterface
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/EntryInterface.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Atom_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Entry_Atom extends Zend_Feed_Reader_EntryAbstract implements Zend_Feed_Reader_EntryInterface
|
||||
{
|
||||
/**
|
||||
* XPath query
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_xpathQuery = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DOMElement $entry
|
||||
* @param int $entryKey
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
parent::__construct($entry, $entryKey, $type);
|
||||
|
||||
// Everyone by now should know XPath indices start from 1 not 0
|
||||
$this->_xpathQuery = '//atom:entry[' . ($this->_entryKey + 1) . ']';
|
||||
|
||||
$atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Entry');
|
||||
$this->_extensions['Atom_Entry'] = new $atomClass($entry, $entryKey, $type);
|
||||
|
||||
$threadClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Thread_Entry');
|
||||
$this->_extensions['Thread_Entry'] = new $threadClass($entry, $entryKey, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the specified author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$people = $this->getExtension('Atom')->getAuthors();
|
||||
|
||||
$this->_data['authors'] = $people;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (array_key_exists('content', $this->_data)) {
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
$content = $this->getExtension('Atom')->getContent();
|
||||
|
||||
$this->_data['content'] = $content;
|
||||
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (array_key_exists('datecreated', $this->_data)) {
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
$dateCreated = $this->getExtension('Atom')->getDateCreated();
|
||||
|
||||
$this->_data['datecreated'] = $dateCreated;
|
||||
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$dateModified = $this->getExtension('Atom')->getDateModified();
|
||||
|
||||
$this->_data['datemodified'] = $dateModified;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry enclosure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure()
|
||||
{
|
||||
if (array_key_exists('enclosure', $this->_data)) {
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
$enclosure = $this->getExtension('Atom')->getEnclosure();
|
||||
|
||||
$this->_data['enclosure'] = $enclosure;
|
||||
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = $this->getExtension('Atom')->getId();
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific link
|
||||
*
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->_data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
if (isset($this->_data['links'][$index])) {
|
||||
return $this->_data['links'][$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
if (array_key_exists('links', $this->_data)) {
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
$links = $this->getExtension('Atom')->getLinks();
|
||||
|
||||
$this->_data['links'] = $links;
|
||||
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a permalink to the entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalink()
|
||||
{
|
||||
return $this->getLink(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of comments/replies for current entry
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
if (array_key_exists('commentcount', $this->_data)) {
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
$commentcount = $this->getExtension('Thread')>getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
$this->_data['commentcount'] = $commentcount;
|
||||
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to the HTML page where comments can be made on this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentLink()
|
||||
{
|
||||
if (array_key_exists('commentlink', $this->_data)) {
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
$commentlink = $this->getExtension('Atom')->getCommentLink();
|
||||
|
||||
$this->_data['commentlink'] = $commentlink;
|
||||
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to a feed of all comments for this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentFeedLink()
|
||||
{
|
||||
if (array_key_exists('commentfeedlink', $this->_data)) {
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink();
|
||||
|
||||
$this->_data['commentfeedlink'] = $commentfeedlink;
|
||||
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the XPath query (incl. on all Extensions)
|
||||
*
|
||||
* @param DOMXPath $xpath
|
||||
*/
|
||||
public function setXpath(DOMXPath $xpath)
|
||||
{
|
||||
parent::setXpath($xpath);
|
||||
foreach ($this->_extensions as $extension) {
|
||||
$extension->setXpath($this->_xpath);
|
||||
}
|
||||
}
|
||||
}
|
611
libs/Zend/Feed/Reader/Entry/Rss.php
Normal file
611
libs/Zend/Feed/Reader/Entry/Rss.php
Normal file
@ -0,0 +1,611 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Rss.php 16966 2009-07-22 15:22:18Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_EntryInterface
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/EntryInterface.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_DublinCore_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/DublinCore/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Content_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Content/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Atom_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Atom/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_WellformedWeb_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Slash_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Slash/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Thread_Entry
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Thread/Entry.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implements Zend_Feed_Reader_EntryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* XPath query for RDF
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_xpathQueryRdf = '';
|
||||
|
||||
/**
|
||||
* XPath query for RSS
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_xpathQueryRss = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Feed_Entry_Abstract $entry
|
||||
* @param string $entryKey
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
parent::__construct($entry, $entryKey, $type);
|
||||
$this->_xpathQueryRss = '//item[' . ($this->_entryKey+1) . ']';
|
||||
$this->_xpathQueryRdf = '//rss:item[' . ($this->_entryKey+1) . ']';
|
||||
|
||||
$pluginLoader = Zend_Feed_Reader::getPluginLoader();
|
||||
|
||||
$dublinCoreClass = $pluginLoader->getClassName('DublinCore_Entry');
|
||||
$this->_extensions['DublinCore_Entry'] = new $dublinCoreClass($entry, $entryKey, $type);
|
||||
|
||||
$contentClass = $pluginLoader->getClassName('Content_Entry');
|
||||
$this->_extensions['Content_Entry'] = new $contentClass($entry, $entryKey, $type);
|
||||
|
||||
$atomClass = $pluginLoader->getClassName('Atom_Entry');
|
||||
$this->_extensions['Atom_Entry'] = new $atomClass($entry, $entryKey, $type);
|
||||
|
||||
$wfwClass = $pluginLoader->getClassName('WellFormedWeb_Entry');
|
||||
$this->_extensions['WellFormedWeb_Entry'] = new $wfwClass($entry, $entryKey, $type);
|
||||
|
||||
$slashClass = $pluginLoader->getClassName('Slash_Entry');
|
||||
$this->_extensions['Slash_Entry'] = new $slashClass($entry, $entryKey, $type);
|
||||
|
||||
$threadClass = $pluginLoader->getClassName('Thread_Entry');
|
||||
$this->_extensions['Thread_Entry'] = new $threadClass($entry, $entryKey, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an author entry
|
||||
*
|
||||
* @param DOMElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
// @todo: create a list from all potential sources rather than from alternatives
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$list = $this->_xpath->evaluate($this->_xpathQueryRss.'//author');
|
||||
} else {
|
||||
$list = $this->_xpath->evaluate($this->_xpathQueryRdf.'//rss:author');
|
||||
}
|
||||
if (!$list->length) {
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$list = $this->_xpath->query('//author');
|
||||
} else {
|
||||
$list = $this->_xpath->query('//rss:author');
|
||||
}
|
||||
}
|
||||
|
||||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_20
|
||||
&& preg_match("/\(([^\)]+)\)/", $author->nodeValue, $matches, PREG_OFFSET_CAPTURE)
|
||||
) {
|
||||
// source name from RSS 2.0 <author>
|
||||
// format "joe@example.com (Joe Bloggs)"
|
||||
$authors[] = $matches[1][0];
|
||||
} else {
|
||||
$authors[] = $author->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
$authors = array_unique($authors);
|
||||
}
|
||||
|
||||
if (empty($authors)) {
|
||||
$authors = $this->getExtension('DublinCore')->getAuthors();
|
||||
}
|
||||
|
||||
if (empty($authors)) {
|
||||
$authors = $this->getExtension('Atom')->getAuthors();
|
||||
}
|
||||
|
||||
$this->_data['authors'] = $authors;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (array_key_exists('content', $this->_data)) {
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
$content = $this->getExtension('Content')->getContent();
|
||||
|
||||
if (!$content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
if (empty($content)) {
|
||||
$content = $this->getExtension('Atom')->getContent();
|
||||
}
|
||||
|
||||
$this->_data['content'] = $content;
|
||||
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry's date of creation
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
return $this->getDateModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry's date of modification
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$dateModified = null;
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$dateModified = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/pubDate)');
|
||||
if ($dateModified) {
|
||||
$date = new Zend_Date();
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::RFC_822);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::RFC_2822);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::DATES);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
throw new Zend_Feed_Exception(
|
||||
'Could not load date due to unrecognised format (should follow RFC 822 or 2822): '
|
||||
. $e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
$this->_data['datemodified'] = $date;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$description = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/description)');
|
||||
} else {
|
||||
$description = $this->_xpath->evaluate('string('.$this->_xpathQueryRdf.'/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
if (empty($description)) {
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
} else {
|
||||
$description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry enclosure
|
||||
* TODO: Is this supported by RSS? Could delegate to Atom Extension if not.
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure()
|
||||
{
|
||||
if (array_key_exists('enclosure', $this->_data)) {
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
$enclosure = null;
|
||||
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_20) {
|
||||
$nodeList = $this->_xpath->query($this->_xpathQueryRss . '/enclosure');
|
||||
|
||||
if ($nodeList->length > 0) {
|
||||
$enclosure = new stdClass();
|
||||
$enclosure->url = $nodeList->item(0)->getAttribute('url');
|
||||
$enclosure->length = $nodeList->item(0)->getAttribute('length');
|
||||
$enclosure->type = $nodeList->item(0)->getAttribute('type');
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['enclosure'] = $enclosure;
|
||||
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$id = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/guid)');
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
$id = $this->getTitle();
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific link
|
||||
*
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->_data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
if (isset($this->_data['links'][$index])) {
|
||||
return $this->_data['links'][$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
if (array_key_exists('links', $this->_data)) {
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
$links = array();
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$list = $this->_xpath->query($this->_xpathQueryRss.'//link');
|
||||
} else {
|
||||
$list = $this->_xpath->query($this->_xpathQueryRdf.'//rss:link');
|
||||
}
|
||||
|
||||
if (!$list->length) {
|
||||
$links = $this->getExtension('Atom')->getLinks();
|
||||
} else {
|
||||
foreach ($list as $link) {
|
||||
$links[] = $link->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['links'] = $links;
|
||||
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a permalink to the entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalink()
|
||||
{
|
||||
return $this->getLink(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$title = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/title)');
|
||||
} else {
|
||||
$title = $this->_xpath->evaluate('string('.$this->_xpathQueryRdf.'/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of comments/replies for current entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
if (array_key_exists('commentcount', $this->_data)) {
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
$commentcount = $this->getExtension('Slash')->getCommentCount();
|
||||
|
||||
if (!$commentcount) {
|
||||
$commentcount = $this->getExtension('Thread')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
$commentcount = $this->getExtension('Atom')->getCommentCount();
|
||||
}
|
||||
|
||||
if (!$commentcount) {
|
||||
$commentcount = null;
|
||||
}
|
||||
|
||||
$this->_data['commentcount'] = $commentcount;
|
||||
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to the HTML page where comments can be made on this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentLink()
|
||||
{
|
||||
if (array_key_exists('commentlink', $this->_data)) {
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
$commentlink = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$commentlink = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/comments)');
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
$commentlink = $this->getExtension('Atom')->getCommentLink();
|
||||
}
|
||||
|
||||
if (!$commentlink) {
|
||||
$commentlink = null;
|
||||
}
|
||||
|
||||
$this->_data['commentlink'] = $commentlink;
|
||||
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to a feed of all comments for this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentFeedLink()
|
||||
{
|
||||
if (array_key_exists('commentfeedlink', $this->_data)) {
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
$commentfeedlink = $this->getExtension('WellFormedWeb')->getCommentFeedLink();
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rss');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
$commentfeedlink = $this->getExtension('Atom')->getCommentFeedLink('rdf');
|
||||
}
|
||||
|
||||
if (!$commentfeedlink) {
|
||||
$commentfeedlink = null;
|
||||
}
|
||||
|
||||
$this->_data['commentfeedlink'] = $commentfeedlink;
|
||||
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the XPath query (incl. on all Extensions)
|
||||
*
|
||||
* @param DOMXPath $xpath
|
||||
*/
|
||||
public function setXpath(DOMXPath $xpath)
|
||||
{
|
||||
parent::setXpath($xpath);
|
||||
foreach ($this->_extensions as $extension) {
|
||||
$extension->setXpath($this->_xpath);
|
||||
}
|
||||
}
|
||||
}
|
242
libs/Zend/Feed/Reader/EntryAbstract.php
Normal file
242
libs/Zend/Feed/Reader/EntryAbstract.php
Normal file
@ -0,0 +1,242 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: EntryAbstract.php 16966 2009-07-22 15:22:18Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Feed_Reader_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Feed entry data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
* DOM document object
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $_domDocument = null;
|
||||
|
||||
/**
|
||||
* Entry instance
|
||||
*
|
||||
* @var Zend_Feed_Entry_Interface
|
||||
*/
|
||||
protected $_entry = null;
|
||||
|
||||
/**
|
||||
* Pointer to the current entry
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_entryKey = 0;
|
||||
|
||||
/**
|
||||
* XPath object
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $_xpath = null;
|
||||
|
||||
/**
|
||||
* Registered extensions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_extensions = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DOMElement $entry
|
||||
* @param int $entryKey
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
$this->_entry = $entry;
|
||||
$this->_entryKey = $entryKey;
|
||||
$this->_domDocument = $entry->ownerDocument;
|
||||
if ($type !== null) {
|
||||
$this->_data['type'] = $type;
|
||||
} else {
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType($feed);
|
||||
}
|
||||
$this->_loadExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOM
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
return $this->_domDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry element
|
||||
*
|
||||
* @return DOMElement
|
||||
*/
|
||||
public function getElement()
|
||||
{
|
||||
return $this->_entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Entry's encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
$assumed = $this->getDomDocument()->encoding;
|
||||
return $assumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entry as xml
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXml()
|
||||
{
|
||||
$dom = new DOMDocument('1.0', $this->getEncoding());
|
||||
$entry = $dom->importNode($this->getElement(), true);
|
||||
$dom->appendChild($entry);
|
||||
return $dom->saveXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_data['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the XPath query object
|
||||
*
|
||||
* @return DOMXPath
|
||||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
return $this->_xpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the XPath query
|
||||
*
|
||||
* @param DOMXPath $xpath
|
||||
* @return Zend_Feed_Reader_Entry_EntryAbstract
|
||||
*/
|
||||
public function setXpath(DOMXPath $xpath)
|
||||
{
|
||||
$this->_xpath = $xpath;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the entry to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get registered extensions
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getExtensions()
|
||||
{
|
||||
return $this->_extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Extension object with the matching name (postfixed with _Entry)
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
public function getExtension($name)
|
||||
{
|
||||
if (array_key_exists($name . '_Entry', $this->_extensions)) {
|
||||
return $this->_extensions[$name . '_Entry'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method overloading: call given method on first extension implementing it
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
* @throws Zend_Feed_Exception if no extensions implements the method
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
foreach ($this->_extensions as $extension) {
|
||||
if (method_exists($extension, $method)) {
|
||||
return call_user_func_array(array($extension, $method), $args);
|
||||
}
|
||||
}
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
throw new Zend_Feed_Exception('Method: ' . $method
|
||||
. 'does not exist and could not be located on a registered Extension');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load extensions from Zend_Feed_Reader
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
$all = Zend_Feed_Reader::getExtensions();
|
||||
$feed = $all['entry'];
|
||||
foreach ($feed as $extension) {
|
||||
if (in_array($extension, $all['core'])) {
|
||||
continue;
|
||||
}
|
||||
$className = Zend_Feed_Reader::getPluginLoader()->getClassName($extension);
|
||||
$this->_extensions[$extension] = new $className(
|
||||
$this->getElement(), $this->_entryKey, $this->_data['type']
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
136
libs/Zend/Feed/Reader/EntryInterface.php
Normal file
136
libs/Zend/Feed/Reader/EntryInterface.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: EntryInterface.php 16953 2009-07-22 11:57:25Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Feed_Reader_EntryInterface
|
||||
{
|
||||
/**
|
||||
* Get the specified author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0);
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors();
|
||||
|
||||
/**
|
||||
* Get the entry content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent();
|
||||
|
||||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
/**
|
||||
* Get the entry description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Get the entry enclosure
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getEnclosure();
|
||||
|
||||
/**
|
||||
* Get the entry ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get a specific link
|
||||
*
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public function getLink($index = 0);
|
||||
|
||||
/**
|
||||
* Get all links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks();
|
||||
|
||||
/**
|
||||
* Get a permalink to the entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalink();
|
||||
|
||||
/**
|
||||
* Get the entry title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle();
|
||||
|
||||
/**
|
||||
* Get the number of comments/replies for current entry
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCommentCount();
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to the HTML page where comments can be made on this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentLink();
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to a feed of all comments for this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentFeedLink();
|
||||
}
|
506
libs/Zend/Feed/Reader/Extension/Atom/Entry.php
Normal file
506
libs/Zend/Feed/Reader/Extension/Atom/Entry.php
Normal file
@ -0,0 +1,506 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Atom_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the specified author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = $this->_xpath->query(
|
||||
$this->getXpathPrefix() . '//atom:author' . '|'
|
||||
. $this->getXpathPrefix(). '//atom:contributor'
|
||||
);
|
||||
|
||||
if (!$authors->length) {
|
||||
$authors = $this->_xpath->query(
|
||||
'//atom:author' . '|' . '//atom:contributor'
|
||||
);
|
||||
}
|
||||
|
||||
$people = array();
|
||||
|
||||
if ($authors->length) {
|
||||
foreach ($authors as $author) {
|
||||
$author = $this->_getAuthor($author);
|
||||
|
||||
if (!empty($author)) {
|
||||
$people[] = $author;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$people = array_unique($people);
|
||||
|
||||
$this->_data['authors'] = $people;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
if (array_key_exists('content', $this->_data)) {
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
$content = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:content)');
|
||||
|
||||
if ($content) {
|
||||
$content = html_entity_decode($content, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
|
||||
if (!$content) {
|
||||
$content = $this->getDescription();
|
||||
}
|
||||
|
||||
$this->_data['content'] = $content;
|
||||
|
||||
return $this->_data['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry creation date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (array_key_exists('datecreated', $this->_data)) {
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:created)');
|
||||
} else {
|
||||
$dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:published)');
|
||||
}
|
||||
|
||||
if ($dateCreated) {
|
||||
$date = new Zend_Date;
|
||||
$date->set($dateCreated, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['datecreated'] = $date;
|
||||
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry modification date
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)');
|
||||
} else {
|
||||
$dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)');
|
||||
}
|
||||
|
||||
if ($dateModified) {
|
||||
$date = new Zend_Date;
|
||||
$date->set($dateModified, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['datemodified'] = $date;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:summary)');
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
} else {
|
||||
$description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry enclosure
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEnclosure()
|
||||
{
|
||||
if (array_key_exists('enclosure', $this->_data)) {
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
$enclosure = null;
|
||||
|
||||
$nodeList = $this->_xpath->query($this->getXpathPrefix() . '/atom:link[@rel="enclosure"]');
|
||||
|
||||
if ($nodeList->length > 0) {
|
||||
$enclosure = new stdClass();
|
||||
$enclosure->url = $nodeList->item(0)->getAttribute('href');
|
||||
$enclosure->length = $nodeList->item(0)->getAttribute('length');
|
||||
$enclosure->type = $nodeList->item(0)->getAttribute('type');
|
||||
}
|
||||
|
||||
$this->_data['enclosure'] = $enclosure;
|
||||
|
||||
return $this->_data['enclosure'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if ($this->getPermalink()) {
|
||||
$id = $this->getPermalink();
|
||||
} elseif ($this->getTitle()) {
|
||||
$id = $this->getTitle();
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific link
|
||||
*
|
||||
* @param int $index
|
||||
* @return string
|
||||
*/
|
||||
public function getLink($index = 0)
|
||||
{
|
||||
if (!array_key_exists('links', $this->_data)) {
|
||||
$this->getLinks();
|
||||
}
|
||||
|
||||
if (isset($this->_data['links'][$index])) {
|
||||
return $this->_data['links'][$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all links
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLinks()
|
||||
{
|
||||
if (array_key_exists('links', $this->_data)) {
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
$links = array();
|
||||
|
||||
$list = $this->_xpath->query(
|
||||
$this->getXpathPrefix() . '//atom:link[@rel="alternate"]/@href' . '|' .
|
||||
$this->getXpathPrefix() . '//atom:link[not(@rel)]/@href'
|
||||
);
|
||||
|
||||
if ($list->length) {
|
||||
foreach ($list as $link) {
|
||||
$links[] = $link->value;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['links'] = $links;
|
||||
|
||||
return $this->_data['links'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a permalink to the entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPermalink()
|
||||
{
|
||||
return $this->getLink(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
} else {
|
||||
$title = html_entity_decode($title, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of comments/replies for current entry
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
if (array_key_exists('commentcount', $this->_data)) {
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
$count = null;
|
||||
|
||||
$this->_xpath->registerNamespace('thread10', 'http://purl.org/syndication/thread/1.0');
|
||||
$list = $this->_xpath->query(
|
||||
$this->getXpathPrefix() . '//atom:link[@rel="replies"]/@thread10:count'
|
||||
);
|
||||
|
||||
if ($list->length) {
|
||||
$count = $list->item(0)->value;
|
||||
}
|
||||
|
||||
$this->_data['commentcount'] = $count;
|
||||
|
||||
return $this->_data['commentcount'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to the HTML page where comments can be made on this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentLink()
|
||||
{
|
||||
if (array_key_exists('commentlink', $this->_data)) {
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
$link = null;
|
||||
|
||||
$list = $this->_xpath->query(
|
||||
$this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="text/html"]/@href'
|
||||
);
|
||||
|
||||
if ($list->length) {
|
||||
$link = $list->item(0)->value;
|
||||
}
|
||||
|
||||
$this->_data['commentlink'] = $link;
|
||||
|
||||
return $this->_data['commentlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a URI pointing to a feed of all comments for this entry
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCommentFeedLink($type = 'atom')
|
||||
{
|
||||
if (array_key_exists('commentfeedlink', $this->_data)) {
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
$link = null;
|
||||
|
||||
$list = $this->_xpath->query(
|
||||
$this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="application/'.$type.'+xml"]/@href'
|
||||
);
|
||||
|
||||
if ($list->length) {
|
||||
$link = $list->item(0)->value;
|
||||
}
|
||||
|
||||
$this->_data['commentfeedlink'] = $link;
|
||||
|
||||
return $this->_data['commentfeedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an author entry
|
||||
*
|
||||
* @param DOMElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getAuthor(DOMElement $element)
|
||||
{
|
||||
$email = null;
|
||||
$name = null;
|
||||
$uri = null;
|
||||
|
||||
$emailNode = $element->getElementsByTagName('email');
|
||||
$nameNode = $element->getElementsByTagName('name');
|
||||
$uriNode = $element->getElementsByTagName('uri');
|
||||
|
||||
if ($emailNode->length) {
|
||||
$email = $emailNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if ($nameNode->length) {
|
||||
$name = $nameNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if ($uriNode->length) {
|
||||
$uri = $uriNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if (!empty($email)) {
|
||||
return $email . (empty($name) ? '' : ' (' . $name . ')');
|
||||
} else if (!empty($name)) {
|
||||
return $name;
|
||||
} else if (!empty($uri)) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10
|
||||
|| $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03
|
||||
) {
|
||||
return; // pre-registered at Feed level
|
||||
}
|
||||
$atomDetected = $this->_getAtomType();
|
||||
switch ($atomDetected) {
|
||||
case Zend_Feed_Reader::TYPE_ATOM_03:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03);
|
||||
break;
|
||||
default:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the presence of any Atom namespaces in use
|
||||
*/
|
||||
protected function _getAtomType()
|
||||
{
|
||||
$nslist = $this->getDomDocument()->documentElement->attributes;
|
||||
if (!$nslist->length) {
|
||||
return null;
|
||||
}
|
||||
foreach ($nslist as $ns) {
|
||||
if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_10) {
|
||||
return Zend_Feed_Reader::TYPE_ATOM_10;
|
||||
}
|
||||
if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_03) {
|
||||
return Zend_Feed_Reader::TYPE_ATOM_03;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
441
libs/Zend/Feed/Reader/Extension/Atom/Feed.php
Normal file
441
libs/Zend/Feed/Reader/Extension/Atom/Feed.php
Normal file
@ -0,0 +1,441 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Feed.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Atom_Feed
|
||||
extends Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Get a single author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = $this->_xpath->query('//atom:author');
|
||||
$contributors = $this->_xpath->query('//atom:contributor');
|
||||
|
||||
$people = array();
|
||||
|
||||
if ($authors->length) {
|
||||
foreach ($authors as $author) {
|
||||
$author = $this->_getAuthor($author);
|
||||
|
||||
if (!empty($author)) {
|
||||
$people[] = $author;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($contributors->length) {
|
||||
foreach ($contributors as $contributor) {
|
||||
$contributor = $this->_getAuthor($contributor);
|
||||
|
||||
if (!empty($contributor)) {
|
||||
$people[] = $contributor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($people)) {
|
||||
$people = null;
|
||||
} else {
|
||||
$people = array_unique($people);
|
||||
}
|
||||
|
||||
$this->_data['authors'] = $people;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copyright entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (array_key_exists('copyright', $this->_data)) {
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
$copyright = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$copyright = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:copyright)');
|
||||
} else {
|
||||
$copyright = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
$this->_data['copyright'] = $copyright;
|
||||
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return Zend_Date|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (array_key_exists('datecreated', $this->_data)) {
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:created)');
|
||||
} else {
|
||||
$dateCreated = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:published)');
|
||||
}
|
||||
|
||||
if ($dateCreated) {
|
||||
$date = new Zend_Date;
|
||||
$date->set($dateCreated, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['datecreated'] = $date;
|
||||
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return Zend_Date|null
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)');
|
||||
} else {
|
||||
$dateModified = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:updated)');
|
||||
}
|
||||
|
||||
if ($dateModified) {
|
||||
$date = new Zend_Date;
|
||||
$date->set($dateModified, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['datemodified'] = $date;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = null;
|
||||
|
||||
if ($this->getType() === Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:tagline)'); // TODO: Is this the same as subtitle?
|
||||
} else {
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:subtitle)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed generator entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
if (array_key_exists('generator', $this->_data)) {
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
// TODO: Add uri support
|
||||
$generator = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:generator)');
|
||||
|
||||
if (!$generator) {
|
||||
$generator = null;
|
||||
} else {
|
||||
$generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
|
||||
$this->_data['generator'] = $generator;
|
||||
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:id)');
|
||||
|
||||
if (!$id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
$id = $this->getTitle();
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed language
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (array_key_exists('language', $this->_data)) {
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
$language = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:lang)');
|
||||
|
||||
if (!$language) {
|
||||
$language = $this->_xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
$this->_data['language'] = $language;
|
||||
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the source website
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (array_key_exists('link', $this->_data)) {
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
$link = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:link/@href)');
|
||||
|
||||
if (!$link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
$this->_data['link'] = $link;
|
||||
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the feed's XML Url
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFeedLink()
|
||||
{
|
||||
if (array_key_exists('feedlink', $this->_data)) {
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
$link = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:link[@rel="self"]/@href)');
|
||||
|
||||
if (!$link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
$this->_data['feedlink'] = $link;
|
||||
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:title)');
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an author entry in RSS format
|
||||
*
|
||||
* @param DOMElement $element
|
||||
* @return string
|
||||
*/
|
||||
protected function _getAuthor(DOMElement $element)
|
||||
{
|
||||
$email = null;
|
||||
$name = null;
|
||||
$uri = null;
|
||||
|
||||
$emailNode = $element->getElementsByTagName('email');
|
||||
$nameNode = $element->getElementsByTagName('name');
|
||||
$uriNode = $element->getElementsByTagName('uri');
|
||||
|
||||
if ($emailNode->length) {
|
||||
$email = $emailNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if ($nameNode->length) {
|
||||
$name = $nameNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if ($uriNode->length) {
|
||||
$uri = $uriNode->item(0)->nodeValue;
|
||||
}
|
||||
|
||||
if (!empty($email)) {
|
||||
return $email . (empty($name) ? '' : ' (' . $name . ')');
|
||||
} else if (!empty($name)) {
|
||||
return $name;
|
||||
} else if (!empty($uri)) {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10
|
||||
|| $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03
|
||||
) {
|
||||
return; // pre-registered at Feed level
|
||||
}
|
||||
$atomDetected = $this->_getAtomType();
|
||||
switch ($atomDetected) {
|
||||
case Zend_Feed_Reader::TYPE_ATOM_03:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03);
|
||||
break;
|
||||
default:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the presence of any Atom namespaces in use
|
||||
*/
|
||||
protected function _getAtomType()
|
||||
{
|
||||
$nslist = $this->getDomDocument()->documentElement->attributes;
|
||||
if (!$nslist->length) {
|
||||
return null;
|
||||
}
|
||||
foreach ($nslist as $ns) {
|
||||
if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_10) {
|
||||
return Zend_Feed_Reader::TYPE_ATOM_10;
|
||||
}
|
||||
if ($ns->value == Zend_Feed_Reader::NAMESPACE_ATOM_03) {
|
||||
return Zend_Feed_Reader::TYPE_ATOM_03;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
64
libs/Zend/Feed/Reader/Extension/Content/Entry.php
Normal file
64
libs/Zend/Feed/Reader/Extension/Content/Entry.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Entry_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Content_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10
|
||||
&& $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090
|
||||
) {
|
||||
$content = $this->_xpath->evaluate('string('.$this->getXpathPrefix().'/content:encoded)');
|
||||
} else {
|
||||
$content = $this->_xpath->evaluate('string('.$this->getXpathPrefix().'/content:encoded)');
|
||||
}
|
||||
if ($content) {
|
||||
$content = html_entity_decode($content, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register RSS Content Module namespace
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('content', 'http://purl.org/rss/1.0/modules/content/');
|
||||
}
|
||||
}
|
97
libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php
Normal file
97
libs/Zend/Feed/Reader/Extension/CreativeCommons/Entry.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_CreativeCommons_Feed
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/CreativeCommons/Feed.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_CreativeCommons_Entry extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry license
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLicense($index = 0)
|
||||
{
|
||||
$licenses = $this->getLicenses();
|
||||
|
||||
if (isset($licenses[$index])) {
|
||||
return $licenses[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry licenses
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLicenses()
|
||||
{
|
||||
$name = 'licenses';
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$licenses = array();
|
||||
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//cc:license');
|
||||
|
||||
if ($list->length) {
|
||||
foreach ($list as $license) {
|
||||
$licenses[] = $license->nodeValue;
|
||||
}
|
||||
|
||||
$licenses = array_unique($licenses);
|
||||
} else {
|
||||
$cc = new Zend_Feed_Reader_Extension_CreativeCommons_Feed(
|
||||
$this->_domDocument, $this->_data['type'], $this->_xpath
|
||||
);
|
||||
$licenses = $cc->getLicenses();
|
||||
}
|
||||
|
||||
$this->_data[$name] = $licenses;
|
||||
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Creative Commons namespaces
|
||||
*
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('cc', 'http://backend.userland.com/creativeCommonsRssModule');
|
||||
}
|
||||
}
|
89
libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php
Normal file
89
libs/Zend/Feed/Reader/Extension/CreativeCommons/Feed.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Feed.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_CreativeCommons_Feed
|
||||
extends Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry license
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLicense($index = 0)
|
||||
{
|
||||
$licenses = $this->getLicenses();
|
||||
|
||||
if (isset($licenses[$index])) {
|
||||
return $licenses[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry licenses
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLicenses()
|
||||
{
|
||||
$name = 'licenses';
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$licenses = array();
|
||||
$list = $this->_xpath->evaluate('channel/cc:license');
|
||||
|
||||
if ($list->length) {
|
||||
foreach ($list as $license) {
|
||||
$licenses[] = $license->nodeValue;
|
||||
}
|
||||
|
||||
$licenses = array_unique($licenses);
|
||||
}
|
||||
|
||||
$this->_data[$name] = $licenses;
|
||||
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Creative Commons namespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('cc', 'http://backend.userland.com/creativeCommonsRssModule');
|
||||
}
|
||||
}
|
232
libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php
Normal file
232
libs/Zend/Feed/Reader/Extension/DublinCore/Entry.php
Normal file
@ -0,0 +1,232 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16711 2009-07-14 16:10:54Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_DublinCore_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get an author entry
|
||||
*
|
||||
* @param DOMElement $element
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
||||
if ($list->length) {
|
||||
foreach ($list as $author) {
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_20
|
||||
&& preg_match("/\(([^\)]+)\)/", $author->nodeValue, $matches, PREG_OFFSET_CAPTURE)
|
||||
) {
|
||||
$authors[] = $matches[1][0];
|
||||
} else {
|
||||
$authors[] = $author->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
$authors = array_unique($authors);
|
||||
}
|
||||
|
||||
$this->_data['authors'] = $authors;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry content
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->getDescription();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = null;
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = null;
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry title
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = null;
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Zend_Date|null
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
if (array_key_exists('date', $this->_data)) {
|
||||
return $this->_data['date'];
|
||||
}
|
||||
|
||||
$d = null;
|
||||
$date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
if ($date) {
|
||||
$d = new Zend_Date;
|
||||
$d->set($date, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['date'] = $d;
|
||||
|
||||
return $this->_data['date'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register DC namespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('dc10', 'http://purl.org/dc/elements/1.0/');
|
||||
$this->_xpath->registerNamespace('dc11', 'http://purl.org/dc/elements/1.1/');
|
||||
}
|
||||
}
|
265
libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php
Normal file
265
libs/Zend/Feed/Reader/Extension/DublinCore/Feed.php
Normal file
@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Feed.php 16711 2009-07-14 16:10:54Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_DublinCore_Feed
|
||||
extends Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Get a single author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
$list = $this->_xpath->query('//dc11:creator');
|
||||
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->query('//dc10:creator');
|
||||
}
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->query('//dc11:publisher');
|
||||
|
||||
if (!$list->length) {
|
||||
$list = $this->_xpath->query('//dc10:publisher');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($list as $authorObj) {
|
||||
$authors[] = $authorObj->nodeValue;
|
||||
}
|
||||
|
||||
if (!empty($authors)) {
|
||||
$authors = array_unique($authors);
|
||||
}
|
||||
|
||||
$this->_data['authors'] = $authors;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copyright entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (array_key_exists('copyright', $this->_data)) {
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
$copyright = null;
|
||||
$copyright = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:rights)');
|
||||
|
||||
if (!$copyright) {
|
||||
$copyright = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:rights)');
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
$this->_data['copyright'] = $copyright;
|
||||
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = null;
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
|
||||
|
||||
if (!$description) {
|
||||
$description = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = null;
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
|
||||
|
||||
if (!$id) {
|
||||
$id = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed language
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (array_key_exists('language', $this->_data)) {
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
$language = null;
|
||||
$language = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:language)');
|
||||
|
||||
if (!$language) {
|
||||
$language = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:language)');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
$this->_data['language'] = $language;
|
||||
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = null;
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
|
||||
|
||||
if (!$title) {
|
||||
$title = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Zend_Date|null
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
if (array_key_exists('date', $this->_data)) {
|
||||
return $this->_data['date'];
|
||||
}
|
||||
|
||||
$d = null;
|
||||
$date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
|
||||
}
|
||||
|
||||
if ($date) {
|
||||
$d = new Zend_Date;
|
||||
$d->set($date, Zend_Date::ISO_8601);
|
||||
}
|
||||
|
||||
$this->_data['date'] = $d;
|
||||
|
||||
return $this->_data['date'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('dc10', 'http://purl.org/dc/elements/1.0/');
|
||||
$this->_xpath->registerNamespace('dc11', 'http://purl.org/dc/elements/1.1/');
|
||||
}
|
||||
}
|
197
libs/Zend/Feed/Reader/Extension/EntryAbstract.php
Normal file
197
libs/Zend/Feed/Reader/Extension/EntryAbstract.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: EntryAbstract.php 16711 2009-07-14 16:10:54Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Feed entry data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
* DOM document object
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $_domDocument = null;
|
||||
|
||||
/**
|
||||
* Entry instance
|
||||
*
|
||||
* @var Zend_Feed_Entry_Abstract
|
||||
*/
|
||||
protected $_entry = null;
|
||||
|
||||
/**
|
||||
* Pointer to the current entry
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_entryKey = 0;
|
||||
|
||||
/**
|
||||
* XPath object
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $_xpath = null;
|
||||
|
||||
/**
|
||||
* XPath query
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_xpathPrefix = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Feed_Entry_Abstract $entry
|
||||
* @param int $entryKey
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DOMElement $entry, $entryKey, $type = null)
|
||||
{
|
||||
$this->_entry = $entry;
|
||||
$this->_entryKey = $entryKey;
|
||||
$this->_domDocument = $entry->ownerDocument;
|
||||
|
||||
if (!is_null($type)) {
|
||||
$this->_data['type'] = $type;
|
||||
} else {
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType($feed);
|
||||
}
|
||||
// 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()
|
||||
{
|
||||
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();
|
||||
}
|
166
libs/Zend/Feed/Reader/Extension/FeedAbstract.php
Normal file
166
libs/Zend/Feed/Reader/Extension/FeedAbstract.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FeedAbstract.php 16711 2009-07-14 16:10:54Z matthew $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Entry_Atom
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Entry/Atom.php';
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Entry_Rss
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Entry/Rss.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Parsed feed data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
* Parsed feed data in the shape of a DOMDocument
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $_domDocument = null;
|
||||
|
||||
/**
|
||||
* The base XPath query used to retrieve feed data
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $_xpath = null;
|
||||
|
||||
/**
|
||||
* The XPath prefix
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_xpathPrefix = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Feed_Abstract $feed The source Zend_Feed object
|
||||
* @param string $type Feed type
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(DomDocument $dom, $type = null, DOMXPath $xpath = null)
|
||||
{
|
||||
$this->_domDocument = $dom;
|
||||
|
||||
if ($type !== null) {
|
||||
$this->_data['type'] = $type;
|
||||
} else {
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType($dom);
|
||||
}
|
||||
|
||||
if ($xpath !== null) {
|
||||
$this->_xpath = $xpath;
|
||||
} else {
|
||||
$this->_xpath = new DOMXPath($this->_domDocument);
|
||||
}
|
||||
|
||||
$this->_registerNamespaces();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOM
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
return $this->_domDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Feed's encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
$assumed = $this->getDomDocument()->encoding;
|
||||
return $assumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_data['type'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the feed as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray() // untested
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the XPath prefix
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getXpathPrefix()
|
||||
{
|
||||
return $this->_xpathPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the XPath prefix
|
||||
*
|
||||
* @return Zend_Feed_Reader_Feed_Atom
|
||||
*/
|
||||
public function setXpathPrefix($prefix)
|
||||
{
|
||||
$this->_xpathPrefix = $prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*/
|
||||
abstract protected function _registerNamespaces();
|
||||
}
|
202
libs/Zend/Feed/Reader/Extension/Podcast/Entry.php
Normal file
202
libs/Zend/Feed/Reader/Extension/Podcast/Entry.php
Normal file
@ -0,0 +1,202 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16792 2009-07-17 02:52:37Z norm2782 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Podcast_Entry extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCastAuthor()
|
||||
{
|
||||
if (isset($this->_data['author'])) {
|
||||
return $this->_data['author'];
|
||||
}
|
||||
|
||||
$author = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
$this->_data['author'] = $author;
|
||||
|
||||
return $this->_data['author'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
{
|
||||
if (isset($this->_data['block'])) {
|
||||
return $this->_data['block'];
|
||||
}
|
||||
|
||||
$block = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
$this->_data['block'] = $block;
|
||||
|
||||
return $this->_data['block'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry duration
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDuration()
|
||||
{
|
||||
if (isset($this->_data['duration'])) {
|
||||
return $this->_data['duration'];
|
||||
}
|
||||
|
||||
$duration = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:duration)');
|
||||
|
||||
if (!$duration) {
|
||||
$duration = null;
|
||||
}
|
||||
|
||||
$this->_data['duration'] = $duration;
|
||||
|
||||
return $this->_data['duration'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry explicit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExplicit()
|
||||
{
|
||||
if (isset($this->_data['explicit'])) {
|
||||
return $this->_data['explicit'];
|
||||
}
|
||||
|
||||
$explicit = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
$this->_data['explicit'] = $explicit;
|
||||
|
||||
return $this->_data['explicit'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords()
|
||||
{
|
||||
if (isset($this->_data['keywords'])) {
|
||||
return $this->_data['keywords'];
|
||||
}
|
||||
|
||||
$keywords = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
$this->_data['keywords'] = $keywords;
|
||||
|
||||
return $this->_data['keywords'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry subtitle
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtitle()
|
||||
{
|
||||
if (isset($this->_data['subtitle'])) {
|
||||
return $this->_data['subtitle'];
|
||||
}
|
||||
|
||||
$subtitle = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
$this->_data['subtitle'] = $subtitle;
|
||||
|
||||
return $this->_data['subtitle'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry summary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSummary()
|
||||
{
|
||||
if (isset($this->_data['summary'])) {
|
||||
return $this->_data['summary'];
|
||||
}
|
||||
|
||||
$summary = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
$this->_data['summary'] = $summary;
|
||||
|
||||
return $this->_data['summary'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register iTunes namespace
|
||||
*
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
}
|
||||
}
|
293
libs/Zend/Feed/Reader/Extension/Podcast/Feed.php
Normal file
293
libs/Zend/Feed/Reader/Extension/Podcast/Feed.php
Normal file
@ -0,0 +1,293 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Feed.php 16792 2009-07-17 02:52:37Z norm2782 $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Podcast_Feed extends Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCastAuthor()
|
||||
{
|
||||
if (isset($this->_data['author'])) {
|
||||
return $this->_data['author'];
|
||||
}
|
||||
|
||||
$author = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:author)');
|
||||
|
||||
if (!$author) {
|
||||
$author = null;
|
||||
}
|
||||
|
||||
$this->_data['author'] = $author;
|
||||
|
||||
return $this->_data['author'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBlock()
|
||||
{
|
||||
if (isset($this->_data['block'])) {
|
||||
return $this->_data['block'];
|
||||
}
|
||||
|
||||
$block = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:block)');
|
||||
|
||||
if (!$block) {
|
||||
$block = null;
|
||||
}
|
||||
|
||||
$this->_data['block'] = $block;
|
||||
|
||||
return $this->_data['block'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry category
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
if (isset($this->_data['categories'])) {
|
||||
return $this->_data['categories'];
|
||||
}
|
||||
|
||||
$categoryList = $this->_xpath->query($this->getXpathPrefix() . '/itunes:category');
|
||||
|
||||
$categories = array();
|
||||
|
||||
if ($categoryList->length > 0) {
|
||||
foreach ($categoryList as $node) {
|
||||
$children = null;
|
||||
|
||||
if ($node->childNodes->length > 0) {
|
||||
$children = array();
|
||||
|
||||
foreach ($node->childNodes as $childNode) {
|
||||
if (!($childNode instanceof DOMText)) {
|
||||
$children[$childNode->getAttribute('text')] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$categories[$node->getAttribute('text')] = $children;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$categories) {
|
||||
$categories = null;
|
||||
}
|
||||
|
||||
$this->_data['categories'] = $categories;
|
||||
|
||||
return $this->_data['categories'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry explicit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExplicit()
|
||||
{
|
||||
if (isset($this->_data['explicit'])) {
|
||||
return $this->_data['explicit'];
|
||||
}
|
||||
|
||||
$explicit = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:explicit)');
|
||||
|
||||
if (!$explicit) {
|
||||
$explicit = null;
|
||||
}
|
||||
|
||||
$this->_data['explicit'] = $explicit;
|
||||
|
||||
return $this->_data['explicit'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry image
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
if (isset($this->_data['image'])) {
|
||||
return $this->_data['image'];
|
||||
}
|
||||
|
||||
$image = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:image/@href)');
|
||||
|
||||
if (!$image) {
|
||||
$image = null;
|
||||
}
|
||||
|
||||
$this->_data['image'] = $image;
|
||||
|
||||
return $this->_data['image'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry keywords
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getKeywords()
|
||||
{
|
||||
if (isset($this->_data['keywords'])) {
|
||||
return $this->_data['keywords'];
|
||||
}
|
||||
|
||||
$keywords = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:keywords)');
|
||||
|
||||
if (!$keywords) {
|
||||
$keywords = null;
|
||||
}
|
||||
|
||||
$this->_data['keywords'] = $keywords;
|
||||
|
||||
return $this->_data['keywords'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry's new feed url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNewFeedUrl()
|
||||
{
|
||||
if (isset($this->_data['new-feed-url'])) {
|
||||
return $this->_data['new-feed-url'];
|
||||
}
|
||||
|
||||
$newFeedUrl = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:new-feed-url)');
|
||||
|
||||
if (!$newFeedUrl) {
|
||||
$newFeedUrl = null;
|
||||
}
|
||||
|
||||
$this->_data['new-feed-url'] = $newFeedUrl;
|
||||
|
||||
return $this->_data['new-feed-url'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry owner
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOwner()
|
||||
{
|
||||
if (isset($this->_data['owner'])) {
|
||||
return $this->_data['owner'];
|
||||
}
|
||||
|
||||
$owner = null;
|
||||
|
||||
$email = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:email)');
|
||||
$name = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:owner/itunes:name)');
|
||||
|
||||
if (!empty($email)) {
|
||||
$owner = $email . (empty($name) ? '' : ' (' . $name . ')');
|
||||
} else if (!empty($name)) {
|
||||
$owner = $name;
|
||||
}
|
||||
|
||||
if (!$owner) {
|
||||
$owner = null;
|
||||
}
|
||||
|
||||
$this->_data['owner'] = $owner;
|
||||
|
||||
return $this->_data['owner'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry subtitle
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtitle()
|
||||
{
|
||||
if (isset($this->_data['subtitle'])) {
|
||||
return $this->_data['subtitle'];
|
||||
}
|
||||
|
||||
$subtitle = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:subtitle)');
|
||||
|
||||
if (!$subtitle) {
|
||||
$subtitle = null;
|
||||
}
|
||||
|
||||
$this->_data['subtitle'] = $subtitle;
|
||||
|
||||
return $this->_data['subtitle'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry summary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSummary()
|
||||
{
|
||||
if (isset($this->_data['summary'])) {
|
||||
return $this->_data['summary'];
|
||||
}
|
||||
|
||||
$summary = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/itunes:summary)');
|
||||
|
||||
if (!$summary) {
|
||||
$summary = null;
|
||||
}
|
||||
|
||||
$this->_data['summary'] = $summary;
|
||||
|
||||
return $this->_data['summary'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Register iTunes namespace
|
||||
*
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
|
||||
}
|
||||
}
|
144
libs/Zend/Feed/Reader/Extension/Slash/Entry.php
Normal file
144
libs/Zend/Feed/Reader/Extension/Slash/Entry.php
Normal file
@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Slash_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry section
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getSection()
|
||||
{
|
||||
return $this->_getData('section');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry department
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDepartment()
|
||||
{
|
||||
return $this->_getData('department');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry hit_parade
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getHitParade()
|
||||
{
|
||||
$name = 'hit_parade';
|
||||
|
||||
if (isset($this->_data[$name])) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$stringParade = $this->_getData($name);
|
||||
$hitParade = array();
|
||||
|
||||
if (!empty($stringParade)) {
|
||||
$stringParade = explode(',', $stringParade);
|
||||
|
||||
foreach ($stringParade as $hit)
|
||||
$hitParade[] = $hit + 0; //cast to integer
|
||||
}
|
||||
|
||||
$this->_data[$name] = $hitParade;
|
||||
return $hitParade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry comments
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
$name = 'comments';
|
||||
|
||||
if (isset($this->_data[$name])) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$comments = $this->_getData($name, 'string');
|
||||
|
||||
if (!$comments) {
|
||||
$this->_data[$name] = null;
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry data specified by name
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function _getData($name, $type = 'string')
|
||||
{
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$data = $this->_xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/slash10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
$this->_data[$name] = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Slash namespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('slash10', 'http://purl.org/rss/1.0/modules/slash/');
|
||||
}
|
||||
}
|
168
libs/Zend/Feed/Reader/Extension/Syndication/Feed.php
Normal file
168
libs/Zend/Feed/Reader/Extension/Syndication/Feed.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Feed.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
|
||||
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Syndication_Feed
|
||||
extends Zend_Feed_Reader_Extension_FeedAbstract
|
||||
{
|
||||
/**
|
||||
* Get update period
|
||||
* @return string
|
||||
*/
|
||||
public function getUpdatePeriod()
|
||||
{
|
||||
$name = 'updatePeriod';
|
||||
$period = $this->_getData($name);
|
||||
|
||||
if ($period === null) {
|
||||
$this->_data[$name] = 'daily';
|
||||
return 'daily'; //Default specified by spec
|
||||
}
|
||||
|
||||
switch ($period)
|
||||
{
|
||||
case 'hourly':
|
||||
case 'daily':
|
||||
case 'weekly':
|
||||
case 'yearly':
|
||||
return $period;
|
||||
default:
|
||||
throw new Zend_Feed_Exception("Feed specified invalid update period: '$period'."
|
||||
. " Must be one of hourly, daily, weekly or yearly"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update frequency
|
||||
* @return int
|
||||
*/
|
||||
public function getUpdateFrequency()
|
||||
{
|
||||
$name = 'updateFrequency';
|
||||
$freq = $this->_getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
$this->_data[$name] = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return $freq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update frequency as ticks
|
||||
* @return int
|
||||
*/
|
||||
public function getUpdateFrequencyAsTicks()
|
||||
{
|
||||
$name = 'updateFrequency';
|
||||
$freq = $this->_getData($name, 'number');
|
||||
|
||||
if (!$freq || $freq < 1) {
|
||||
$this->_data[$name] = 1;
|
||||
$freq = 1;
|
||||
}
|
||||
|
||||
$period = $this->getUpdatePeriod();
|
||||
$ticks = 1;
|
||||
|
||||
switch ($period)
|
||||
{
|
||||
//intentional fall through
|
||||
case 'yearly':
|
||||
$ticks *= 52; //TODO: fix generalisation, how?
|
||||
case 'weekly':
|
||||
$ticks *= 7;
|
||||
case 'daily':
|
||||
$ticks *= 24;
|
||||
case 'hourly':
|
||||
$ticks *= 3600;
|
||||
break;
|
||||
default: //Never arrive here, exception thrown in getPeriod()
|
||||
break;
|
||||
}
|
||||
|
||||
return $ticks / $freq;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get update base
|
||||
*
|
||||
* @return Zend_Date|null
|
||||
*/
|
||||
public function getUpdateBase()
|
||||
{
|
||||
$updateBase = $this->_getData('updateBase');
|
||||
$date = null;
|
||||
if ($updateBase) {
|
||||
$date = new Zend_Date;
|
||||
$date->set($updateBase, Zend_Date::W3C);
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry data specified by name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @return mixed|null
|
||||
*/
|
||||
private function _getData($name, $type = 'string')
|
||||
{
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$data = $this->_xpath->evaluate($type . '(' . $this->getXpathPrefix() . '/syn10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
$this->_data[$name] = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Syndication namespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('syn10', 'http://purl.org/rss/1.0/modules/syndication/');
|
||||
}
|
||||
}
|
91
libs/Zend/Feed/Reader/Extension/Thread/Entry.php
Normal file
91
libs/Zend/Feed/Reader/Extension/Thread/Entry.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_Thread_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the "in-reply-to" value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getInReplyTo()
|
||||
{
|
||||
// TODO: to be implemented
|
||||
}
|
||||
|
||||
// TODO: Implement "replies" and "updated" constructs from standard
|
||||
|
||||
/**
|
||||
* Get the total number of threaded responses (i.e comments)
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCommentCount()
|
||||
{
|
||||
return $this->_getData('total');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the entry data specified by name
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $type
|
||||
* @return mixed|null
|
||||
*/
|
||||
protected function _getData($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$data = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/thread10:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
$this->_data[$name] = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Atom Thread Extension 1.0 namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('thread10', 'http://purl.org/syndication/thread/1.0');
|
||||
}
|
||||
}
|
73
libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php
Normal file
73
libs/Zend/Feed/Reader/Extension/WellFormedWeb/Entry.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_EntryAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Extension_WellFormedWeb_Entry
|
||||
extends Zend_Feed_Reader_Extension_EntryAbstract
|
||||
{
|
||||
/**
|
||||
* Get the entry comment Uri
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCommentFeedLink()
|
||||
{
|
||||
$name = 'commentRss';
|
||||
if (array_key_exists($name, $this->_data)) {
|
||||
return $this->_data[$name];
|
||||
}
|
||||
|
||||
$data = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/wfw:' . $name . ')');
|
||||
|
||||
if (!$data) {
|
||||
$data = null;
|
||||
}
|
||||
|
||||
$this->_data[$name] = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Slash namespaces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
$this->_xpath->registerNamespace('wfw', 'http://wellformedweb.org/CommentAPI/');
|
||||
}
|
||||
}
|
329
libs/Zend/Feed/Reader/Feed/Atom.php
Normal file
329
libs/Zend/Feed/Reader/Feed/Atom.php
Normal file
@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Atom.php 16963 2009-07-22 14:39:31Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_Atom_Feed
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Feed_Abstract $feed
|
||||
* @param string $type
|
||||
* @param string $xpath
|
||||
*/
|
||||
public function __construct(DomDocument $dom, $type = null)
|
||||
{
|
||||
parent::__construct($dom, $type);
|
||||
$atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Feed');
|
||||
$this->_extensions['Atom_Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath);
|
||||
foreach ($this->_extensions as $extension) {
|
||||
$extension->setXpathPrefix('/atom:feed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$people = $this->getExtension('Atom')->getAuthors();
|
||||
|
||||
$this->_data['authors'] = $people;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copyright entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (array_key_exists('copyright', $this->_data)) {
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
|
||||
if (!$copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
$this->_data['copyright'] = $copyright;
|
||||
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
if (array_key_exists('datecreated', $this->_data)) {
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
$dateCreated = $this->getExtension('Atom')->getDateCreated();
|
||||
|
||||
if (!$dateCreated) {
|
||||
$dateCreated = null;
|
||||
}
|
||||
|
||||
$this->_data['datecreated'] = $dateCreated;
|
||||
|
||||
return $this->_data['datecreated'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$dateModified = $this->getExtension('Atom')->getDateModified();
|
||||
|
||||
if (!$dateModified) {
|
||||
$dateModified = null;
|
||||
}
|
||||
|
||||
$this->_data['datemodified'] = $dateModified;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed generator entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
if (array_key_exists('generator', $this->_data)) {
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
|
||||
$generator = $this->getExtension('Atom')->getGenerator();
|
||||
|
||||
$this->_data['generator'] = $generator;
|
||||
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = $this->getExtension('Atom')->getId();
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed language
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (array_key_exists('language', $this->_data)) {
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
|
||||
if (!$language) {
|
||||
$language = $this->_xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
$this->_data['language'] = $language;
|
||||
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the source website
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (array_key_exists('link', $this->_data)) {
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
$link = $this->getExtension('Atom')->getLink();
|
||||
|
||||
$this->_data['link'] = $link;
|
||||
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the feed's XML Url
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFeedLink()
|
||||
{
|
||||
if (array_key_exists('feedlink', $this->_data)) {
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
$link = $this->getExtension('Atom')->getFeedLink();
|
||||
|
||||
$this->_data['feedlink'] = $link;
|
||||
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all entries to the internal entries array
|
||||
*
|
||||
*/
|
||||
protected function _indexEntries()
|
||||
{
|
||||
if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10 ||
|
||||
$this->getType() == Zend_Feed_Reader::TYPE_ATOM_03) {
|
||||
$entries = array();
|
||||
$entries = $this->_xpath->evaluate('//atom:entry');
|
||||
|
||||
foreach($entries as $index=>$entry) {
|
||||
$this->_entries[$index] = $entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
switch ($this->_data['type']) {
|
||||
case Zend_Feed_Reader::TYPE_ATOM_03:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03);
|
||||
break;
|
||||
case Zend_Feed_Reader::TYPE_ATOM_10:
|
||||
default:
|
||||
$this->_xpath->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10);
|
||||
}
|
||||
}
|
||||
}
|
533
libs/Zend/Feed/Reader/Feed/Rss.php
Normal file
533
libs/Zend/Feed/Reader/Feed/Rss.php
Normal file
@ -0,0 +1,533 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Rss.php 16963 2009-07-22 14:39:31Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_FeedAbstract
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/FeedAbstract.php';
|
||||
|
||||
/**
|
||||
* @see Zend_feed_Reader_Extension_Atom_Feed
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/Atom/Feed.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Extension_DublinCore_Feed
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Extension/DublinCore/Feed.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Date
|
||||
*/
|
||||
require_once 'Zend/Date.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Zend_Feed_Abstract $feed
|
||||
* @param string $type
|
||||
* @param string $xpath
|
||||
*/
|
||||
public function __construct(DomDocument $dom, $type = null)
|
||||
{
|
||||
parent::__construct($dom, $type);
|
||||
|
||||
$dublinCoreClass = Zend_Feed_Reader::getPluginLoader()->getClassName('DublinCore_Feed');
|
||||
$this->_extensions['DublinCore_Feed'] = new $dublinCoreClass($dom, $this->_data['type'], $this->_xpath);
|
||||
$atomClass = Zend_Feed_Reader::getPluginLoader()->getClassName('Atom_Feed');
|
||||
$this->_extensions['Atom_Feed'] = new $atomClass($dom, $this->_data['type'], $this->_xpath);
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$xpathPrefix = '/rss/channel';
|
||||
} else {
|
||||
$xpathPrefix = '/rdf:RDF/rss:channel';
|
||||
}
|
||||
foreach ($this->_extensions as $extension) {
|
||||
$extension->setXpathPrefix($xpathPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0)
|
||||
{
|
||||
$authors = $this->getAuthors();
|
||||
|
||||
if (isset($authors[$index])) {
|
||||
return $authors[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors()
|
||||
{
|
||||
if (array_key_exists('authors', $this->_data)) {
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
$authors = array();
|
||||
|
||||
if (empty($authors)) {
|
||||
$authors = $this->getExtension('DublinCore')->getAuthors();
|
||||
}
|
||||
|
||||
if (empty($authors)) {
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$list = $this->_xpath->query('//author');
|
||||
} else {
|
||||
$list = $this->_xpath->query('//rss:author');
|
||||
}
|
||||
|
||||
foreach ($list as $authorObj) {
|
||||
$authors[] = $authorObj->nodeValue;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($authors)) {
|
||||
$authors = $this->getExtension('Atom')->getAuthors();
|
||||
}
|
||||
|
||||
if (empty($authors)) {
|
||||
$authors = null;
|
||||
} else {
|
||||
$authors = array_unique($authors);
|
||||
}
|
||||
|
||||
$this->_data['authors'] = $authors;
|
||||
|
||||
return $this->_data['authors'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the copyright entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCopyright()
|
||||
{
|
||||
if (array_key_exists('copyright', $this->_data)) {
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
$copyright = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$copyright = $this->_xpath->evaluate('string(/rss/channel/copyright)');
|
||||
}
|
||||
|
||||
if (!$copyright && !is_null($this->getExtension('DublinCore'))) {
|
||||
$copyright = $this->getExtension('DublinCore')->getCopyright();
|
||||
}
|
||||
|
||||
if (empty($copyright)) {
|
||||
$copyright = $this->getExtension('Atom')->getCopyright();
|
||||
}
|
||||
|
||||
if (!$copyright) {
|
||||
$copyright = null;
|
||||
}
|
||||
|
||||
$this->_data['copyright'] = $copyright;
|
||||
|
||||
return $this->_data['copyright'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateCreated()
|
||||
{
|
||||
return $this->getDateModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return Zend_Date
|
||||
*/
|
||||
public function getDateModified()
|
||||
{
|
||||
if (array_key_exists('datemodified', $this->_data)) {
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
$dateModified = null;
|
||||
$date = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$dateModified = $this->_xpath->evaluate('string(/rss/channel/pubDate)');
|
||||
if (!$dateModified) {
|
||||
$dateModified = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)');
|
||||
}
|
||||
if ($dateModified) {
|
||||
$date = new Zend_Date();
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::RFC_822);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::RFC_2822);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
try {
|
||||
$date->set($dateModified, Zend_Date::DATES);
|
||||
} catch (Zend_Date_Exception $e) {
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
throw new Zend_Feed_Exception(
|
||||
'Could not load date due to unrecognised format (should follow RFC 822 or 2822): '
|
||||
. $e->getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->getExtension('DublinCore')->getDate();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = $this->getExtension('Atom')->getDateModified();
|
||||
}
|
||||
|
||||
if (!$date) {
|
||||
$date = null;
|
||||
}
|
||||
|
||||
$this->_data['datemodified'] = $date;
|
||||
|
||||
return $this->_data['datemodified'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
if (array_key_exists('description', $this->_data)) {
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
$description = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$description = $this->_xpath->evaluate('string(/rss/channel/description)');
|
||||
} else {
|
||||
$description = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/rss:description)');
|
||||
}
|
||||
|
||||
if (!$description && !is_null($this->getExtension('DublinCore'))) {
|
||||
$description = $this->getExtension('DublinCore')->getDescription();
|
||||
}
|
||||
|
||||
if (empty($description)) {
|
||||
$description = $this->getExtension('Atom')->getDescription();
|
||||
}
|
||||
|
||||
if (!$description) {
|
||||
$description = null;
|
||||
}
|
||||
|
||||
$this->_data['description'] = $description;
|
||||
|
||||
return $this->_data['description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
if (array_key_exists('id', $this->_data)) {
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
$id = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$id = $this->_xpath->evaluate('string(/rss/channel/guid)');
|
||||
}
|
||||
|
||||
if (!$id && !is_null($this->getExtension('DublinCore'))) {
|
||||
$id = $this->getExtension('DublinCore')->getId();
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
$id = $this->getExtension('Atom')->getId();
|
||||
}
|
||||
|
||||
if (!$id) {
|
||||
if ($this->getLink()) {
|
||||
$id = $this->getLink();
|
||||
} elseif ($this->getTitle()) {
|
||||
$id = $this->getTitle();
|
||||
} else {
|
||||
$id = null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_data['id'] = $id;
|
||||
|
||||
return $this->_data['id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed language
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguage()
|
||||
{
|
||||
if (array_key_exists('language', $this->_data)) {
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
$language = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$language = $this->_xpath->evaluate('string(/rss/channel/language)');
|
||||
}
|
||||
|
||||
if (!$language && !is_null($this->getExtension('DublinCore'))) {
|
||||
$language = $this->getExtension('DublinCore')->getLanguage();
|
||||
}
|
||||
|
||||
if (empty($language)) {
|
||||
$language = $this->getExtension('Atom')->getLanguage();
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
$language = $this->_xpath->evaluate('string(//@xml:lang[1])');
|
||||
}
|
||||
|
||||
if (!$language) {
|
||||
$language = null;
|
||||
}
|
||||
|
||||
$this->_data['language'] = $language;
|
||||
|
||||
return $this->_data['language'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the feed
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
if (array_key_exists('link', $this->_data)) {
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
$link = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$link = $this->_xpath->evaluate('string(/rss/channel/link)');
|
||||
} else {
|
||||
$link = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/rss:link)');
|
||||
}
|
||||
|
||||
if (empty($link)) {
|
||||
$link = $this->getExtension('Atom')->getLink();
|
||||
}
|
||||
|
||||
if (!$link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
$this->_data['link'] = $link;
|
||||
|
||||
return $this->_data['link'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a link to the feed XML
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFeedLink()
|
||||
{
|
||||
if (array_key_exists('feedlink', $this->_data)) {
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
$link = null;
|
||||
|
||||
$link = $this->getExtension('Atom')->getFeedLink();
|
||||
|
||||
if (!$link) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
$this->_data['feedlink'] = $link;
|
||||
|
||||
return $this->_data['feedlink'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed generator entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
if (array_key_exists('generator', $this->_data)) {
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
|
||||
$generator = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$generator = $this->_xpath->evaluate('string(/rss/channel/generator)');
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$generator = $this->_xpath->evaluate('string(/rss/channel/atom:generator)');
|
||||
} else {
|
||||
$generator = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/atom:generator)');
|
||||
}
|
||||
if ($generator) {
|
||||
$generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding());
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($generator)) {
|
||||
$generator = $this->getExtension('Atom')->getGenerator();
|
||||
}
|
||||
|
||||
if (!$generator) {
|
||||
$generator = null;
|
||||
}
|
||||
|
||||
$this->_data['generator'] = $generator;
|
||||
|
||||
return $this->_data['generator'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
if (array_key_exists('title', $this->_data)) {
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
$title = null;
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 &&
|
||||
$this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$title = $this->_xpath->evaluate('string(/rss/channel/title)');
|
||||
} else {
|
||||
$title = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/rss:title)');
|
||||
}
|
||||
|
||||
if (!$title && !is_null($this->getExtension('DublinCore'))) {
|
||||
$title = $this->getExtension('DublinCore')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = $this->getExtension('Atom')->getTitle();
|
||||
}
|
||||
|
||||
if (!$title) {
|
||||
$title = null;
|
||||
}
|
||||
|
||||
$this->_data['title'] = $title;
|
||||
|
||||
return $this->_data['title'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all entries to the internal entries array
|
||||
*
|
||||
*/
|
||||
protected function _indexEntries()
|
||||
{
|
||||
$entries = array();
|
||||
|
||||
if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) {
|
||||
$entries = $this->_xpath->evaluate('//item');
|
||||
} else {
|
||||
$entries = $this->_xpath->evaluate('//rss:item');
|
||||
}
|
||||
|
||||
foreach($entries as $index=>$entry) {
|
||||
$this->_entries[$index] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*
|
||||
*/
|
||||
protected function _registerNamespaces()
|
||||
{
|
||||
switch ($this->_data['type']) {
|
||||
case Zend_Feed_Reader::TYPE_RSS_10:
|
||||
$this->_xpath->registerNamespace('rdf', Zend_Feed_Reader::NAMESPACE_RDF);
|
||||
$this->_xpath->registerNamespace('rss', Zend_Feed_Reader::NAMESPACE_RSS_10);
|
||||
break;
|
||||
|
||||
case Zend_Feed_Reader::TYPE_RSS_090:
|
||||
$this->_xpath->registerNamespace('rdf', Zend_Feed_Reader::NAMESPACE_RDF);
|
||||
$this->_xpath->registerNamespace('rss', Zend_Feed_Reader::NAMESPACE_RSS_090);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
304
libs/Zend/Feed/Reader/FeedAbstract.php
Normal file
304
libs/Zend/Feed/Reader/FeedAbstract.php
Normal file
@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FeedAbstract.php 16966 2009-07-22 15:22:18Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Entry_Atom
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Entry/Atom.php';
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Reader_Entry_Rss
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/Entry/Rss.php';
|
||||
|
||||
/**
|
||||
* @see Zend_feed_Reader_FeedInterface
|
||||
*/
|
||||
require_once 'Zend/Feed/Reader/FeedInterface.php';
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInterface
|
||||
{
|
||||
/**
|
||||
* Parsed feed data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_data = array();
|
||||
|
||||
/**
|
||||
* Parsed feed data in the shape of a DOMDocument
|
||||
*
|
||||
* @var DOMDocument
|
||||
*/
|
||||
protected $_domDocument = null;
|
||||
|
||||
/**
|
||||
* An array of parsed feed entries
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_entries = array();
|
||||
|
||||
/**
|
||||
* A pointer for the iterator to keep track of the entries array
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_entriesKey = 0;
|
||||
|
||||
/**
|
||||
* The base XPath query used to retrieve feed data
|
||||
*
|
||||
* @var DOMXPath
|
||||
*/
|
||||
protected $_xpath = null;
|
||||
|
||||
protected $_extensions = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DomDocument The DOM object for the feed's XML
|
||||
* @param string $type Feed type
|
||||
*/
|
||||
public function __construct(DomDocument $domDocument, $type = null)
|
||||
{
|
||||
$this->_domDocument = $domDocument;
|
||||
$this->_xpath = new DOMXPath($this->_domDocument);
|
||||
|
||||
if ($type !== null) {
|
||||
$this->_data['type'] = $type;
|
||||
} else {
|
||||
$this->_data['type'] = Zend_Feed_Reader::detectType($this->_domDocument);
|
||||
}
|
||||
$this->_registerNamespaces();
|
||||
$this->_indexEntries();
|
||||
$this->_loadExtensions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of feed entries.
|
||||
* Required by the Iterator interface.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->_entries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current entry
|
||||
*
|
||||
* @return Zend_Feed_Reader_Entry_Interface
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
if (substr($this->getType(), 0, 3) == 'rss') {
|
||||
$reader = new Zend_Feed_Reader_Entry_Rss($this->_entries[$this->key()], $this->key(), $this->getType());
|
||||
} else {
|
||||
$reader = new Zend_Feed_Reader_Entry_Atom($this->_entries[$this->key()], $this->key(), $this->getType());
|
||||
}
|
||||
|
||||
$reader->setXpath($this->_xpath);
|
||||
|
||||
return $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOM
|
||||
*
|
||||
* @return DOMDocument
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
return $this->_domDocument;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Feed's encoding
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEncoding()
|
||||
{
|
||||
$assumed = $this->getDomDocument()->encoding;
|
||||
return $assumed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get feed as xml
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function saveXml()
|
||||
{
|
||||
return $this->getDomDocument()->saveXml();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOMElement representing the items/feed element
|
||||
*
|
||||
* @return DOMElement
|
||||
*/
|
||||
public function getElement()
|
||||
{
|
||||
return $this->getDomDocument()->documentElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the DOMXPath object for this feed
|
||||
*
|
||||
* @return DOMXPath
|
||||
*/
|
||||
public function getXpath()
|
||||
{
|
||||
return $this->_xpath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the feed type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->_data['type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current feed key
|
||||
*
|
||||
* @return unknown
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->_entriesKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the feed pointer forward
|
||||
*
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
++$this->_entriesKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the pointer in the feed object
|
||||
*
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->_entriesKey = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the feed as an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray() // untested
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the iterator is still valid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return 0 <= $this->_entriesKey && $this->_entriesKey < $this->count();
|
||||
}
|
||||
|
||||
public function getExtensions()
|
||||
{
|
||||
return $this->_extensions;
|
||||
}
|
||||
|
||||
public function __call($method, $args)
|
||||
{
|
||||
foreach ($this->_extensions as $extension) {
|
||||
if (method_exists($extension, $method)) {
|
||||
return call_user_func_array(array($extension, $method), $args);
|
||||
}
|
||||
}
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
throw new Zend_Feed_Exception('Method: ' . $method
|
||||
. 'does not exist and could not be located on a registered Extension');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Extension object with the matching name (postfixed with _Feed)
|
||||
*
|
||||
* @param string $name
|
||||
* @return Zend_Feed_Reader_Extension_FeedAbstract
|
||||
*/
|
||||
public function getExtension($name)
|
||||
{
|
||||
if (array_key_exists($name . '_Feed', $this->_extensions)) {
|
||||
return $this->_extensions[$name . '_Feed'];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function _loadExtensions()
|
||||
{
|
||||
$all = Zend_Feed_Reader::getExtensions();
|
||||
$feed = $all['feed'];
|
||||
foreach ($feed as $extension) {
|
||||
if (in_array($extension, $all['core'])) {
|
||||
continue;
|
||||
}
|
||||
$className = Zend_Feed_Reader::getPluginLoader()->getClassName($extension);
|
||||
$this->_extensions[$extension] = new $className(
|
||||
$this->getDomDocument(), $this->_data['type'], $this->_xpath
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all entries to the internal entries array
|
||||
*
|
||||
*/
|
||||
abstract protected function _indexEntries();
|
||||
|
||||
/**
|
||||
* Register the default namespaces for the current feed format
|
||||
*
|
||||
*/
|
||||
abstract protected function _registerNamespaces();
|
||||
}
|
115
libs/Zend/Feed/Reader/FeedInterface.php
Normal file
115
libs/Zend/Feed/Reader/FeedInterface.php
Normal file
@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: FeedInterface.php 16953 2009-07-22 11:57:25Z padraic $
|
||||
*/
|
||||
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Feed_Reader
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Feed_Reader_FeedInterface extends Iterator, Countable
|
||||
{
|
||||
/**
|
||||
* Get a single author
|
||||
*
|
||||
* @param int $index
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAuthor($index = 0);
|
||||
|
||||
/**
|
||||
* Get an array with feed authors
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthors();
|
||||
|
||||
/**
|
||||
* Get the copyright entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getCopyright();
|
||||
|
||||
/**
|
||||
* Get the feed creation date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateCreated();
|
||||
|
||||
/**
|
||||
* Get the feed modification date
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateModified();
|
||||
|
||||
/**
|
||||
* Get the feed description
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDescription();
|
||||
|
||||
/**
|
||||
* Get the feed generator entry
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getGenerator();
|
||||
|
||||
/**
|
||||
* Get the feed ID
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getId();
|
||||
|
||||
/**
|
||||
* Get the feed language
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLanguage();
|
||||
|
||||
/**
|
||||
* Get a link to the HTML source
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getLink();
|
||||
|
||||
/**
|
||||
* Get a link to the XML feed
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFeedLink();
|
||||
|
||||
/**
|
||||
* Get the feed title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTitle();
|
||||
|
||||
}
|
Reference in New Issue
Block a user