diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-12-06 18:47:09 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-12-06 18:47:09 +0000 |
commit | 287a46f11e429ff8a11bc646afaeadce122425c6 (patch) | |
tree | 7e3330c9aec43f5b24a9ddee767fb4c083d79965 /lib/class/xmldata.class.php | |
parent | 286840fbcc42ea190b7700ad9a00d0aaf4acbbf2 (diff) | |
download | ampache-287a46f11e429ff8a11bc646afaeadce122425c6.tar.gz ampache-287a46f11e429ff8a11bc646afaeadce122425c6.tar.bz2 ampache-287a46f11e429ff8a11bc646afaeadce122425c6.zip |
some work on the rss feed stuff
Diffstat (limited to 'lib/class/xmldata.class.php')
-rw-r--r-- | lib/class/xmldata.class.php | 44 |
1 files changed, 41 insertions, 3 deletions
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 @@ -66,6 +67,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 * nothing fancy here... @@ -281,21 +294,43 @@ class xmlData { } // songs /** + * rss_feed + */ + public static function rss_feed($data,$title,$description,$date) { + + $string = "\t<title>$title</title>\n\t<link>" . Config::get('web_path') . "</link>\n\t" . + "<pubDate>$date</pubDate>\n"; + + // Pass it to the keyed array xml function + $string .= self::keyed_array($data); + + $final = self::_header() . $string . self::_footer(); + + return $final; + + } // rss_feed + + /** * _header * this returns a standard header, there are a few types * so we allow them to pass a type if they want to */ private static function _header($type='') { - switch ($type) { + switch (self::$type) { case 'xspf': break; case 'itunes': break; + case 'rss': + $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n " . + "<!-- RSS Generated by Ampache v." . Config::get('version') . " on " . date("r",time()) . "\n" . + "<rss version=\"2.0\">\n\t<channel>\n"; + break; default: - $header = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<root>\n"; + $header = "<?xml version=\"1.0\" encoding=\"" . Config::get('site_charset') . "\" ?>\n<root>\n"; break; } // end switch @@ -309,7 +344,10 @@ class xmlData { */ private static function _footer($type='') { - switch ($type) { + switch (self::$type) { + case 'rss': + $footer = "\n\t<channel>\n</rss>\n"; + break; default: $footer = "\n</root>\n"; break; |