12 * obtain it through the world-wide-web, please send an email |
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. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Feed_Writer |
16 * @package Zend_Feed_Writer |
17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
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 $ |
19 * @version $Id: Deleted.php 25160 2012-12-18 15:17:16Z matthew $ |
20 */ |
20 */ |
21 |
21 |
22 require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; |
22 require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; |
23 |
23 |
24 /** |
24 /** |
25 * @category Zend |
25 * @category Zend |
26 * @package Zend_Feed_Writer |
26 * @package Zend_Feed_Writer |
27 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
27 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
29 */ |
29 */ |
30 class Zend_Feed_Writer_Deleted |
30 class Zend_Feed_Writer_Deleted |
31 { |
31 { |
32 |
32 |
93 */ |
93 */ |
94 public function setType($type) |
94 public function setType($type) |
95 { |
95 { |
96 $this->_type = $type; |
96 $this->_type = $type; |
97 } |
97 } |
98 |
98 |
99 /** |
99 /** |
100 * Retrieve the current or last feed type exported. |
100 * Retrieve the current or last feed type exported. |
101 * |
101 * |
102 * @return string Value will be "rss" or "atom" |
102 * @return string Value will be "rss" or "atom" |
103 */ |
103 */ |
104 public function getType() |
104 public function getType() |
105 { |
105 { |
106 return $this->_type; |
106 return $this->_type; |
107 } |
107 } |
108 |
108 |
109 public function setReference($reference) |
109 public function setReference($reference) |
110 { |
110 { |
111 if (empty($reference) || !is_string($reference)) { |
111 if (empty($reference) || !is_string($reference)) { |
112 require_once 'Zend/Feed/Exception.php'; |
112 require_once 'Zend/Feed/Exception.php'; |
113 throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string'); |
113 throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string'); |
114 } |
114 } |
115 $this->_data['reference'] = $reference; |
115 $this->_data['reference'] = $reference; |
116 } |
116 } |
117 |
117 |
118 public function getReference() |
118 public function getReference() |
119 { |
119 { |
120 if (!array_key_exists('reference', $this->_data)) { |
120 if (!array_key_exists('reference', $this->_data)) { |
121 return null; |
121 return null; |
122 } |
122 } |
123 return $this->_data['reference']; |
123 return $this->_data['reference']; |
124 } |
124 } |
125 |
125 |
126 public function setWhen($date = null) |
126 public function setWhen($date = null) |
127 { |
127 { |
128 $zdate = null; |
128 $zdate = null; |
129 if ($date === null) { |
129 if ($date === null) { |
130 $zdate = new Zend_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) { |
131 } elseif ($date instanceof Zend_Date) { |
134 $zdate = $date; |
132 $zdate = $date; |
|
133 } elseif (ctype_digit((string)$date)) { |
|
134 $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); |
135 } else { |
135 } else { |
136 require_once 'Zend/Feed/Exception.php'; |
136 require_once 'Zend/Feed/Exception.php'; |
137 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); |
137 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); |
138 } |
138 } |
139 $this->_data['when'] = $zdate; |
139 $this->_data['when'] = $zdate; |
140 } |
140 } |
141 |
141 |
142 public function getWhen() |
142 public function getWhen() |
143 { |
143 { |
144 if (!array_key_exists('when', $this->_data)) { |
144 if (!array_key_exists('when', $this->_data)) { |
145 return null; |
145 return null; |
146 } |
146 } |
147 return $this->_data['when']; |
147 return $this->_data['when']; |
148 } |
148 } |
149 |
149 |
150 public function setBy(array $by) |
150 public function setBy(array $by) |
151 { |
151 { |
152 $author = array(); |
152 $author = array(); |
153 if (!array_key_exists('name', $by) |
153 if (!array_key_exists('name', $by) |
154 || empty($by['name']) |
154 || empty($by['name']) |
155 || !is_string($by['name']) |
155 || !is_string($by['name']) |
156 ) { |
156 ) { |
157 require_once 'Zend/Feed/Exception.php'; |
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'); |
158 throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); |
159 } |
159 } |
164 throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); |
164 throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); |
165 } |
165 } |
166 $author['email'] = $by['email']; |
166 $author['email'] = $by['email']; |
167 } |
167 } |
168 if (isset($by['uri'])) { |
168 if (isset($by['uri'])) { |
169 if (empty($by['uri']) |
169 if (empty($by['uri']) |
170 || !is_string($by['uri']) |
170 || !is_string($by['uri']) |
171 || !Zend_Uri::check($by['uri']) |
171 || !Zend_Uri::check($by['uri']) |
172 ) { |
172 ) { |
173 require_once 'Zend/Feed/Exception.php'; |
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'); |
174 throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); |
175 } |
175 } |
176 $author['uri'] = $by['uri']; |
176 $author['uri'] = $by['uri']; |
177 } |
177 } |
178 $this->_data['by'] = $author; |
178 $this->_data['by'] = $author; |
179 } |
179 } |
180 |
180 |
181 public function getBy() |
181 public function getBy() |
182 { |
182 { |
183 if (!array_key_exists('by', $this->_data)) { |
183 if (!array_key_exists('by', $this->_data)) { |
184 return null; |
184 return null; |
185 } |
185 } |
186 return $this->_data['by']; |
186 return $this->_data['by']; |
187 } |
187 } |
188 |
188 |
189 public function setComment($comment) |
189 public function setComment($comment) |
190 { |
190 { |
191 $this->_data['comment'] = $comment; |
191 $this->_data['comment'] = $comment; |
192 } |
192 } |
193 |
193 |
194 public function getComment() |
194 public function getComment() |
195 { |
195 { |
196 if (!array_key_exists('comment', $this->_data)) { |
196 if (!array_key_exists('comment', $this->_data)) { |
197 return null; |
197 return null; |
198 } |
198 } |