CC-2166: Packaging Improvements. Moved the Zend app into airtime_mvc. It is now installed to /var/www/airtime. Storage is now set to /srv/airtime/stor. Utils are now installed to /usr/lib/airtime/utils/. Added install/airtime-dircheck.php as a simple test to see if everything is install/uninstalled correctly.

This commit is contained in:
Paul Baranowski 2011-04-14 18:55:04 -04:00
parent 514777e8d2
commit b11cbd8159
4546 changed files with 138 additions and 51 deletions

View file

@ -0,0 +1,665 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20507 2010-01-21 22:21:07Z padraic $
*/
/**
* @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';
/**
* @see Zend_Uri
*/
require_once 'Zend/Uri.php';
/**
* @see Zend_Feed_Reader_Collection_Category
*/
require_once 'Zend/Feed/Reader/Collection/Category.php';
/**
* @see Zend_Feed_Reader_Feed_Atom_Source
*/
require_once 'Zend/Feed/Reader/Feed/Atom/Source.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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 = array();
$list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:author');
if (!$list->length) {
/**
* TODO: Limit query to feed level els only!
*/
$list = $this->getXpath()->query('//atom:author');
}
if ($list->length) {
foreach ($list as $author) {
$author = $this->_getAuthor($author);
if (!empty($author)) {
$authors[] = $author;
}
}
}
if (count($authors) == 0) {
$authors = null;
} else {
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($authors)
);
}
$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 = null;
$el = $this->getXpath()->query($this->getXpathPrefix() . '/atom:content');
if($el->length > 0) {
$el = $el->item(0);
$type = $el->getAttribute('type');
switch ($type) {
case '':
case 'text':
case 'text/plain':
case 'html':
case 'text/html':
$content = $el->nodeValue;
break;
case 'xhtml':
$this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
$xhtml = $this->getXpath()->query(
$this->getXpathPrefix() . '/atom:content/xhtml:div'
)->item(0);
//$xhtml->setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
$d = new DOMDocument('1.0', $this->getEncoding());
$xhtmls = $d->importNode($xhtml, true);
$d->appendChild($xhtmls);
$content = $this->_collectXhtml(
$d->saveXML(),
$d->lookupPrefix('http://www.w3.org/1999/xhtml')
);
break;
}
}
//var_dump($content); exit;
if (!$content) {
$content = $this->getDescription();
}
$this->_data['content'] = trim($content);
return $this->_data['content'];
}
/**
* Parse out XHTML to remove the namespacing
*/
protected function _collectXhtml($xhtml, $prefix)
{
if (!empty($prefix)) $prefix = $prefix . ':';
$matches = array(
"/<\?xml[^<]*>[^<]*<" . $prefix . "div[^<]*/",
"/<\/" . $prefix . "div>\s*$/"
);
$xhtml = preg_replace($matches, '', $xhtml);
if (!empty($prefix)) {
$xhtml = preg_replace("/(<[\/]?)" . $prefix . "([a-zA-Z]+)/", '$1$2', $xhtml);
}
return $xhtml;
}
/**
* 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->_getAtomType() === Zend_Feed_Reader::TYPE_ATOM_03) {
$dateCreated = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:created)');
} else {
$dateCreated = $this->getXpath()->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->_getAtomType() === Zend_Feed_Reader::TYPE_ATOM_03) {
$dateModified = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/atom:modified)');
} else {
$dateModified = $this->getXpath()->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->getXpath()->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->getXpath()->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->getXpath()->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 the base URI of the feed (if set).
*
* @return string|null
*/
public function getBaseUrl()
{
if (array_key_exists('baseUrl', $this->_data)) {
return $this->_data['baseUrl'];
}
$baseUrl = $this->getXpath()->evaluate('string('
. $this->getXpathPrefix() . '/@xml:base[1]'
. ')');
if (!$baseUrl) {
$baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])');
}
if (!$baseUrl) {
$baseUrl = null;
}
$this->_data['baseUrl'] = $baseUrl;
return $this->_data['baseUrl'];
}
/**
* 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->getXpath()->query(
$this->getXpathPrefix() . '//atom:link[@rel="alternate"]/@href' . '|' .
$this->getXpathPrefix() . '//atom:link[not(@rel)]/@href'
);
if ($list->length) {
foreach ($list as $link) {
$links[] = $this->_absolutiseUri($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->getXpath()->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->getXpath()->registerNamespace('thread10', 'http://purl.org/syndication/thread/1.0');
$list = $this->getXpath()->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->getXpath()->query(
$this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="text/html"]/@href'
);
if ($list->length) {
$link = $list->item(0)->value;
$link = $this->_absolutiseUri($link);
}
$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->getXpath()->query(
$this->getXpathPrefix() . '//atom:link[@rel="replies" and @type="application/'.$type.'+xml"]/@href'
);
if ($list->length) {
$link = $list->item(0)->value;
$link = $this->_absolutiseUri($link);
}
$this->_data['commentfeedlink'] = $link;
return $this->_data['commentfeedlink'];
}
/**
* Get all categories
*
* @return Zend_Feed_Reader_Collection_Category
*/
public function getCategories()
{
if (array_key_exists('categories', $this->_data)) {
return $this->_data['categories'];
}
if ($this->_getAtomType() == Zend_Feed_Reader::TYPE_ATOM_10) {
$list = $this->getXpath()->query($this->getXpathPrefix() . '//atom:category');
} else {
/**
* Since Atom 0.3 did not support categories, it would have used the
* Dublin Core extension. However there is a small possibility Atom 0.3
* may have been retrofittied to use Atom 1.0 instead.
*/
$this->getXpath()->registerNamespace('atom10', Zend_Feed_Reader::NAMESPACE_ATOM_10);
$list = $this->getXpath()->query($this->getXpathPrefix() . '//atom10:category');
}
if ($list->length) {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
foreach ($list as $category) {
$categoryCollection[] = array(
'term' => $category->getAttribute('term'),
'scheme' => $category->getAttribute('scheme'),
'label' => html_entity_decode($category->getAttribute('label'))
);
}
} else {
return new Zend_Feed_Reader_Collection_Category;
}
$this->_data['categories'] = $categoryCollection;
return $this->_data['categories'];
}
/**
* Get source feed metadata from the entry
*
* @return Zend_Feed_Reader_Feed_Atom_Source|null
*/
public function getSource()
{
if (array_key_exists('source', $this->_data)) {
return $this->_data['source'];
}
$source = null;
// TODO: Investigate why _getAtomType() fails here. Is it even needed?
if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) {
$list = $this->getXpath()->query($this->getXpathPrefix() . '/atom:source[1]');
if ($list->length) {
$element = $list->item(0);
$source = new Zend_Feed_Reader_Feed_Atom_Source($element, $this->getXpathPrefix());
}
}
$this->_data['source'] = $source;
return $this->_data['source'];
}
/**
* Attempt to absolutise the URI, i.e. if a relative URI apply the
* xml:base value as a prefix to turn into an absolute URI.
*/
protected function _absolutiseUri($link)
{
if (!Zend_Uri::check($link)) {
if (!is_null($this->getBaseUrl())) {
$link = $this->getBaseUrl() . $link;
if (!Zend_Uri::check($link)) {
$link = null;
}
}
}
return $link;
}
/**
* Get an author entry
*
* @param DOMElement $element
* @return string
*/
protected function _getAuthor(DOMElement $element)
{
$author = array();
$emailNode = $element->getElementsByTagName('email');
$nameNode = $element->getElementsByTagName('name');
$uriNode = $element->getElementsByTagName('uri');
if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) {
$author['email'] = $emailNode->item(0)->nodeValue;
}
if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) {
$author['name'] = $nameNode->item(0)->nodeValue;
}
if ($uriNode->length && strlen($uriNode->item(0)->nodeValue) > 0) {
$author['uri'] = $uriNode->item(0)->nodeValue;
}
if (empty($author)) {
return null;
}
return $author;
}
/**
* Register the default namespaces for the current feed format
*/
protected function _registerNamespaces()
{
switch ($this->_getAtomType()) {
case Zend_Feed_Reader::TYPE_ATOM_03:
$this->getXpath()->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_03);
break;
default:
$this->getXpath()->registerNamespace('atom', Zend_Feed_Reader::NAMESPACE_ATOM_10);
break;
}
}
/**
* Detect the presence of any Atom namespaces in use
*/
protected function _getAtomType()
{
$dom = $this->getDomDocument();
$prefixAtom03 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_03);
$prefixAtom10 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_10);
if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_03)
|| !empty($prefixAtom03)) {
return Zend_Feed_Reader::TYPE_ATOM_03;
}
if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_10)
|| !empty($prefixAtom10)) {
return Zend_Feed_Reader::TYPE_ATOM_10;
}
}
}

