diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index ffbae08aa..cda2e9dcb 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -411,7 +411,9 @@ class ApiController extends Zend_Controller_Action $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName, $tempFileName); if (!is_null($result)) { - $this->_helper->json->sendJson('{"jsonrpc" : "2.0", "error" : {"code": '.$result['code'].', "message" : "'.$result['message'].'"}}'); + $this->_helper->json->sendJson( + array("jsonrpc" => "2.0", "error" => array("code" => $result['code'], "message" => $result['message'])) + ); } } @@ -600,7 +602,7 @@ class ApiController extends Zend_Controller_Action $response['key'] = $k; array_push($responses, $response); } - $this->_helper->json->sendJson( json_encode($responses) ); + $this->_helper->json->sendJson($responses); } public function listAllFilesAction() diff --git a/airtime_mvc/application/controllers/ListenerstatController.php b/airtime_mvc/application/controllers/ListenerstatController.php index f64ea8bfb..bb280378d 100644 --- a/airtime_mvc/application/controllers/ListenerstatController.php +++ b/airtime_mvc/application/controllers/ListenerstatController.php @@ -76,6 +76,6 @@ class ListenerstatController extends Zend_Controller_Action $endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC")); $data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"), $mountName); - $this->_helper->json->sendJson(json_encode($data)); + $this->_helper->json->sendJson($data); } } diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 11d397bc3..e474b9177 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -133,7 +133,7 @@ class PlaylistController extends Zend_Controller_Action if (!$p_isJson) { $this->createFullResponse(null); } else { - $this->_helper->json->sendJson(json_encode(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson)))); + $this->_helper->json->sendJson(array("error"=>$this->view->error, "result"=>1, "html"=>$this->createFullResponse(null, $p_isJson))); } } @@ -509,7 +509,7 @@ class PlaylistController extends Zend_Controller_Action } $result["modified"] = $this->view->modified; - $this->_helper->json->sendJson(json_encode($result)); + $this->_helper->json->sendJson($result); } public function smartBlockGenerateAction() @@ -525,7 +525,7 @@ class PlaylistController extends Zend_Controller_Action $form->startForm($params['obj_id']); if ($form->isValid($params)) { $result = $bl->generateSmartBlock($params['data']); - $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true)))); + $this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true, true))); } else { $this->view->obj = $bl; $this->view->id = $bl->getId(); @@ -533,7 +533,7 @@ class PlaylistController extends Zend_Controller_Action $viewPath = 'playlist/smart-block.phtml'; $result['html'] = $this->view->render($viewPath); $result['result'] = 1; - $this->_helper->json->sendJson(json_encode($result)); + $this->_helper->json->sendJson($result); } } catch (BlockNotFoundException $e) { $this->playlistNotFound('block', true); @@ -552,9 +552,9 @@ class PlaylistController extends Zend_Controller_Action $result = $bl->shuffleSmartBlock(); if ($result['result'] == 0) { - $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true)))); + $this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($bl, true))); } else { - $this->_helper->json->sendJson(json_encode($result)); + $this->_helper->json->sendJson($result); } } catch (BlockNotFoundException $e) { $this->playlistNotFound('block', true); @@ -572,9 +572,9 @@ class PlaylistController extends Zend_Controller_Action $result = $pl->shuffle(); if ($result['result'] == 0) { - $this->_helper->json->sendJson(json_encode(array("result"=>0, "html"=>$this->createFullResponse($pl, true)))); + $this->_helper->json->sendJson(array("result"=>0, "html"=>$this->createFullResponse($pl, true))); } else { - $this->_helper->json->sendJson(json_encode($result)); + $this->_helper->json->sendJson($result); } } catch (PlaylistNotFoundException $e) { $this->playlistNotFound('block', true); @@ -595,7 +595,7 @@ class PlaylistController extends Zend_Controller_Action $out = $bl->getCriteria(); $out['isStatic'] = false; } - $this->_helper->json->sendJson(json_encode($out)); + $this->_helper->json->sendJson($out); } } class WrongTypeToBlockException extends Exception {} diff --git a/airtime_mvc/application/controllers/PluploadController.php b/airtime_mvc/application/controllers/PluploadController.php index 49b706644..9698b163a 100644 --- a/airtime_mvc/application/controllers/PluploadController.php +++ b/airtime_mvc/application/controllers/PluploadController.php @@ -43,8 +43,8 @@ class PluploadController extends Zend_Controller_Action $result = Application_Model_StoredFile::copyFileToStor($upload_dir, $filename, $tempname); if (!is_null($result)) - $this->_helper->json->sendJson('{"jsonrpc" : "2.0", "error" : '.json_encode($result).'}'); + $this->_helper->json->sendJson(array("jsonrpc" => "2.0", "error" => $result)); - $this->_helper->json->sendJson('{"jsonrpc" : "2.0"}'); + $this->_helper->json->sendJson(array("jsonrpc" => "2.0")); } } diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 33a021aa4..d30a0d292 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -70,10 +70,10 @@ class PreferenceController extends Zend_Controller_Action $this->view->statusMsg = "
". _("Preferences updated.")."
"; $this->view->form = $form; - $this->_helper->json->sendJson(json_encode(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('preference/index.phtml'))); } else { $this->view->form = $form; - $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/index.phtml'))); } } $this->view->form = $form; @@ -323,19 +323,19 @@ class PreferenceController extends Zend_Controller_Action $this->view->form = $form; $this->view->num_stream = $num_of_stream; $this->view->statusMsg = "
"._("Stream Setting Updated.")."
"; - $this->_helper->json->sendJson(json_encode(array( + $this->_helper->json->sendJson(array( "valid"=>"true", "html"=>$this->view->render('preference/stream-setting.phtml'), "s1_set_admin_pass"=>$s1_set_admin_pass, "s2_set_admin_pass"=>$s2_set_admin_pass, "s3_set_admin_pass"=>$s3_set_admin_pass, - ))); + )); } else { $live_stream_subform->updateVariables(); $this->view->enable_stream_conf = Application_Model_Preference::GetEnableStreamConf(); $this->view->form = $form; $this->view->num_stream = $num_of_stream; - $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('preference/stream-setting.phtml'))); } } @@ -441,7 +441,7 @@ class PreferenceController extends Zend_Controller_Action if (Application_Model_Preference::GetImportTimestamp()+10 > $now) { $res = true; } - $this->_helper->json->sendJson(json_encode($res)); + $this->_helper->json->sendJson($res); } public function getLiquidsoapStatusAction() @@ -456,7 +456,7 @@ class PreferenceController extends Zend_Controller_Action } $out[] = array("id"=>$i, "status"=>$status); } - $this->_helper->json->sendJson(json_encode($out)); + $this->_helper->json->sendJson($out); } public function setSourceConnectionUrlAction() @@ -479,6 +479,7 @@ class PreferenceController extends Zend_Controller_Action public function getAdminPasswordStatusAction() { + Logging::info("11111111111"); $out = array(); for ($i=1; $i<=3; $i++) { if (Application_Model_StreamSetting::getAdminPass('s'.$i)=='') { @@ -487,6 +488,6 @@ class PreferenceController extends Zend_Controller_Action $out["s".$i] = true; } } - $this->_helper->json->sendJson(json_encode($out)); + $this->_helper->json->sendJson($out); } } diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 3ce212513..c4fd65205 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -925,7 +925,7 @@ class ScheduleController extends Zend_Controller_Action 'title' => _('Download')); //returns format jjmenu is looking for. - $this->_helper->json->sendJson(json_encode($menu)); + $this->_helper->json->sendJson($menu); } /** @@ -983,6 +983,6 @@ class ScheduleController extends Zend_Controller_Action { $schedId = $this->_getParam('schedId'); $redrawLibTable = Application_Model_StoredFile::setIsScheduled($schedId, false); - $this->_helper->json->sendJson(json_encode(array("redrawLibTable" => $redrawLibTable))); + $this->_helper->json->sendJson(array("redrawLibTable" => $redrawLibTable)); } } diff --git a/airtime_mvc/application/controllers/UserController.php b/airtime_mvc/application/controllers/UserController.php index 14728512a..319c57767 100644 --- a/airtime_mvc/application/controllers/UserController.php +++ b/airtime_mvc/application/controllers/UserController.php @@ -53,7 +53,7 @@ class UserController extends Zend_Controller_Action && $formData['user_id'] != 0) { $this->view->form = $form; $this->view->successMessage = "
"._("Specific action is not allowed in demo version!")."
"; - $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml'))); } elseif ($form->validateLogin($formData)) { $user = new Application_Model_User($formData['user_id']); if (empty($formData['user_id'])) { @@ -89,14 +89,14 @@ class UserController extends Zend_Controller_Action $this->view->successMessage = "
"._("User updated successfully!")."
"; } - $this->_helper->json->sendJson(json_encode(array("valid"=>"true", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"true", "html"=>$this->view->render('user/add-user.phtml'))); } else { $this->view->form = $form; - $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml'))); } } else { $this->view->form = $form; - $this->_helper->json->sendJson(json_encode(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml')))); + $this->_helper->json->sendJson(array("valid"=>"false", "html"=>$this->view->render('user/add-user.phtml'))); } } @@ -135,7 +135,7 @@ class UserController extends Zend_Controller_Action && $formData['cu_login'] == 'admin') { $this->view->form = $form; $this->view->successMessage = "
"._("Specific action is not allowed in demo version!")."
"; - $this->_helper->json->sendJson(json_encode(array("html"=>$this->view->render('user/edit-user.phtml')))); + $this->_helper->json->sendJson(array("html"=>$this->view->render('user/edit-user.phtml'))); } else if ($form->isValid($formData) && $form->validateLogin($formData['cu_login'], $formData['cu_user_id'])) { $user = new Application_Model_User($formData['cu_user_id']); diff --git a/airtime_mvc/public/js/airtime/library/plupload.js b/airtime_mvc/public/js/airtime/library/plupload.js index b429c5602..91fdc63ee 100644 --- a/airtime_mvc/public/js/airtime/library/plupload.js +++ b/airtime_mvc/public/js/airtime/library/plupload.js @@ -30,8 +30,7 @@ $(document).ready(function() { var tempFileName = j.tempfilepath; $.get(baseUrl+'Plupload/copyfile/format/json/name/'+ encodeURIComponent(file.name)+'/tempname/' + - encodeURIComponent(tempFileName), function(json){ - var jr = jQuery.parseJSON(json); + encodeURIComponent(tempFileName), function(jr){ if(jr.error !== undefined) { var row = $("") .append('' + file.name +'') diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 6c49443ff..4f61517e5 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -450,9 +450,8 @@ var AIRTIME = (function(AIRTIME){ if ($(this).hasClass('close')) { var sUrl = baseUrl+"playlist/get-block-info"; mod.disableUI(); - $.post(sUrl, {format:"json", id:blockId}, function(json){ + $.post(sUrl, {format:"json", id:blockId}, function(data){ $html = ""; - var data = $.parseJSON(json); var isStatic = data.isStatic; delete data.type; if (isStatic) { @@ -643,8 +642,7 @@ var AIRTIME = (function(AIRTIME){ obj_id = $('input[id="obj_id"]').val(); url = baseUrl+"Playlist/shuffle"; enableLoadingIcon(); - $.post(url, {format: "json", obj_id: obj_id}, function(data){ - var json = $.parseJSON(data) + $.post(url, {format: "json", obj_id: obj_id}, function(json){ if (json.error !== undefined) { alert(json.error); @@ -727,8 +725,7 @@ var AIRTIME = (function(AIRTIME){ enableLoadingIcon(); $.post(save_action, {format: "json", data: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod}, - function(data){ - var json = $.parseJSON(data); + function(json){ if (json.error !== undefined) { alert(json.error); } diff --git a/airtime_mvc/public/js/airtime/listenerstat/listenerstat.js b/airtime_mvc/public/js/airtime/listenerstat/listenerstat.js index 926368966..bebfd1471 100644 --- a/airtime_mvc/public/js/airtime/listenerstat/listenerstat.js +++ b/airtime_mvc/public/js/airtime/listenerstat/listenerstat.js @@ -23,7 +23,6 @@ $(document).ready(function() { function getDataAndPlot(startTimestamp, endTimestamp){ // get data $.get(baseUrl+'Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){ - data = JSON.parse(data); out = new Object(); $.each(data, function(mpName, v){ plotData = new Object(); diff --git a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js index a06ee081e..022e93148 100644 --- a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js +++ b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js @@ -480,9 +480,8 @@ function getCriteriaOptionType(e) { return criteriaTypes[criteria]; } -function callback(data, type) { - var json = $.parseJSON(data), - dt = $('table[id="library_display"]').dataTable(); +function callback(json, type) { + var dt = $('table[id="library_display"]').dataTable(); if (type == 'shuffle' || type == 'generate') { if (json.error !== undefined) { diff --git a/airtime_mvc/public/js/airtime/preferences/preferences.js b/airtime_mvc/public/js/airtime/preferences/preferences.js index eec5e1c7e..50466f462 100644 --- a/airtime_mvc/public/js/airtime/preferences/preferences.js +++ b/airtime_mvc/public/js/airtime/preferences/preferences.js @@ -108,8 +108,7 @@ $(document).ready(function() { var data = $('#pref_form').serialize(); var url = baseUrl+'Preference/index'; - $.post(url, {format: "json", data: data}, function(data){ - var json = $.parseJSON(data); + $.post(url, {format: "json", data: data}, function(json){ $('#content').empty().append(json.html); $.cookie("default_airtime_locale", $('#locale').val(), {path: '/'}); setTimeout(removeSuccessMsg, 5000); diff --git a/airtime_mvc/public/js/airtime/preferences/streamsetting.js b/airtime_mvc/public/js/airtime/preferences/streamsetting.js index 6e76b693c..0fdd82f2c 100644 --- a/airtime_mvc/public/js/airtime/preferences/streamsetting.js +++ b/airtime_mvc/public/js/airtime/preferences/streamsetting.js @@ -77,8 +77,7 @@ function showForIcecast(ele){ function checkLiquidsoapStatus(){ var url = baseUrl+'Preference/get-liquidsoap-status/format/json'; var id = $(this).attr("id"); - $.post(url, function(json){ - var json_obj = jQuery.parseJSON(json); + $.post(url, function(json_obj){ for(var i=0;i