1 | <?php |
||
10 | class RSSFeed extends ViewableData { |
||
11 | |||
12 | /** |
||
13 | * Casting information for this object's methods. |
||
14 | * Let's us use $Title.XML in templates |
||
15 | */ |
||
16 | private static $casting = array( |
||
17 | "Title" => "Varchar", |
||
18 | "Description" => "Varchar", |
||
19 | "Link" => "Varchar", |
||
20 | ); |
||
21 | |||
22 | /** |
||
23 | * Holds the feed entries |
||
24 | * |
||
25 | * @var SS_List |
||
26 | */ |
||
27 | protected $entries; |
||
28 | |||
29 | /** |
||
30 | * Title of the feed |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $title; |
||
35 | |||
36 | /** |
||
37 | * Description of the feed |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $description; |
||
42 | |||
43 | /** |
||
44 | * Link to the feed |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $link; |
||
49 | |||
50 | /** |
||
51 | * Name of the title field of feed entries |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $titleField; |
||
56 | |||
57 | /** |
||
58 | * Name of the description field of feed entries |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $descriptionField; |
||
63 | |||
64 | /** |
||
65 | * Name of the author field of feed entries |
||
66 | * |
||
67 | * @var string |
||
68 | */ |
||
69 | protected $authorField; |
||
70 | |||
71 | /** |
||
72 | * Last modification of the RSS feed |
||
73 | * |
||
74 | * @var int Unix timestamp of the last modification |
||
75 | */ |
||
76 | protected $lastModified; |
||
77 | |||
78 | /** |
||
79 | * ETag for the RSS feed (used for client-site caching) |
||
80 | * |
||
81 | * @var string The value for the HTTP ETag header. |
||
82 | */ |
||
83 | protected $etag; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | */ |
||
88 | protected $template = 'RSSFeed'; |
||
89 | |||
90 | /** |
||
91 | * Constructor |
||
92 | * |
||
93 | * @param SS_List $entries RSS feed entries |
||
94 | * @param string $link Link to the feed |
||
95 | * @param string $title Title of the feed |
||
96 | * @param string $description Description of the field |
||
97 | * @param string $titleField Name of the field that should be used for the |
||
98 | * titles for the feed entries |
||
99 | * @param string $descriptionField Name of the field that should be used |
||
100 | * for the description for the feed |
||
101 | * entries |
||
102 | * @param string $authorField Name of the field that should be used for |
||
103 | * the author for the feed entries |
||
104 | * @param int $lastModified Unix timestamp of the latest modification |
||
105 | * (latest posting) |
||
106 | * @param string $etag The ETag is an unique identifier that is changed |
||
107 | * every time the representation does |
||
108 | */ |
||
109 | public function __construct(SS_List $entries, $link, $title, |
||
127 | |||
128 | /** |
||
129 | * Include an link to the feed |
||
130 | * |
||
131 | * @param string $url URL of the feed |
||
132 | * @param string $title Title to show |
||
133 | */ |
||
134 | public static function linkToFeed($url, $title = null) { |
||
140 | |||
141 | /** |
||
142 | * Get the RSS feed entries |
||
143 | * |
||
144 | * @return SS_List Returns the {@link RSSFeed_Entry} objects. |
||
145 | */ |
||
146 | public function Entries() { |
||
157 | |||
158 | /** |
||
159 | * Get the title of thisfeed |
||
160 | * |
||
161 | * @return string Returns the title of the feed. |
||
162 | */ |
||
163 | public function Title() { |
||
166 | |||
167 | /** |
||
168 | * Get the URL of this feed |
||
169 | * |
||
170 | * @param string $action |
||
171 | * @return string Returns the URL of the feed. |
||
172 | */ |
||
173 | public function Link($action = null) { |
||
176 | |||
177 | /** |
||
178 | * Get the description of this feed |
||
179 | * |
||
180 | * @return string Returns the description of the feed. |
||
181 | */ |
||
182 | public function Description() { |
||
185 | |||
186 | /** |
||
187 | * Output the feed to the browser. |
||
188 | * |
||
189 | * TODO: Pass $response object to ->outputToBrowser() to loosen dependence on global state for easier testing/prototyping so dev can inject custom SS_HTTPResponse instance. |
||
190 | * |
||
191 | * @return HTMLText |
||
192 | */ |
||
193 | public function outputToBrowser() { |
||
213 | |||
214 | /** |
||
215 | * Set the name of the template to use. Actual template will be resolved |
||
216 | * via the standard template inclusion process. |
||
217 | * |
||
218 | * @param string |
||
219 | */ |
||
220 | public function setTemplate($template) { |
||
223 | |||
224 | /** |
||
225 | * Returns the name of the template to use. |
||
226 | * |
||
227 | * @return string |
||
228 | */ |
||
229 | public function getTemplate() { |
||
232 | } |
||
233 | |||
347 |