CC-4895: Remove all json die() statements from code

- removed json_encode
This commit is contained in:
denise 2013-02-07 15:41:47 -05:00
parent 7bc4151741
commit 525b2dcb33
15 changed files with 43 additions and 51 deletions

View File

@ -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()

View File

@ -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);
}
}

View File

@ -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 {}

View File

@ -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"));
}
}

View File

@ -70,10 +70,10 @@ class PreferenceController extends Zend_Controller_Action
$this->view->statusMsg = "<div class='success'>". _("Preferences updated.")."</div>";
$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 = "<div class='success'>"._("Stream Setting Updated.")."</div>";
$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);
}
}

View File

@ -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));
}
}

View File

@ -53,7 +53,7 @@ class UserController extends Zend_Controller_Action
&& $formData['user_id'] != 0) {
$this->view->form = $form;
$this->view->successMessage = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>";
$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 = "<div class='success'>"._("User updated successfully!")."</div>";
}
$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 = "<div class='errors'>"._("Specific action is not allowed in demo version!")."</div>";
$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']);

View File

@ -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 = $("<tr/>")
.append('<td>' + file.name +'</td>')

View File

@ -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);
}

View File

@ -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();

View File

@ -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) {

View File

@ -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);

View File

@ -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<json_obj.length;i++){
var obj = json_obj[i];
var id;
@ -441,8 +440,7 @@ $(document).ready(function() {
var data = $('#stream_form').serialize();
var url = baseUrl+'Preference/stream-setting';
$.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);
setupEventListeners();
setSliderForReplayGain();

View File

@ -87,8 +87,7 @@ var AIRTIME = (function(AIRTIME){
// once a track plays out we need to check if we can update
// the is_scheduled flag in cc_files
$.post(baseUrl+"schedule/update-future-is-scheduled",
{"format": "json", "schedId": schedId}, function(json) {
var data = $.parseJSON(json);
{"format": "json", "schedId": schedId}, function(data) {
if (data.redrawLibTable !== undefined && data.redrawLibTable) {
$("#library_content").find("#library_display").dataTable().fnStandingRedraw();
}

View File

@ -189,8 +189,7 @@ $(document).ready(function() {
var data = $('#user_form').serialize();
var url = baseUrl+'User/add-user';
$.post(url, {format: "json", data: data}, function(data){
var json = $.parseJSON(data);
$.post(url, {format: "json", data: data}, function(json){
if (json.valid === "true") {
$('#content').empty().append(json.html);
populateUserTable();