From a3e1bf7850a641f0c0c3f5b7d1a755edbb053a6c Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 10 Mar 2009 00:03:16 +0000 Subject: add video data to the API and add missing count="X" value to tag information --- lib/class/xmldata.class.php | 49 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) (limited to 'lib/class/xmldata.class.php') diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php index e2a4ef2e..71554464 100644 --- a/lib/class/xmldata.class.php +++ b/lib/class/xmldata.class.php @@ -126,13 +126,14 @@ class xmlData { * tags_string * This returns the formated 'tags' string for an xml document */ - private static function tags_string($tags) { + private static function tags_string($tags,$type,$object_id) { $string = ''; foreach ($tags as $tag_id) { $tag = new Tag($tag_id); - $string .= "\tid\">name]]>\n"; + $tag->format($type,$object_id); + $string .= "\tid\" count=\"$tag->weight\">name]]>\n"; } return $string; @@ -188,7 +189,7 @@ class xmlData { $artist->format(); $rating = new Rating($artist_id,'artist'); - $tag_string = self::tags_string($artist->tags); + $tag_string = self::tags_string($artist->tags,'artist',$artist->id); $string .= "id\">\n" . "\tf_full_name]]>\n" . @@ -241,7 +242,7 @@ class xmlData { $string .= "\t$album->year\n" . "\t$album->song_count\n" . "\t$album->disk\n" . - self::tags_string($album->tags) . + self::tags_string($album->tags,'album',$album->id) . "\t\n" . "\t" . $rating->preciserating . "\n" . "\t" . $rating->rating . "\n" . @@ -314,11 +315,7 @@ class xmlData { $song->genre = $tag->id; $song->f_genre = $tag->name; - // Build up the tag's text - foreach ($song->tags as $tag_id) { - $tag = new Tag($tag_id); - $tag_string .= "\tid\">name]]>\n"; - } + $tag_string = self::tags_string($song->tags,'song',$song->id); $rating = new Rating($song_id,'song'); @@ -348,6 +345,40 @@ class xmlData { } // songs + /** + * videos + * This builds the xml document for displaying video objects + */ + public static function videos($videos) { + + if (count($videos) > self::$limit) { + $videos = array_slice($videos,self::$offset,self::$limit); + } + + $string = ''; + + foreach ($videos as $video_id) { + $video = new Video($video_id); + $video->format(); + + $string .= "\n"; + + } // end foreach + + $final = self::_header() . $string . self::_footer(); + + return $final; + + + } // videos + /** * rss_feed */ -- cgit