CC-4090: Make code style PSR compliant - part 4

-controllers dir
This commit is contained in:
Martin Konecny 2012-08-29 10:54:36 -04:00
parent b2327472e8
commit 699a49a103
6 changed files with 104 additions and 112 deletions

View File

@ -378,7 +378,6 @@ class ApiController extends Zend_Controller_Action
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()), Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
$excludeInstance = null, $onlyRecord = true); $excludeInstance = null, $onlyRecord = true);
$this->view->is_recording = false; $this->view->is_recording = false;
$this->view->server_timezone = Application_Model_Preference::GetTimezone(); $this->view->server_timezone = Application_Model_Preference::GetTimezone();
@ -482,35 +481,32 @@ class ApiController extends Zend_Controller_Action
$file->setFileExistsFlag(true); $file->setFileExistsFlag(true);
$file->setMetadata($md); $file->setMetadata($md);
} }
} } elseif ($mode == "modify") {
else if ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
$file = Application_Model_StoredFile::RecallByFilepath($filepath); $file = Application_Model_StoredFile::RecallByFilepath($filepath);
//File is not in database anymore. //File is not in database anymore.
if (is_null($file)) { if (is_null($file)) {
$return_hash['error'] = "File does not exist in Airtime."; $return_hash['error'] = "File does not exist in Airtime.";
return $return_hash; return $return_hash;
} }
//Updating a metadata change. //Updating a metadata change.
else { else {
$file->setMetadata($md); $file->setMetadata($md);
} }
} } elseif ($mode == "moved") {
else if ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5']; $md5 = $md['MDATA_KEY_MD5'];
$file = Application_Model_StoredFile::RecallByMd5($md5); $file = Application_Model_StoredFile::RecallByMd5($md5);
if (is_null($file)) { if (is_null($file)) {
return "File doesn't exist in Airtime."; return "File doesn't exist in Airtime.";
} } else {
else {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath); //$filepath = str_replace("\\", "", $filepath);
$file->setFilePath($filepath); $file->setFilePath($filepath);
} }
} } elseif ($mode == "delete") {
else if ($mode == "delete") {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath); //$filepath = str_replace("\\", "", $filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath); $file = Application_Model_StoredFile::RecallByFilepath($filepath);
@ -519,13 +515,12 @@ class ApiController extends Zend_Controller_Action
$return_hash['error'] = "File doesn't exist in Airtime."; $return_hash['error'] = "File doesn't exist in Airtime.";
Logging::warn("Attempt to delete file that doesn't exist. Logging::warn("Attempt to delete file that doesn't exist.
Path: '$filepath'"); Path: '$filepath'");
return $return_hash; return $return_hash;
} } else {
else {
$file->deleteByMediaMonitor(); $file->deleteByMediaMonitor();
} }
} } elseif ($mode == "delete_dir") {
else if ($mode == "delete_dir") {
$filepath = $md['MDATA_KEY_FILEPATH']; $filepath = $md['MDATA_KEY_FILEPATH'];
//$filepath = str_replace("\\", "", $filepath); //$filepath = str_replace("\\", "", $filepath);
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath); $files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
@ -534,9 +529,11 @@ class ApiController extends Zend_Controller_Action
$file->deleteByMediaMonitor(); $file->deleteByMediaMonitor();
} }
$return_hash['success'] = 1; $return_hash['success'] = 1;
return $return_hash; return $return_hash;
} }
$return_hash['fileid'] = $file->getId(); $return_hash['fileid'] = $file->getId();
return $return_hash; return $return_hash;
} }

View File

@ -29,7 +29,6 @@ class AudiopreviewController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']); $baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
$this->view->headScript()->appendFile( $this->view->headScript()->appendFile(
@ -219,6 +218,7 @@ class AudiopreviewController extends Zend_Controller_Action
} else { } else {
$elementMap['uri'] = $track['path']; $elementMap['uri'] = $track['path'];
} }
return $elementMap; return $elementMap;
} }

View File

@ -143,7 +143,6 @@ class LibraryController extends Zend_Controller_Action
} }
} }
public function contextMenuAction() public function contextMenuAction()
{ {
$id = $this->_getParam('id'); $id = $this->_getParam('id');
@ -296,10 +295,10 @@ class LibraryController extends Zend_Controller_Action
Application_Model_Playlist::deletePlaylists($playlists, $user->getId()); Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
} catch (PlaylistNoPermissionException $e) { } catch (PlaylistNoPermissionException $e) {
$this->view->message = "You don't have permission to delete selected items."; $this->view->message = "You don't have permission to delete selected items.";
return; return;
} }
try { try {
Application_Model_Block::deleteBlocks($blocks, $user->getId()); Application_Model_Block::deleteBlocks($blocks, $user->getId());
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -48,7 +48,6 @@ class PlaylistController extends Zend_Controller_Action
return $obj; return $obj;
} }
private function createUpdateResponse($obj) private function createUpdateResponse($obj)
{ {
$formatter = new LengthFormatter($obj->getLength()); $formatter = new LengthFormatter($obj->getLength());
@ -205,7 +204,6 @@ class PlaylistController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id); $user = new Application_Model_User($userInfo->id);
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME); $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
try { try {
@ -274,17 +272,13 @@ class PlaylistController extends Zend_Controller_Action
$this->playlistOutdated($e); $this->playlistOutdated($e);
} catch (PlaylistNotFoundException $e) { } catch (PlaylistNotFoundException $e) {
$this->playlistNotFound($obj_type); $this->playlistNotFound($obj_type);
} } catch (WrongTypeToBlockException $e) {
catch (WrongTypeToBlockException $e) {
$this->wrongTypeToBlock($obj); $this->wrongTypeToBlock($obj);
} } catch (WrongTypeToPlaylistException $e) {
catch (WrongTypeToPlaylistException $e) {
$this->wrongTypeToPlaylist($obj); $this->wrongTypeToPlaylist($obj);
} } catch (BlockDynamicException $e) {
catch (BlockDynamicException $e) {
$this->blockDynamic($obj); $this->blockDynamic($obj);
} } catch (Exception $e) {
catch (Exception $e) {
$this->playlistUnknownError($e); $this->playlistUnknownError($e);
} }
} }

View File

@ -18,6 +18,7 @@ class WebstreamController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
if (!$this->isAuthorized(-1)) { if (!$this->isAuthorized(-1)) {
header("Status: 401 Not Authorized"); header("Status: 401 Not Authorized");
return; return;
} }
@ -63,7 +64,6 @@ class WebstreamController extends Zend_Controller_Action
throw new Exception("Missing parameter 'id'"); throw new Exception("Missing parameter 'id'");
} }
$webstream = CcWebstreamQuery::create()->findPK($id); $webstream = CcWebstreamQuery::create()->findPK($id);
if ($webstream) { if ($webstream) {
Application_Model_Library::changePlaylist($id, "stream"); Application_Model_Library::changePlaylist($id, "stream");
@ -80,6 +80,7 @@ class WebstreamController extends Zend_Controller_Action
if (!$this->isAuthorized($id)) { if (!$this->isAuthorized($id)) {
header("Status: 401 Not Authorized"); header("Status: 401 Not Authorized");
return; return;
} }
@ -135,6 +136,7 @@ class WebstreamController extends Zend_Controller_Action
if (!$this->isAuthorized($id)) { if (!$this->isAuthorized($id)) {
header("Status: 401 Not Authorized"); header("Status: 401 Not Authorized");
return; return;
} }