diff --git a/lib/class/rss.class.php b/lib/class/rss.class.php index 17d3b154..21362131 100644 --- a/lib/class/rss.class.php +++ b/lib/class/rss.class.php @@ -27,24 +27,38 @@ */ class RSS { - private static $types = array('nowplaying', - 'latestartist', - 'latestalbum', - 'popularalbum', - 'popularartist', - 'popularsong', - 'recentlyplayed'); + public $type; + public $data; /** * Constructor * This takes a flagged.id and then pulls in the information for said flag entry */ - public function __construct() { + public function __construct($type) { - // Nothing here for now + if (!RSS::valid_type($type)) { + $type = 'now_playing'; + } } // constructor + /** + * validate_type + * this returns a valid type for an rss feed, if the specified type is invalid it returns a default value + */ + public static function validate_type($type) { + + $valid_types = array('now_playing','recently_played','latest_album','latest_artist','latest_song', + 'popular_song','popular_album','popular_artist'); + + if (!in_array($type,$valid_types)) { + return 'now_playing'; + } + + return $type; + + } // validate_type + /** * get_display * This dumps out some html and an icon for the type of rss that we specify diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php index 1fc7bc2e..cae0fa04 100644 --- a/lib/class/xmldata.class.php +++ b/lib/class/xmldata.class.php @@ -30,6 +30,7 @@ class xmlData { // This is added so that we don't pop any webservers private static $limit = '5000'; private static $offset = '0'; + private static $type = ''; /** * constructor @@ -65,6 +66,18 @@ class xmlData { } // set_limit + /** + * set_type + * This sets the type of xmlData we are working on + */ + public static function set_type($type) { + + if (!in_array($type,array('rss','xspf','itunes'))) { return false; } + + self::$type = $type; + + } // set_type + /** * error * This generates a standard XML Error message @@ -280,6 +293,23 @@ class xmlData { } // songs + /** + * rss_feed + */ + public static function rss_feed($data,$title,$description,$date) { + + $string = "\t