Add RSSFeedURL page type allowing easy embedding of an RSS feed (suchmashups
authorElijah Lofgren <elijahlofgren@kubuntu.(none)>
Sat, 11 Aug 2007 20:06:17 +0000 (11 15:06 -0500)
committerElijah Lofgren <elijahlofgren@kubuntu.(none)>
Sat, 11 Aug 2007 20:06:17 +0000 (11 15:06 -0500)
as one from del.icio.us) on a page.

code/RSSFeedURL.php [new file with mode: 0644]

diff --git a/code/RSSFeedURL.php b/code/RSSFeedURL.php
new file mode 100644 (file)
index 0000000..6d3398e
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+class RSSFeedURL extends Page {
+       // define your database fields here
+       static $db = array(
+               "RSSFeedURL" => "Varchar",
+       );
+       
+       // static $icon = "mashups/images/treeicons/flickr";
+       
+       // add custom fields for this RSS Feed page
+       function getCMSFields($cms) {
+               $fields = parent::getCMSFields($cms);
+               $fields->addFieldToTab("Root.Content.Main", new TextField("RSSFeedURL","RSS Feed URL"));
+               return $fields;
+       }
+
+       function showRSSFeedURL(){
+               $delicious = new RestfulService($this->RSSFeedURL);
+               
+               $conn = $delicious->connect();
+               $result = $delicious->getValues($conn, "item");
+               $output = '';
+               foreach ($result as $key => $value) {
+                       // Fix quote encoding
+                       $description = str_replace('&amp;quot;', '&quot;', $value->description);
+                       $output .=  '<li><a href="'.$value->link.'">'.$value->title.'</a><br />'.$description.'</li>';
+               }
+               return $output;
+       }
+}
+
+class RSSFeedURL_Controller extends Page_Controller {
+       function Content(){
+               return $this->Content.$this->showRSSFeedURL();
+       }
+}
+?>
\ No newline at end of file