import v1.0.0-RC4 | 2009-05-20
This commit is contained in:
285
libs/Zend/Feed/Builder/Entry.php
Normal file
285
libs/Zend/Feed/Builder/Entry.php
Normal file
@ -0,0 +1,285 @@
|
||||
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Entry.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An entry of a custom build feed
|
||||
*
|
||||
* Classes implementing the Zend_Feed_Builder_Interface interface
|
||||
* uses this class to describe an entry of a feed
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Builder_Entry extends ArrayObject
|
||||
{
|
||||
/**
|
||||
* Create a new builder entry
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $link
|
||||
* @param string $description short version of the entry, no html
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($title, $link, $description)
|
||||
{
|
||||
$this->offsetSet('title', $title);
|
||||
$this->offsetSet('link', $link);
|
||||
$this->offsetSet('description', $description);
|
||||
$this->setLastUpdate(time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Read only properties accessor
|
||||
*
|
||||
* @param string $name property to read
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!$this->offsetExists($name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $this->offsetGet($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write properties accessor
|
||||
*
|
||||
* @param string $name name of the property to set
|
||||
* @param mixed $value value to set
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->offsetSet($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->offsetExists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
if ($this->offsetExists($key)) {
|
||||
$this->offsetUnset($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id/guid of the entry
|
||||
*
|
||||
* @param string $id
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->offsetSet('guid', $id);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the full html content of the entry
|
||||
*
|
||||
* @param string $content
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->offsetSet('content', $content);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp of the update date
|
||||
*
|
||||
* @param int $lastUpdate
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setLastUpdate($lastUpdate)
|
||||
{
|
||||
$this->offsetSet('lastUpdate', $lastUpdate);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url of the commented page associated to the entry
|
||||
*
|
||||
* @param string $comments
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setCommentsUrl($comments)
|
||||
{
|
||||
$this->offsetSet('comments', $comments);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the url of the comments feed link
|
||||
*
|
||||
* @param string $commentRss
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setCommentsRssUrl($commentRss)
|
||||
{
|
||||
$this->offsetSet('commentRss', $commentRss);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a reference to the original source
|
||||
*
|
||||
* @param string $title
|
||||
* @param string $url
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setSource($title, $url)
|
||||
{
|
||||
$this->offsetSet('source', array('title' => $title,
|
||||
'url' => $url));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the categories of the entry
|
||||
* Format of the array:
|
||||
* <code>
|
||||
* array(
|
||||
* array(
|
||||
* 'term' => 'first category label',
|
||||
* 'scheme' => 'url that identifies a categorization scheme' // optional
|
||||
* ),
|
||||
* // second category and so one
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param array $categories
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function setCategories(array $categories)
|
||||
{
|
||||
foreach ($categories as $category) {
|
||||
$this->addCategory($category);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a category to the entry
|
||||
*
|
||||
* @param array $category see Zend_Feed_Builder_Entry::setCategories() for format
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function addCategory(array $category)
|
||||
{
|
||||
if (empty($category['term'])) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to define the name of the category");
|
||||
}
|
||||
|
||||
if (!$this->offsetExists('category')) {
|
||||
$categories = array($category);
|
||||
} else {
|
||||
$categories = $this->offsetGet('category');
|
||||
$categories[] = $category;
|
||||
}
|
||||
$this->offsetSet('category', $categories);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enclosures of the entry
|
||||
* Format of the array:
|
||||
* <code>
|
||||
* array(
|
||||
* array(
|
||||
* 'url' => 'url of the linked enclosure',
|
||||
* 'type' => 'mime type of the enclosure' // optional
|
||||
* 'length' => 'length of the linked content in octets' // optional
|
||||
* ),
|
||||
* // second enclosure and so one
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param array $enclosures
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setEnclosures(array $enclosures)
|
||||
{
|
||||
foreach ($enclosures as $enclosure) {
|
||||
if (empty($enclosure['url'])) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to supply an url for your enclosure");
|
||||
}
|
||||
$type = isset($enclosure['type']) ? $enclosure['type'] : '';
|
||||
$length = isset($enclosure['length']) ? $enclosure['length'] : '';
|
||||
$this->addEnclosure($enclosure['url'], $type, $length);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an enclosure to the entry
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $type
|
||||
* @param string $length
|
||||
* @return Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function addEnclosure($url, $type = '', $length = '')
|
||||
{
|
||||
if (!$this->offsetExists('enclosure')) {
|
||||
$enclosure = array();
|
||||
} else {
|
||||
$enclosure = $this->offsetGet('enclosure');
|
||||
}
|
||||
$enclosure[] = array('url' => $url,
|
||||
'type' => $type,
|
||||
'length' => $length);
|
||||
$this->offsetSet('enclosure', $enclosure);
|
||||
return $this;
|
||||
}
|
||||
}
|
40
libs/Zend/Feed/Builder/Exception.php
Normal file
40
libs/Zend/Feed/Builder/Exception.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Exception.php';
|
||||
|
||||
|
||||
/**
|
||||
* Zend_Feed_Builder exception class
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Builder_Exception extends Zend_Feed_Exception
|
||||
{
|
||||
}
|
420
libs/Zend/Feed/Builder/Header.php
Normal file
420
libs/Zend/Feed/Builder/Header.php
Normal file
@ -0,0 +1,420 @@
|
||||
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Header.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @see Zend_Loader
|
||||
*/
|
||||
require_once 'Zend/Loader.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Header/Itunes.php';
|
||||
|
||||
/**
|
||||
* @see Zend_Uri
|
||||
*/
|
||||
require_once 'Zend/Uri.php';
|
||||
|
||||
|
||||
/**
|
||||
* Header of a custom build feed
|
||||
*
|
||||
* Classes implementing the Zend_Feed_Builder_Interface interface
|
||||
* uses this class to describe the header of a feed
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Builder_Header extends ArrayObject
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $title title of the feed
|
||||
* @param string $link canonical url of the feed
|
||||
* @param string $charset charset of the textual data
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($title, $link, $charset = 'utf-8')
|
||||
{
|
||||
$this->offsetSet('title', $title);
|
||||
$this->offsetSet('link', $link);
|
||||
$this->offsetSet('charset', $charset);
|
||||
$this->setLastUpdate(time())
|
||||
->setGenerator('Zend_Feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Read only properties accessor
|
||||
*
|
||||
* @param string $name property to read
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!$this->offsetExists($name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $this->offsetGet($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write properties accessor
|
||||
*
|
||||
* @param string $name name of the property to set
|
||||
* @param mixed $value value to set
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->offsetSet($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->offsetExists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
if ($this->offsetExists($key)) {
|
||||
$this->offsetUnset($key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp of the update date
|
||||
*
|
||||
* @param int $lastUpdate
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setLastUpdate($lastUpdate)
|
||||
{
|
||||
$this->offsetSet('lastUpdate', $lastUpdate);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp of the publication date
|
||||
*
|
||||
* @param int $published
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setPublishedDate($published)
|
||||
{
|
||||
$this->offsetSet('published', $published);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Short description of the feed
|
||||
*
|
||||
* @param string $description
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->offsetSet('description', $description);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author of the feed
|
||||
*
|
||||
* @param string $author
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->offsetSet('author', $author);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author's email
|
||||
*
|
||||
* @param string $email
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
Zend_Loader::loadClass('Zend_Validate_EmailAddress');
|
||||
$validate = new Zend_Validate_EmailAddress();
|
||||
if (!$validate->isValid($email)) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the email property");
|
||||
}
|
||||
$this->offsetSet('email', $email);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the copyright notice
|
||||
*
|
||||
* @param string $copyright
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setCopyright($copyright)
|
||||
{
|
||||
$this->offsetSet('copyright', $copyright);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image of the feed
|
||||
*
|
||||
* @param string $image
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setImage($image)
|
||||
{
|
||||
$this->offsetSet('image', $image);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the generator of the feed
|
||||
*
|
||||
* @param string $generator
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setGenerator($generator)
|
||||
{
|
||||
$this->offsetSet('generator', $generator);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the language of the feed
|
||||
*
|
||||
* @param string $language
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->offsetSet('language', $language);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Email address for person responsible for technical issues
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param string $webmaster
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setWebmaster($webmaster)
|
||||
{
|
||||
Zend_Loader::loadClass('Zend_Validate_EmailAddress');
|
||||
$validate = new Zend_Validate_EmailAddress();
|
||||
if (!$validate->isValid($webmaster)) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the webmaster property");
|
||||
}
|
||||
$this->offsetSet('webmaster', $webmaster);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long in minutes a feed can be cached before refreshing
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param int $ttl
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setTtl($ttl)
|
||||
{
|
||||
Zend_Loader::loadClass('Zend_Validate_Int');
|
||||
$validate = new Zend_Validate_Int();
|
||||
if (!$validate->isValid($ttl)) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property");
|
||||
}
|
||||
$this->offsetSet('ttl', $ttl);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* PICS rating for the feed
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param string $rating
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setRating($rating)
|
||||
{
|
||||
$this->offsetSet('rating', $rating);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloud to be notified of updates of the feed
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param string|Zend_Uri_Http $uri
|
||||
* @param string $procedure procedure to call, e.g. myCloud.rssPleaseNotify
|
||||
* @param string $protocol protocol to use, e.g. soap or xml-rpc
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setCloud($uri, $procedure, $protocol)
|
||||
{
|
||||
if (is_string($uri) && Zend_Uri_Http::check($uri)) {
|
||||
$uri = Zend_Uri::factory($uri);
|
||||
}
|
||||
if (!$uri instanceof Zend_Uri_Http) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception('Passed parameter is not a valid HTTP URI');
|
||||
}
|
||||
if (!$uri->getPort()) {
|
||||
$uri->setPort(80);
|
||||
}
|
||||
$this->offsetSet('cloud', array('uri' => $uri,
|
||||
'procedure' => $procedure,
|
||||
'protocol' => $protocol));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A text input box that can be displayed with the feed
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param string $title the label of the Submit button in the text input area
|
||||
* @param string $description explains the text input area
|
||||
* @param string $name the name of the text object in the text input area
|
||||
* @param string $link the URL of the CGI script that processes text input requests
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setTextInput($title, $description, $name, $link)
|
||||
{
|
||||
$this->offsetSet('textInput', array('title' => $title,
|
||||
'description' => $description,
|
||||
'name' => $name,
|
||||
'link' => $link));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hint telling aggregators which hours they can skip
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param array $hours list of hours in 24 format
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setSkipHours(array $hours)
|
||||
{
|
||||
if (count($hours) > 24) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you can not have more than 24 rows in the skipHours property");
|
||||
}
|
||||
foreach ($hours as $hour) {
|
||||
if ($hour < 0 || $hour > 23) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("$hour has te be between 0 and 23");
|
||||
}
|
||||
}
|
||||
$this->offsetSet('skipHours', $hours);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hint telling aggregators which days they can skip
|
||||
* Ignored if atom is used
|
||||
*
|
||||
* @param array $days list of days to skip, e.g. Monday
|
||||
* @return Zend_Feed_Builder_Header
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setSkipDays(array $days)
|
||||
{
|
||||
if (count($days) > 7) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you can not have more than 7 days in the skipDays property");
|
||||
}
|
||||
$valid = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
|
||||
foreach ($days as $day) {
|
||||
if (!in_array(strtolower($day), $valid)) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("$day is not a valid day");
|
||||
}
|
||||
}
|
||||
$this->offsetSet('skipDays', $days);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the iTunes rss extension
|
||||
*
|
||||
* @param Zend_Feed_Builder_Header_Itunes $itunes
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function setITunes(Zend_Feed_Builder_Header_Itunes $itunes)
|
||||
{
|
||||
$this->offsetSet('itunes', $itunes);
|
||||
return $this;
|
||||
}
|
||||
}
|
285
libs/Zend/Feed/Builder/Header/Itunes.php
Normal file
285
libs/Zend/Feed/Builder/Header/Itunes.php
Normal file
@ -0,0 +1,285 @@
|
||||
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Itunes.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* ITunes rss extension
|
||||
*
|
||||
* Classes used to describe the itunes channel extension
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Feed_Builder_Header_Itunes extends ArrayObject
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $categories Categories columns and in iTunes Music Store Browse
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $categories)
|
||||
{
|
||||
$this->setCategories($categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the categories column and in iTunes Music Store Browse
|
||||
* $categories must conform to the following format:
|
||||
* <code>
|
||||
* array(array('main' => 'main category',
|
||||
* 'sub' => 'sub category' // optionnal
|
||||
* ),
|
||||
* // up to 3 rows
|
||||
* )
|
||||
* </code>
|
||||
*
|
||||
* @param array $categories
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setCategories(array $categories)
|
||||
{
|
||||
$nb = count($categories);
|
||||
if (0 === $nb) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set at least one itunes category");
|
||||
}
|
||||
if ($nb > 3) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set at most three itunes categories");
|
||||
}
|
||||
foreach ($categories as $i => $category) {
|
||||
if (empty($category['main'])) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set the main category (category #$i)");
|
||||
}
|
||||
}
|
||||
$this->offsetSet('category', $categories);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the artist value, default to the feed's author value
|
||||
*
|
||||
* @param string $author
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->offsetSet('author', $author);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the owner of the postcast
|
||||
*
|
||||
* @param string $name default to the feed's author value
|
||||
* @param string $email default to the feed's email value
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setOwner($name = '', $email = '')
|
||||
{
|
||||
if (!empty($email)) {
|
||||
Zend_Loader::loadClass('Zend_Validate_EmailAddress');
|
||||
$validate = new Zend_Validate_EmailAddress();
|
||||
if (!$validate->isValid($email)) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the itunes owner's email property");
|
||||
}
|
||||
}
|
||||
$this->offsetSet('owner', array('name' => $name, 'email' => $email));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the album/podcast art picture
|
||||
* Default to the feed's image value
|
||||
*
|
||||
* @param string $image
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setImage($image)
|
||||
{
|
||||
$this->offsetSet('image', $image);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the short description of the podcast
|
||||
* Default to the feed's description
|
||||
*
|
||||
* @param string $subtitle
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setSubtitle($subtitle)
|
||||
{
|
||||
$this->offsetSet('subtitle', $subtitle);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the longer description of the podcast
|
||||
* Default to the feed's description
|
||||
*
|
||||
* @param string $summary
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setSummary($summary)
|
||||
{
|
||||
$this->offsetSet('summary', $summary);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent a feed from appearing
|
||||
*
|
||||
* @param string $block can be 'yes' or 'no'
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setBlock($block)
|
||||
{
|
||||
$block = strtolower($block);
|
||||
if (!in_array($block, array('yes', 'no'))) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set yes or no to the itunes block property");
|
||||
}
|
||||
$this->offsetSet('block', $block);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration of the parental advisory graphic
|
||||
*
|
||||
* @param string $explicit can be 'yes', 'no' or 'clean'
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
* @throws Zend_Feed_Builder_Exception
|
||||
*/
|
||||
public function setExplicit($explicit)
|
||||
{
|
||||
$explicit = strtolower($explicit);
|
||||
if (!in_array($explicit, array('yes', 'no', 'clean'))) {
|
||||
/**
|
||||
* @see Zend_Feed_Builder_Exception
|
||||
*/
|
||||
require_once 'Zend/Feed/Builder/Exception.php';
|
||||
throw new Zend_Feed_Builder_Exception("you have to set yes, no or clean to the itunes explicit property");
|
||||
}
|
||||
$this->offsetSet('explicit', $explicit);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a comma separated list of 12 keywords maximum
|
||||
*
|
||||
* @param string $keywords
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setKeywords($keywords)
|
||||
{
|
||||
$this->offsetSet('keywords', $keywords);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new feed URL location
|
||||
*
|
||||
* @param string $url
|
||||
* @return Zend_Feed_Builder_Header_Itunes
|
||||
*/
|
||||
public function setNewFeedUrl($url)
|
||||
{
|
||||
$this->offsetSet('new_feed_url', $url);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read only properties accessor
|
||||
*
|
||||
* @param string $name property to read
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if (!$this->offsetExists($name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return $this->offsetGet($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write properties accessor
|
||||
*
|
||||
* @param string $name name of the property to set
|
||||
* @param mixed $value value to set
|
||||
* @return void
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->offsetSet($name, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
*/
|
||||
public function __isset($key)
|
||||
{
|
||||
return $this->offsetExists($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset accessor
|
||||
*
|
||||
* @param string $key
|
||||
* @return void
|
||||
*/
|
||||
public function __unset($key)
|
||||
{
|
||||
if ($this->offsetExists($key)) {
|
||||
$this->offsetUnset($key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
52
libs/Zend/Feed/Builder/Interface.php
Normal file
52
libs/Zend/Feed/Builder/Interface.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?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-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Interface.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Input feed data interface
|
||||
*
|
||||
* Classes implementing this interface can be passe to Zend_Feed::importBuilder
|
||||
* as an input data source for the Zend_Feed construction
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Feed
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
interface Zend_Feed_Builder_Interface
|
||||
{
|
||||
/**
|
||||
* Returns an instance of Zend_Feed_Builder_Header
|
||||
* describing the header of the feed
|
||||
*
|
||||
* @return Zend_Feed_Builder_Header
|
||||
*/
|
||||
public function getHeader();
|
||||
|
||||
/**
|
||||
* Returns an array of Zend_Feed_Builder_Entry instances
|
||||
* describing the entries of the feed
|
||||
*
|
||||
* @return array of Zend_Feed_Builder_Entry
|
||||
*/
|
||||
public function getEntries();
|
||||
}
|
Reference in New Issue
Block a user