use sendJson, instead of manually disabling layouts + encoding data
This commit is contained in:
parent
21b84c153a
commit
acfc72f422
|
@ -64,14 +64,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function versionAction()
|
public function versionAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
$this->_helper->json->sendJson( array(
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$jsonStr = json_encode( array(
|
|
||||||
"version" => Application_Model_Preference::GetAirtimeVersion()));
|
"version" => Application_Model_Preference::GetAirtimeVersion()));
|
||||||
echo $jsonStr;
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,9 +74,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function calendarInitAction()
|
public function calendarInitAction()
|
||||||
{
|
{
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
|
if (is_null(Zend_Auth::getInstance()->getStorage()->read())) {
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
print _('You are not allowed to access this resource.');
|
print _('You are not allowed to access this resource.');
|
||||||
|
@ -97,6 +88,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
|
"timeInterval" => Application_Model_Preference::GetCalendarTimeInterval(),
|
||||||
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
|
"weekStartDay" => Application_Model_Preference::GetWeekStartDay()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->_helper->json->sendJson(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,10 +100,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function getMediaAction()
|
public function getMediaAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$fileId = $this->_getParam("file");
|
$fileId = $this->_getParam("file");
|
||||||
|
|
||||||
$media = Application_Model_StoredFile::RecallById($fileId);
|
$media = Application_Model_StoredFile::RecallById($fileId);
|
||||||
|
@ -151,7 +140,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
$this->_helper->json->sendJson(array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -359,22 +348,15 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function scheduleAction()
|
public function scheduleAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$data = Application_Model_Schedule::getSchedule();
|
$data = Application_Model_Schedule::getSchedule();
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
echo json_encode($data, JSON_FORCE_OBJECT);
|
echo json_encode($data, JSON_FORCE_OBJECT);
|
||||||
die();
|
$this->_helper->json->sendJson($data, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyMediaItemStartPlayAction()
|
public function notifyMediaItemStartPlayAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$media_id = $this->_getParam("media_id");
|
$media_id = $this->_getParam("media_id");
|
||||||
Logging::debug("Received notification of new media item start: $media_id");
|
Logging::debug("Received notification of new media item start: $media_id");
|
||||||
Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
||||||
|
@ -404,8 +386,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
Logging::info($e);
|
Logging::info($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array("status"=>1, "message"=>""));
|
$this->_helper->json->sendJson(array("status"=>1, "message"=>""));
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function recordedShowsAction()
|
public function recordedShowsAction()
|
||||||
|
@ -493,10 +474,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
public function mediaMonitorSetupAction()
|
public function mediaMonitorSetupAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
|
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
|
||||||
|
|
||||||
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
|
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
|
||||||
|
@ -612,8 +589,6 @@ class ApiController extends Zend_Controller_Action
|
||||||
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
|
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||||
$info_json = json_decode($raw_json, $assoc = true);
|
$info_json = json_decode($raw_json, $assoc = true);
|
||||||
|
|
||||||
Logging::info($info_json);
|
|
||||||
|
|
||||||
// Log invalid requests
|
// Log invalid requests
|
||||||
if ( !array_key_exists('mode', $info_json) ) {
|
if ( !array_key_exists('mode', $info_json) ) {
|
||||||
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
|
Logging::info("Received bad request(key=$k), no 'mode' parameter. Bad request is:");
|
||||||
|
@ -940,38 +915,24 @@ class ApiController extends Zend_Controller_Action
|
||||||
* out a message to pypo that a potential change has been made. */
|
* out a message to pypo that a potential change has been made. */
|
||||||
public function getFilesWithoutReplayGainAction()
|
public function getFilesWithoutReplayGainAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$dir_id = $this->_getParam('dir_id');
|
$dir_id = $this->_getParam('dir_id');
|
||||||
|
|
||||||
//connect to db and get get sql
|
//connect to db and get get sql
|
||||||
$rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100);
|
$rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100);
|
||||||
|
|
||||||
echo json_encode($rows);
|
$this->_helper->json->sendJson($rows);
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFilesWithoutSilanValueAction()
|
public function getFilesWithoutSilanValueAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
//connect to db and get get sql
|
//connect to db and get get sql
|
||||||
$rows = Application_Model_StoredFile::getAllFilesWithoutSilan();
|
$rows = Application_Model_StoredFile::getAllFilesWithoutSilan();
|
||||||
|
|
||||||
echo json_encode($rows);
|
$this->_helper->json->sendJson($rows);
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateReplayGainValueAction()
|
public function updateReplayGainValueAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$data = json_decode($request->getParam('data'));
|
$data = json_decode($request->getParam('data'));
|
||||||
|
|
||||||
|
@ -983,16 +944,11 @@ class ApiController extends Zend_Controller_Action
|
||||||
$file->save();
|
$file->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array());
|
$this->_helper->json->sendJson(array());
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCueValuesBySilanAction()
|
public function updateCueValuesBySilanAction()
|
||||||
{
|
{
|
||||||
// disable the view and the layout
|
|
||||||
$this->view->layout()->disableLayout();
|
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
|
||||||
|
|
||||||
$request = $this->getRequest();
|
$request = $this->getRequest();
|
||||||
$data = json_decode($request->getParam('data'), $assoc = true);
|
$data = json_decode($request->getParam('data'), $assoc = true);
|
||||||
|
|
||||||
|
@ -1024,8 +980,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
$file->save();
|
$file->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(array());
|
$this->_helper->json->sendJson(array());
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function notifyWebstreamDataAction()
|
public function notifyWebstreamDataAction()
|
||||||
|
@ -1094,5 +1049,4 @@ class ApiController extends Zend_Controller_Action
|
||||||
Application_Model_StreamSetting::SetListenerStatError($k, $v);
|
Application_Model_StreamSetting::SetListenerStatError($k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue