Add RSSFeedURL page type allowing easy embedding of an RSS feed (such
[silverstripe-elijah.git] / code / RSSFeedURL.php
blob6d3398efa34e3aaed956468572ebbbdebe8a924b
1 <?php
3 class RSSFeedURL extends Page {
5 // define your database fields here
6 static $db = array(
7 "RSSFeedURL" => "Varchar",
8 );
10 // static $icon = "mashups/images/treeicons/flickr";
12 // add custom fields for this RSS Feed page
13 function getCMSFields($cms) {
14 $fields = parent::getCMSFields($cms);
15 $fields->addFieldToTab("Root.Content.Main", new TextField("RSSFeedURL","RSS Feed URL"));
16 return $fields;
19 function showRSSFeedURL(){
20 $delicious = new RestfulService($this->RSSFeedURL);
22 $conn = $delicious->connect();
23 $result = $delicious->getValues($conn, "item");
24 $output = '';
25 foreach ($result as $key => $value) {
26 // Fix quote encoding
27 $description = str_replace('&amp;quot;', '&quot;', $value->description);
28 $output .= '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>';
30 return $output;
34 class RSSFeedURL_Controller extends Page_Controller {
35 function Content(){
36 return $this->Content.$this->showRSSFeedURL();