From 17e631bc5e327514596ce8761fe7f93d414a8717 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 23 Sep 2011 22:22:59 +0200 Subject: Use OC_JSON for json responses Create OC_JSON class, for single point of creating json responses. No real logic change, this just cleans up the code a bit. --- apps/media/ajax/api.php | 12 ++++++------ apps/media/ajax/autoupdate.php | 4 ++-- apps/media/tomahawk.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'apps/media') diff --git a/apps/media/ajax/api.php b/apps/media/ajax/api.php index c5909e4c78b..84ee6334463 100644 --- a/apps/media/ajax/api.php +++ b/apps/media/ajax/api.php @@ -67,7 +67,7 @@ if($arguments['action']){ $data['artists']=OC_MEDIA_COLLECTION::getArtists(); $data['albums']=OC_MEDIA_COLLECTION::getAlbums(); $data['songs']=OC_MEDIA_COLLECTION::getSongs(); - echo json_encode($data); + OC_JSON::encodedPrint($data); break; case 'scan': OC_DB::beginTransaction(); @@ -81,13 +81,13 @@ if($arguments['action']){ echo (OC_MEDIA_SCANNER::scanFile($arguments['path']))?'true':'false'; break; case 'get_artists': - echo json_encode(OC_MEDIA_COLLECTION::getArtists($arguments['search'])); + OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getArtists($arguments['search'])); break; case 'get_albums': - echo json_encode(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search'])); + OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getAlbums($arguments['artist'],$arguments['search'])); break; case 'get_songs': - echo json_encode(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search'])); + OC_JSON::encodedPrint(OC_MEDIA_COLLECTION::getSongs($arguments['artist'],$arguments['album'],$arguments['search'])); break; case 'get_path_info': if(OC_Filesystem::file_exists($arguments['path'])){ @@ -100,7 +100,7 @@ if($arguments['action']){ $song=OC_MEDIA_COLLECTION::getSong($songId); $song['artist']=OC_MEDIA_COLLECTION::getArtistName($song['song_artist']); $song['album']=OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); - echo json_encode($song); + OC_JSON::encodedPrint($song); } } break; @@ -129,7 +129,7 @@ if($arguments['action']){ OC_Filesystem::readfile($arguments['path']); exit; case 'find_music': - echo json_encode(findMusic()); + OC_JSON::encodedPrint(findMusic()); exit; } } diff --git a/apps/media/ajax/autoupdate.php b/apps/media/ajax/autoupdate.php index ac3d0650b4b..ad103d1c39b 100644 --- a/apps/media/ajax/autoupdate.php +++ b/apps/media/ajax/autoupdate.php @@ -35,5 +35,5 @@ if(defined("DEBUG") && DEBUG) {error_log((integer)$autoUpdate);} OC_Preferences::setValue(OC_User::getUser(),'media','autoupdate',(integer)$autoUpdate); -echo json_encode( array( "status" => "success", "data" => $autoUpdate)); -?> \ No newline at end of file +OC_JSON::success(array('data' => $autoUpdate)); +?> diff --git a/apps/media/tomahawk.php b/apps/media/tomahawk.php index bf0c2c2a756..1db982a3504 100644 --- a/apps/media/tomahawk.php +++ b/apps/media/tomahawk.php @@ -77,5 +77,5 @@ foreach($songs as $song) { 'score' => (float)1.0 ); } -echo json_encode($results); -?> \ No newline at end of file +OC_JSON::encodedPrint($results); +?> -- cgit v1.2.3