|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
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. |
|
14 * |
|
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: Deleted.php 22662 2010-07-24 17:37:36Z mabe $ |
|
20 */ |
|
21 |
|
22 require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; |
|
23 |
|
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 |
|
29 */ |
|
30 class Zend_Feed_Writer_Deleted |
|
31 { |
|
32 |
|
33 /** |
|
34 * Internal array containing all data associated with this entry or item. |
|
35 * |
|
36 * @var array |
|
37 */ |
|
38 protected $_data = array(); |
|
39 |
|
40 /** |
|
41 * Holds the value "atom" or "rss" depending on the feed type set when |
|
42 * when last exported. |
|
43 * |
|
44 * @var string |
|
45 */ |
|
46 protected $_type = null; |
|
47 |
|
48 /** |
|
49 * Set the feed character encoding |
|
50 * |
|
51 * @return string|null |
|
52 */ |
|
53 public function setEncoding($encoding) |
|
54 { |
|
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'); |
|
58 } |
|
59 $this->_data['encoding'] = $encoding; |
|
60 } |
|
61 |
|
62 /** |
|
63 * Get the feed character encoding |
|
64 * |
|
65 * @return string|null |
|
66 */ |
|
67 public function getEncoding() |
|
68 { |
|
69 if (!array_key_exists('encoding', $this->_data)) { |
|
70 return 'UTF-8'; |
|
71 } |
|
72 return $this->_data['encoding']; |
|
73 } |
|
74 |
|
75 /** |
|
76 * Unset a specific data point |
|
77 * |
|
78 * @param string $name |
|
79 */ |
|
80 public function remove($name) |
|
81 { |
|
82 if (isset($this->_data[$name])) { |
|
83 unset($this->_data[$name]); |
|
84 } |
|
85 } |
|
86 |
|
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. |
|
91 * |
|
92 * @param string $type |
|
93 */ |
|
94 public function setType($type) |
|
95 { |
|
96 $this->_type = $type; |
|
97 } |
|
98 |
|
99 /** |
|
100 * Retrieve the current or last feed type exported. |
|
101 * |
|
102 * @return string Value will be "rss" or "atom" |
|
103 */ |
|
104 public function getType() |
|
105 { |
|
106 return $this->_type; |
|
107 } |
|
108 |
|
109 public function setReference($reference) |
|
110 { |
|
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'); |
|
114 } |
|
115 $this->_data['reference'] = $reference; |
|
116 } |
|
117 |
|
118 public function getReference() |
|
119 { |
|
120 if (!array_key_exists('reference', $this->_data)) { |
|
121 return null; |
|
122 } |
|
123 return $this->_data['reference']; |
|
124 } |
|
125 |
|
126 public function setWhen($date = null) |
|
127 { |
|
128 $zdate = null; |
|
129 if ($date === null) { |
|
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'); |
|
138 } |
|
139 $this->_data['when'] = $zdate; |
|
140 } |
|
141 |
|
142 public function getWhen() |
|
143 { |
|
144 if (!array_key_exists('when', $this->_data)) { |
|
145 return null; |
|
146 } |
|
147 return $this->_data['when']; |
|
148 } |
|
149 |
|
150 public function setBy(array $by) |
|
151 { |
|
152 $author = array(); |
|
153 if (!array_key_exists('name', $by) |
|
154 || empty($by['name']) |
|
155 || !is_string($by['name']) |
|
156 ) { |
|
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'); |
|
159 } |
|
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'); |
|
165 } |
|
166 $author['email'] = $by['email']; |
|
167 } |
|
168 if (isset($by['uri'])) { |
|
169 if (empty($by['uri']) |
|
170 || !is_string($by['uri']) |
|
171 || !Zend_Uri::check($by['uri']) |
|
172 ) { |
|
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'); |
|
175 } |
|
176 $author['uri'] = $by['uri']; |
|
177 } |
|
178 $this->_data['by'] = $author; |
|
179 } |
|
180 |
|
181 public function getBy() |
|
182 { |
|
183 if (!array_key_exists('by', $this->_data)) { |
|
184 return null; |
|
185 } |
|
186 return $this->_data['by']; |
|
187 } |
|
188 |
|
189 public function setComment($comment) |
|
190 { |
|
191 $this->_data['comment'] = $comment; |
|
192 } |
|
193 |
|
194 public function getComment() |
|
195 { |
|
196 if (!array_key_exists('comment', $this->_data)) { |
|
197 return null; |
|
198 } |
|
199 return $this->_data['comment']; |
|
200 } |
|
201 |
|
202 } |