View file

@ -0,0 +1,544 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Feed_Reader_Extension_FeedAbstract
*/
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
/**
* @see Zend_Date
*/
require_once 'Zend/Date.php';
/**
* @see Zend_Uri
*/
require_once 'Zend/Uri.php';
/**
* @see Zend_Feed_Reader_Collection_Author
*/
require_once 'Zend/Feed/Reader/Collection/Author.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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'];
}
$list = $this->_xpath->query('//atom:author');
$authors = array();
if ($list->length) {
foreach ($list as $author) {
$author = $this->_getAuthor($author);
if (!empty($author)) {
$authors[] = $author;
}
}
}
if (count($authors) == 0) {
$authors = null;
} else {
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($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_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 the base URI of the feed (if set).
*
* @return string|null
*/
public function getBaseUrl()
{
if (array_key_exists('baseUrl', $this->_data)) {
return $this->_data['baseUrl'];
}
$baseUrl = $this->_xpath->evaluate('string(//@xml:base[1])');
if (!$baseUrl) {
$baseUrl = null;
}
$this->_data['baseUrl'] = $baseUrl;
return $this->_data['baseUrl'];
}
/**
* 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 = null;
$list = $this->_xpath->query(
$this->getXpathPrefix() . '/atom:link[@rel="alternate"]/@href' . '|' .
$this->getXpathPrefix() . '/atom:link[not(@rel)]/@href'
);
if ($list->length) {
$link = $list->item(0)->nodeValue;
$link = $this->_absolutiseUri($link);
}
$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)');
$link = $this->_absolutiseUri($link);
$this->_data['feedlink'] = $link;
return $this->_data['feedlink'];
}
/**
* Get an array of any supported Pusubhubbub endpoints
*
* @return array|null
*/
public function getHubs()
{
if (array_key_exists('hubs', $this->_data)) {
return $this->_data['hubs'];
}
$hubs = array();
$list = $this->_xpath->query($this->getXpathPrefix()
. '//atom:link[@rel="hub"]/@href');
if ($list->length) {
foreach ($list as $uri) {
$hubs[] = $this->_absolutiseUri($uri->nodeValue);
}
} else {
$hubs = null;
}
$this->_data['hubs'] = $hubs;
return $this->_data['hubs'];
}
/**
* 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 all categories
*
* @return Zend_Feed_Reader_Collection_Category
*/
public function getCategories()
{
if (array_key_exists('categories', $this->_data)) {
return $this->_data['categories'];
}
if ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10) {
$list = $this->_xpath->query($this->getXpathPrefix() . '/atom:category');
} else {
/**
* Since Atom 0.3 did not support categories, it would have used the
* Dublin Core extension. However there is a small possibility Atom 0.3
* may have been retrofittied to use Atom 1.0 instead.
*/
$this->_xpath->registerNamespace('atom10', Zend_Feed_Reader::NAMESPACE_ATOM_10);
$list = $this->_xpath->query($this->getXpathPrefix() . '/atom10:category');
}
if ($list->length) {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
foreach ($list as $category) {
$categoryCollection[] = array(
'term' => $category->getAttribute('term'),
'scheme' => $category->getAttribute('scheme'),
'label' => html_entity_decode($category->getAttribute('label'))
);
}
} else {
return new Zend_Feed_Reader_Collection_Category;
}
$this->_data['categories'] = $categoryCollection;
return $this->_data['categories'];
}
/**
* Get an author entry in RSS format
*
* @param DOMElement $element
* @return string
*/
protected function _getAuthor(DOMElement $element)
{
$author = array();
$emailNode = $element->getElementsByTagName('email');
$nameNode = $element->getElementsByTagName('name');
$uriNode = $element->getElementsByTagName('uri');
if ($emailNode->length && strlen($emailNode->item(0)->nodeValue) > 0) {
$author['email'] = $emailNode->item(0)->nodeValue;
}
if ($nameNode->length && strlen($nameNode->item(0)->nodeValue) > 0) {
$author['name'] = $nameNode->item(0)->nodeValue;
}
if ($uriNode->length && strlen($uriNode->item(0)->nodeValue) > 0) {
$author['uri'] = $uriNode->item(0)->nodeValue;
}
if (empty($author)) {
return null;
}
return $author;
}
/**
* Attempt to absolutise the URI, i.e. if a relative URI apply the
* xml:base value as a prefix to turn into an absolute URI.
*/
protected function _absolutiseUri($link)
{
if (!Zend_Uri::check($link)) {
if (!is_null($this->getBaseUrl())) {
$link = $this->getBaseUrl() . $link;
if (!Zend_Uri::check($link)) {
$link = null;
}
}
}
return $link;
}
/**
* 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()
{
$dom = $this->getDomDocument();
$prefixAtom03 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_03);
$prefixAtom10 = $dom->lookupPrefix(Zend_Feed_Reader::NAMESPACE_ATOM_10);
if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_10)
|| !empty($prefixAtom10)) {
return Zend_Feed_Reader::TYPE_ATOM_10;
}
if ($dom->isDefaultNamespace(Zend_Feed_Reader::NAMESPACE_ATOM_03)
|| !empty($prefixAtom03)) {
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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Feed_Reader_Extension_FeedAbstract
*/
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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,266 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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) {
$authors[] = array(
'name' => $author->nodeValue
);
}
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($authors)
);
} else {
$authors = null;
}
$this->_data['authors'] = $authors;
return $this->_data['authors'];
}
/**
* Get categories (subjects under DC)
*
* @return Zend_Feed_Reader_Collection_Category
*/
public function getCategories()
{
if (array_key_exists('categories', $this->_data)) {
return $this->_data['categories'];
}
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject');
if (!$list->length) {
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject');
}
if ($list->length) {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
foreach ($list as $category) {
$categoryCollection[] = array(
'term' => $category->nodeValue,
'scheme' => null,
'label' => $category->nodeValue,
);
}
} else {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
}
$this->_data['categories'] = $categoryCollection;
return $this->_data['categories'];
}
/**
* 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,309 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Feed_Reader_Extension_FeedAbstract
*/
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
/**
* @see Zend_Date
*/
require_once 'Zend/Date.php';
/**
* @see Zend_Feed_Reader_Collection_Author
*/
require_once 'Zend/Feed/Reader/Collection/Author.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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');
}
}
if ($list->length) {
foreach ($list as $author) {
$authors[] = array(
'name' => $author->nodeValue
);
}
$authors = new Zend_Feed_Reader_Collection_Author(
Zend_Feed_Reader::arrayUnique($authors)
);
} else {
$authors = null;
}
$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'];
}
/**
* Get categories (subjects under DC)
*
* @return Zend_Feed_Reader_Collection_Category
*/
public function getCategories()
{
if (array_key_exists('categories', $this->_data)) {
return $this->_data['categories'];
}
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc11:subject');
if (!$list->length) {
$list = $this->_xpath->evaluate($this->getXpathPrefix() . '//dc10:subject');
}
if ($list->length) {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
foreach ($list as $category) {
$categoryCollection[] = array(
'term' => $category->nodeValue,
'scheme' => null,
'label' => $category->nodeValue,
);
}
} else {
$categoryCollection = new Zend_Feed_Reader_Collection_Category;
}
$this->_data['categories'] = $categoryCollection;
return $this->_data['categories'];
}
/**
* 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,200 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: EntryAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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($entry->ownerDocument, true);
}
// set the XPath query prefix for the entry being queried
if ($this->getType() == Zend_Feed_Reader::TYPE_RSS_10
|| $this->getType() == Zend_Feed_Reader::TYPE_RSS_090
) {
$this->setXpathPrefix('//rss:item[' . ($this->_entryKey+1) . ']');
} elseif ($this->getType() == Zend_Feed_Reader::TYPE_ATOM_10
|| $this->getType() == Zend_Feed_Reader::TYPE_ATOM_03
) {
$this->setXpathPrefix('//atom:entry[' . ($this->_entryKey+1) . ']');
} else {
$this->setXpathPrefix('//item[' . ($this->_entryKey+1) . ']');
}
}
/**
* Get the DOM
*
* @return DOMDocument
*/
public function getDomDocument()
{
return $this->_domDocument;
}
/**
* Get the Entry's encoding
*
* @return string
*/
public function getEncoding()
{
$assumed = $this->getDomDocument()->encoding;
return $assumed;
}
/**
* Get the entry type
*
* @return string
*/
public function getType()
{
return $this->_data['type'];
}
/**
* Set the XPath query
*
* @param DOMXPath $xpath
* @return Zend_Feed_Reader_Extension_EntryAbstract
*/
public function setXpath(DOMXPath $xpath)
{
$this->_xpath = $xpath;
$this->_registerNamespaces();
return $this;
}
/**
* Get the XPath query object
*
* @return DOMXPath
*/
public function getXpath()
{
if (!$this->_xpath) {
$this->setXpath(new DOMXPath($this->getDomDocument()));
}
return $this->_xpath;
}
/**
* Serialize the entry to an array
*
* @return array
*/
public function toArray()
{
return $this->_data;
}
/**
* Get the XPath prefix
*
* @return string
*/
public function getXpathPrefix()
{
return $this->_xpathPrefix;
}
/**
* Set the XPath prefix
*
* @param string $prefix
* @return Zend_Feed_Reader_Extension_EntryAbstract
*/
public function setXpathPrefix($prefix)
{
$this->_xpathPrefix = $prefix;
return $this;
}
/**
* Register XML namespaces
*
* @return void
*/
protected abstract function _registerNamespaces();
}

View file

@ -0,0 +1,189 @@
<?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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: FeedAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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;
}
/**
* 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 DOMXPath object
*
* @return string
*/
public function getXpath()
{
return $this->_xpath;
}
/**
* 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Feed_Reader_Extension_FeedAbstract
*/
require_once 'Zend/Feed/Reader/Extension/FeedAbstract.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @see Zend_Feed_Reader_Extension_EntryAbstract
*/
require_once 'Zend/Feed/Reader/Extension/EntryAbstract.php';
/**
* @category Zend
* @package Zend_Feed_Reader
* @copyright Copyright (c) 2005-2010 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-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
*/
/**
* @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-2010 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/');
}
}