summaryrefslogtreecommitdiffstats
path: root/lib/class/xmldata.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-20 06:23:05 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-11-20 06:23:05 +0000
commit5869da3fe58876644364941fa7216caee09adbf5 (patch)
tree66d981851a8e3d024ccd662c26cdad6612f7e6b0 /lib/class/xmldata.class.php
parentc1829308f4207eda5fbfff668ad0fcd6e1f16143 (diff)
downloadampache-5869da3fe58876644364941fa7216caee09adbf5.tar.gz
ampache-5869da3fe58876644364941fa7216caee09adbf5.tar.bz2
ampache-5869da3fe58876644364941fa7216caee09adbf5.zip
little more work on the xml api, artists and albums now works
Diffstat (limited to 'lib/class/xmldata.class.php')
-rw-r--r--lib/class/xmldata.class.php64
1 files changed, 62 insertions, 2 deletions
diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php
index de71fbc8..655a65f3 100644
--- a/lib/class/xmldata.class.php
+++ b/lib/class/xmldata.class.php
@@ -29,6 +29,9 @@ class xmlData {
public static $version = '340001';
+ // This is added so that we don't pop any webservers
+ public static $limit = '5000';
+
/**
* constructor
* We don't use this, as its really a static class
@@ -52,18 +55,34 @@ class xmlData {
} // error
/**
+ * single_string
+ * This takes two values, first the key second the string
+ */
+ public static function single_string($key,$string) {
+
+ $final = self::_header() . "\t<$key><![CDATA[$string]]></$key>" . self::_footer();
+
+ return $final;
+
+ } // single_string
+
+ /**
* artists
* This takes an array of artists and then returns a pretty xml document with the information
* we want
*/
public static function artists($artists) {
+ if (count($artists) > self::$limit) {
+ $artists = array_splice($artists,0,self::$limit);
+ }
+
foreach ($artists as $artist_id) {
$artist = new Artist($artist_id);
$artist->format();
- $string .= "<artist id="$artist->id">\n" .
- "\t<name>$artist->f_full_name</name>\n";
+ $string .= "<artist id=\"$artist->id\">\n" .
+ "\t<name><![CDATA[$artist->f_full_name]]></name>\n" .
"</artist>\n";
} // end foreach artists
@@ -73,6 +92,47 @@ class xmlData {
} // artists
/**
+ * albums
+ * This echos out a standard albums XML document, it pays attention to the limit
+ */
+ public static function albums($albums) {
+
+ if (count($albums) > self::$limit) {
+ $albums = array_splice($albums,0,self::$limit);
+ }
+
+ foreach ($albums as $album_id) {
+ $album = new Album($album_id);
+ $album->format();
+
+ // Build the Art URL
+ $art_url = Config::get('web_path') . '/image.php?id=' . $album->id;
+
+ $string .= "<album id=\"$album->id\">\n" .
+ "\t<name><![CDATA[$album->name]]></name>\n";
+
+ // Do a little check for artist stuff
+ if ($album->artist_count != 1) {
+ $string .= "\t<artist id=\"0\"><![CDATA[Various]]></artist>\n";
+ }
+ else {
+ $string .= "\t<artist id=\"$album->artist_id\"><![CDATA[$album->artist_name]]></artist>\n";
+ }
+
+ $string .= "\t<year>$album->year</year>\n" .
+ "\t<tracks>$album->song_count</tracks>\n" .
+ "\t<disk>$album->disk</disk>\n" .
+ "\t<art>$art_url</art>\n" .
+ "</album>\n";
+ } // end foreach
+
+ $final = self::_header() . $string . self::_footer();
+
+ return $final;
+
+ } // albums
+
+ /**
* _header
* this returns a standard header, there are a few types
* so we allow them to pass a type if they want to