fix collection browsing using the ampache api

This commit is contained in:
Robin Appelman 2011-08-17 00:07:08 +02:00
parent ea65d90a41
commit 9f28c20660
2 changed files with 6 additions and 4 deletions

View File

@ -201,6 +201,7 @@ class OC_MEDIA_AMPACHE{
$filter=isset($params['filter'])?$params['filter']:''; $filter=isset($params['filter'])?$params['filter']:'';
$exact=isset($params['exact'])?($params['exact']=='true'):false; $exact=isset($params['exact'])?($params['exact']=='true'):false;
$artists=OC_MEDIA_COLLECTION::getArtists($filter,$exact); $artists=OC_MEDIA_COLLECTION::getArtists($filter,$exact);
error_log('artists found: '.print_r($artists,true));
echo('<root>'); echo('<root>');
foreach($artists as $artist){ foreach($artists as $artist){
self::printArtist($artist); self::printArtist($artist);
@ -215,8 +216,7 @@ class OC_MEDIA_AMPACHE{
</root>"); </root>");
return; return;
} }
global $SITEROOT; $filter=isset($params['filter'])?$params['filter']:'';
$filter=$params['filter'];
$songs=OC_MEDIA_COLLECTION::getSongs($filter); $songs=OC_MEDIA_COLLECTION::getSongs($filter);
$artist=OC_MEDIA_COLLECTION::getArtistName($filter); $artist=OC_MEDIA_COLLECTION::getArtistName($filter);
echo('<root>'); echo('<root>');

View File

@ -123,10 +123,12 @@ class OC_MEDIA_COLLECTION{
static public function getArtists($search='%',$exact=false){ static public function getArtists($search='%',$exact=false){
if(!$exact and $search!='%'){ if(!$exact and $search!='%'){
$search="%$search%"; $search="%$search%";
}elseif($search==''){
$search='%';
} }
$query=OC_DB::prepare("SELECT DISTINCT *PREFIX*media_artists.artist_name AS artist_name , *PREFIX*media_artists.artist_id AS artist_id FROM *PREFIX*media_artists $query=OC_DB::prepare("SELECT DISTINCT *PREFIX*media_artists.artist_name AS artist_name , *PREFIX*media_artists.artist_id AS artist_id FROM *PREFIX*media_artists
INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=?"); INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=?");
return $query->execute(array($search,OC_User::getUser()))->fetchAll(); return $query->execute(array($search,self::$uid))->fetchAll();
} }
/** /**
@ -159,7 +161,7 @@ class OC_MEDIA_COLLECTION{
static public function getAlbums($artist=0,$search='%',$exact=false){ static public function getAlbums($artist=0,$search='%',$exact=false){
$cmd="SELECT DISTINCT *PREFIX*media_albums.album_name AS album_name , *PREFIX*media_albums.album_artist AS album_artist , *PREFIX*media_albums.album_id AS album_id $cmd="SELECT DISTINCT *PREFIX*media_albums.album_name AS album_name , *PREFIX*media_albums.album_artist AS album_artist , *PREFIX*media_albums.album_id AS album_id
FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON *PREFIX*media_albums.album_id=*PREFIX*media_songs.song_album WHERE *PREFIX*media_songs.song_user=? "; FROM *PREFIX*media_albums INNER JOIN *PREFIX*media_songs ON *PREFIX*media_albums.album_id=*PREFIX*media_songs.song_album WHERE *PREFIX*media_songs.song_user=? ";
$params=array(OC_User::getUser()); $params=array(self::$uid);
if($artist!=0){ if($artist!=0){
$cmd.="AND *PREFIX*media_albums.album_artist = ? "; $cmd.="AND *PREFIX*media_albums.album_artist = ? ";
array_push($params,$artist); array_push($params,$artist);