From 0bd925f488affe2f2a82a8be5e1e461d2f1ebae3 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Wed, 19 Nov 2008 17:02:37 +0000 Subject: add the ratings to the album and artist xml results, fixed a logic error on the api session extending --- lib/class/xmldata.class.php | 47 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) (limited to 'lib/class/xmldata.class.php') diff --git a/lib/class/xmldata.class.php b/lib/class/xmldata.class.php index 807a9a5d..a22805c8 100644 --- a/lib/class/xmldata.class.php +++ b/lib/class/xmldata.class.php @@ -131,15 +131,21 @@ class xmlData { } $string = ''; + + Rating::build_cache('artist',$artists); foreach ($artists as $artist_id) { $artist = new Artist($artist_id); $artist->format(); + $rating = new Rating($artist_id,'artist'); + $string .= "id\">\n" . "\tf_full_name]]>\n" . "\t$artist->albums\n" . "\t$artist->songs\n" . + "\t" . $rating->preciserating . "\n" . + "\t" . $rating->rating . "\n" . "\n"; } // end foreach artists @@ -158,11 +164,15 @@ class xmlData { if (count($albums) > self::$limit) { $albums = array_splice($albums,self::$offset,self::$limit); } + + Rating::build_cache('album',$albums); foreach ($albums as $album_id) { $album = new Album($album_id); $album->format(); + $rating = new Rating($album_id,'album'); + // Build the Art URL, include session $art_url = Config::get('web_path') . '/image.php?id=' . $album->id . '&auth=' . scrub_out($_REQUEST['auth']); @@ -181,6 +191,8 @@ class xmlData { "\t$album->song_count\n" . "\t$album->disk\n" . "\t\n" . + "\t" . $rating->preciserating . "\n" . + "\t" . $rating->rating . "\n" . "\n"; } // end foreach @@ -190,39 +202,6 @@ class xmlData { } // albums - /** - * genres - * This takes an array of genre ids and returns a nice little pretty xml doc - */ - public static function genres($genres) { - - if (count($genres) > self::$limit) { - $genres = array_slice($genres,self::$offset,self::$limit); - } - - // Foreach the ids - foreach ($genres as $genre_id) { - $genre = new Genre($genre_id); - $genre->format(); - $song_count = $genre->get_song_count(); - $album_count = $genre->get_album_count(); - $artist_count = $genre->get_artist_count(); - - $string .= "id\">\n" . - "\tname]]>\n" . - "\t$song_count\n" . - "\t$album_count\n" . - "\t$artist_count\n" . - "\n"; - - } // end foreach - - $final = self::_header() . $string . self::_footer(); - - return $final; - - } // genres - /** * playlists * This takes an array of playlist ids and then returns a nice pretty XML document @@ -269,6 +248,8 @@ class xmlData { $songs = array_slice($songs,self::$offset,self::$limit); } + Rating::build_cache('song',$songs); + // Foreach the ids! foreach ($songs as $song_id) { $song = new Song($song_id); -- cgit