Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libs/Zend/Feed/Writer')
-rw-r--r--libs/Zend/Feed/Writer/Deleted.php202
-rw-r--r--libs/Zend/Feed/Writer/Entry.php771
-rw-r--r--libs/Zend/Feed/Writer/Exception/InvalidMethodException.php41
-rw-r--r--libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php123
-rw-r--r--libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php92
-rw-r--r--libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php96
-rw-r--r--libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php96
-rw-r--r--libs/Zend/Feed/Writer/Extension/ITunes/Entry.php242
-rw-r--r--libs/Zend/Feed/Writer/Extension/ITunes/Feed.php361
-rw-r--r--libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php216
-rw-r--r--libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php320
-rw-r--r--libs/Zend/Feed/Writer/Extension/RendererAbstract.php179
-rw-r--r--libs/Zend/Feed/Writer/Extension/RendererInterface.php59
-rw-r--r--libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php91
-rw-r--r--libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php145
-rw-r--r--libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php96
-rw-r--r--libs/Zend/Feed/Writer/Feed.php281
-rw-r--r--libs/Zend/Feed/Writer/Feed/FeedAbstract.php716
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Entry/Atom.php405
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php121
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Entry/Rss.php315
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Feed/Atom.php129
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php408
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php110
-rw-r--r--libs/Zend/Feed/Writer/Renderer/Feed/Rss.php374
-rw-r--r--libs/Zend/Feed/Writer/Renderer/RendererAbstract.php250
-rw-r--r--libs/Zend/Feed/Writer/Renderer/RendererInterface.php111
-rw-r--r--libs/Zend/Feed/Writer/Source.php33
28 files changed, 6383 insertions, 0 deletions
diff --git a/libs/Zend/Feed/Writer/Deleted.php b/libs/Zend/Feed/Writer/Deleted.php
new file mode 100644
index 0000000000..4f17c9d7ac
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Deleted.php
@@ -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_Writer
+ * @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 $
+ */
+
+require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
+
+ /**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Deleted
+{
+
+ /**
+ * Internal array containing all data associated with this entry or item.
+ *
+ * @var array
+ */
+ protected $_data = array();
+
+ /**
+ * Holds the value "atom" or "rss" depending on the feed type set when
+ * when last exported.
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * Set the feed character encoding
+ *
+ * @return string|null
+ */
+ public function setEncoding($encoding)
+ {
+ if (empty($encoding) || !is_string($encoding)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['encoding'] = $encoding;
+ }
+
+ /**
+ * Get the feed character encoding
+ *
+ * @return string|null
+ */
+ public function getEncoding()
+ {
+ if (!array_key_exists('encoding', $this->_data)) {
+ return 'UTF-8';
+ }
+ return $this->_data['encoding'];
+ }
+
+ /**
+ * Unset a specific data point
+ *
+ * @param string $name
+ */
+ public function remove($name)
+ {
+ if (isset($this->_data[$name])) {
+ unset($this->_data[$name]);
+ }
+ }
+
+ /**
+ * Set the current feed type being exported to "rss" or "atom". This allows
+ * other objects to gracefully choose whether to execute or not, depending
+ * on their appropriateness for the current type, e.g. renderers.
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ }
+
+ /**
+ * Retrieve the current or last feed type exported.
+ *
+ * @return string Value will be "rss" or "atom"
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ public function setReference($reference)
+ {
+ if (empty($reference) || !is_string($reference)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string');
+ }
+ $this->_data['reference'] = $reference;
+ }
+
+ public function getReference()
+ {
+ if (!array_key_exists('reference', $this->_data)) {
+ return null;
+ }
+ return $this->_data['reference'];
+ }
+
+ public function setWhen($date = null)
+ {
+ $zdate = null;
+ if (is_null($date)) {
+ $zdate = new Zend_Date;
+ } elseif (ctype_digit($date) && strlen($date) == 10) {
+ $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
+ } elseif ($date instanceof Zend_Date) {
+ $zdate = $date;
+ } else {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
+ }
+ $this->_data['when'] = $zdate;
+ }
+
+ public function getWhen()
+ {
+ if (!array_key_exists('when', $this->_data)) {
+ return null;
+ }
+ return $this->_data['when'];
+ }
+
+ public function setBy(array $by)
+ {
+ $author = array();
+ if (!array_key_exists('name', $by)
+ || empty($by['name'])
+ || !is_string($by['name'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
+ }
+ $author['name'] = $by['name'];
+ if (isset($by['email'])) {
+ if (empty($by['email']) || !is_string($by['email'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string');
+ }
+ $author['email'] = $by['email'];
+ }
+ if (isset($by['uri'])) {
+ if (empty($by['uri'])
+ || !is_string($by['uri'])
+ || !Zend_Uri::check($by['uri'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
+ }
+ $author['uri'] = $by['uri'];
+ }
+ $this->_data['by'] = $author;
+ }
+
+ public function getBy()
+ {
+ if (!array_key_exists('by', $this->_data)) {
+ return null;
+ }
+ return $this->_data['by'];
+ }
+
+ public function setComment($comment)
+ {
+ $this->_data['comment'] = $comment;
+ }
+
+ public function getComment()
+ {
+ if (!array_key_exists('comment', $this->_data)) {
+ return null;
+ }
+ return $this->_data['comment'];
+ }
+
+}
diff --git a/libs/Zend/Feed/Writer/Entry.php b/libs/Zend/Feed/Writer/Entry.php
new file mode 100644
index 0000000000..ff9550b528
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Entry.php
@@ -0,0 +1,771 @@
+<?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_Writer
+ * @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 20519 2010-01-22 14:06:24Z padraic $
+ */
+
+/**
+ * @see Zend_Date
+ */
+require_once 'Zend/Date.php';
+
+/**
+ * @see Zend_Date
+ */
+require_once 'Zend/Uri.php';
+
+require_once 'Zend/Feed/Writer/Source.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Entry
+{
+
+ /**
+ * Internal array containing all data associated with this entry or item.
+ *
+ * @var array
+ */
+ protected $_data = array();
+
+ /**
+ * Registered extensions
+ *
+ * @var array
+ */
+ protected $_extensions = array();
+
+ /**
+ * Holds the value "atom" or "rss" depending on the feed type set when
+ * when last exported.
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * Constructor: Primarily triggers the registration of core extensions and
+ * loads those appropriate to this data container.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ Zend_Feed_Writer::registerCoreExtensions();
+ $this->_loadExtensions();
+ }
+
+ /**
+ * Set a single author
+ *
+ * @param int $index
+ * @return string|null
+ */
+ public function addAuthor($name, $email = null, $uri = null)
+ {
+ $author = array();
+ if (is_array($name)) {
+ if (!array_key_exists('name', $name)
+ || empty($name['name'])
+ || !is_string($name['name'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
+ }
+ $author['name'] = $name['name'];
+ if (isset($name['email'])) {
+ if (empty($name['email']) || !is_string($name['email'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string');
+ }
+ $author['email'] = $name['email'];
+ }
+ if (isset($name['uri'])) {
+ if (empty($name['uri'])
+ || !is_string($name['uri'])
+ || !Zend_Uri::check($name['uri'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
+ }
+ $author['uri'] = $name['uri'];
+ }
+ /**
+ * @deprecated
+ * Array notation (above) is preferred and will be the sole supported input from ZF 2.0
+ */
+ } else {
+ if (empty($name['name']) || !is_string($name['name'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string value');
+ }
+ $author['name'] = $name;
+ if (isset($email)) {
+ if (empty($email) || !is_string($email)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "email" value must be a non-empty string');
+ }
+ $author['email'] = $email;
+ }
+ if (isset($uri)) {
+ if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" value must be a non-empty string and valid URI/IRI');
+ }
+ $author['uri'] = $uri;
+ }
+ }
+ $this->_data['authors'][] = $author;
+ }
+
+ /**
+ * Set an array with feed authors
+ *
+ * @return array
+ */
+ public function addAuthors(array $authors)
+ {
+ foreach($authors as $author) {
+ $this->addAuthor($author);
+ }
+ }
+
+ /**
+ * Set the feed character encoding
+ *
+ * @return string|null
+ */
+ public function setEncoding($encoding)
+ {
+ if (empty($encoding) || !is_string($encoding)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['encoding'] = $encoding;
+ }
+
+ /**
+ * Get the feed character encoding
+ *
+ * @return string|null
+ */
+ public function getEncoding()
+ {
+ if (!array_key_exists('encoding', $this->_data)) {
+ return 'UTF-8';
+ }
+ return $this->_data['encoding'];
+ }
+
+ /**
+ * Set the copyright entry
+ *
+ * @return string|null
+ */
+ public function setCopyright($copyright)
+ {
+ if (empty($copyright) || !is_string($copyright)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['copyright'] = $copyright;
+ }
+
+ /**
+ * Set the entry's content
+ *
+ * @return string|null
+ */
+ public function setContent($content)
+ {
+ if (empty($content) || !is_string($content)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['content'] = $content;
+ }
+
+ /**
+ * Set the feed creation date
+ *
+ * @return string|null
+ */
+ public function setDateCreated($date = null)
+ {
+ $zdate = null;
+ if (is_null($date)) {
+ $zdate = new Zend_Date;
+ } elseif (ctype_digit($date) && strlen($date) == 10) {
+ $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
+ } elseif ($date instanceof Zend_Date) {
+ $zdate = $date;
+ } else {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
+ }
+ $this->_data['dateCreated'] = $zdate;
+ }
+
+ /**
+ * Set the feed modification date
+ *
+ * @return string|null
+ */
+ public function setDateModified($date = null)
+ {
+ $zdate = null;
+ if (is_null($date)) {
+ $zdate = new Zend_Date;
+ } elseif (ctype_digit($date) && strlen($date) == 10) {
+ $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
+ } elseif ($date instanceof Zend_Date) {
+ $zdate = $date;
+ } else {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
+ }
+ $this->_data['dateModified'] = $zdate;
+ }
+
+ /**
+ * Set the feed description
+ *
+ * @return string|null
+ */
+ public function setDescription($description)
+ {
+ if (empty($description) || !is_string($description)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['description'] = $description;
+ }
+
+ /**
+ * Set the feed ID
+ *
+ * @return string|null
+ */
+ public function setId($id)
+ {
+ if (empty($id) || !is_string($id)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['id'] = $id;
+ }
+
+ /**
+ * Set a link to the HTML source of this entry
+ *
+ * @return string|null
+ */
+ public function setLink($link)
+ {
+ if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
+ }
+ $this->_data['link'] = $link;
+ }
+
+ /**
+ * Set the number of comments associated with this entry
+ *
+ * @return string|null
+ */
+ public function setCommentCount($count)
+ {
+ if (empty($count) || !is_numeric($count) || (int) $count < 0) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "count" must be a non-empty integer number');
+ }
+ $this->_data['commentCount'] = (int) $count;
+ }
+
+ /**
+ * Set a link to a HTML page containing comments associated with this entry
+ *
+ * @return string|null
+ */
+ public function setCommentLink($link)
+ {
+ if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
+ }
+ $this->_data['commentLink'] = $link;
+ }
+
+ /**
+ * Set a link to an XML feed for any comments associated with this entry
+ *
+ * @return string|null
+ */
+ public function setCommentFeedLink(array $link)
+ {
+ if (!isset($link['uri']) || !is_string($link['uri']) || !Zend_Uri::check($link['uri'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI');
+ }
+ if (!isset($link['type']) || !in_array($link['type'], array('atom', 'rss', 'rdf'))) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "type" must be one'
+ . ' of "atom", "rss" or "rdf"');
+ }
+ if (!isset($this->_data['commentFeedLinks'])) {
+ $this->_data['commentFeedLinks'] = array();
+ }
+ $this->_data['commentFeedLinks'][] = $link;
+ }
+
+ /**
+ * Set a links to an XML feed for any comments associated with this entry.
+ * Each link is an array with keys "uri" and "type", where type is one of:
+ * "atom", "rss" or "rdf".
+ *
+ * @return string|null
+ */
+ public function setCommentFeedLinks(array $links)
+ {
+ foreach ($links as $link) {
+ $this->setCommentFeedLink($link);
+ }
+ }
+
+ /**
+ * Set the feed title
+ *
+ * @return string|null
+ */
+ public function setTitle($title)
+ {
+ if (empty($title) || !is_string($title)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['title'] = $title;
+ }
+
+ /**
+ * Get an array with feed authors
+ *
+ * @return array
+ */
+ public function getAuthors()
+ {
+ if (!array_key_exists('authors', $this->_data)) {
+ return null;
+ }
+ return $this->_data['authors'];
+ }
+
+ /**
+ * Get the entry content
+ *
+ * @return string
+ */
+ public function getContent()
+ {
+ if (!array_key_exists('content', $this->_data)) {
+ return null;
+ }
+ return $this->_data['content'];
+ }
+
+ /**
+ * Get the entry copyright information
+ *
+ * @return string
+ */
+ public function getCopyright()
+ {
+ if (!array_key_exists('copyright', $this->_data)) {
+ return null;
+ }
+ return $this->_data['copyright'];
+ }
+
+ /**
+ * Get the entry creation date
+ *
+ * @return string
+ */
+ public function getDateCreated()
+ {
+ if (!array_key_exists('dateCreated', $this->_data)) {
+ return null;
+ }
+ return $this->_data['dateCreated'];
+ }
+
+ /**
+ * Get the entry modification date
+ *
+ * @return string
+ */
+ public function getDateModified()
+ {
+ if (!array_key_exists('dateModified', $this->_data)) {
+ return null;
+ }
+ return $this->_data['dateModified'];
+ }
+
+ /**
+ * Get the entry description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ if (!array_key_exists('description', $this->_data)) {
+ return null;
+ }
+ return $this->_data['description'];
+ }
+
+ /**
+ * Get the entry ID
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ if (!array_key_exists('id', $this->_data)) {
+ return null;
+ }
+ return $this->_data['id'];
+ }
+
+ /**
+ * Get a link to the HTML source
+ *
+ * @return string|null
+ */
+ public function getLink()
+ {
+ if (!array_key_exists('link', $this->_data)) {
+ return null;
+ }
+ return $this->_data['link'];
+ }
+
+
+ /**
+ * Get all links
+ *
+ * @return array
+ */
+ public function getLinks()
+ {
+ if (!array_key_exists('links', $this->_data)) {
+ return null;
+ }
+ return $this->_data['links'];
+ }
+
+ /**
+ * Get the entry title
+ *
+ * @return string
+ */
+ public function getTitle()
+ {
+ if (!array_key_exists('title', $this->_data)) {
+ return null;
+ }
+ 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 null;
+ }
+ 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 null;
+ }
+ return $this->_data['commentLink'];
+ }
+
+ /**
+ * Returns an array of URIs pointing to a feed of all comments for this entry
+ * where the array keys indicate the feed type (atom, rss or rdf).
+ *
+ * @return string
+ */
+ public function getCommentFeedLinks()
+ {
+ if (!array_key_exists('commentFeedLinks', $this->_data)) {
+ return null;
+ }
+ return $this->_data['commentFeedLinks'];
+ }
+
+ /**
+ * Add a entry category
+ *
+ * @param string $category
+ */
+ public function addCategory(array $category)
+ {
+ if (!isset($category['term'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Each category must be an array and '
+ . 'contain at least a "term" element containing the machine '
+ . ' readable category name');
+ }
+ if (isset($category['scheme'])) {
+ if (empty($category['scheme'])
+ || !is_string($category['scheme'])
+ || !Zend_Uri::check($category['scheme'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('The Atom scheme or RSS domain of'
+ . ' a category must be a valid URI');
+ }
+ }
+ if (!isset($this->_data['categories'])) {
+ $this->_data['categories'] = array();
+ }
+ $this->_data['categories'][] = $category;
+ }
+
+ /**
+ * Set an array of entry categories
+ *
+ * @param array $categories
+ */
+ public function addCategories(array $categories)
+ {
+ foreach ($categories as $category) {
+ $this->addCategory($category);
+ }
+ }
+
+ /**
+ * Get the entry categories
+ *
+ * @return string|null
+ */
+ public function getCategories()
+ {
+ if (!array_key_exists('categories', $this->_data)) {
+ return null;
+ }
+ return $this->_data['categories'];
+ }
+
+ /**
+ * Adds an enclosure to the entry.
+ *
+ * @param array $enclosures
+ */
+ public function setEnclosure(array $enclosure)
+ {
+ if (!isset($enclosure['type'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Enclosure "type" is not set');
+ }
+ if (!isset($enclosure['length'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Enclosure "length" is not set');
+ }
+ if (!isset($enclosure['uri'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Enclosure "uri" is not set');
+ }
+ if (!Zend_Uri::check($enclosure['uri'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Enclosure "uri" is not a valid URI/IRI');
+ }
+ if ((int) $enclosure['length'] <= 0) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Enclosure "length" must be an integer'
+ . ' indicating the content\'s length in bytes');
+ }
+ $this->_data['enclosure'] = $enclosure;
+ }
+
+ /**
+ * Retrieve an array of all enclosures to be added to entry.
+ *
+ * @return array
+ */
+ public function getEnclosure()
+ {
+ if (!array_key_exists('enclosure', $this->_data)) {
+ return null;
+ }
+ return $this->_data['enclosure'];
+ }
+
+ /**
+ * Unset a specific data point
+ *
+ * @param string $name
+ */
+ public function remove($name)
+ {
+ if (isset($this->_data[$name])) {
+ unset($this->_data[$name]);
+ }
+ }
+
+ /**
+ * Get registered extensions
+ *
+ * @return array
+ */
+ public function getExtensions()
+ {
+ return $this->_extensions;
+ }
+
+ /**
+ * Return an Extension object with the matching name (postfixed with _Entry)
+ *
+ * @param string $name
+ * @return object
+ */
+ public function getExtension($name)
+ {
+ if (array_key_exists($name . '_Entry', $this->_extensions)) {
+ return $this->_extensions[$name . '_Entry'];
+ }
+ return null;
+ }
+
+ /**
+ * Set the current feed type being exported to "rss" or "atom". This allows
+ * other objects to gracefully choose whether to execute or not, depending
+ * on their appropriateness for the current type, e.g. renderers.
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ }
+
+ /**
+ * Retrieve the current or last feed type exported.
+ *
+ * @return string Value will be "rss" or "atom"
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /**
+ * Method overloading: call given method on first extension implementing it
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ * @throws Zend_Feed_Exception if no extensions implements the method
+ */
+ public function __call($method, $args)
+ {
+ foreach ($this->_extensions as $extension) {
+ try {
+ return call_user_func_array(array($extension, $method), $args);
+ } catch (Zend_Feed_Writer_Exception_InvalidMethodException $e) {
+ }
+ }
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Method: ' . $method
+ . ' does not exist and could not be located on a registered Extension');
+ }
+
+ /**
+ * Creates a new Zend_Feed_Writer_Source data container for use. This is NOT
+ * added to the current feed automatically, but is necessary to create a
+ * container with some initial values preset based on the current feed data.
+ *
+ * @return Zend_Feed_Writer_Source
+ */
+ public function createSource()
+ {
+ $source = new Zend_Feed_Writer_Source;
+ if ($this->getEncoding()) {
+ $source->setEncoding($this->getEncoding());
+ }
+ $source->setType($this->getType());
+ return $source;
+ }
+
+ /**
+ * Appends a Zend_Feed_Writer_Entry object representing a new entry/item
+ * the feed data container's internal group of entries.
+ *
+ * @param Zend_Feed_Writer_Source $source
+ */
+ public function setSource(Zend_Feed_Writer_Source $source)
+ {
+ $this->_data['source'] = $source;
+ }
+
+ /**
+ * @return Zend_Feed_Writer_Source
+ */
+ public function getSource()
+ {
+ if (isset($this->_data['source'])) {
+ return $this->_data['source'];
+ }
+ return null;
+ }
+
+ /**
+ * Load extensions from Zend_Feed_Writer
+ *
+ * @return void
+ */
+ protected function _loadExtensions()
+ {
+ $all = Zend_Feed_Writer::getExtensions();
+ $exts = $all['entry'];
+ foreach ($exts as $ext) {
+ $className = Zend_Feed_Writer::getPluginLoader()->getClassName($ext);
+ $this->_extensions[$ext] = new $className();
+ $this->_extensions[$ext]->setEncoding($this->getEncoding());
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php b/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php
new file mode 100644
index 0000000000..f6c4f9331d
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Exception/InvalidMethodException.php
@@ -0,0 +1,41 @@
+<?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
+ * @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: InvalidMethodException.php 20096 2010-01-06 02:05:09Z bkarwin $
+ */
+
+
+/**
+ * @see Zend_Feed_Exception
+ */
+require_once 'Zend/Feed/Exception.php';
+
+
+/**
+ * Feed exceptions
+ *
+ * Class to represent exceptions that occur during Feed operations.
+ *
+ * @category Zend
+ * @package Zend_Feed
+ * @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_Writer_Exception_InvalidMethodException extends Zend_Exception
+{}
diff --git a/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php
new file mode 100644
index 0000000000..f23901d7e8
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/Atom/Renderer/Feed.php
@@ -0,0 +1,123 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_Atom_Renderer_Feed
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render feed
+ *
+ * @return void
+ */
+ public function render()
+ {
+ /**
+ * RSS 2.0 only. Used mainly to include Atom links and
+ * Pubsubhubbub Hub endpoint URIs under the Atom namespace
+ */
+ if (strtolower($this->getType()) == 'atom') {
+ return;
+ }
+ $this->_setFeedLinks($this->_dom, $this->_base);
+ $this->_setHubs($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append namespaces to root element of feed
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:atom',
+ 'http://www.w3.org/2005/Atom');
+ }
+
+ /**
+ * Set feed link elements
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
+ {
+ $flinks = $this->getDataContainer()->getFeedLinks();
+ if(!$flinks || empty($flinks)) {
+ return;
+ }
+ foreach ($flinks as $type => $href) {
+ $mime = 'application/' . strtolower($type) . '+xml';
+ $flink = $dom->createElement('atom:link');
+ $root->appendChild($flink);
+ $flink->setAttribute('rel', 'self');
+ $flink->setAttribute('type', $mime);
+ $flink->setAttribute('href', $href);
+ }
+ $this->_called = true;
+ }
+
+ /**
+ * Set PuSH hubs
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setHubs(DOMDocument $dom, DOMElement $root)
+ {
+ $hubs = $this->getDataContainer()->getHubs();
+ if (!$hubs || empty($hubs)) {
+ return;
+ }
+ foreach ($hubs as $hubUrl) {
+ $hub = $dom->createElement('atom:link');
+ $hub->setAttribute('rel', 'hub');
+ $hub->setAttribute('href', $hubUrl);
+ $root->appendChild($hub);
+ }
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php
new file mode 100644
index 0000000000..7960f4cdf3
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/Content/Renderer/Entry.php
@@ -0,0 +1,92 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_Content_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'atom') {
+ return;
+ }
+ $this->_setContent($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append namespaces to root element
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:content',
+ 'http://purl.org/rss/1.0/modules/content/');
+ }
+
+ /**
+ * Set entry content
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setContent(DOMDocument $dom, DOMElement $root)
+ {
+ $content = $this->getDataContainer()->getContent();
+ if (!$content) {
+ return;
+ }
+ $element = $dom->createElement('content:encoded');
+ $root->appendChild($element);
+ $cdata = $dom->createCDATASection($content);
+ $element->appendChild($cdata);
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php
new file mode 100644
index 0000000000..6a72277815
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Entry.php
@@ -0,0 +1,96 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_DublinCore_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'atom') {
+ return;
+ }
+ $this->_setAuthors($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append namespaces to entry
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:dc',
+ 'http://purl.org/dc/elements/1.1/');
+ }
+
+ /**
+ * Set entry author elements
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->getDataContainer()->getAuthors();
+ if (!$authors || empty($authors)) {
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('dc:creator');
+ if (array_key_exists('name', $data)) {
+ $text = $dom->createTextNode($data['name']);
+ $author->appendChild($text);
+ $root->appendChild($author);
+ }
+ }
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php
new file mode 100644
index 0000000000..bfa4de49a1
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/DublinCore/Renderer/Feed.php
@@ -0,0 +1,96 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_DublinCore_Renderer_Feed
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render feed
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'atom') {
+ return;
+ }
+ $this->_setAuthors($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append namespaces to feed element
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:dc',
+ 'http://purl.org/dc/elements/1.1/');
+ }
+
+ /**
+ * Set feed authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->getDataContainer()->getAuthors();
+ if (!$authors || empty($authors)) {
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('dc:creator');
+ if (array_key_exists('name', $data)) {
+ $text = $dom->createTextNode($data['name']);
+ $author->appendChild($text);
+ $root->appendChild($author);
+ }
+ }
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php b/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php
new file mode 100644
index 0000000000..49eecb7132
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/ITunes/Entry.php
@@ -0,0 +1,242 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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 $
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_ITunes_Entry
+{
+ /**
+ * Array of Feed data for rendering by Extension's renderers
+ *
+ * @var array
+ */
+ protected $_data = array();
+
+ /**
+ * Encoding of all text values
+ *
+ * @var string
+ */
+ protected $_encoding = 'UTF-8';
+
+ /**
+ * Set feed encoding
+ *
+ * @param string $enc
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setEncoding($enc)
+ {
+ $this->_encoding = $enc;
+ return $this;
+ }
+
+ /**
+ * Get feed encoding
+ *
+ * @return string
+ */
+ public function getEncoding()
+ {
+ return $this->_encoding;
+ }
+
+ /**
+ * Set a block value of "yes" or "no". You may also set an empty string.
+ *
+ * @param string
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesBlock($value)
+ {
+ if (!ctype_alpha($value) && strlen($value) > 0) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "block" may only'
+ . ' contain alphabetic characters');
+ }
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "block" may only'
+ . ' contain a maximum of 255 characters');
+ }
+ $this->_data['block'] = $value;
+ }
+
+ /**
+ * Add authors to itunes entry
+ *
+ * @param array $values
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function addItunesAuthors(array $values)
+ {
+ foreach ($values as $value) {
+ $this->addItunesAuthor($value);
+ }
+ return $this;
+ }
+
+ /**
+ * Add author to itunes entry
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function addItunesAuthor($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "author" may only'
+ . ' contain a maximum of 255 characters each');
+ }
+ if (!isset($this->_data['authors'])) {
+ $this->_data['authors'] = array();
+ }
+ $this->_data['authors'][] = $value;
+ return $this;
+ }
+
+ /**
+ * Set duration
+ *
+ * @param int $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesDuration($value)
+ {
+ $value = (string) $value;
+ if (!ctype_digit($value)
+ && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
+ && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "duration" may only'
+ . ' be of a specified [[HH:]MM:]SS format');
+ }
+ $this->_data['duration'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set "explicit" flag
+ *
+ * @param bool $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesExplicit($value)
+ {
+ if (!in_array($value, array('yes','no','clean'))) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "explicit" may only'
+ . ' be one of "yes", "no" or "clean"');
+ }
+ $this->_data['explicit'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set keywords
+ *
+ * @param array $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesKeywords(array $value)
+ {
+ if (count($value) > 12) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "keywords" may only'
+ . ' contain a maximum of 12 terms');
+ }
+ $concat = implode(',', $value);
+ if (iconv_strlen($concat, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "keywords" may only'
+ . ' have a concatenated length of 255 chars where terms are delimited'
+ . ' by a comma');
+ }
+ $this->_data['keywords'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set subtitle
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesSubtitle($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "subtitle" may only'
+ . ' contain a maximum of 255 characters');
+ }
+ $this->_data['subtitle'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set summary
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Entry
+ */
+ public function setItunesSummary($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 4000) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "summary" may only'
+ . ' contain a maximum of 4000 characters');
+ }
+ $this->_data['summary'] = $value;
+ return $this;
+ }
+
+ /**
+ * Overloading to itunes specific setters
+ *
+ * @param string $method
+ * @param array $params
+ * @return mixed
+ */
+ public function __call($method, array $params)
+ {
+ $point = Zend_Feed_Writer::lcfirst(substr($method, 9));
+ if (!method_exists($this, 'setItunes' . ucfirst($point))
+ && !method_exists($this, 'addItunes' . ucfirst($point))
+ ) {
+ require_once 'Zend/Feed/Writer/Exception/InvalidMethodException.php';
+ throw new Zend_Feed_Writer_Exception_InvalidMethodException(
+ 'invalid method: ' . $method
+ );
+ }
+ if (!array_key_exists($point, $this->_data)
+ || empty($this->_data[$point])
+ ) {
+ return null;
+ }
+ return $this->_data[$point];
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php b/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php
new file mode 100644
index 0000000000..565fdc5c78
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/ITunes/Feed.php
@@ -0,0 +1,361 @@
+<?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_Writer
+ * @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 $
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_ITunes_Feed
+{
+ /**
+ * Array of Feed data for rendering by Extension's renderers
+ *
+ * @var array
+ */
+ protected $_data = array();
+
+ /**
+ * Encoding of all text values
+ *
+ * @var string
+ */
+ protected $_encoding = 'UTF-8';
+
+ /**
+ * Set feed encoding
+ *
+ * @param string $enc
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setEncoding($enc)
+ {
+ $this->_encoding = $enc;
+ return $this;
+ }
+
+ /**
+ * Get feed encoding
+ *
+ * @return string
+ */
+ public function getEncoding()
+ {
+ return $this->_encoding;
+ }
+
+ /**
+ * Set a block value of "yes" or "no". You may also set an empty string.
+ *
+ * @param string
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesBlock($value)
+ {
+ if (!ctype_alpha($value) && strlen($value) > 0) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "block" may only'
+ . ' contain alphabetic characters');
+ }
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "block" may only'
+ . ' contain a maximum of 255 characters');
+ }
+ $this->_data['block'] = $value;
+ return $this;
+ }
+
+ /**
+ * Add feed authors
+ *
+ * @param array $values
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function addItunesAuthors(array $values)
+ {
+ foreach ($values as $value) {
+ $this->addItunesAuthor($value);
+ }
+ return $this;
+ }
+
+ /**
+ * Add feed author
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function addItunesAuthor($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "author" may only'
+ . ' contain a maximum of 255 characters each');
+ }
+ if (!isset($this->_data['authors'])) {
+ $this->_data['authors'] = array();
+ }
+ $this->_data['authors'][] = $value;
+ return $this;
+ }
+
+ /**
+ * Set feed categories
+ *
+ * @param array $values
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesCategories(array $values)
+ {
+ if (!isset($this->_data['categories'])) {
+ $this->_data['categories'] = array();
+ }
+ foreach ($values as $key=>$value) {
+ if (!is_array($value)) {
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "category" may only'
+ . ' contain a maximum of 255 characters each');
+ }
+ $this->_data['categories'][] = $value;
+ } else {
+ if (iconv_strlen($key, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "category" may only'
+ . ' contain a maximum of 255 characters each');
+ }
+ $this->_data['categories'][$key] = array();
+ foreach ($value as $val) {
+ if (iconv_strlen($val, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "category" may only'
+ . ' contain a maximum of 255 characters each');
+ }
+ $this->_data['categories'][$key][] = $val;
+ }
+ }
+ }
+ return $this;
+ }
+
+ /**
+ * Set feed image (icon)
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesImage($value)
+ {
+ if (!Zend_Uri::check($value)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "image" may only'
+ . ' be a valid URI/IRI');
+ }
+ if (!in_array(substr($value, -3), array('jpg','png'))) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "image" may only'
+ . ' use file extension "jpg" or "png" which must be the last three'
+ . ' characters of the URI (i.e. no query string or fragment)');
+ }
+ $this->_data['image'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set feed cumulative duration
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesDuration($value)
+ {
+ $value = (string) $value;
+ if (!ctype_digit($value)
+ && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
+ && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "duration" may only'
+ . ' be of a specified [[HH:]MM:]SS format');
+ }
+ $this->_data['duration'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set "explicit" flag
+ *
+ * @param bool $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesExplicit($value)
+ {
+ if (!in_array($value, array('yes','no','clean'))) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "explicit" may only'
+ . ' be one of "yes", "no" or "clean"');
+ }
+ $this->_data['explicit'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set feed keywords
+ *
+ * @param array $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesKeywords(array $value)
+ {
+ if (count($value) > 12) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "keywords" may only'
+ . ' contain a maximum of 12 terms');
+ }
+ $concat = implode(',', $value);
+ if (iconv_strlen($concat, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "keywords" may only'
+ . ' have a concatenated length of 255 chars where terms are delimited'
+ . ' by a comma');
+ }
+ $this->_data['keywords'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set new feed URL
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesNewFeedUrl($value)
+ {
+ if (!Zend_Uri::check($value)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "newFeedUrl" may only'
+ . ' be a valid URI/IRI');
+ }
+ $this->_data['newFeedUrl'] = $value;
+ return $this;
+ }
+
+ /**
+ * Add feed owners
+ *
+ * @param array $values
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function addItunesOwners(array $values)
+ {
+ foreach ($values as $value) {
+ $this->addItunesOwner($value);
+ }
+ return $this;
+ }
+
+ /**
+ * Add feed owner
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function addItunesOwner(array $value)
+ {
+ if (!isset($value['name']) || !isset($value['email'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "owner" must'
+ . ' be an array containing keys "name" and "email"');
+ }
+ if (iconv_strlen($value['name'], $this->getEncoding()) > 255
+ || iconv_strlen($value['email'], $this->getEncoding()) > 255
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: any "owner" may only'
+ . ' contain a maximum of 255 characters each for "name" and "email"');
+ }
+ if (!isset($this->_data['owners'])) {
+ $this->_data['owners'] = array();
+ }
+ $this->_data['owners'][] = $value;
+ return $this;
+ }
+
+ /**
+ * Set feed subtitle
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesSubtitle($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 255) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "subtitle" may only'
+ . ' contain a maximum of 255 characters');
+ }
+ $this->_data['subtitle'] = $value;
+ return $this;
+ }
+
+ /**
+ * Set feed summary
+ *
+ * @param string $value
+ * @return Zend_Feed_Writer_Extension_ITunes_Feed
+ */
+ public function setItunesSummary($value)
+ {
+ if (iconv_strlen($value, $this->getEncoding()) > 4000) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('invalid parameter: "summary" may only'
+ . ' contain a maximum of 4000 characters');
+ }
+ $this->_data['summary'] = $value;
+ return $this;
+ }
+
+ /**
+ * Overloading: proxy to internal setters
+ *
+ * @param string $method
+ * @param array $params
+ * @return mixed
+ */
+ public function __call($method, array $params)
+ {
+ $point = Zend_Feed_Writer::lcfirst(substr($method, 9));
+ if (!method_exists($this, 'setItunes' . ucfirst($point))
+ && !method_exists($this, 'addItunes' . ucfirst($point))
+ ) {
+ require_once 'Zend/Feed/Writer/Exception/InvalidMethodException.php';
+ throw new Zend_Feed_Writer_Exception_InvalidMethodException(
+ 'invalid method: ' . $method
+ );
+ }
+ if (!array_key_exists($point, $this->_data) || empty($this->_data[$point])) {
+ return null;
+ }
+ return $this->_data[$point];
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php
new file mode 100644
index 0000000000..fc6b98d3ad
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Entry.php
@@ -0,0 +1,216 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_ITunes_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ $this->_setAuthors($this->_dom, $this->_base);
+ $this->_setBlock($this->_dom, $this->_base);
+ $this->_setDuration($this->_dom, $this->_base);
+ $this->_setExplicit($this->_dom, $this->_base);
+ $this->_setKeywords($this->_dom, $this->_base);
+ $this->_setSubtitle($this->_dom, $this->_base);
+ $this->_setSummary($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append namespaces to entry root
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:itunes',
+ 'http://www.itunes.com/dtds/podcast-1.0.dtd');
+ }
+
+ /**
+ * Set entry authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->getDataContainer()->getItunesAuthors();
+ if (!$authors || empty($authors)) {
+ return;
+ }
+ foreach ($authors as $author) {
+ $el = $dom->createElement('itunes:author');
+ $text = $dom->createTextNode($author);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+ }
+
+ /**
+ * Set itunes block
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setBlock(DOMDocument $dom, DOMElement $root)
+ {
+ $block = $this->getDataContainer()->getItunesBlock();
+ if (is_null($block)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:block');
+ $text = $dom->createTextNode($block);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set entry duration
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDuration(DOMDocument $dom, DOMElement $root)
+ {
+ $duration = $this->getDataContainer()->getItunesDuration();
+ if (!$duration) {
+ return;
+ }
+ $el = $dom->createElement('itunes:duration');
+ $text = $dom->createTextNode($duration);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set explicit flag
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setExplicit(DOMDocument $dom, DOMElement $root)
+ {
+ $explicit = $this->getDataContainer()->getItunesExplicit();
+ if (is_null($explicit)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:explicit');
+ $text = $dom->createTextNode($explicit);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set entry keywords
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setKeywords(DOMDocument $dom, DOMElement $root)
+ {
+ $keywords = $this->getDataContainer()->getItunesKeywords();
+ if (!$keywords || empty($keywords)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:keywords');
+ $text = $dom->createTextNode(implode(',', $keywords));
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set entry subtitle
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
+ {
+ $subtitle = $this->getDataContainer()->getItunesSubtitle();
+ if (!$subtitle) {
+ return;
+ }
+ $el = $dom->createElement('itunes:subtitle');
+ $text = $dom->createTextNode($subtitle);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set entry summary
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setSummary(DOMDocument $dom, DOMElement $root)
+ {
+ $summary = $this->getDataContainer()->getItunesSummary();
+ if (!$summary) {
+ return;
+ }
+ $el = $dom->createElement('itunes:summary');
+ $text = $dom->createTextNode($summary);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php
new file mode 100644
index 0000000000..1fafdaa13e
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/ITunes/Renderer/Feed.php
@@ -0,0 +1,320 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_ITunes_Renderer_Feed
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render feed
+ *
+ * @return void
+ */
+ public function render()
+ {
+ $this->_setAuthors($this->_dom, $this->_base);
+ $this->_setBlock($this->_dom, $this->_base);
+ $this->_setCategories($this->_dom, $this->_base);
+ $this->_setImage($this->_dom, $this->_base);
+ $this->_setDuration($this->_dom, $this->_base);
+ $this->_setExplicit($this->_dom, $this->_base);
+ $this->_setKeywords($this->_dom, $this->_base);
+ $this->_setNewFeedUrl($this->_dom, $this->_base);
+ $this->_setOwners($this->_dom, $this->_base);
+ $this->_setSubtitle($this->_dom, $this->_base);
+ $this->_setSummary($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append feed namespaces
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:itunes',
+ 'http://www.itunes.com/dtds/podcast-1.0.dtd');
+ }
+
+ /**
+ * Set feed authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->getDataContainer()->getItunesAuthors();
+ if (!$authors || empty($authors)) {
+ return;
+ }
+ foreach ($authors as $author) {
+ $el = $dom->createElement('itunes:author');
+ $text = $dom->createTextNode($author);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ }
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed itunes block
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setBlock(DOMDocument $dom, DOMElement $root)
+ {
+ $block = $this->getDataContainer()->getItunesBlock();
+ if (is_null($block)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:block');
+ $text = $dom->createTextNode($block);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed categories
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCategories(DOMDocument $dom, DOMElement $root)
+ {
+ $cats = $this->getDataContainer()->getItunesCategories();
+ if (!$cats || empty($cats)) {
+ return;
+ }
+ foreach ($cats as $key=>$cat) {
+ if (!is_array($cat)) {
+ $el = $dom->createElement('itunes:category');
+ $el->setAttribute('text', $cat);
+ $root->appendChild($el);
+ } else {
+ $el = $dom->createElement('itunes:category');
+ $el->setAttribute('text', $key);
+ $root->appendChild($el);
+ foreach ($cat as $subcat) {
+ $el2 = $dom->createElement('itunes:category');
+ $el2->setAttribute('text', $subcat);
+ $el->appendChild($el2);
+ }
+ }
+ }
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed image (icon)
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setImage(DOMDocument $dom, DOMElement $root)
+ {
+ $image = $this->getDataContainer()->getItunesImage();
+ if (!$image) {
+ return;
+ }
+ $el = $dom->createElement('itunes:image');
+ $el->setAttribute('href', $image);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed cumulative duration
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDuration(DOMDocument $dom, DOMElement $root)
+ {
+ $duration = $this->getDataContainer()->getItunesDuration();
+ if (!$duration) {
+ return;
+ }
+ $el = $dom->createElement('itunes:duration');
+ $text = $dom->createTextNode($duration);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set explicit flag
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setExplicit(DOMDocument $dom, DOMElement $root)
+ {
+ $explicit = $this->getDataContainer()->getItunesExplicit();
+ if (is_null($explicit)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:explicit');
+ $text = $dom->createTextNode($explicit);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed keywords
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setKeywords(DOMDocument $dom, DOMElement $root)
+ {
+ $keywords = $this->getDataContainer()->getItunesKeywords();
+ if (!$keywords || empty($keywords)) {
+ return;
+ }
+ $el = $dom->createElement('itunes:keywords');
+ $text = $dom->createTextNode(implode(',', $keywords));
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed's new URL
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setNewFeedUrl(DOMDocument $dom, DOMElement $root)
+ {
+ $url = $this->getDataContainer()->getItunesNewFeedUrl();
+ if (!$url) {
+ return;
+ }
+ $el = $dom->createElement('itunes:new-feed-url');
+ $text = $dom->createTextNode($url);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed owners
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setOwners(DOMDocument $dom, DOMElement $root)
+ {
+ $owners = $this->getDataContainer()->getItunesOwners();
+ if (!$owners || empty($owners)) {
+ return;
+ }
+ foreach ($owners as $owner) {
+ $el = $dom->createElement('itunes:owner');
+ $name = $dom->createElement('itunes:name');
+ $text = $dom->createTextNode($owner['name']);
+ $name->appendChild($text);
+ $email = $dom->createElement('itunes:email');
+ $text = $dom->createTextNode($owner['email']);
+ $email->appendChild($text);
+ $root->appendChild($el);
+ $el->appendChild($name);
+ $el->appendChild($email);
+ }
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed subtitle
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setSubtitle(DOMDocument $dom, DOMElement $root)
+ {
+ $subtitle = $this->getDataContainer()->getItunesSubtitle();
+ if (!$subtitle) {
+ return;
+ }
+ $el = $dom->createElement('itunes:subtitle');
+ $text = $dom->createTextNode($subtitle);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+
+ /**
+ * Set feed summary
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setSummary(DOMDocument $dom, DOMElement $root)
+ {
+ $summary = $this->getDataContainer()->getItunesSummary();
+ if (!$summary) {
+ return;
+ }
+ $el = $dom->createElement('itunes:summary');
+ $text = $dom->createTextNode($summary);
+ $el->appendChild($text);
+ $root->appendChild($el);
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/RendererAbstract.php b/libs/Zend/Feed/Writer/Extension/RendererAbstract.php
new file mode 100644
index 0000000000..9a0f93dfeb
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/RendererAbstract.php
@@ -0,0 +1,179 @@
+<?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 padraic dot brady at yahoo dot com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Feed_Writer_Entry_Rss
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererInterface
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererInterface.php';
+
+ /**
+ * @category Zend
+ * @package Zend_Feed_Writer_Entry_Rss
+ * @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_Writer_Extension_RendererAbstract
+ implements Zend_Feed_Writer_Extension_RendererInterface
+{
+ /**
+ * @var DOMDocument
+ */
+ protected $_dom = null;
+
+ /**
+ * @var mixed
+ */
+ protected $_entry = null;
+
+ /**
+ * @var DOMElement
+ */
+ protected $_base = null;
+
+ /**
+ * @var mixed
+ */
+ protected $_container = null;
+
+ /**
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * @var DOMElement
+ */
+ protected $_rootElement = null;
+
+ /**
+ * Encoding of all text values
+ *
+ * @var string
+ */
+ protected $_encoding = 'UTF-8';
+
+ /**
+ * Constructor
+ *
+ * @param mixed $container
+ * @return void
+ */
+ public function __construct($container)
+ {
+ $this->_container = $container;
+ }
+
+ /**
+ * Set feed encoding
+ *
+ * @param string $enc
+ * @return Zend_Feed_Writer_Extension_RendererAbstract
+ */
+ public function setEncoding($enc)
+ {
+ $this->_encoding = $enc;
+ return $this;
+ }
+
+ /**
+ * Get feed encoding
+ *
+ * @return void
+ */
+ public function getEncoding()
+ {
+ return $this->_encoding;
+ }
+
+ /**
+ * Set DOMDocument and DOMElement on which to operate
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $base
+ * @return Zend_Feed_Writer_Extension_RendererAbstract
+ */
+ public function setDomDocument(DOMDocument $dom, DOMElement $base)
+ {
+ $this->_dom = $dom;
+ $this->_base = $base;
+ return $this;
+ }
+
+ /**
+ * Get data container being rendered
+ *
+ * @return mixed
+ */
+ public function getDataContainer()
+ {
+ return $this->_container;
+ }
+
+ /**
+ * Set feed type
+ *
+ * @param string $type
+ * @return Zend_Feed_Writer_Extension_RendererAbstract
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ return $this;
+ }
+
+ /**
+ * Get feedtype
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /**
+ * Set root element of document
+ *
+ * @param DOMElement $root
+ * @return Zend_Feed_Writer_Extension_RendererAbstract
+ */
+ public function setRootElement(DOMElement $root)
+ {
+ $this->_rootElement = $root;
+ return $this;
+ }
+
+ /**
+ * Get root element
+ *
+ * @return DOMElement
+ */
+ public function getRootElement()
+ {
+ return $this->_rootElement;
+ }
+
+ /**
+ * Append namespaces to feed
+ *
+ * @return void
+ */
+ abstract protected function _appendNamespaces();
+}
diff --git a/libs/Zend/Feed/Writer/Extension/RendererInterface.php b/libs/Zend/Feed/Writer/Extension/RendererInterface.php
new file mode 100644
index 0000000000..e9c9014176
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/RendererInterface.php
@@ -0,0 +1,59 @@
+<?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 padraic dot brady at yahoo dot com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Feed_Writer_Extension_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param mixed $container
+ * @return void
+ */
+ public function __construct($container);
+
+ /**
+ * Set DOMDocument and DOMElement on which to operate
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $base
+ * @return void
+ */
+ public function setDomDocument(DOMDocument $dom, DOMElement $base);
+
+ /**
+ * Render
+ *
+ * @return void
+ */
+ public function render();
+
+ /**
+ * Retrieve container
+ *
+ * @return mixed
+ */
+ public function getDataContainer();
+}
diff --git a/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php
new file mode 100644
index 0000000000..aae81fbbd4
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/Slash/Renderer/Entry.php
@@ -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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_Slash_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'atom') {
+ return; // RSS 2.0 only
+ }
+ $this->_setCommentCount($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append entry namespaces
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:slash',
+ 'http://purl.org/rss/1.0/modules/slash/');
+ }
+
+ /**
+ * Set entry comment count
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
+ {
+ $count = $this->getDataContainer()->getCommentCount();
+ if (!$count) {
+ $count = 0;
+ }
+ $tcount = $this->_dom->createElement('slash:comments');
+ $tcount->nodeValue = $count;
+ $root->appendChild($tcount);
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php
new file mode 100644
index 0000000000..1900ec459f
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/Threading/Renderer/Entry.php
@@ -0,0 +1,145 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_Threading_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'rss') {
+ return; // Atom 1.0 only
+ }
+ $this->_setCommentLink($this->_dom, $this->_base);
+ $this->_setCommentFeedLinks($this->_dom, $this->_base);
+ $this->_setCommentCount($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append entry namespaces
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:thr',
+ 'http://purl.org/syndication/thread/1.0');
+ }
+
+ /**
+ * Set comment link
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
+ {
+ $link = $this->getDataContainer()->getCommentLink();
+ if (!$link) {
+ return;
+ }
+ $clink = $this->_dom->createElement('link');
+ $clink->setAttribute('rel', 'replies');
+ $clink->setAttribute('type', 'text/html');
+ $clink->setAttribute('href', $link);
+ $count = $this->getDataContainer()->getCommentCount();
+ if (!is_null($count)) {
+ $clink->setAttribute('thr:count', $count);
+ }
+ $root->appendChild($clink);
+ $this->_called = true;
+ }
+
+ /**
+ * Set comment feed links
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
+ {
+ $links = $this->getDataContainer()->getCommentFeedLinks();
+ if (!$links || empty($links)) {
+ return;
+ }
+ foreach ($links as $link) {
+ $flink = $this->_dom->createElement('link');
+ $flink->setAttribute('rel', 'replies');
+ $flink->setAttribute('type', 'application/'. $link['type'] .'+xml');
+ $flink->setAttribute('href', $link['uri']);
+ $count = $this->getDataContainer()->getCommentCount();
+ if (!is_null($count)) {
+ $flink->setAttribute('thr:count', $count);
+ }
+ $root->appendChild($flink);
+ $this->_called = true;
+ }
+ }
+
+ /**
+ * Set entry comment count
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentCount(DOMDocument $dom, DOMElement $root)
+ {
+ $count = $this->getDataContainer()->getCommentCount();
+ if (is_null($count)) {
+ return;
+ }
+ $tcount = $this->_dom->createElement('thr:total');
+ $tcount->nodeValue = $count;
+ $root->appendChild($tcount);
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php b/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php
new file mode 100644
index 0000000000..d6a17454d9
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Extension/WellFormedWeb/Renderer/Entry.php
@@ -0,0 +1,96 @@
+<?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_Writer
+ * @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 20326 2010-01-16 00:20:43Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Extension_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Extension/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Extension_WellFormedWeb_Renderer_Entry
+ extends Zend_Feed_Writer_Extension_RendererAbstract
+{
+
+ /**
+ * Set to TRUE if a rendering method actually renders something. This
+ * is used to prevent premature appending of a XML namespace declaration
+ * until an element which requires it is actually appended.
+ *
+ * @var bool
+ */
+ protected $_called = false;
+
+ /**
+ * Render entry
+ *
+ * @return void
+ */
+ public function render()
+ {
+ if (strtolower($this->getType()) == 'atom') {
+ return; // RSS 2.0 only
+ }
+ $this->_setCommentFeedLinks($this->_dom, $this->_base);
+ if ($this->_called) {
+ $this->_appendNamespaces();
+ }
+ }
+
+ /**
+ * Append entry namespaces
+ *
+ * @return void
+ */
+ protected function _appendNamespaces()
+ {
+ $this->getRootElement()->setAttribute('xmlns:wfw',
+ 'http://wellformedweb.org/CommentAPI/');
+ }
+
+ /**
+ * Set entry comment feed links
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentFeedLinks(DOMDocument $dom, DOMElement $root)
+ {
+ $links = $this->getDataContainer()->getCommentFeedLinks();
+ if (!$links || empty($links)) {
+ return;
+ }
+ foreach ($links as $link) {
+ if ($link['type'] == 'rss') {
+ $flink = $this->_dom->createElement('wfw:commentRss');
+ $text = $dom->createTextNode($link['uri']);
+ $flink->appendChild($text);
+ $root->appendChild($flink);
+ }
+ }
+ $this->_called = true;
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Feed.php b/libs/Zend/Feed/Writer/Feed.php
new file mode 100644
index 0000000000..dd69dde834
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Feed.php
@@ -0,0 +1,281 @@
+<?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_Writer
+ * @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 20519 2010-01-22 14:06:24Z padraic $
+ */
+
+/**
+ * @see Zend_Date
+ */
+require_once 'Zend/Date.php';
+
+/**
+ * @see Zend_Date
+ */
+require_once 'Zend/Uri.php';
+
+/**
+ * @see Zend_Feed_Writer
+ */
+require_once 'Zend/Feed/Writer.php';
+
+/**
+ * @see Zend_Feed_Writer_Entry
+ */
+require_once 'Zend/Feed/Writer/Entry.php';
+
+/**
+ * @see Zend_Feed_Writer_Deleted
+ */
+require_once 'Zend/Feed/Writer/Deleted.php';
+
+/**
+ * @see Zend_Feed_Writer_Renderer_Feed_Atom
+ */
+require_once 'Zend/Feed/Writer/Renderer/Feed/Atom.php';
+
+/**
+ * @see Zend_Feed_Writer_Renderer_Feed_Rss
+ */
+require_once 'Zend/Feed/Writer/Renderer/Feed/Rss.php';
+
+require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Feed extends Zend_Feed_Writer_Feed_FeedAbstract
+implements Iterator, Countable
+{
+
+ /**
+ * Contains all entry objects
+ *
+ * @var array
+ */
+ protected $_entries = array();
+
+ /**
+ * A pointer for the iterator to keep track of the entries array
+ *
+ * @var int
+ */
+ protected $_entriesKey = 0;
+
+ /**
+ * Creates a new Zend_Feed_Writer_Entry data container for use. This is NOT
+ * added to the current feed automatically, but is necessary to create a
+ * container with some initial values preset based on the current feed data.
+ *
+ * @return Zend_Feed_Writer_Entry
+ */
+ public function createEntry()
+ {
+ $entry = new Zend_Feed_Writer_Entry;
+ if ($this->getEncoding()) {
+ $entry->setEncoding($this->getEncoding());
+ }
+ $entry->setType($this->getType());
+ return $entry;
+ }
+
+ /**
+ * Appends a Zend_Feed_Writer_Deleted object representing a new entry tombstone
+ * to the feed data container's internal group of entries.
+ *
+ * @param Zend_Feed_Writer_Deleted $entry
+ */
+ public function addTombstone(Zend_Feed_Writer_Deleted $deleted)
+ {
+ $this->_entries[] = $deleted;
+ }
+
+ /**
+ * Creates a new Zend_Feed_Writer_Deleted data container for use. This is NOT
+ * added to the current feed automatically, but is necessary to create a
+ * container with some initial values preset based on the current feed data.
+ *
+ * @return Zend_Feed_Writer_Deleted
+ */
+ public function createTombstone()
+ {
+ $deleted = new Zend_Feed_Writer_Deleted;
+ if ($this->getEncoding()) {
+ $deleted->setEncoding($this->getEncoding());
+ }
+ $deleted->setType($this->getType());
+ return $deleted;
+ }
+
+ /**
+ * Appends a Zend_Feed_Writer_Entry object representing a new entry/item
+ * the feed data container's internal group of entries.
+ *
+ * @param Zend_Feed_Writer_Entry $entry
+ */
+ public function addEntry(Zend_Feed_Writer_Entry $entry)
+ {
+ $this->_entries[] = $entry;
+ }
+
+ /**
+ * Removes a specific indexed entry from the internal queue. Entries must be
+ * added to a feed container in order to be indexed.
+ *
+ * @param int $index
+ */
+ public function removeEntry($index)
+ {
+ if (isset($this->_entries[$index])) {
+ unset($this->_entries[$index]);
+ }
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Undefined index: ' . $index . '. Entry does not exist.');
+ }
+
+ /**
+ * Retrieve a specific indexed entry from the internal queue. Entries must be
+ * added to a feed container in order to be indexed.
+ *
+ * @param int $index
+ */
+ public function getEntry($index = 0)
+ {
+ if (isset($this->_entries[$index])) {
+ return $this->_entries[$index];
+ }
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Undefined index: ' . $index . '. Entry does not exist.');
+ }
+
+ /**
+ * Orders all indexed entries by date, thus offering date ordered readable
+ * content where a parser (or Homo Sapien) ignores the generic rule that
+ * XML element order is irrelevant and has no intrinsic meaning.
+ *
+ * Using this method will alter the original indexation.
+ *
+ * @return void
+ */
+ public function orderByDate()
+ {
+ /**
+ * Could do with some improvement for performance perhaps
+ */
+ $timestamp = time();
+ $entries = array();
+ foreach ($this->_entries as $entry) {
+ if ($entry->getDateModified()) {
+ $timestamp = (int) $entry->getDateModified()->get(Zend_Date::TIMESTAMP);
+ } elseif ($entry->getDateCreated()) {
+ $timestamp = (int) $entry->getDateCreated()->get(Zend_Date::TIMESTAMP);
+ }
+ $entries[$timestamp] = $entry;
+ }
+ krsort($entries, SORT_NUMERIC);
+ $this->_entries = array_values($entries);
+ }
+
+ /**
+ * Get the number of feed entries.
+ * Required by the Iterator interface.
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->_entries);
+ }
+
+ /**
+ * Return the current entry
+ *
+ * @return Zend_Feed_Reader_Entry_Interface
+ */
+ public function current()
+ {
+ return $this->_entries[$this->key()];
+ }
+
+ /**
+ * Return the current feed key
+ *
+ * @return unknown
+ */
+ public function key()
+ {
+ return $this->_entriesKey;
+ }
+
+ /**
+ * Move the feed pointer forward
+ *
+ * @return void
+ */
+ public function next()
+ {
+ ++$this->_entriesKey;
+ }
+
+ /**
+ * Reset the pointer in the feed object
+ *
+ * @return void
+ */
+ public function rewind()
+ {
+ $this->_entriesKey = 0;
+ }
+
+ /**
+ * Check to see if the iterator is still valid
+ *
+ * @return boolean
+ */
+ public function valid()
+ {
+ return 0 <= $this->_entriesKey && $this->_entriesKey < $this->count();
+ }
+
+ /**
+ * Attempt to build and return the feed resulting from the data set
+ *
+ * @param $type The feed type "rss" or "atom" to export as
+ * @return string
+ */
+ public function export($type, $ignoreExceptions = false)
+ {
+ $this->setType(strtolower($type));
+ $type = ucfirst($this->getType());
+ if ($type !== 'Rss' && $type !== 'Atom') {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid feed type specified: ' . $type . '.'
+ . ' Should be one of "rss" or "atom".');
+ }
+ $renderClass = 'Zend_Feed_Writer_Renderer_Feed_' . $type;
+ $renderer = new $renderClass($this);
+ if ($ignoreExceptions) {
+ $renderer->ignoreExceptions();
+ }
+ return $renderer->render()->saveXml();
+ }
+
+}
diff --git a/libs/Zend/Feed/Writer/Feed/FeedAbstract.php b/libs/Zend/Feed/Writer/Feed/FeedAbstract.php
new file mode 100644
index 0000000000..24fbe73025
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Feed/FeedAbstract.php
@@ -0,0 +1,716 @@
+<?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_Writer
+ * @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_Date
+ */
+require_once 'Zend/Date.php';
+
+/**
+ * @see Zend_Date
+ */
+require_once 'Zend/Uri.php';
+
+/**
+ * @see Zend_Feed_Writer
+ */
+require_once 'Zend/Feed/Writer.php';
+
+/**
+ * @see Zend_Feed_Writer_Entry
+ */
+require_once 'Zend/Feed/Writer/Entry.php';
+
+/**
+ * @see Zend_Feed_Writer_Renderer_Feed_Atom
+ */
+require_once 'Zend/Feed/Writer/Renderer/Feed/Atom.php';
+
+/**
+ * @see Zend_Feed_Writer_Renderer_Feed_Rss
+ */
+require_once 'Zend/Feed/Writer/Renderer/Feed/Rss.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Feed_FeedAbstract
+{
+ /**
+ * Contains all Feed level date to append in feed output
+ *
+ * @var array
+ */
+ protected $_data = array();
+
+ /**
+ * Holds the value "atom" or "rss" depending on the feed type set when
+ * when last exported.
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * Constructor: Primarily triggers the registration of core extensions and
+ * loads those appropriate to this data container.
+ *
+ * @return void
+ */
+ public function __construct()
+ {
+ Zend_Feed_Writer::registerCoreExtensions();
+ $this->_loadExtensions();
+ }
+
+ /**
+ * Set a single author
+ *
+ * @param int $index
+ * @return string|null
+ */
+ public function addAuthor($name, $email = null, $uri = null)
+ {
+ $author = array();
+ if (is_array($name)) {
+ if (!array_key_exists('name', $name) || empty($name['name']) || !is_string($name['name'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
+ }
+ $author['name'] = $name['name'];
+ if (isset($name['email'])) {
+ if (empty($name['email']) || !is_string($name['email'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string');
+ }
+ $author['email'] = $name['email'];
+ }
+ if (isset($name['uri'])) {
+ if (empty($name['uri']) || !is_string($name['uri']) || !Zend_Uri::check($name['uri'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
+ }
+ $author['uri'] = $name['uri'];
+ }
+ } else {
+ if (empty($name['name']) || !is_string($name['name'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string value');
+ }
+ $author['name'] = $name;
+ if (isset($email)) {
+ if (empty($email) || !is_string($email)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "email" value must be a non-empty string');
+ }
+ $author['email'] = $email;
+ }
+ if (isset($uri)) {
+ if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" value must be a non-empty string and valid URI/IRI');
+ }
+ $author['uri'] = $uri;
+ }
+ }
+ $this->_data['authors'][] = $author;
+ }
+
+ /**
+ * Set an array with feed authors
+ *
+ * @return array
+ */
+ public function addAuthors(array $authors)
+ {
+ foreach($authors as $author) {
+ $this->addAuthor($author);
+ }
+ }
+
+ /**
+ * Set the copyright entry
+ *
+ * @return string|null
+ */
+ public function setCopyright($copyright)
+ {
+ if (empty($copyright) || !is_string($copyright)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['copyright'] = $copyright;
+ }
+
+ /**
+ * Set the feed creation date
+ *
+ * @param null|integer|Zend_Date
+ */
+ public function setDateCreated($date = null)
+ {
+ $zdate = null;
+ if (is_null($date)) {
+ $zdate = new Zend_Date;
+ } elseif (ctype_digit($date) && strlen($date) == 10) {
+ $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
+ } elseif ($date instanceof Zend_Date) {
+ $zdate = $date;
+ } else {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
+ }
+ $this->_data['dateCreated'] = $zdate;
+ }
+
+ /**
+ * Set the feed modification date
+ *
+ * @param null|integer|Zend_Date
+ */
+ public function setDateModified($date = null)
+ {
+ $zdate = null;
+ if (is_null($date)) {
+ $zdate = new Zend_Date;
+ } elseif (ctype_digit($date) && strlen($date) == 10) {
+ $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
+ } elseif ($date instanceof Zend_Date) {
+ $zdate = $date;
+ } else {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
+ }
+ $this->_data['dateModified'] = $zdate;
+ }
+
+ /**
+ * Set the feed description
+ *
+ * @return string|null
+ */
+ public function setDescription($description)
+ {
+ if (empty($description) || !is_string($description)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['description'] = $description;
+ }
+
+ /**
+ * Set the feed generator entry
+ *
+ * @return string|null
+ */
+ public function setGenerator($name, $version = null, $uri = null)
+ {
+ if (empty($name) || !is_string($name)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string');
+ }
+ $generator = array('name' => $name);
+ if (isset($version)) {
+ if (empty($version) || !is_string($version)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string');
+ }
+ $generator['version'] = $version;
+ }
+ if (isset($uri)) {
+ if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI');
+ }
+ $generator['uri'] = $uri;
+ }
+ $this->_data['generator'] = $generator;
+ }
+
+ /**
+ * Set the feed ID - URI or URN (via PCRE pattern) supported
+ *
+ * @return string|null
+ */
+ public function setId($id)
+ {
+ if ((empty($id) || !is_string($id) || !Zend_Uri::check($id)) &&
+ !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $id)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
+ }
+ $this->_data['id'] = $id;
+ }
+
+ /**
+ * Set the feed language
+ *
+ * @return string|null
+ */
+ public function setLanguage($language)
+ {
+ if (empty($language) || !is_string($language)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['language'] = $language;
+ }
+
+ /**
+ * Set a link to the HTML source
+ *
+ * @return string|null
+ */
+ public function setLink($link)
+ {
+ if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI');
+ }
+ $this->_data['link'] = $link;
+ }
+
+ /**
+ * Set a link to an XML feed for any feed type/version
+ *
+ * @return string|null
+ */
+ public function setFeedLink($link, $type)
+ {
+ if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "link"" must be a non-empty string and valid URI/IRI');
+ }
+ if (!in_array(strtolower($type), array('rss', 'rdf', 'atom'))) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "type"; You must declare the type of feed the link points to, i.e. RSS, RDF or Atom');
+ }
+ $this->_data['feedLinks'][strtolower($type)] = $link;
+ }
+
+ /**
+ * Set the feed title
+ *
+ * @return string|null
+ */
+ public function setTitle($title)
+ {
+ if (empty($title) || !is_string($title)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['title'] = $title;
+ }
+
+ /**
+ * Set the feed character encoding
+ *
+ * @param string $encoding
+ */
+ public function setEncoding($encoding)
+ {
+ if (empty($encoding) || !is_string($encoding)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
+ }
+ $this->_data['encoding'] = $encoding;
+ }
+
+ /**
+ * Set the feed's base URL
+ *
+ * @param string $url
+ */
+ public function setBaseUrl($url)
+ {
+ if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "url" array value'
+ . ' must be a non-empty string and valid URI/IRI');
+ }
+ $this->_data['baseUrl'] = $url;
+ }
+
+ /**
+ * Add a Pubsubhubbub hub endpoint URL
+ *
+ * @param string $url
+ */
+ public function addHub($url)
+ {
+ if (empty($url) || !is_string($url) || !Zend_Uri::check($url)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: "url" array value'
+ . ' must be a non-empty string and valid URI/IRI');
+ }
+ if (!isset($this->_data['hubs'])) {
+ $this->_data['hubs'] = array();
+ }
+ $this->_data['hubs'][] = $url;
+ }
+
+ /**
+ * Add Pubsubhubbub hub endpoint URLs
+ *
+ * @param array $urls
+ */
+ public function addHubs(array $urls)
+ {
+ foreach ($urls as $url) {
+ $this->addHub($url);
+ }
+ }
+
+ /**
+ * Add a feed category
+ *
+ * @param string $category
+ */
+ public function addCategory(array $category)
+ {
+ if (!isset($category['term'])) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Each category must be an array and '
+ . 'contain at least a "term" element containing the machine '
+ . ' readable category name');
+ }
+ if (isset($category['scheme'])) {
+ if (empty($category['scheme'])
+ || !is_string($category['scheme'])
+ || !Zend_Uri::check($category['scheme'])
+ ) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('The Atom scheme or RSS domain of'
+ . ' a category must be a valid URI');
+ }
+ }
+ if (!isset($this->_data['categories'])) {
+ $this->_data['categories'] = array();
+ }
+ $this->_data['categories'][] = $category;
+ }
+
+ /**
+ * Set an array of feed categories
+ *
+ * @param array $categories
+ */
+ public function addCategories(array $categories)
+ {
+ foreach ($categories as $category) {
+ $this->addCategory($category);
+ }
+ }
+
+ /**
+ * Get a single author
+ *
+ * @param int $index
+ * @return string|null
+ */
+ public function getAuthor($index = 0)
+ {
+ if (isset($this->_data['authors'][$index])) {
+ return $this->_data['authors'][$index];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get an array with feed authors
+ *
+ * @return array
+ */
+ public function getAuthors()
+ {
+ if (!array_key_exists('authors', $this->_data)) {
+ return null;
+ }
+ return $this->_data['authors'];
+ }
+
+ /**
+ * Get the copyright entry
+ *
+ * @return string|null
+ */
+ public function getCopyright()
+ {
+ if (!array_key_exists('copyright', $this->_data)) {
+ return null;
+ }
+ return $this->_data['copyright'];
+ }
+
+ /**
+ * Get the feed creation date
+ *
+ * @return string|null
+ */
+ public function getDateCreated()
+ {
+ if (!array_key_exists('dateCreated', $this->_data)) {
+ return null;
+ }
+ return $this->_data['dateCreated'];
+ }
+
+ /**
+ * Get the feed modification date
+ *
+ * @return string|null
+ */
+ public function getDateModified()
+ {
+ if (!array_key_exists('dateModified', $this->_data)) {
+ return null;
+ }
+ return $this->_data['dateModified'];
+ }
+
+ /**
+ * Get the feed description
+ *
+ * @return string|null
+ */
+ public function getDescription()
+ {
+ if (!array_key_exists('description', $this->_data)) {
+ return null;
+ }
+ return $this->_data['description'];
+ }
+
+ /**
+ * Get the feed generator entry
+ *
+ * @return string|null
+ */
+ public function getGenerator()
+ {
+ if (!array_key_exists('generator', $this->_data)) {
+ return null;
+ }
+ return $this->_data['generator'];
+ }
+
+ /**
+ * Get the feed ID
+ *
+ * @return string|null
+ */
+ public function getId()
+ {
+ if (!array_key_exists('id', $this->_data)) {
+ return null;
+ }
+ return $this->_data['id'];
+ }
+
+ /**
+ * Get the feed language
+ *
+ * @return string|null
+ */
+ public function getLanguage()
+ {
+ if (!array_key_exists('language', $this->_data)) {
+ return null;
+ }
+ return $this->_data['language'];
+ }
+
+ /**
+ * Get a link to the HTML source
+ *
+ * @return string|null
+ */
+ public function getLink()
+ {
+ if (!array_key_exists('link', $this->_data)) {
+ return null;
+ }
+ return $this->_data['link'];
+ }
+
+ /**
+ * Get a link to the XML feed
+ *
+ * @return string|null
+ */
+ public function getFeedLinks()
+ {
+ if (!array_key_exists('feedLinks', $this->_data)) {
+ return null;
+ }
+ return $this->_data['feedLinks'];
+ }
+
+ /**
+ * Get the feed title
+ *
+ * @return string|null
+ */
+ public function getTitle()
+ {
+ if (!array_key_exists('title', $this->_data)) {
+ return null;
+ }
+ return $this->_data['title'];
+ }
+
+ /**
+ * Get the feed character encoding
+ *
+ * @return string|null
+ */
+ public function getEncoding()
+ {
+ if (!array_key_exists('encoding', $this->_data)) {
+ return 'UTF-8';
+ }
+ return $this->_data['encoding'];
+ }
+
+ /**
+ * Get the feed's base url
+ *
+ * @return string|null
+ */
+ public function getBaseUrl()
+ {
+ if (!array_key_exists('baseUrl', $this->_data)) {
+ return null;
+ }
+ return $this->_data['baseUrl'];
+ }
+
+ /**
+ * Get the URLs used as Pubsubhubbub hubs endpoints
+ *
+ * @return string|null
+ */
+ public function getHubs()
+ {
+ if (!array_key_exists('hubs', $this->_data)) {
+ return null;
+ }
+ return $this->_data['hubs'];
+ }
+
+ /**
+ * Get the feed categories
+ *
+ * @return string|null
+ */
+ public function getCategories()
+ {
+ if (!array_key_exists('categories', $this->_data)) {
+ return null;
+ }
+ return $this->_data['categories'];
+ }
+
+ /**
+ * Resets the instance and deletes all data
+ *
+ * @return void
+ */
+ public function reset()
+ {
+ $this->_data = array();
+ }
+
+ /**
+ * Set the current feed type being exported to "rss" or "atom". This allows
+ * other objects to gracefully choose whether to execute or not, depending
+ * on their appropriateness for the current type, e.g. renderers.
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ }
+
+ /**
+ * Retrieve the current or last feed type exported.
+ *
+ * @return string Value will be "rss" or "atom"
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /**
+ * Unset a specific data point
+ *
+ * @param string $name
+ */
+ public function remove($name)
+ {
+ if (isset($this->_data[$name])) {
+ unset($this->_data[$name]);
+ }
+ }
+
+ /**
+ * Method overloading: call given method on first extension implementing it
+ *
+ * @param string $method
+ * @param array $args
+ * @return mixed
+ * @throws Zend_Feed_Exception if no extensions implements the method
+ */
+ public function __call($method, $args)
+ {
+ foreach ($this->_extensions as $extension) {
+ try {
+ return call_user_func_array(array($extension, $method), $args);
+ } catch (Zend_Feed_Writer_Exception_InvalidMethodException $e) {
+ }
+ }
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Method: ' . $method
+ . ' does not exist and could not be located on a registered Extension');
+ }
+
+ /**
+ * Load extensions from Zend_Feed_Writer
+ *
+ * @return void
+ */
+ protected function _loadExtensions()
+ {
+ $all = Zend_Feed_Writer::getExtensions();
+ $exts = $all['feed'];
+ foreach ($exts as $ext) {
+ $className = Zend_Feed_Writer::getPluginLoader()->getClassName($ext);
+ $this->_extensions[$ext] = new $className();
+ $this->_extensions[$ext]->setEncoding($this->getEncoding());
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php b/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php
new file mode 100644
index 0000000000..b029dede42
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php
@@ -0,0 +1,405 @@
+<?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_Writer
+ * @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: Atom.php 20507 2010-01-21 22:21:07Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Renderer_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/Source.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Entry_Atom
+ extends Zend_Feed_Writer_Renderer_RendererAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Entry $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Entry $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render atom entry
+ *
+ * @return Zend_Feed_Writer_Renderer_Entry_Atom
+ */
+ public function render()
+ {
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $entry = $this->_dom->createElementNS(Zend_Feed_Writer::NAMESPACE_ATOM_10, 'entry');
+ $this->_dom->appendChild($entry);
+
+ $this->_setSource($this->_dom, $entry);
+ $this->_setTitle($this->_dom, $entry);
+ $this->_setDescription($this->_dom, $entry);
+ $this->_setDateCreated($this->_dom, $entry);
+ $this->_setDateModified($this->_dom, $entry);
+ $this->_setLink($this->_dom, $entry);
+ $this->_setId($this->_dom, $entry);
+ $this->_setAuthors($this->_dom, $entry);
+ $this->_setEnclosure($this->_dom, $entry);
+ $this->_setContent($this->_dom, $entry);
+ $this->_setCategories($this->_dom, $entry);
+
+ foreach ($this->_extensions as $ext) {
+ $ext->setType($this->getType());
+ $ext->setRootElement($this->getRootElement());
+ $ext->setDomDocument($this->getDomDocument(), $entry);
+ $ext->render();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set entry title
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setTitle(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getTitle()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 entry elements MUST contain exactly one'
+ . ' atom:title element but a title has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ $title = $dom->createElement('title');
+ $root->appendChild($title);
+ $title->setAttribute('type', 'html');
+ $cdata = $dom->createCDATASection($this->getDataContainer()->getTitle());
+ $title->appendChild($cdata);
+ }
+
+ /**
+ * Set entry description
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDescription(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDescription()) {
+ return; // unless src content or base64
+ }
+ $subtitle = $dom->createElement('summary');
+ $root->appendChild($subtitle);
+ $subtitle->setAttribute('type', 'html');
+ $cdata = $dom->createCDATASection(
+ $this->getDataContainer()->getDescription()
+ );
+ $subtitle->appendChild($cdata);
+ }
+
+ /**
+ * Set date entry was modified
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateModified()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 entry elements MUST contain exactly one'
+ . ' atom:updated element but a modification date has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ $updated = $dom->createElement('updated');
+ $root->appendChild($updated);
+ $text = $dom->createTextNode(
+ $this->getDataContainer()->getDateModified()->get(Zend_Date::ISO_8601)
+ );
+ $updated->appendChild($text);
+ }
+
+ /**
+ * Set date entry was created
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
+ {
+ if (!$this->getDataContainer()->getDateCreated()) {
+ return;
+ }
+ $el = $dom->createElement('published');
+ $root->appendChild($el);
+ $text = $dom->createTextNode(
+ $this->getDataContainer()->getDateCreated()->get(Zend_Date::ISO_8601)
+ );
+ $el->appendChild($text);
+ }
+
+ /**
+ * Set entry authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->_container->getAuthors();
+ if ((!$authors || empty($authors))) {
+ /**
+ * This will actually trigger an Exception at the feed level if
+ * a feed level author is not set.
+ */
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('author');
+ $name = $this->_dom->createElement('name');
+ $author->appendChild($name);
+ $root->appendChild($author);
+ $text = $dom->createTextNode($data['name']);
+ $name->appendChild($text);
+ if (array_key_exists('email', $data)) {
+ $email = $this->_dom->createElement('email');
+ $author->appendChild($email);
+ $text = $dom->createTextNode($data['email']);
+ $email->appendChild($text);
+ }
+ if (array_key_exists('uri', $data)) {
+ $uri = $this->_dom->createElement('uri');
+ $author->appendChild($uri);
+ $text = $dom->createTextNode($data['uri']);
+ $uri->appendChild($text);
+ }
+ }
+ }
+
+ /**
+ * Set entry enclosure
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
+ {
+ $data = $this->_container->getEnclosure();
+ if ((!$data || empty($data))) {
+ return;
+ }
+ $enclosure = $this->_dom->createElement('link');
+ $enclosure->setAttribute('rel', 'enclosure');
+ $enclosure->setAttribute('type', $data['type']);
+ $enclosure->setAttribute('length', $data['length']);
+ $enclosure->setAttribute('href', $data['uri']);
+ $root->appendChild($enclosure);
+ }
+
+ protected function _setLink(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getLink()) {
+ return;
+ }
+ $link = $dom->createElement('link');
+ $root->appendChild($link);
+ $link->setAttribute('rel', 'alternate');
+ $link->setAttribute('type', 'text/html');
+ $link->setAttribute('href', $this->getDataContainer()->getLink());
+ }
+
+ /**
+ * Set entry identifier
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setId(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getId()
+ && !$this->getDataContainer()->getLink()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 entry elements MUST contain exactly one '
+ . 'atom:id element, or as an alternative, we can use the same '
+ . 'value as atom:link however neither a suitable link nor an '
+ . 'id have been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ if (!$this->getDataContainer()->getId()) {
+ $this->getDataContainer()->setId(
+ $this->getDataContainer()->getLink());
+ }
+ if (!Zend_Uri::check($this->getDataContainer()->getId()) &&
+ !preg_match("#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#", $this->getDataContainer()->getId())) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Atom 1.0 IDs must be a valid URI/IRI');
+ }
+ $id = $dom->createElement('id');
+ $root->appendChild($id);
+ $text = $dom->createTextNode($this->getDataContainer()->getId());
+ $id->appendChild($text);
+ }
+
+ /**
+ * Set entry content
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setContent(DOMDocument $dom, DOMElement $root)
+ {
+ $content = $this->getDataContainer()->getContent();
+ if (!$content && !$this->getDataContainer()->getLink()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 entry elements MUST contain exactly one '
+ . 'atom:content element, or as an alternative, at least one link '
+ . 'with a rel attribute of "alternate" to indicate an alternate '
+ . 'method to consume the content.';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ if (!$content) {
+ return;
+ }
+ $element = $dom->createElement('content');
+ $element->setAttribute('type', 'xhtml');
+ $xhtmlElement = $this->_loadXhtml($content);
+ $xhtml = $dom->importNode($xhtmlElement, true);
+ $element->appendChild($xhtml);
+ $root->appendChild($element);
+ }
+
+ /**
+ * Load a HTML string and attempt to normalise to XML
+ */
+ protected function _loadXhtml($content)
+ {
+ $xhtml = '';
+ if (class_exists('tidy', false)) {
+ $tidy = new tidy;
+ $config = array(
+ 'output-xhtml' => true,
+ 'show-body-only' => true
+ );
+ $encoding = str_replace('-', '', $this->getEncoding());
+ $tidy->parseString($content, $config, $encoding);
+ $tidy->cleanRepair();
+ $xhtml = (string) $tidy;
+ } else {
+ $xhtml = $content;
+ }
+ $xhtml = preg_replace(array(
+ "/(<[\/]?)([a-zA-Z]+)/"
+ ), '$1xhtml:$2', $xhtml);
+ $dom = new DOMDocument('1.0', $this->getEncoding());
+ $dom->loadXML('<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">'
+ . $xhtml . '</xhtml:div>');
+ return $dom->documentElement;
+ }
+
+ /**
+ * Set entry cateories
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCategories(DOMDocument $dom, DOMElement $root)
+ {
+ $categories = $this->getDataContainer()->getCategories();
+ if (!$categories) {
+ return;
+ }
+ foreach ($categories as $cat) {
+ $category = $dom->createElement('category');
+ $category->setAttribute('term', $cat['term']);
+ if (isset($cat['label'])) {
+ $category->setAttribute('label', $cat['label']);
+ } else {
+ $category->setAttribute('label', $cat['term']);
+ }
+ if (isset($cat['scheme'])) {
+ $category->setAttribute('scheme', $cat['scheme']);
+ }
+ $root->appendChild($category);
+ }
+ }
+
+ /**
+ * Append Source element (Atom 1.0 Feed Metadata)
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setSource(DOMDocument $dom, DOMElement $root)
+ {
+ $source = $this->getDataContainer()->getSource();
+ if (!$source) {
+ return;
+ }
+ $renderer = new Zend_Feed_Writer_Renderer_Feed_Atom_Source($source);
+ $renderer->setType($this->getType());
+ $element = $renderer->render()->getElement();
+ $imported = $dom->importNode($element, true);
+ $root->appendChild($imported);
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php b/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php
new file mode 100644
index 0000000000..f7baf60c54
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php
@@ -0,0 +1,121 @@
+<?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_Writer
+ * @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: Atom.php 20506 2010-01-21 22:19:05Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Renderer_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Entry_Atom_Deleted
+ extends Zend_Feed_Writer_Renderer_RendererAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Deleted $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Deleted $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render atom entry
+ *
+ * @return Zend_Feed_Writer_Renderer_Entry_Atom
+ */
+ public function render()
+ {
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $entry = $this->_dom->createElement('at:deleted-entry');
+ $this->_dom->appendChild($entry);
+
+ $entry->setAttribute('ref', $this->_container->getReference());
+ $entry->setAttribute('when', $this->_container->getWhen()->get(Zend_Date::ISO_8601));
+
+ $this->_setBy($this->_dom, $entry);
+ $this->_setComment($this->_dom, $entry);
+
+ return $this;
+ }
+
+ /**
+ * Set tombstone comment
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setComment(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getComment()) {
+ return;
+ }
+ $c = $dom->createElement('at:comment');
+ $root->appendChild($c);
+ $c->setAttribute('type', 'html');
+ $cdata = $dom->createCDATASection($this->getDataContainer()->getComment());
+ $c->appendChild($cdata);
+ }
+
+ /**
+ * Set entry authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setBy(DOMDocument $dom, DOMElement $root)
+ {
+ $data = $this->_container->getBy();
+ if ((!$data || empty($data))) {
+ return;
+ }
+ $author = $this->_dom->createElement('at:by');
+ $name = $this->_dom->createElement('name');
+ $author->appendChild($name);
+ $root->appendChild($author);
+ $text = $dom->createTextNode($data['name']);
+ $name->appendChild($text);
+ if (array_key_exists('email', $data)) {
+ $email = $this->_dom->createElement('email');
+ $author->appendChild($email);
+ $text = $dom->createTextNode($data['email']);
+ $email->appendChild($text);
+ }
+ if (array_key_exists('uri', $data)) {
+ $uri = $this->_dom->createElement('uri');
+ $author->appendChild($uri);
+ $text = $dom->createTextNode($data['uri']);
+ $uri->appendChild($text);
+ }
+ }
+
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php b/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php
new file mode 100644
index 0000000000..6f2c349d51
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php
@@ -0,0 +1,315 @@
+<?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_Writer
+ * @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: Rss.php 20241 2010-01-12 20:19:46Z padraic $
+ */
+
+/**
+ * @see Zend_Feed_Writer_Renderer_RendererAbstract
+ */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Entry_Rss
+ extends Zend_Feed_Writer_Renderer_RendererAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Entry $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Entry $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render RSS entry
+ *
+ * @return Zend_Feed_Writer_Renderer_Entry_Rss
+ */
+ public function render()
+ {
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $this->_dom->substituteEntities = false;
+ $entry = $this->_dom->createElement('item');
+ $this->_dom->appendChild($entry);
+
+ $this->_setTitle($this->_dom, $entry);
+ $this->_setDescription($this->_dom, $entry);
+ $this->_setDateCreated($this->_dom, $entry);
+ $this->_setDateModified($this->_dom, $entry);
+ $this->_setLink($this->_dom, $entry);
+ $this->_setId($this->_dom, $entry);
+ $this->_setAuthors($this->_dom, $entry);
+ $this->_setEnclosure($this->_dom, $entry);
+ $this->_setCommentLink($this->_dom, $entry);
+ $this->_setCategories($this->_dom, $entry);
+ foreach ($this->_extensions as $ext) {
+ $ext->setType($this->getType());
+ $ext->setRootElement($this->getRootElement());
+ $ext->setDomDocument($this->getDomDocument(), $entry);
+ $ext->render();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Set entry title
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setTitle(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDescription()
+ && !$this->getDataContainer()->getTitle()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'RSS 2.0 entry elements SHOULD contain exactly one'
+ . ' title element but a title has not been set. In addition, there'
+ . ' is no description as required in the absence of a title.';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ $title = $dom->createElement('title');
+ $root->appendChild($title);
+ $text = $dom->createTextNode($this->getDataContainer()->getTitle());
+ $title->appendChild($text);
+ }
+
+ /**
+ * Set entry description
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDescription(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDescription()
+ && !$this->getDataContainer()->getTitle()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'RSS 2.0 entry elements SHOULD contain exactly one'
+ . ' description element but a description has not been set. In'
+ . ' addition, there is no title element as required in the absence'
+ . ' of a description.';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ if (!$this->getDataContainer()->getDescription()) {
+ return;
+ }
+ $subtitle = $dom->createElement('description');
+ $root->appendChild($subtitle);
+ $text = $dom->createCDATASection($this->getDataContainer()->getDescription());
+ $subtitle->appendChild($text);
+ }
+
+ /**
+ * Set date entry was last modified
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateModified()) {
+ return;
+ }
+
+ $updated = $dom->createElement('pubDate');
+ $root->appendChild($updated);
+ $text = $dom->createTextNode(
+ $this->getDataContainer()->getDateModified()->get(Zend_Date::RSS)
+ );
+ $updated->appendChild($text);
+ }
+
+ /**
+ * Set date entry was created
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
+ {
+ if (!$this->getDataContainer()->getDateCreated()) {
+ return;
+ }
+ if (!$this->getDataContainer()->getDateModified()) {
+ $this->getDataContainer()->setDateModified(
+ $this->getDataContainer()->getDateCreated()
+ );
+ }
+ }
+
+ /**
+ * Set entry authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->_container->getAuthors();
+ if ((!$authors || empty($authors))) {
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('author');
+ $name = $data['name'];
+ if (array_key_exists('email', $data)) {
+ $name = $data['email'] . ' (' . $data['name'] . ')';
+ }
+ $text = $dom->createTextNode($name);
+ $author->appendChild($text);
+ $root->appendChild($author);
+ }
+ }
+
+ /**
+ * Set entry enclosure
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setEnclosure(DOMDocument $dom, DOMElement $root)
+ {
+ $data = $this->_container->getEnclosure();
+ if ((!$data || empty($data))) {
+ return;
+ }
+ $enclosure = $this->_dom->createElement('enclosure');
+ $enclosure->setAttribute('type', $data['type']);
+ $enclosure->setAttribute('length', $data['length']);
+ $enclosure->setAttribute('url', $data['uri']);
+ $root->appendChild($enclosure);
+ }
+
+ /**
+ * Set link to entry
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setLink(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getLink()) {
+ return;
+ }
+ $link = $dom->createElement('link');
+ $root->appendChild($link);
+ $text = $dom->createTextNode($this->getDataContainer()->getLink());
+ $link->appendChild($text);
+ }
+
+ /**
+ * Set entry identifier
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setId(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getId()
+ && !$this->getDataContainer()->getLink()) {
+ return;
+ }
+
+ $id = $dom->createElement('guid');
+ $root->appendChild($id);
+ if (!$this->getDataContainer()->getId()) {
+ $this->getDataContainer()->setId(
+ $this->getDataContainer()->getLink());
+ }
+ $text = $dom->createTextNode($this->getDataContainer()->getId());
+ $id->appendChild($text);
+ if (!Zend_Uri::check($this->getDataContainer()->getId())) {
+ $id->setAttribute('isPermaLink', 'false');
+ }
+ }
+
+ /**
+ * Set link to entry comments
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCommentLink(DOMDocument $dom, DOMElement $root)
+ {
+ $link = $this->getDataContainer()->getCommentLink();
+ if (!$link) {
+ return;
+ }
+ $clink = $this->_dom->createElement('comments');
+ $text = $dom->createTextNode($link);
+ $clink->appendChild($text);
+ $root->appendChild($clink);
+ }
+
+ /**
+ * Set entry categories
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCategories(DOMDocument $dom, DOMElement $root)
+ {
+ $categories = $this->getDataContainer()->getCategories();
+ if (!$categories) {
+ return;
+ }
+ foreach ($categories as $cat) {
+ $category = $dom->createElement('category');
+ if (isset($cat['scheme'])) {
+ $category->setAttribute('domain', $cat['scheme']);
+ }
+ $text = $dom->createCDATASection($cat['term']);
+ $category->appendChild($text);
+ $root->appendChild($category);
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php
new file mode 100644
index 0000000000..ed080c1515
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php
@@ -0,0 +1,129 @@
+<?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_Writer
+ * @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: Atom.php 20519 2010-01-22 14:06:24Z padraic $
+ */
+
+/** @see Zend_Feed_Writer_Feed */
+require_once 'Zend/Feed/Writer/Feed.php';
+
+/** @see Zend_Version */
+require_once 'Zend/Version.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererInterface */
+require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php';
+
+/** @see Zend_Feed_Writer_Renderer_Entry_Atom */
+require_once 'Zend/Feed/Writer/Renderer/Entry/Atom.php';
+
+/** @see Zend_Feed_Writer_Renderer_Entry_Atom_Deleted */
+require_once 'Zend/Feed/Writer/Renderer/Entry/Atom/Deleted.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererAbstract */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Feed_Atom
+ extends Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Feed $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Feed $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render Atom feed
+ *
+ * @return Zend_Feed_Writer_Renderer_Feed_Atom
+ */
+ public function render()
+ {
+ if (!$this->_container->getEncoding()) {
+ $this->_container->setEncoding('UTF-8');
+ }
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $root = $this->_dom->createElementNS(
+ Zend_Feed_Writer::NAMESPACE_ATOM_10, 'feed'
+ );
+ $this->setRootElement($root);
+ $this->_dom->appendChild($root);
+ $this->_setLanguage($this->_dom, $root);
+ $this->_setBaseUrl($this->_dom, $root);
+ $this->_setTitle($this->_dom, $root);
+ $this->_setDescription($this->_dom, $root);
+ $this->_setDateCreated($this->_dom, $root);
+ $this->_setDateModified($this->_dom, $root);
+ $this->_setGenerator($this->_dom, $root);
+ $this->_setLink($this->_dom, $root);
+ $this->_setFeedLinks($this->_dom, $root);
+ $this->_setId($this->_dom, $root);
+ $this->_setAuthors($this->_dom, $root);
+ $this->_setCopyright($this->_dom, $root);
+ $this->_setCategories($this->_dom, $root);
+ $this->_setHubs($this->_dom, $root);
+
+ foreach ($this->_extensions as $ext) {
+ $ext->setType($this->getType());
+ $ext->setRootElement($this->getRootElement());
+ $ext->setDomDocument($this->getDomDocument(), $root);
+ $ext->render();
+ }
+
+ foreach ($this->_container as $entry) {
+ if ($this->getDataContainer()->getEncoding()) {
+ $entry->setEncoding($this->getDataContainer()->getEncoding());
+ }
+ if ($entry instanceof Zend_Feed_Writer_Entry) {
+ $renderer = new Zend_Feed_Writer_Renderer_Entry_Atom($entry);
+ } else {
+ if (!$this->_dom->documentElement->hasAttribute('xmlns:at')) {
+ $this->_dom->documentElement->setAttribute(
+ 'xmlns:at', 'http://purl.org/atompub/tombstones/1.0'
+ );
+ }
+ $renderer = new Zend_Feed_Writer_Renderer_Entry_Atom_Deleted($entry);
+ }
+ if ($this->_ignoreExceptions === true) {
+ $renderer->ignoreExceptions();
+ }
+ $renderer->setType($this->getType());
+ $renderer->setRootElement($this->_dom->documentElement);
+ $renderer->render();
+ $element = $renderer->getElement();
+ $imported = $this->_dom->importNode($element, true);
+ $root->appendChild($imported);
+ }
+ return $this;
+ }
+
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php
new file mode 100644
index 0000000000..35be0464d9
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php
@@ -0,0 +1,408 @@
+<?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_Writer
+ * @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: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $
+ */
+
+/** @see Zend_Feed_Writer_Feed */
+require_once 'Zend/Feed/Writer/Feed.php';
+
+/** @see Zend_Version */
+require_once 'Zend/Version.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererInterface */
+require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php';
+
+/** @see Zend_Feed_Writer_Renderer_Entry_Atom */
+require_once 'Zend/Feed/Writer/Renderer/Entry/Atom.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererAbstract */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Feed_Atom_AtomAbstract
+ extends Zend_Feed_Writer_Renderer_RendererAbstract
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Feed $container
+ * @return void
+ */
+ public function __construct ($container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Set feed language
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setLanguage(DOMDocument $dom, DOMElement $root)
+ {
+ if ($this->getDataContainer()->getLanguage()) {
+ $root->setAttribute('xml:lang', $this->getDataContainer()
+ ->getLanguage());
+ }
+ }
+
+ /**
+ * Set feed title
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setTitle(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getTitle()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 feed elements MUST contain exactly one'
+ . ' atom:title element but a title has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ $title = $dom->createElement('title');
+ $root->appendChild($title);
+ $title->setAttribute('type', 'text');
+ $text = $dom->createTextNode($this->getDataContainer()->getTitle());
+ $title->appendChild($text);
+ }
+
+ /**
+ * Set feed description
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDescription(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDescription()) {
+ return;
+ }
+ $subtitle = $dom->createElement('subtitle');
+ $root->appendChild($subtitle);
+ $subtitle->setAttribute('type', 'text');
+ $text = $dom->createTextNode($this->getDataContainer()->getDescription());
+ $subtitle->appendChild($text);
+ }
+
+ /**
+ * Set date feed was last modified
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateModified()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 feed elements MUST contain exactly one'
+ . ' atom:updated element but a modification date has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ $updated = $dom->createElement('updated');
+ $root->appendChild($updated);
+ $text = $dom->createTextNode(
+ $this->getDataContainer()->getDateModified()->get(Zend_Date::ISO_8601)
+ );
+ $updated->appendChild($text);
+ }
+
+ /**
+ * Set feed generator string
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setGenerator(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getGenerator()) {
+ $this->getDataContainer()->setGenerator('Zend_Feed_Writer',
+ Zend_Version::VERSION, 'http://framework.zend.com');
+ }
+
+ $gdata = $this->getDataContainer()->getGenerator();
+ $generator = $dom->createElement('generator');
+ $root->appendChild($generator);
+ $text = $dom->createTextNode($gdata['name']);
+ $generator->appendChild($text);
+ if (array_key_exists('uri', $gdata)) {
+ $generator->setAttribute('uri', $gdata['uri']);
+ }
+ if (array_key_exists('version', $gdata)) {
+ $generator->setAttribute('version', $gdata['version']);
+ }
+ }
+
+ /**
+ * Set link to feed
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setLink(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getLink()) {
+ return;
+ }
+ $link = $dom->createElement('link');
+ $root->appendChild($link);
+ $link->setAttribute('rel', 'alternate');
+ $link->setAttribute('type', 'text/html');
+ $link->setAttribute('href', $this->getDataContainer()->getLink());
+ }
+
+ /**
+ * Set feed links
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setFeedLinks(DOMDocument $dom, DOMElement $root)
+ {
+ $flinks = $this->getDataContainer()->getFeedLinks();
+ if(!$flinks || !array_key_exists('atom', $flinks)) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 feed elements SHOULD contain one atom:link '
+ . 'element with a rel attribute value of "self". This is the '
+ . 'preferred URI for retrieving Atom Feed Documents representing '
+ . 'this Atom feed but a feed link has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ foreach ($flinks as $type => $href) {
+ $mime = 'application/' . strtolower($type) . '+xml';
+ $flink = $dom->createElement('link');
+ $root->appendChild($flink);
+ $flink->setAttribute('rel', 'self');
+ $flink->setAttribute('type', $mime);
+ $flink->setAttribute('href', $href);
+ }
+ }
+
+ /**
+ * Set feed authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->_container->getAuthors();
+ if (!$authors || empty($authors)) {
+ /**
+ * Technically we should defer an exception until we can check
+ * that all entries contain an author. If any entry is missing
+ * an author, then a missing feed author element is invalid
+ */
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('author');
+ $name = $this->_dom->createElement('name');
+ $author->appendChild($name);
+ $root->appendChild($author);
+ $text = $dom->createTextNode($data['name']);
+ $name->appendChild($text);
+ if (array_key_exists('email', $data)) {
+ $email = $this->_dom->createElement('email');
+ $author->appendChild($email);
+ $text = $dom->createTextNode($data['email']);
+ $email->appendChild($text);
+ }
+ if (array_key_exists('uri', $data)) {
+ $uri = $this->_dom->createElement('uri');
+ $author->appendChild($uri);
+ $text = $dom->createTextNode($data['uri']);
+ $uri->appendChild($text);
+ }
+ }
+ }
+
+ /**
+ * Set feed identifier
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setId(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getId()
+ && !$this->getDataContainer()->getLink()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'Atom 1.0 feed elements MUST contain exactly one '
+ . 'atom:id element, or as an alternative, we can use the same '
+ . 'value as atom:link however neither a suitable link nor an '
+ . 'id have been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ if (!$this->getDataContainer()->getId()) {
+ $this->getDataContainer()->setId(
+ $this->getDataContainer()->getLink());
+ }
+ $id = $dom->createElement('id');
+ $root->appendChild($id);
+ $text = $dom->createTextNode($this->getDataContainer()->getId());
+ $id->appendChild($text);
+ }
+
+ /**
+ * Set feed copyright
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCopyright(DOMDocument $dom, DOMElement $root)
+ {
+ $copyright = $this->getDataContainer()->getCopyright();
+ if (!$copyright) {
+ return;
+ }
+ $copy = $dom->createElement('rights');
+ $root->appendChild($copy);
+ $text = $dom->createTextNode($copyright);
+ $copy->appendChild($text);
+ }
+
+ /**
+ * Set date feed was created
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateCreated()) {
+ return;
+ }
+ if(!$this->getDataContainer()->getDateModified()) {
+ $this->getDataContainer()->setDateModified(
+ $this->getDataContainer()->getDateCreated()
+ );
+ }
+ }
+
+ /**
+ * Set base URL to feed links
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
+ {
+ $baseUrl = $this->getDataContainer()->getBaseUrl();
+ if (!$baseUrl) {
+ return;
+ }
+ $root->setAttribute('xml:base', $baseUrl);
+ }
+
+ /**
+ * Set hubs to which this feed pushes
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setHubs(DOMDocument $dom, DOMElement $root)
+ {
+ $hubs = $this->getDataContainer()->getHubs();
+ if (!$hubs) {
+ return;
+ }
+ foreach ($hubs as $hubUrl) {
+ $hub = $dom->createElement('link');
+ $hub->setAttribute('rel', 'hub');
+ $hub->setAttribute('href', $hubUrl);
+ $root->appendChild($hub);
+ }
+ }
+
+ /**
+ * Set feed cateories
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCategories(DOMDocument $dom, DOMElement $root)
+ {
+ $categories = $this->getDataContainer()->getCategories();
+ if (!$categories) {
+ return;
+ }
+ foreach ($categories as $cat) {
+ $category = $dom->createElement('category');
+ $category->setAttribute('term', $cat['term']);
+ if (isset($cat['label'])) {
+ $category->setAttribute('label', $cat['label']);
+ } else {
+ $category->setAttribute('label', $cat['term']);
+ }
+ if (isset($cat['scheme'])) {
+ $category->setAttribute('scheme', $cat['scheme']);
+ }
+ $root->appendChild($category);
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php
new file mode 100644
index 0000000000..2fda14a06c
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/Source.php
@@ -0,0 +1,110 @@
+<?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_Writer
+ * @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: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $
+ */
+
+require_once 'Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Feed_Atom_Source
+ extends Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Feed_Source $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Source $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render Atom Feed Metadata (Source element)
+ *
+ * @return Zend_Feed_Writer_Renderer_Feed_Atom
+ */
+ public function render()
+ {
+ if (!$this->_container->getEncoding()) {
+ $this->_container->setEncoding('UTF-8');
+ }
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $root = $this->_dom->createElement('source');
+ $this->setRootElement($root);
+ $this->_dom->appendChild($root);
+ $this->_setLanguage($this->_dom, $root);
+ $this->_setBaseUrl($this->_dom, $root);
+ $this->_setTitle($this->_dom, $root);
+ $this->_setDescription($this->_dom, $root);
+ $this->_setDateCreated($this->_dom, $root);
+ $this->_setDateModified($this->_dom, $root);
+ $this->_setGenerator($this->_dom, $root);
+ $this->_setLink($this->_dom, $root);
+ $this->_setFeedLinks($this->_dom, $root);
+ $this->_setId($this->_dom, $root);
+ $this->_setAuthors($this->_dom, $root);
+ $this->_setCopyright($this->_dom, $root);
+ $this->_setCategories($this->_dom, $root);
+
+ foreach ($this->_extensions as $ext) {
+ $ext->setType($this->getType());
+ $ext->setRootElement($this->getRootElement());
+ $ext->setDomDocument($this->getDomDocument(), $root);
+ $ext->render();
+ }
+ return $this;
+ }
+
+ /**
+ * Set feed generator string
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setGenerator(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getGenerator()) {
+ return;
+ }
+
+ $gdata = $this->getDataContainer()->getGenerator();
+ $generator = $dom->createElement('generator');
+ $root->appendChild($generator);
+ $text = $dom->createTextNode($gdata['name']);
+ $generator->appendChild($text);
+ if (array_key_exists('uri', $gdata)) {
+ $generator->setAttribute('uri', $gdata['uri']);
+ }
+ if (array_key_exists('version', $gdata)) {
+ $generator->setAttribute('version', $gdata['version']);
+ }
+ }
+
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php b/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php
new file mode 100644
index 0000000000..2d8ab5c8a0
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php
@@ -0,0 +1,374 @@
+<?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_Writer
+ * @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: Rss.php 20519 2010-01-22 14:06:24Z padraic $
+ */
+
+/** @see Zend_Feed_Writer_Feed */
+require_once 'Zend/Feed/Writer/Feed.php';
+
+/** @see Zend_Version */
+require_once 'Zend/Version.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererInterface */
+require_once 'Zend/Feed/Writer/Renderer/RendererInterface.php';
+
+/** @see Zend_Feed_Writer_Renderer_Entry_Rss */
+require_once 'Zend/Feed/Writer/Renderer/Entry/Rss.php';
+
+/** @see Zend_Feed_Writer_Renderer_RendererAbstract */
+require_once 'Zend/Feed/Writer/Renderer/RendererAbstract.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_Feed_Rss
+ extends Zend_Feed_Writer_Renderer_RendererAbstract
+ implements Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Constructor
+ *
+ * @param Zend_Feed_Writer_Feed $container
+ * @return void
+ */
+ public function __construct (Zend_Feed_Writer_Feed $container)
+ {
+ parent::__construct($container);
+ }
+
+ /**
+ * Render RSS feed
+ *
+ * @return Zend_Feed_Writer_Renderer_Feed_Rss
+ */
+ public function render()
+ {
+ if (!$this->_container->getEncoding()) {
+ $this->_container->setEncoding('UTF-8');
+ }
+ $this->_dom = new DOMDocument('1.0', $this->_container->getEncoding());
+ $this->_dom->formatOutput = true;
+ $this->_dom->substituteEntities = false;
+ $rss = $this->_dom->createElement('rss');
+ $this->setRootElement($rss);
+ $rss->setAttribute('version', '2.0');
+
+ $channel = $this->_dom->createElement('channel');
+ $rss->appendChild($channel);
+ $this->_dom->appendChild($rss);
+ $this->_setLanguage($this->_dom, $channel);
+ $this->_setBaseUrl($this->_dom, $channel);
+ $this->_setTitle($this->_dom, $channel);
+ $this->_setDescription($this->_dom, $channel);
+ $this->_setDateCreated($this->_dom, $channel);
+ $this->_setDateModified($this->_dom, $channel);
+ $this->_setGenerator($this->_dom, $channel);
+ $this->_setLink($this->_dom, $channel);
+ $this->_setAuthors($this->_dom, $channel);
+ $this->_setCopyright($this->_dom, $channel);
+ $this->_setCategories($this->_dom, $channel);
+
+ foreach ($this->_extensions as $ext) {
+ $ext->setType($this->getType());
+ $ext->setRootElement($this->getRootElement());
+ $ext->setDomDocument($this->getDomDocument(), $channel);
+ $ext->render();
+ }
+
+ foreach ($this->_container as $entry) {
+ if ($this->getDataContainer()->getEncoding()) {
+ $entry->setEncoding($this->getDataContainer()->getEncoding());
+ }
+ if ($entry instanceof Zend_Feed_Writer_Entry) {
+ $renderer = new Zend_Feed_Writer_Renderer_Entry_Rss($entry);
+ } else {
+ continue;
+ }
+ if ($this->_ignoreExceptions === true) {
+ $renderer->ignoreExceptions();
+ }
+ $renderer->setType($this->getType());
+ $renderer->setRootElement($this->_dom->documentElement);
+ $renderer->render();
+ $element = $renderer->getElement();
+ $imported = $this->_dom->importNode($element, true);
+ $channel->appendChild($imported);
+ }
+ return $this;
+ }
+
+ /**
+ * Set feed language
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setLanguage(DOMDocument $dom, DOMElement $root)
+ {
+ $lang = $this->getDataContainer()->getLanguage();
+ if (!$lang) {
+ return;
+ }
+ $language = $dom->createElement('language');
+ $root->appendChild($language);
+ $language->nodeValue = $lang;
+ }
+
+ /**
+ * Set feed title
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setTitle(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getTitle()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'RSS 2.0 feed elements MUST contain exactly one'
+ . ' title element but a title has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+
+ $title = $dom->createElement('title');
+ $root->appendChild($title);
+ $text = $dom->createTextNode($this->getDataContainer()->getTitle());
+ $title->appendChild($text);
+ }
+
+ /**
+ * Set feed description
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDescription(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDescription()) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'RSS 2.0 feed elements MUST contain exactly one'
+ . ' description element but one has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ $subtitle = $dom->createElement('description');
+ $root->appendChild($subtitle);
+ $text = $dom->createTextNode($this->getDataContainer()->getDescription());
+ $subtitle->appendChild($text);
+ }
+
+ /**
+ * Set date feed was last modified
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateModified()) {
+ return;
+ }
+
+ $updated = $dom->createElement('pubDate');
+ $root->appendChild($updated);
+ $text = $dom->createTextNode(
+ $this->getDataContainer()->getDateModified()->get(Zend_Date::RSS)
+ );
+ $updated->appendChild($text);
+ }
+
+ /**
+ * Set feed generator string
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setGenerator(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getGenerator()) {
+ $this->getDataContainer()->setGenerator('Zend_Feed_Writer',
+ Zend_Version::VERSION, 'http://framework.zend.com');
+ }
+
+ $gdata = $this->getDataContainer()->getGenerator();
+ $generator = $dom->createElement('generator');
+ $root->appendChild($generator);
+ $name = $gdata['name'];
+ if (array_key_exists('version', $gdata)) {
+ $name .= ' ' . $gdata['version'];
+ }
+ if (array_key_exists('uri', $gdata)) {
+ $name .= ' (' . $gdata['uri'] . ')';
+ }
+ $text = $dom->createTextNode($name);
+ $generator->appendChild($text);
+ }
+
+ /**
+ * Set link to feed
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setLink(DOMDocument $dom, DOMElement $root)
+ {
+ $value = $this->getDataContainer()->getLink();
+ if(!$value) {
+ require_once 'Zend/Feed/Exception.php';
+ $message = 'RSS 2.0 feed elements MUST contain exactly one'
+ . ' link element but one has not been set';
+ $exception = new Zend_Feed_Exception($message);
+ if (!$this->_ignoreExceptions) {
+ throw $exception;
+ } else {
+ $this->_exceptions[] = $exception;
+ return;
+ }
+ }
+ $link = $dom->createElement('link');
+ $root->appendChild($link);
+ $text = $dom->createTextNode($value);
+ $link->appendChild($text);
+ if (!Zend_Uri::check($value)) {
+ $link->setAttribute('isPermaLink', 'false');
+ }
+ }
+
+ /**
+ * Set feed authors
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setAuthors(DOMDocument $dom, DOMElement $root)
+ {
+ $authors = $this->getDataContainer()->getAuthors();
+ if (!$authors || empty($authors)) {
+ return;
+ }
+ foreach ($authors as $data) {
+ $author = $this->_dom->createElement('author');
+ $name = $data['name'];
+ if (array_key_exists('email', $data)) {
+ $name = $data['email'] . ' (' . $data['name'] . ')';
+ }
+ $text = $dom->createTextNode($name);
+ $author->appendChild($text);
+ $root->appendChild($author);
+ }
+ }
+
+ /**
+ * Set feed copyright
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCopyright(DOMDocument $dom, DOMElement $root)
+ {
+ $copyright = $this->getDataContainer()->getCopyright();
+ if (!$copyright) {
+ return;
+ }
+ $copy = $dom->createElement('copyright');
+ $root->appendChild($copy);
+ $text = $dom->createTextNode($copyright);
+ $copy->appendChild($text);
+ }
+
+ /**
+ * Set date feed was created
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setDateCreated(DOMDocument $dom, DOMElement $root)
+ {
+ if(!$this->getDataContainer()->getDateCreated()) {
+ return;
+ }
+ if(!$this->getDataContainer()->getDateModified()) {
+ $this->getDataContainer()->setDateModified(
+ $this->getDataContainer()->getDateCreated()
+ );
+ }
+ }
+
+ /**
+ * Set base URL to feed links
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setBaseUrl(DOMDocument $dom, DOMElement $root)
+ {
+ $baseUrl = $this->getDataContainer()->getBaseUrl();
+ if (!$baseUrl) {
+ return;
+ }
+ $root->setAttribute('xml:base', $baseUrl);
+ }
+
+ /**
+ * Set feed categories
+ *
+ * @param DOMDocument $dom
+ * @param DOMElement $root
+ * @return void
+ */
+ protected function _setCategories(DOMDocument $dom, DOMElement $root)
+ {
+ $categories = $this->getDataContainer()->getCategories();
+ if (!$categories) {
+ return;
+ }
+ foreach ($categories as $cat) {
+ $category = $dom->createElement('category');
+ if (isset($cat['scheme'])) {
+ $category->setAttribute('domain', $cat['scheme']);
+ }
+ $text = $dom->createTextNode($cat['term']);
+ $category->appendChild($text);
+ $root->appendChild($category);
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php b/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php
new file mode 100644
index 0000000000..0778e435cd
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/RendererAbstract.php
@@ -0,0 +1,250 @@
+<?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_Writer
+ * @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: RendererAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $
+ */
+
+/** @see Zend_Feed_Writer */
+require_once 'Zend/Feed/Writer.php';
+
+/** @see Zend_Version */
+require_once 'Zend/Version.php';
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Renderer_RendererAbstract
+{
+ /**
+ * Extensions
+ * @var array
+ */
+ protected $_extensions = array();
+
+ /**
+ * @var mixed
+ */
+ protected $_container = null;
+
+ /**
+ * @var DOMDocument
+ */
+ protected $_dom = null;
+
+ /**
+ * @var bool
+ */
+ protected $_ignoreExceptions = false;
+
+ /**
+ * @var array
+ */
+ protected $_exceptions = array();
+
+ /**
+ * Encoding of all text values
+ *
+ * @var string
+ */
+ protected $_encoding = 'UTF-8';
+
+ /**
+ * Holds the value "atom" or "rss" depending on the feed type set when
+ * when last exported.
+ *
+ * @var string
+ */
+ protected $_type = null;
+
+ /**
+ * @var DOMElement
+ */
+ protected $_rootElement = null;
+
+ /**
+ * Constructor
+ *
+ * @param mixed $container
+ * @return void
+ */
+ public function __construct($container)
+ {
+ $this->_container = $container;
+ $this->setType($container->getType());
+ $this->_loadExtensions();
+ }
+
+ /**
+ * Save XML to string
+ *
+ * @return string
+ */
+ public function saveXml()
+ {
+ return $this->getDomDocument()->saveXml();
+ }
+
+ /**
+ * Get DOM document
+ *
+ * @return DOMDocument
+ */
+ public function getDomDocument()
+ {
+ return $this->_dom;
+ }
+
+ /**
+ * Get document element from DOM
+ *
+ * @return DOMElement
+ */
+ public function getElement()
+ {
+ return $this->getDomDocument()->documentElement;
+ }
+
+ /**
+ * Get data container of items being rendered
+ *
+ * @return mixed
+ */
+ public function getDataContainer()
+ {
+ return $this->_container;
+ }
+
+ /**
+ * Set feed encoding
+ *
+ * @param string $enc
+ * @return Zend_Feed_Writer_Renderer_RendererAbstract
+ */
+ public function setEncoding($enc)
+ {
+ $this->_encoding = $enc;
+ return $this;
+ }
+
+ /**
+ * Get feed encoding
+ *
+ * @return string
+ */
+ public function getEncoding()
+ {
+ return $this->_encoding;
+ }
+
+ /**
+ * Indicate whether or not to ignore exceptions
+ *
+ * @param bool $bool
+ * @return Zend_Feed_Writer_Renderer_RendererAbstract
+ */
+ public function ignoreExceptions($bool = true)
+ {
+ if (!is_bool($bool)) {
+ require_once 'Zend/Feed/Exception.php';
+ throw new Zend_Feed_Exception('Invalid parameter: $bool. Should be TRUE or FALSE (defaults to TRUE if null)');
+ }
+ $this->_ignoreExceptions = $bool;
+ return $this;
+ }
+
+ /**
+ * Get exception list
+ *
+ * @return array
+ */
+ public function getExceptions()
+ {
+ return $this->_exceptions;
+ }
+
+ /**
+ * Set the current feed type being exported to "rss" or "atom". This allows
+ * other objects to gracefully choose whether to execute or not, depending
+ * on their appropriateness for the current type, e.g. renderers.
+ *
+ * @param string $type
+ */
+ public function setType($type)
+ {
+ $this->_type = $type;
+ }
+
+ /**
+ * Retrieve the current or last feed type exported.
+ *
+ * @return string Value will be "rss" or "atom"
+ */
+ public function getType()
+ {
+ return $this->_type;
+ }
+
+ /**
+ * Sets the absolute root element for the XML feed being generated. This
+ * helps simplify the appending of namespace declarations, but also ensures
+ * namespaces are added to the root element - not scattered across the entire
+ * XML file - may assist namespace unsafe parsers and looks pretty ;).
+ *
+ * @param DOMElement $root
+ */
+ public function setRootElement(DOMElement $root)
+ {
+ $this->_rootElement = $root;
+ }
+
+ /**
+ * Retrieve the absolute root element for the XML feed being generated.
+ *
+ * @return DOMElement
+ */
+ public function getRootElement()
+ {
+ return $this->_rootElement;
+ }
+
+ /**
+ * Load extensions from Zend_Feed_Writer
+ *
+ * @return void
+ */
+ protected function _loadExtensions()
+ {
+ Zend_Feed_Writer::registerCoreExtensions();
+ $all = Zend_Feed_Writer::getExtensions();
+ if (stripos(get_class($this), 'entry')) {
+ $exts = $all['entryRenderer'];
+ } else {
+ $exts = $all['feedRenderer'];
+ }
+ foreach ($exts as $extension) {
+ $className = Zend_Feed_Writer::getPluginLoader()->getClassName($extension);
+ $this->_extensions[$extension] = new $className(
+ $this->getDataContainer()
+ );
+ $this->_extensions[$extension]->setEncoding($this->getEncoding());
+ }
+ }
+}
diff --git a/libs/Zend/Feed/Writer/Renderer/RendererInterface.php b/libs/Zend/Feed/Writer/Renderer/RendererInterface.php
new file mode 100644
index 0000000000..89b4294416
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Renderer/RendererInterface.php
@@ -0,0 +1,111 @@
+<?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_Writer
+ * @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: RendererInterface.php 20096 2010-01-06 02:05:09Z bkarwin $
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+interface Zend_Feed_Writer_Renderer_RendererInterface
+{
+ /**
+ * Render feed/entry
+ *
+ * @return void
+ */
+ public function render();
+
+ /**
+ * Save feed and/or entry to XML and return string
+ *
+ * @return string
+ */
+ public function saveXml();
+
+ /**
+ * Get DOM document
+ *
+ * @return DOMDocument
+ */
+ public function getDomDocument();
+
+ /**
+ * Get document element from DOM
+ *
+ * @return DOMElement
+ */
+ public function getElement();
+
+ /**
+ * Get data container containing feed items
+ *
+ * @return mixed
+ */
+ public function getDataContainer();
+
+ /**
+ * Should exceptions be ignored?
+ *
+ * @return mixed
+ */
+ public function ignoreExceptions();
+
+ /**
+ * Get list of thrown exceptions
+ *
+ * @return array
+ */
+ public function getExceptions();
+
+ /**
+ * Set the current feed type being exported to "rss" or "atom". This allows
+ * other objects to gracefully choose whether to execute or not, depending
+ * on their appropriateness for the current type, e.g. renderers.
+ *
+ * @param string $type
+ */
+ public function setType($type);
+
+ /**
+ * Retrieve the current or last feed type exported.
+ *
+ * @return string Value will be "rss" or "atom"
+ */
+ public function getType();
+
+ /**
+ * Sets the absolute root element for the XML feed being generated. This
+ * helps simplify the appending of namespace declarations, but also ensures
+ * namespaces are added to the root element - not scattered across the entire
+ * XML file - may assist namespace unsafe parsers and looks pretty ;).
+ *
+ * @param DOMElement $root
+ */
+ public function setRootElement(DOMElement $root);
+
+ /**
+ * Retrieve the absolute root element for the XML feed being generated.
+ *
+ * @return DOMElement
+ */
+ public function getRootElement();
+}
diff --git a/libs/Zend/Feed/Writer/Source.php b/libs/Zend/Feed/Writer/Source.php
new file mode 100644
index 0000000000..37fcd4833c
--- /dev/null
+++ b/libs/Zend/Feed/Writer/Source.php
@@ -0,0 +1,33 @@
+<?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_Writer
+ * @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 $
+ */
+
+require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
+
+ /**
+ * @category Zend
+ * @package Zend_Feed_Writer
+ * @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_Writer_Source extends Zend_Feed_Writer_Feed_FeedAbstract
+{
+
+}