|
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: Entry.php 22662 2010-07-24 17:37:36Z mabe $ |
|
20 */ |
|
21 |
|
22 /** |
|
23 * @see Zend_Date |
|
24 */ |
|
25 require_once 'Zend/Date.php'; |
|
26 |
|
27 /** |
|
28 * @see Zend_Date |
|
29 */ |
|
30 require_once 'Zend/Uri.php'; |
|
31 |
|
32 require_once 'Zend/Feed/Writer/Source.php'; |
|
33 |
|
34 /** |
|
35 * @category Zend |
|
36 * @package Zend_Feed_Writer |
|
37 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
38 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
39 */ |
|
40 class Zend_Feed_Writer_Entry |
|
41 { |
|
42 |
|
43 /** |
|
44 * Internal array containing all data associated with this entry or item. |
|
45 * |
|
46 * @var array |
|
47 */ |
|
48 protected $_data = array(); |
|
49 |
|
50 /** |
|
51 * Registered extensions |
|
52 * |
|
53 * @var array |
|
54 */ |
|
55 protected $_extensions = array(); |
|
56 |
|
57 /** |
|
58 * Holds the value "atom" or "rss" depending on the feed type set when |
|
59 * when last exported. |
|
60 * |
|
61 * @var string |
|
62 */ |
|
63 protected $_type = null; |
|
64 |
|
65 /** |
|
66 * Constructor: Primarily triggers the registration of core extensions and |
|
67 * loads those appropriate to this data container. |
|
68 * |
|
69 * @return void |
|
70 */ |
|
71 public function __construct() |
|
72 { |
|
73 Zend_Feed_Writer::registerCoreExtensions(); |
|
74 $this->_loadExtensions(); |
|
75 } |
|
76 |
|
77 /** |
|
78 * Set a single author |
|
79 * |
|
80 * @param int $index |
|
81 * @return string|null |
|
82 */ |
|
83 public function addAuthor($name, $email = null, $uri = null) |
|
84 { |
|
85 $author = array(); |
|
86 if (is_array($name)) { |
|
87 if (!array_key_exists('name', $name) |
|
88 || empty($name['name']) |
|
89 || !is_string($name['name']) |
|
90 ) { |
|
91 require_once 'Zend/Feed/Exception.php'; |
|
92 throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); |
|
93 } |
|
94 $author['name'] = $name['name']; |
|
95 if (isset($name['email'])) { |
|
96 if (empty($name['email']) || !is_string($name['email'])) { |
|
97 require_once 'Zend/Feed/Exception.php'; |
|
98 throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); |
|
99 } |
|
100 $author['email'] = $name['email']; |
|
101 } |
|
102 if (isset($name['uri'])) { |
|
103 if (empty($name['uri']) |
|
104 || !is_string($name['uri']) |
|
105 || !Zend_Uri::check($name['uri']) |
|
106 ) { |
|
107 require_once 'Zend/Feed/Exception.php'; |
|
108 throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); |
|
109 } |
|
110 $author['uri'] = $name['uri']; |
|
111 } |
|
112 /** |
|
113 * @deprecated |
|
114 * Array notation (above) is preferred and will be the sole supported input from ZF 2.0 |
|
115 */ |
|
116 } else { |
|
117 if (empty($name['name']) || !is_string($name['name'])) { |
|
118 require_once 'Zend/Feed/Exception.php'; |
|
119 throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string value'); |
|
120 } |
|
121 $author['name'] = $name; |
|
122 if (isset($email)) { |
|
123 if (empty($email) || !is_string($email)) { |
|
124 require_once 'Zend/Feed/Exception.php'; |
|
125 throw new Zend_Feed_Exception('Invalid parameter: "email" value must be a non-empty string'); |
|
126 } |
|
127 $author['email'] = $email; |
|
128 } |
|
129 if (isset($uri)) { |
|
130 if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { |
|
131 require_once 'Zend/Feed/Exception.php'; |
|
132 throw new Zend_Feed_Exception('Invalid parameter: "uri" value must be a non-empty string and valid URI/IRI'); |
|
133 } |
|
134 $author['uri'] = $uri; |
|
135 } |
|
136 } |
|
137 $this->_data['authors'][] = $author; |
|
138 } |
|
139 |
|
140 /** |
|
141 * Set an array with feed authors |
|
142 * |
|
143 * @return array |
|
144 */ |
|
145 public function addAuthors(array $authors) |
|
146 { |
|
147 foreach($authors as $author) { |
|
148 $this->addAuthor($author); |
|
149 } |
|
150 } |
|
151 |
|
152 /** |
|
153 * Set the feed character encoding |
|
154 * |
|
155 * @return string|null |
|
156 */ |
|
157 public function setEncoding($encoding) |
|
158 { |
|
159 if (empty($encoding) || !is_string($encoding)) { |
|
160 require_once 'Zend/Feed/Exception.php'; |
|
161 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
162 } |
|
163 $this->_data['encoding'] = $encoding; |
|
164 } |
|
165 |
|
166 /** |
|
167 * Get the feed character encoding |
|
168 * |
|
169 * @return string|null |
|
170 */ |
|
171 public function getEncoding() |
|
172 { |
|
173 if (!array_key_exists('encoding', $this->_data)) { |
|
174 return 'UTF-8'; |
|
175 } |
|
176 return $this->_data['encoding']; |
|
177 } |
|
178 |
|
179 /** |
|
180 * Set the copyright entry |
|
181 * |
|
182 * @return string|null |
|
183 */ |
|
184 public function setCopyright($copyright) |
|
185 { |
|
186 if (empty($copyright) || !is_string($copyright)) { |
|
187 require_once 'Zend/Feed/Exception.php'; |
|
188 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
189 } |
|
190 $this->_data['copyright'] = $copyright; |
|
191 } |
|
192 |
|
193 /** |
|
194 * Set the entry's content |
|
195 * |
|
196 * @return string|null |
|
197 */ |
|
198 public function setContent($content) |
|
199 { |
|
200 if (empty($content) || !is_string($content)) { |
|
201 require_once 'Zend/Feed/Exception.php'; |
|
202 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
203 } |
|
204 $this->_data['content'] = $content; |
|
205 } |
|
206 |
|
207 /** |
|
208 * Set the feed creation date |
|
209 * |
|
210 * @return string|null |
|
211 */ |
|
212 public function setDateCreated($date = null) |
|
213 { |
|
214 $zdate = null; |
|
215 if ($date === null) { |
|
216 $zdate = new Zend_Date; |
|
217 } elseif (ctype_digit($date) && strlen($date) == 10) { |
|
218 $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); |
|
219 } elseif ($date instanceof Zend_Date) { |
|
220 $zdate = $date; |
|
221 } else { |
|
222 require_once 'Zend/Feed/Exception.php'; |
|
223 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); |
|
224 } |
|
225 $this->_data['dateCreated'] = $zdate; |
|
226 } |
|
227 |
|
228 /** |
|
229 * Set the feed modification date |
|
230 * |
|
231 * @return string|null |
|
232 */ |
|
233 public function setDateModified($date = null) |
|
234 { |
|
235 $zdate = null; |
|
236 if ($date === null) { |
|
237 $zdate = new Zend_Date; |
|
238 } elseif (ctype_digit($date) && strlen($date) == 10) { |
|
239 $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); |
|
240 } elseif ($date instanceof Zend_Date) { |
|
241 $zdate = $date; |
|
242 } else { |
|
243 require_once 'Zend/Feed/Exception.php'; |
|
244 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); |
|
245 } |
|
246 $this->_data['dateModified'] = $zdate; |
|
247 } |
|
248 |
|
249 /** |
|
250 * Set the feed description |
|
251 * |
|
252 * @return string|null |
|
253 */ |
|
254 public function setDescription($description) |
|
255 { |
|
256 if (empty($description) || !is_string($description)) { |
|
257 require_once 'Zend/Feed/Exception.php'; |
|
258 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
259 } |
|
260 $this->_data['description'] = $description; |
|
261 } |
|
262 |
|
263 /** |
|
264 * Set the feed ID |
|
265 * |
|
266 * @return string|null |
|
267 */ |
|
268 public function setId($id) |
|
269 { |
|
270 if (empty($id) || !is_string($id)) { |
|
271 require_once 'Zend/Feed/Exception.php'; |
|
272 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
273 } |
|
274 $this->_data['id'] = $id; |
|
275 } |
|
276 |
|
277 /** |
|
278 * Set a link to the HTML source of this entry |
|
279 * |
|
280 * @return string|null |
|
281 */ |
|
282 public function setLink($link) |
|
283 { |
|
284 if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { |
|
285 require_once 'Zend/Feed/Exception.php'; |
|
286 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string and valid URI/IRI'); |
|
287 } |
|
288 $this->_data['link'] = $link; |
|
289 } |
|
290 |
|
291 /** |
|
292 * Set the number of comments associated with this entry |
|
293 * |
|
294 * @return string|null |
|
295 */ |
|
296 public function setCommentCount($count) |
|
297 { |
|
298 if (empty($count) || !is_numeric($count) || (int) $count < 0) { |
|
299 require_once 'Zend/Feed/Exception.php'; |
|
300 throw new Zend_Feed_Exception('Invalid parameter: "count" must be a non-empty integer number'); |
|
301 } |
|
302 $this->_data['commentCount'] = (int) $count; |
|
303 } |
|
304 |
|
305 /** |
|
306 * Set a link to a HTML page containing comments associated with this entry |
|
307 * |
|
308 * @return string|null |
|
309 */ |
|
310 public function setCommentLink($link) |
|
311 { |
|
312 if (empty($link) || !is_string($link) || !Zend_Uri::check($link)) { |
|
313 require_once 'Zend/Feed/Exception.php'; |
|
314 throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI'); |
|
315 } |
|
316 $this->_data['commentLink'] = $link; |
|
317 } |
|
318 |
|
319 /** |
|
320 * Set a link to an XML feed for any comments associated with this entry |
|
321 * |
|
322 * @return string|null |
|
323 */ |
|
324 public function setCommentFeedLink(array $link) |
|
325 { |
|
326 if (!isset($link['uri']) || !is_string($link['uri']) || !Zend_Uri::check($link['uri'])) { |
|
327 require_once 'Zend/Feed/Exception.php'; |
|
328 throw new Zend_Feed_Exception('Invalid parameter: "link" must be a non-empty string and valid URI/IRI'); |
|
329 } |
|
330 if (!isset($link['type']) || !in_array($link['type'], array('atom', 'rss', 'rdf'))) { |
|
331 require_once 'Zend/Feed/Exception.php'; |
|
332 throw new Zend_Feed_Exception('Invalid parameter: "type" must be one' |
|
333 . ' of "atom", "rss" or "rdf"'); |
|
334 } |
|
335 if (!isset($this->_data['commentFeedLinks'])) { |
|
336 $this->_data['commentFeedLinks'] = array(); |
|
337 } |
|
338 $this->_data['commentFeedLinks'][] = $link; |
|
339 } |
|
340 |
|
341 /** |
|
342 * Set a links to an XML feed for any comments associated with this entry. |
|
343 * Each link is an array with keys "uri" and "type", where type is one of: |
|
344 * "atom", "rss" or "rdf". |
|
345 * |
|
346 * @return string|null |
|
347 */ |
|
348 public function setCommentFeedLinks(array $links) |
|
349 { |
|
350 foreach ($links as $link) { |
|
351 $this->setCommentFeedLink($link); |
|
352 } |
|
353 } |
|
354 |
|
355 /** |
|
356 * Set the feed title |
|
357 * |
|
358 * @return string|null |
|
359 */ |
|
360 public function setTitle($title) |
|
361 { |
|
362 if (empty($title) || !is_string($title)) { |
|
363 require_once 'Zend/Feed/Exception.php'; |
|
364 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); |
|
365 } |
|
366 $this->_data['title'] = $title; |
|
367 } |
|
368 |
|
369 /** |
|
370 * Get an array with feed authors |
|
371 * |
|
372 * @return array |
|
373 */ |
|
374 public function getAuthors() |
|
375 { |
|
376 if (!array_key_exists('authors', $this->_data)) { |
|
377 return null; |
|
378 } |
|
379 return $this->_data['authors']; |
|
380 } |
|
381 |
|
382 /** |
|
383 * Get the entry content |
|
384 * |
|
385 * @return string |
|
386 */ |
|
387 public function getContent() |
|
388 { |
|
389 if (!array_key_exists('content', $this->_data)) { |
|
390 return null; |
|
391 } |
|
392 return $this->_data['content']; |
|
393 } |
|
394 |
|
395 /** |
|
396 * Get the entry copyright information |
|
397 * |
|
398 * @return string |
|
399 */ |
|
400 public function getCopyright() |
|
401 { |
|
402 if (!array_key_exists('copyright', $this->_data)) { |
|
403 return null; |
|
404 } |
|
405 return $this->_data['copyright']; |
|
406 } |
|
407 |
|
408 /** |
|
409 * Get the entry creation date |
|
410 * |
|
411 * @return string |
|
412 */ |
|
413 public function getDateCreated() |
|
414 { |
|
415 if (!array_key_exists('dateCreated', $this->_data)) { |
|
416 return null; |
|
417 } |
|
418 return $this->_data['dateCreated']; |
|
419 } |
|
420 |
|
421 /** |
|
422 * Get the entry modification date |
|
423 * |
|
424 * @return string |
|
425 */ |
|
426 public function getDateModified() |
|
427 { |
|
428 if (!array_key_exists('dateModified', $this->_data)) { |
|
429 return null; |
|
430 } |
|
431 return $this->_data['dateModified']; |
|
432 } |
|
433 |
|
434 /** |
|
435 * Get the entry description |
|
436 * |
|
437 * @return string |
|
438 */ |
|
439 public function getDescription() |
|
440 { |
|
441 if (!array_key_exists('description', $this->_data)) { |
|
442 return null; |
|
443 } |
|
444 return $this->_data['description']; |
|
445 } |
|
446 |
|
447 /** |
|
448 * Get the entry ID |
|
449 * |
|
450 * @return string |
|
451 */ |
|
452 public function getId() |
|
453 { |
|
454 if (!array_key_exists('id', $this->_data)) { |
|
455 return null; |
|
456 } |
|
457 return $this->_data['id']; |
|
458 } |
|
459 |
|
460 /** |
|
461 * Get a link to the HTML source |
|
462 * |
|
463 * @return string|null |
|
464 */ |
|
465 public function getLink() |
|
466 { |
|
467 if (!array_key_exists('link', $this->_data)) { |
|
468 return null; |
|
469 } |
|
470 return $this->_data['link']; |
|
471 } |
|
472 |
|
473 |
|
474 /** |
|
475 * Get all links |
|
476 * |
|
477 * @return array |
|
478 */ |
|
479 public function getLinks() |
|
480 { |
|
481 if (!array_key_exists('links', $this->_data)) { |
|
482 return null; |
|
483 } |
|
484 return $this->_data['links']; |
|
485 } |
|
486 |
|
487 /** |
|
488 * Get the entry title |
|
489 * |
|
490 * @return string |
|
491 */ |
|
492 public function getTitle() |
|
493 { |
|
494 if (!array_key_exists('title', $this->_data)) { |
|
495 return null; |
|
496 } |
|
497 return $this->_data['title']; |
|
498 } |
|
499 |
|
500 /** |
|
501 * Get the number of comments/replies for current entry |
|
502 * |
|
503 * @return integer |
|
504 */ |
|
505 public function getCommentCount() |
|
506 { |
|
507 if (!array_key_exists('commentCount', $this->_data)) { |
|
508 return null; |
|
509 } |
|
510 return $this->_data['commentCount']; |
|
511 } |
|
512 |
|
513 /** |
|
514 * Returns a URI pointing to the HTML page where comments can be made on this entry |
|
515 * |
|
516 * @return string |
|
517 */ |
|
518 public function getCommentLink() |
|
519 { |
|
520 if (!array_key_exists('commentLink', $this->_data)) { |
|
521 return null; |
|
522 } |
|
523 return $this->_data['commentLink']; |
|
524 } |
|
525 |
|
526 /** |
|
527 * Returns an array of URIs pointing to a feed of all comments for this entry |
|
528 * where the array keys indicate the feed type (atom, rss or rdf). |
|
529 * |
|
530 * @return string |
|
531 */ |
|
532 public function getCommentFeedLinks() |
|
533 { |
|
534 if (!array_key_exists('commentFeedLinks', $this->_data)) { |
|
535 return null; |
|
536 } |
|
537 return $this->_data['commentFeedLinks']; |
|
538 } |
|
539 |
|
540 /** |
|
541 * Add a entry category |
|
542 * |
|
543 * @param string $category |
|
544 */ |
|
545 public function addCategory(array $category) |
|
546 { |
|
547 if (!isset($category['term'])) { |
|
548 require_once 'Zend/Feed/Exception.php'; |
|
549 throw new Zend_Feed_Exception('Each category must be an array and ' |
|
550 . 'contain at least a "term" element containing the machine ' |
|
551 . ' readable category name'); |
|
552 } |
|
553 if (isset($category['scheme'])) { |
|
554 if (empty($category['scheme']) |
|
555 || !is_string($category['scheme']) |
|
556 || !Zend_Uri::check($category['scheme']) |
|
557 ) { |
|
558 require_once 'Zend/Feed/Exception.php'; |
|
559 throw new Zend_Feed_Exception('The Atom scheme or RSS domain of' |
|
560 . ' a category must be a valid URI'); |
|
561 } |
|
562 } |
|
563 if (!isset($this->_data['categories'])) { |
|
564 $this->_data['categories'] = array(); |
|
565 } |
|
566 $this->_data['categories'][] = $category; |
|
567 } |
|
568 |
|
569 /** |
|
570 * Set an array of entry categories |
|
571 * |
|
572 * @param array $categories |
|
573 */ |
|
574 public function addCategories(array $categories) |
|
575 { |
|
576 foreach ($categories as $category) { |
|
577 $this->addCategory($category); |
|
578 } |
|
579 } |
|
580 |
|
581 /** |
|
582 * Get the entry categories |
|
583 * |
|
584 * @return string|null |
|
585 */ |
|
586 public function getCategories() |
|
587 { |
|
588 if (!array_key_exists('categories', $this->_data)) { |
|
589 return null; |
|
590 } |
|
591 return $this->_data['categories']; |
|
592 } |
|
593 |
|
594 /** |
|
595 * Adds an enclosure to the entry. The array parameter may contain the |
|
596 * keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the |
|
597 * others must also be provided or RSS rendering (where they are required) |
|
598 * will throw an Exception. |
|
599 * |
|
600 * @param array $enclosures |
|
601 */ |
|
602 public function setEnclosure(array $enclosure) |
|
603 { |
|
604 if (!isset($enclosure['uri'])) { |
|
605 require_once 'Zend/Feed/Exception.php'; |
|
606 throw new Zend_Feed_Exception('Enclosure "uri" is not set'); |
|
607 } |
|
608 if (!Zend_Uri::check($enclosure['uri'])) { |
|
609 require_once 'Zend/Feed/Exception.php'; |
|
610 throw new Zend_Feed_Exception('Enclosure "uri" is not a valid URI/IRI'); |
|
611 } |
|
612 $this->_data['enclosure'] = $enclosure; |
|
613 } |
|
614 |
|
615 /** |
|
616 * Retrieve an array of all enclosures to be added to entry. |
|
617 * |
|
618 * @return array |
|
619 */ |
|
620 public function getEnclosure() |
|
621 { |
|
622 if (!array_key_exists('enclosure', $this->_data)) { |
|
623 return null; |
|
624 } |
|
625 return $this->_data['enclosure']; |
|
626 } |
|
627 |
|
628 /** |
|
629 * Unset a specific data point |
|
630 * |
|
631 * @param string $name |
|
632 */ |
|
633 public function remove($name) |
|
634 { |
|
635 if (isset($this->_data[$name])) { |
|
636 unset($this->_data[$name]); |
|
637 } |
|
638 } |
|
639 |
|
640 /** |
|
641 * Get registered extensions |
|
642 * |
|
643 * @return array |
|
644 */ |
|
645 public function getExtensions() |
|
646 { |
|
647 return $this->_extensions; |
|
648 } |
|
649 |
|
650 /** |
|
651 * Return an Extension object with the matching name (postfixed with _Entry) |
|
652 * |
|
653 * @param string $name |
|
654 * @return object |
|
655 */ |
|
656 public function getExtension($name) |
|
657 { |
|
658 if (array_key_exists($name . '_Entry', $this->_extensions)) { |
|
659 return $this->_extensions[$name . '_Entry']; |
|
660 } |
|
661 return null; |
|
662 } |
|
663 |
|
664 /** |
|
665 * Set the current feed type being exported to "rss" or "atom". This allows |
|
666 * other objects to gracefully choose whether to execute or not, depending |
|
667 * on their appropriateness for the current type, e.g. renderers. |
|
668 * |
|
669 * @param string $type |
|
670 */ |
|
671 public function setType($type) |
|
672 { |
|
673 $this->_type = $type; |
|
674 } |
|
675 |
|
676 /** |
|
677 * Retrieve the current or last feed type exported. |
|
678 * |
|
679 * @return string Value will be "rss" or "atom" |
|
680 */ |
|
681 public function getType() |
|
682 { |
|
683 return $this->_type; |
|
684 } |
|
685 |
|
686 /** |
|
687 * Method overloading: call given method on first extension implementing it |
|
688 * |
|
689 * @param string $method |
|
690 * @param array $args |
|
691 * @return mixed |
|
692 * @throws Zend_Feed_Exception if no extensions implements the method |
|
693 */ |
|
694 public function __call($method, $args) |
|
695 { |
|
696 foreach ($this->_extensions as $extension) { |
|
697 try { |
|
698 return call_user_func_array(array($extension, $method), $args); |
|
699 } catch (Zend_Feed_Writer_Exception_InvalidMethodException $e) { |
|
700 } |
|
701 } |
|
702 require_once 'Zend/Feed/Exception.php'; |
|
703 throw new Zend_Feed_Exception('Method: ' . $method |
|
704 . ' does not exist and could not be located on a registered Extension'); |
|
705 } |
|
706 |
|
707 /** |
|
708 * Creates a new Zend_Feed_Writer_Source data container for use. This is NOT |
|
709 * added to the current feed automatically, but is necessary to create a |
|
710 * container with some initial values preset based on the current feed data. |
|
711 * |
|
712 * @return Zend_Feed_Writer_Source |
|
713 */ |
|
714 public function createSource() |
|
715 { |
|
716 $source = new Zend_Feed_Writer_Source; |
|
717 if ($this->getEncoding()) { |
|
718 $source->setEncoding($this->getEncoding()); |
|
719 } |
|
720 $source->setType($this->getType()); |
|
721 return $source; |
|
722 } |
|
723 |
|
724 /** |
|
725 * Appends a Zend_Feed_Writer_Entry object representing a new entry/item |
|
726 * the feed data container's internal group of entries. |
|
727 * |
|
728 * @param Zend_Feed_Writer_Source $source |
|
729 */ |
|
730 public function setSource(Zend_Feed_Writer_Source $source) |
|
731 { |
|
732 $this->_data['source'] = $source; |
|
733 } |
|
734 |
|
735 /** |
|
736 * @return Zend_Feed_Writer_Source |
|
737 */ |
|
738 public function getSource() |
|
739 { |
|
740 if (isset($this->_data['source'])) { |
|
741 return $this->_data['source']; |
|
742 } |
|
743 return null; |
|
744 } |
|
745 |
|
746 /** |
|
747 * Load extensions from Zend_Feed_Writer |
|
748 * |
|
749 * @return void |
|
750 */ |
|
751 protected function _loadExtensions() |
|
752 { |
|
753 $all = Zend_Feed_Writer::getExtensions(); |
|
754 $exts = $all['entry']; |
|
755 foreach ($exts as $ext) { |
|
756 $className = Zend_Feed_Writer::getPluginLoader()->getClassName($ext); |
|
757 $this->_extensions[$ext] = new $className(); |
|
758 $this->_extensions[$ext]->setEncoding($this->getEncoding()); |
|
759 } |
|
760 } |
|
761 } |