import v1.1.0_RC2 | 2009-09-20

This commit is contained in:
2019-07-17 22:19:00 +02:00
parent 3b7ba80568
commit 38c146901c
2504 changed files with 101817 additions and 62316 deletions

View 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;
}
}
}
}

View 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;
}
}
}
}

View 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/');
}
}

View 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');
}
}

View 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');
}
}

View 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/');
}
}

View 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/');
}
}

View 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();
}

View 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();
}

View 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');
}
}

View 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');
}
}

View 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/');
}
}

View 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/');
}
}

View 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');
}
}

View 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/');
}
}