root/trunk/lib/sfFeed/sfRss201rev2Feed.class.php

Revision 2, 2.3 kB (checked in by fabien, 6 years ago)

initial import

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 /**
12  *
13  * Specification: http://blogs.law.harvard.edu/tech/rss
14  *
15  * @package    symfony
16  * @subpackage addon
17  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
18  * @version    SVN: $Id$
19  */
20 class sfRss201rev2Feed extends sfRssFeed
21 {
22   protected function getFeedElements()
23   {
24     $xml = array();
25     foreach ($this->getItems() as $item)
26     {
27       $xml[] = '<item>';
28       $xml[] = '  <title>'.htmlspecialchars($this->getItemFeedTitle($item)).'</title>';
29       if ($this->getItemFeedDescription($item))
30       {
31         $xml[] = '  <description>'.htmlspecialchars($this->getItemFeedDescription($item)).'</description>';
32       }
33       $xml[] = '  <link>'.$this->getItemFeedLink($item).'</link>';
34       if ($this->getItemFeedUniqueId($item))
35       {
36         $xml[] = '  <guid>'.$this->getItemFeedUniqueId($item).'</guid>';
37       }
38
39       // author information
40       if ($this->getItemFeedAuthorEmail($item) && $this->getItemFeedAuthorName($item))
41       {
42         $xml[] = sprintf('  <author>%s (%s)</author>', $this->getItemFeedAuthorEmail($item), $this->getItemFeedAuthorName($item));
43       }
44       if ($this->getItemFeedPubdate($item))
45       {
46         $xml[] = '  <pubDate>'.date('r', $this->getItemFeedPubdate($item)).'</pubDate>';
47       }
48       if ($this->getItemFeedComments($item))
49       {
50         $xml[] = '  <comments>'.htmlspecialchars($this->getItemFeedComments($item)).'</comments>';
51       }
52
53       // enclosure
54       if ((method_exists($item, 'getFeedEnclosure')) && ($enclosure = $item->getFeedEnclosure()))
55       {
56         $enclosure_attributes = sprintf('url="%s" length="%s" type="%s"', $enclosure->getUrl(), $enclosure->getLength(), $enclosure->getMimeType());
57         $xml[] = '  <enclosure '.$enclosure_attributes.'></enclosure>';
58       }
59
60       // categories
61       foreach ($this->getItemFeedCategories($item) as $category)
62       {
63         $xml[] = '  <category>'.$category.'</category>';
64       }
65
66       $xml[] = '</item>';
67     }
68
69     return $xml;
70   }
71
72   protected function getVersion()
73   {
74     return '2.0';
75   }
76 }
77
78 ?>
Note: See TracBrowser for help on using the browser.