[ZF-10089] Zend_Log
[zend/radio.git] / library / Zend / Feed / Writer / Deleted.php
blobce5b00f8246ec50a6d8d158cf142e2cad40d7285
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Feed_Writer
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
18 * @license http://framework.zend.com/license/new-bsd New BSD License
19 * @version $Id$
22 require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
24 /**
25 * @category Zend
26 * @package Zend_Feed_Writer
27 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
28 * @license http://framework.zend.com/license/new-bsd New BSD License
30 class Zend_Feed_Writer_Deleted
33 /**
34 * Internal array containing all data associated with this entry or item.
36 * @var array
38 protected $_data = array();
40 /**
41 * Holds the value "atom" or "rss" depending on the feed type set when
42 * when last exported.
44 * @var string
46 protected $_type = null;
48 /**
49 * Set the feed character encoding
51 * @return string|null
53 public function setEncoding($encoding)
55 if (empty($encoding) || !is_string($encoding)) {
56 require_once 'Zend/Feed/Exception.php';
57 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
59 $this->_data['encoding'] = $encoding;
62 /**
63 * Get the feed character encoding
65 * @return string|null
67 public function getEncoding()
69 if (!array_key_exists('encoding', $this->_data)) {
70 return 'UTF-8';
72 return $this->_data['encoding'];
75 /**
76 * Unset a specific data point
78 * @param string $name
80 public function remove($name)
82 if (isset($this->_data[$name])) {
83 unset($this->_data[$name]);
87 /**
88 * Set the current feed type being exported to "rss" or "atom". This allows
89 * other objects to gracefully choose whether to execute or not, depending
90 * on their appropriateness for the current type, e.g. renderers.
92 * @param string $type
94 public function setType($type)
96 $this->_type = $type;
99 /**
100 * Retrieve the current or last feed type exported.
102 * @return string Value will be "rss" or "atom"
104 public function getType()
106 return $this->_type;
109 public function setReference($reference)
111 if (empty($reference) || !is_string($reference)) {
112 require_once 'Zend/Feed/Exception.php';
113 throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string');
115 $this->_data['reference'] = $reference;
118 public function getReference()
120 if (!array_key_exists('reference', $this->_data)) {
121 return null;
123 return $this->_data['reference'];
126 public function setWhen($date = null)
128 $zdate = null;
129 if (is_null($date)) {
130 $zdate = new Zend_Date;
131 } elseif (ctype_digit($date) && strlen($date) == 10) {
132 $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
133 } elseif ($date instanceof Zend_Date) {
134 $zdate = $date;
135 } else {
136 require_once 'Zend/Feed/Exception.php';
137 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
139 $this->_data['when'] = $zdate;
142 public function getWhen()
144 if (!array_key_exists('when', $this->_data)) {
145 return null;
147 return $this->_data['when'];
150 public function setBy(array $by)
152 $author = array();
153 if (!array_key_exists('name', $by)
154 || empty($by['name'])
155 || !is_string($by['name'])
157 require_once 'Zend/Feed/Exception.php';
158 throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
160 $author['name'] = $by['name'];
161 if (isset($by['email'])) {
162 if (empty($by['email']) || !is_string($by['email'])) {
163 require_once 'Zend/Feed/Exception.php';
164 throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string');
166 $author['email'] = $by['email'];
168 if (isset($by['uri'])) {
169 if (empty($by['uri'])
170 || !is_string($by['uri'])
171 || !Zend_Uri::check($by['uri'])
173 require_once 'Zend/Feed/Exception.php';
174 throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
176 $author['uri'] = $by['uri'];
178 $this->_data['by'] = $author;
181 public function getBy()
183 if (!array_key_exists('by', $this->_data)) {
184 return null;
186 return $this->_data['by'];
189 public function setComment($comment)
191 $this->_data['comment'] = $comment;
194 public function getComment()
196 if (!array_key_exists('comment', $this->_data)) {
197 return null;
199 return $this->_data['comment'];