CC-4090: Make code style PSR compliant - part 4
-controllers dir
This commit is contained in:
parent
b2327472e8
commit
699a49a103
|
@ -257,7 +257,7 @@ class ApiController extends Zend_Controller_Action
|
|||
if ($limit == "" || !is_numeric($limit)) {
|
||||
$limit = "5";
|
||||
}
|
||||
|
||||
|
||||
// make getNextShows use end of day
|
||||
$utcTimeEnd = Application_Common_DateHelper::GetDayEndTimestampInUtc();
|
||||
$result = array("env"=>APPLICATION_ENV,
|
||||
|
@ -265,7 +265,7 @@ class ApiController extends Zend_Controller_Action
|
|||
"currentShow"=>Application_Model_Show::getCurrentShow($utcTimeNow),
|
||||
"nextShow"=>Application_Model_Show::getNextShows($utcTimeNow, $limit, $utcTimeEnd)
|
||||
);
|
||||
|
||||
|
||||
Application_Model_Show::convertToLocalTimeZone($result["currentShow"],
|
||||
array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
Application_Model_Show::convertToLocalTimeZone($result["nextShow"],
|
||||
|
@ -283,7 +283,7 @@ class ApiController extends Zend_Controller_Action
|
|||
//used by caller to determine if the airtime they are running or widgets in use is out of date.
|
||||
$result['AIRTIME_API_VERSION'] = AIRTIME_API_VERSION;
|
||||
header("Content-type: text/javascript");
|
||||
|
||||
|
||||
// If a callback is not given, then just provide the raw JSON.
|
||||
echo isset($_GET['callback']) ? $_GET['callback'].'('.json_encode($result).')' : json_encode($result);
|
||||
} else {
|
||||
|
@ -347,7 +347,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$schedule_group_id = $this->_getParam("schedule_id");
|
||||
$media_id = $this->_getParam("media_id");
|
||||
$result = Application_Model_Schedule::UpdateMediaPlayedStatus($media_id);
|
||||
|
||||
|
||||
//set a 'last played' timestamp for media item
|
||||
//needed for smart blocks
|
||||
try {
|
||||
|
@ -361,7 +361,7 @@ class ApiController extends Zend_Controller_Action
|
|||
} catch (Exception $e) {
|
||||
Logging::info($e);
|
||||
}
|
||||
|
||||
|
||||
echo json_encode(array("status"=>1, "message"=>""));
|
||||
}
|
||||
|
||||
|
@ -372,13 +372,12 @@ class ApiController extends Zend_Controller_Action
|
|||
$end_timestamp = $now->add(new DateInterval("PT2H"));
|
||||
$end_timestamp = $end_timestamp->format("Y-m-d H:i:s");
|
||||
|
||||
$this->view->shows =
|
||||
$this->view->shows =
|
||||
Application_Model_Show::getShows(
|
||||
Application_Common_DateHelper::ConvertToUtcDateTime($today_timestamp, date_default_timezone_get()),
|
||||
Application_Common_DateHelper::ConvertToUtcDateTime($end_timestamp, date_default_timezone_get()),
|
||||
$excludeInstance = null, $onlyRecord = true);
|
||||
|
||||
|
||||
$this->view->is_recording = false;
|
||||
$this->view->server_timezone = Application_Model_Preference::GetTimezone();
|
||||
|
||||
|
@ -463,8 +462,8 @@ class ApiController extends Zend_Controller_Action
|
|||
$this->view->watched_dirs = $watchedDirsPath;
|
||||
}
|
||||
|
||||
public function dispatchMetadata($md, $mode)
|
||||
{
|
||||
public function dispatchMetadata($md, $mode)
|
||||
{
|
||||
// Replace this compound result in a hash with proper error handling later on
|
||||
$return_hash = array();
|
||||
Application_Model_Preference::SetImportTimestamp();
|
||||
|
@ -482,35 +481,32 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->setFileExistsFlag(true);
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
else if ($mode == "modify") {
|
||||
} elseif ($mode == "modify") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
||||
//File is not in database anymore.
|
||||
if (is_null($file)) {
|
||||
$return_hash['error'] = "File does not exist in Airtime.";
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
//Updating a metadata change.
|
||||
else {
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
else if ($mode == "moved") {
|
||||
} elseif ($mode == "moved") {
|
||||
$md5 = $md['MDATA_KEY_MD5'];
|
||||
$file = Application_Model_StoredFile::RecallByMd5($md5);
|
||||
|
||||
if (is_null($file)) {
|
||||
return "File doesn't exist in Airtime.";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file->setFilePath($filepath);
|
||||
}
|
||||
}
|
||||
else if ($mode == "delete") {
|
||||
} elseif ($mode == "delete") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -519,24 +515,25 @@ class ApiController extends Zend_Controller_Action
|
|||
$return_hash['error'] = "File doesn't exist in Airtime.";
|
||||
Logging::warn("Attempt to delete file that doesn't exist.
|
||||
Path: '$filepath'");
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
}
|
||||
else if ($mode == "delete_dir") {
|
||||
} elseif ($mode == "delete_dir") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||
|
||||
foreach($files as $file){
|
||||
foreach ($files as $file) {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
$return_hash['success'] = 1;
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
$return_hash['fileid'] = $file->getId();
|
||||
|
||||
return $return_hash;
|
||||
}
|
||||
|
||||
|
@ -554,19 +551,19 @@ class ApiController extends Zend_Controller_Action
|
|||
foreach ($request->getParams() as $k => $raw_json) {
|
||||
// Valid requests must start with mdXXX where XXX represents at
|
||||
// least 1 digit
|
||||
if( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
if ( !preg_match('/^md\d+$/', $k) ) { continue; }
|
||||
$info_json = json_decode($raw_json, $assoc = true);
|
||||
$recorded = $info_json["is_record"];
|
||||
unset( $info_json["is_record"] );
|
||||
// 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( $info_json );
|
||||
array_push( $responses, array(
|
||||
'error' => "Bad request. no 'mode' parameter passed.",
|
||||
'key' => $k));
|
||||
continue;
|
||||
} elseif ( !in_array($info_json['mode'], $valid_modes) ) {
|
||||
} elseif ( !in_array($info_json['mode'], $valid_modes) ) {
|
||||
// A request still has a chance of being invalid even if it
|
||||
// exists but it's validated by $valid_modes array
|
||||
$mode = $info_json['mode'];
|
||||
|
@ -631,7 +628,7 @@ class ApiController extends Zend_Controller_Action
|
|||
$file->setMetadata($md);
|
||||
}
|
||||
}
|
||||
} else if ($mode == "modify") {
|
||||
} elseif ($mode == "modify") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -645,7 +642,7 @@ class ApiController extends Zend_Controller_Action
|
|||
//Updating a metadata change.
|
||||
$file->setMetadata($md);
|
||||
}
|
||||
} else if ($mode == "moved") {
|
||||
} elseif ($mode == "moved") {
|
||||
$md5 = $md['MDATA_KEY_MD5'];
|
||||
$file = Application_Model_StoredFile::RecallByMd5($md5);
|
||||
|
||||
|
@ -658,7 +655,7 @@ class ApiController extends Zend_Controller_Action
|
|||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file->setFilePath($filepath);
|
||||
}
|
||||
} else if ($mode == "delete") {
|
||||
} elseif ($mode == "delete") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
|
||||
|
@ -670,7 +667,7 @@ class ApiController extends Zend_Controller_Action
|
|||
} else {
|
||||
$file->deleteByMediaMonitor();
|
||||
}
|
||||
} else if ($mode == "delete_dir") {
|
||||
} elseif ($mode == "delete_dir") {
|
||||
$filepath = $md['MDATA_KEY_FILEPATH'];
|
||||
//$filepath = str_replace("\\", "", $filepath);
|
||||
$files = Application_Model_StoredFile::RecallByPartialFilepath($filepath);
|
||||
|
@ -833,7 +830,7 @@ class ApiController extends Zend_Controller_Action
|
|||
// if mount path itself was watched
|
||||
if ($dirPath == $ad) {
|
||||
Application_Model_MusicDir::addWatchedDir($dirPath, false);
|
||||
} else if (substr($dirPath, 0, strlen($ad)) === $ad && $dir->getExistsFlag() == false) {
|
||||
} elseif (substr($dirPath, 0, strlen($ad)) === $ad && $dir->getExistsFlag() == false) {
|
||||
// if dir contains any dir in removed_list( if watched dir resides on new mounted path )
|
||||
Application_Model_MusicDir::addWatchedDir($dirPath, false);
|
||||
} elseif (substr($ad, 0, strlen($dirPath)) === $dirPath) {
|
||||
|
@ -983,7 +980,7 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
//connect to db and get get sql
|
||||
$rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100);
|
||||
|
||||
|
||||
echo json_encode($rows);
|
||||
}
|
||||
|
||||
|
@ -995,10 +992,10 @@ class ApiController extends Zend_Controller_Action
|
|||
|
||||
$request = $this->getRequest();
|
||||
$data = json_decode($request->getParam('data'));
|
||||
|
||||
|
||||
foreach ($data as $pair) {
|
||||
list($id, $gain) = $pair;
|
||||
|
||||
|
||||
$file = Application_Model_StoredFile::Recall($p_id = $id)->getPropelOrm();
|
||||
$file->setDbReplayGain($gain);
|
||||
$file->save();
|
||||
|
|
|
@ -29,14 +29,13 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
$this->view->headScript()->appendFile(
|
||||
$baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],
|
||||
$baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],
|
||||
'text/javascript');
|
||||
$this->view->headScript()->appendFile(
|
||||
$baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],
|
||||
$baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],
|
||||
'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet(
|
||||
$baseUrl.'/js/jplayer/skin/jplayer.airtime.audio.preview.css?'.$CC_CONFIG['airtime_version']);
|
||||
|
@ -53,7 +52,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
$uri = "/api/get-media/file/".$audioFileID;
|
||||
$media = Application_Model_StoredFile::Recall($audioFileID);
|
||||
$mime = $media->getPropelOrm()->getDbMime();
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
$webstream = CcWebstreamQuery::create()->findPk($audioFileID);
|
||||
$uri = $webstream->getDbUrl();
|
||||
$mime = $webstream->getDbMime();
|
||||
|
@ -107,20 +106,20 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
public function blockPreviewAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
|
||||
$blockIndex = $this->_getParam('blockIndex');
|
||||
$blockId = $this->_getParam('blockId');
|
||||
|
||||
|
||||
$request = $this->getRequest();
|
||||
$baseUrl = $request->getBaseUrl();
|
||||
|
||||
|
||||
$baseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
|
||||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/audiopreview/preview_jplayer.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jplayer.playlist.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->headLink()->appendStylesheet($baseUrl.'/js/jplayer/skin/jplayer.airtime.audio.preview.css?'.$CC_CONFIG['airtime_version']);
|
||||
$this->_helper->layout->setLayout('audioPlayer');
|
||||
|
||||
|
||||
$logo = Application_Model_Preference::GetStationLogo();
|
||||
if ($logo) {
|
||||
$this->view->logo = "data:image/png;base64,$logo";
|
||||
|
@ -129,7 +128,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
}
|
||||
$this->view->blockIndex= $blockIndex;
|
||||
$this->view->blockId = $blockId;
|
||||
|
||||
|
||||
$this->_helper->viewRenderer->setRender('audio-preview');
|
||||
}
|
||||
public function getBlockAction()
|
||||
|
@ -137,13 +136,13 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
|
||||
$blockId = $this->_getParam('blockId');
|
||||
|
||||
|
||||
if (!isset($blockId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$bl = new Application_Model_Block($blockId);
|
||||
$result = array();
|
||||
foreach ($bl->getContents(true) as $ele) {
|
||||
|
@ -168,7 +167,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
|
||||
$pl = new Application_Model_Playlist($playlistID);
|
||||
$result = Array();
|
||||
|
||||
|
||||
foreach ($pl->getContents(true) as $ele) {
|
||||
if ($ele['type'] == 2) {
|
||||
// if element is a block expand and add
|
||||
|
@ -184,15 +183,15 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
}
|
||||
$this->_helper->json($result);
|
||||
}
|
||||
|
||||
private function createElementMap($track)
|
||||
|
||||
private function createElementMap($track)
|
||||
{
|
||||
$elementMap = array( 'element_title' => isset($track['track_title'])?$track['track_title']:"",
|
||||
'element_artist' => isset($track['artist_name'])?$track['artist_name']:"",
|
||||
'element_id' => isset($track['id'])?$track['id']:"",
|
||||
'element_position' => isset($track['position'])?$track['position']:"",
|
||||
);
|
||||
|
||||
|
||||
/* If the track type is static we know it must be
|
||||
* a track because static blocks can only contain
|
||||
* tracks
|
||||
|
@ -208,7 +207,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
//TODO: use MIME type for this
|
||||
if (strtolower($fileExtension) === 'mp3') {
|
||||
$elementMap['element_mp3'] = $track['item_id'];
|
||||
} else if (strtolower($fileExtension) === 'ogg') {
|
||||
} elseif (strtolower($fileExtension) === 'ogg') {
|
||||
$elementMap['element_oga'] = $track['item_id'];
|
||||
} else {
|
||||
//the media was neither mp3 or ogg
|
||||
|
@ -219,6 +218,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
} else {
|
||||
$elementMap['uri'] = $track['path'];
|
||||
}
|
||||
|
||||
return $elementMap;
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ class AudiopreviewController extends Zend_Controller_Action
|
|||
'element_id' => ++$position,
|
||||
);
|
||||
|
||||
$elementMap['type'] = $track['type'];
|
||||
$elementMap['type'] = $track['type'];
|
||||
if ($track['type'] == 0) {
|
||||
$fileExtension = pathinfo($track['filepath'], PATHINFO_EXTENSION);
|
||||
if (strtolower($fileExtension) === 'mp3') {
|
||||
|
|
|
@ -65,7 +65,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
|
||||
if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) {
|
||||
$this->view->obj = $obj;
|
||||
if ($obj_sess->type == "block") {
|
||||
|
@ -74,7 +74,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->form = $form;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$formatter = new LengthFormatter($obj->getLength());
|
||||
$this->view->length = $formatter->format();
|
||||
$this->view->type = $obj_sess->type;
|
||||
|
@ -114,16 +114,16 @@ class LibraryController extends Zend_Controller_Action
|
|||
$isBlock = true;
|
||||
$viewPath = 'playlist/smart-block.phtml';
|
||||
}
|
||||
|
||||
|
||||
if (isset($obj)) {
|
||||
$formatter = new LengthFormatter($obj->getLength());
|
||||
$this->view->length = $formatter->format();
|
||||
|
||||
|
||||
if ($isBlock) {
|
||||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
$form->startForm($obj->getId());
|
||||
|
||||
|
||||
$this->view->form = $form;
|
||||
$this->view->obj = $obj;
|
||||
$this->view->id = $obj->getId();
|
||||
|
@ -143,7 +143,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function contextMenuAction()
|
||||
{
|
||||
$id = $this->_getParam('id');
|
||||
|
@ -172,13 +171,13 @@ class LibraryController extends Zend_Controller_Action
|
|||
// if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
|
||||
if ($obj_sess->type == 'playlist') {
|
||||
$obj = new Application_Model_Playlist($obj_sess->id);
|
||||
} else if ($obj_sess->type == 'block') {
|
||||
} elseif ($obj_sess->type == 'block') {
|
||||
$obj = new Application_Model_Block($obj_sess->id);
|
||||
}
|
||||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
if ($obj_sess->type === "playlist") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
|
||||
} else if ($obj_sess->type === "block") {
|
||||
} elseif ($obj_sess->type === "block") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy");
|
||||
}
|
||||
}
|
||||
|
@ -190,10 +189,10 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
||||
$menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
|
||||
} else if ($type === "playlist" || $type === "block") {
|
||||
} elseif ($type === "playlist" || $type === "block") {
|
||||
if ($type === 'playlist') {
|
||||
$obj = new Application_Model_Playlist($id);
|
||||
} else if ($type === 'block') {
|
||||
} elseif ($type === 'block') {
|
||||
$obj = new Application_Model_Block($id);
|
||||
if (!$obj->isStatic()) {
|
||||
unset($menu["play"]);
|
||||
|
@ -204,7 +203,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($obj_sess->id !== $id && $screen == "playlist") {
|
||||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
$menu["edit"] = array("name"=> "Edit", "icon" => "edit");
|
||||
|
@ -213,7 +212,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
$menu["del"] = array("name"=> "Delete", "icon" => "delete", "url" => "/library/delete");
|
||||
}
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
$obj = new Application_Model_Webstream($webstream);
|
||||
|
@ -256,7 +255,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}");
|
||||
}
|
||||
|
||||
|
||||
if (empty($menu)) {
|
||||
$menu["noaction"] = array("name"=>"No action available");
|
||||
}
|
||||
|
@ -296,10 +295,10 @@ class LibraryController extends Zend_Controller_Action
|
|||
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
||||
} catch (PlaylistNoPermissionException $e) {
|
||||
$this->view->message = "You don't have permission to delete selected items.";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
||||
} catch (Exception $e) {
|
||||
|
@ -425,7 +424,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$this->view->md = $md;
|
||||
|
||||
} else if ($type == "playlist") {
|
||||
} elseif ($type == "playlist") {
|
||||
|
||||
$file = new Application_Model_Playlist($id);
|
||||
$this->view->type = $type;
|
||||
|
@ -436,7 +435,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
|
||||
$this->view->md = $md;
|
||||
$this->view->contents = $file->getContents();
|
||||
} else if ($type == "block") {
|
||||
} elseif ($type == "block") {
|
||||
$block = new Application_Model_Block($id);
|
||||
$this->view->type = $type;
|
||||
$md = $block->getAllPLMetaData();
|
||||
|
@ -453,7 +452,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
$this->view->contents = $block->getCriteria();
|
||||
}
|
||||
$this->view->block = $block;
|
||||
} else if ($type == "stream") {
|
||||
} elseif ($type == "stream") {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
$ws = new Application_Model_Webstream($webstream);
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
private function createUpdateResponse($obj)
|
||||
{
|
||||
$formatter = new LengthFormatter($obj->getLength());
|
||||
|
@ -72,11 +71,11 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$isBlock = true;
|
||||
$viewPath = 'playlist/smart-block.phtml';
|
||||
}
|
||||
|
||||
|
||||
if (isset($obj)) {
|
||||
$formatter = new LengthFormatter($obj->getLength());
|
||||
$this->view->length = $formatter->format();
|
||||
|
||||
|
||||
if ($isBlock) {
|
||||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->removeDecorator('DtDdWrapper');
|
||||
|
@ -85,7 +84,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->view->form = $form;
|
||||
$this->view->obj = $obj;
|
||||
$this->view->id = $obj->getId();
|
||||
|
||||
|
||||
if ($isJson) {
|
||||
return $this->view->render($viewPath);
|
||||
} else {
|
||||
|
@ -112,7 +111,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->view->error = "You cannot add tracks to dynamic blocks.";
|
||||
$this->createFullResponse($obj);
|
||||
}
|
||||
|
||||
|
||||
private function playlistNotFound($p_type)
|
||||
{
|
||||
$this->view->error = "{$p_type} not found";
|
||||
|
@ -121,7 +120,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
Application_Model_Library::changePlaylist(null, $p_type);
|
||||
$this->createFullResponse(null);
|
||||
}
|
||||
|
||||
|
||||
private function playlistNoPermission($p_type)
|
||||
{
|
||||
$this->view->error = "You don't have permission to delete selected {$p_type}(s).";
|
||||
|
@ -137,13 +136,13 @@ class PlaylistController extends Zend_Controller_Action
|
|||
Logging::info("{$e->getLine()}");
|
||||
Logging::info("{$e->getMessage()}");
|
||||
}
|
||||
|
||||
|
||||
private function wrongTypeToBlock($obj)
|
||||
{
|
||||
$this->view->error = "You can only add tracks to smart block.";
|
||||
$this->createFullResponse($obj);
|
||||
}
|
||||
|
||||
|
||||
private function wrongTypeToPlaylist($obj)
|
||||
{
|
||||
$this->view->error = "You can only add tracks and smart blocks to playlists.";
|
||||
|
@ -155,9 +154,9 @@ class PlaylistController extends Zend_Controller_Action
|
|||
//$pl_sess = $this->pl_sess;
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
|
||||
$objInfo = Application_Model_Library::getObjInfo($type);
|
||||
|
||||
|
||||
$name = 'Untitled Playlist';
|
||||
if ($type == 'block') {
|
||||
$name = 'Untitled Smart Block';
|
||||
|
@ -170,7 +169,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
Application_Model_Library::changePlaylist($obj->getId(), $type);
|
||||
$this->createFullResponse($obj);
|
||||
}
|
||||
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
$id = $this->_getParam('id', null);
|
||||
|
@ -197,15 +196,14 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$ids = $this->_getParam('ids');
|
||||
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
|
||||
$obj = null;
|
||||
|
||||
|
||||
$objInfo = Application_Model_Library::getObjInfo($type);
|
||||
|
||||
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
||||
|
||||
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
||||
|
||||
try {
|
||||
|
@ -243,7 +241,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$addType = $this->_getParam('type', 'after');
|
||||
// this is the obj type of destination
|
||||
$obj_type = $this->_getParam('obj_type');
|
||||
|
||||
|
||||
try {
|
||||
$obj = $this->getPlaylist($obj_type);
|
||||
if ($obj_type == 'playlist') {
|
||||
|
@ -255,7 +253,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
$obj->addAudioClips($ids, $afterItem, $addType);
|
||||
} else if ($obj->isStatic()) {
|
||||
} elseif ($obj->isStatic()) {
|
||||
// if the dest is a block object
|
||||
//check if any items are playlists
|
||||
foreach ($ids as $id) {
|
||||
|
@ -274,17 +272,13 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->playlistOutdated($e);
|
||||
} catch (PlaylistNotFoundException $e) {
|
||||
$this->playlistNotFound($obj_type);
|
||||
}
|
||||
catch (WrongTypeToBlockException $e) {
|
||||
} catch (WrongTypeToBlockException $e) {
|
||||
$this->wrongTypeToBlock($obj);
|
||||
}
|
||||
catch (WrongTypeToPlaylistException $e) {
|
||||
} catch (WrongTypeToPlaylistException $e) {
|
||||
$this->wrongTypeToPlaylist($obj);
|
||||
}
|
||||
catch (BlockDynamicException $e) {
|
||||
} catch (BlockDynamicException $e) {
|
||||
$this->blockDynamic($obj);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
|
@ -430,7 +424,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$name = $this->_getParam('name', 'Unknown Playlist');
|
||||
$description = $this->_getParam('description', "");
|
||||
$type = $this->_getParam('type');
|
||||
|
||||
|
||||
try {
|
||||
$obj = $this->getPlaylist($type);
|
||||
$obj->setName($name);
|
||||
|
@ -446,15 +440,15 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
$result = array();
|
||||
|
||||
|
||||
$this->setPlaylistNameDescAction();
|
||||
|
||||
|
||||
if ($params['type'] == 'block') {
|
||||
$form = new Application_Form_SmartBlockCriteria();
|
||||
$form->startForm($params['obj_id']);
|
||||
|
@ -472,11 +466,11 @@ class PlaylistController extends Zend_Controller_Action
|
|||
$result['result'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$result["modified"] = $this->view->modified;
|
||||
die(json_encode($result));
|
||||
}
|
||||
|
||||
|
||||
public function smartBlockGenerateAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
@ -503,14 +497,14 @@ class PlaylistController extends Zend_Controller_Action
|
|||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function smartBlockShuffleAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$params = $request->getPost();
|
||||
$bl = new Application_Model_Block($params['obj_id']);
|
||||
$result = $bl->shuffleSmartBlock();
|
||||
|
||||
|
||||
if ($result['result'] == 0) {
|
||||
try {
|
||||
die(json_encode(array("result"=>0, "html"=>$this->createFullResponse($bl, true))));
|
||||
|
@ -521,7 +515,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
die(json_encode($result));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getBlockInfoAction()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
|
|
@ -118,7 +118,7 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$events = &Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
|
||||
$this->view->events = $events;
|
||||
}
|
||||
|
||||
|
||||
public function getCurrentShowAction()
|
||||
{
|
||||
$currentShow = Application_Model_Show::GetCurrentShow();
|
||||
|
|
|
@ -18,6 +18,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
if (!$this->isAuthorized(-1)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +39,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
/*
|
||||
$type = "stream";
|
||||
$objInfo = Application_Model_Library::getObjInfo($type);
|
||||
|
||||
|
||||
$obj = new $objInfo['className']($webstream);
|
||||
$obj->setName($webstream->getDbName());
|
||||
$obj->setMetadata('dc:creator', $userInfo->id);
|
||||
|
@ -60,10 +61,9 @@ class WebstreamController extends Zend_Controller_Action
|
|||
|
||||
$id = $request->getParam("id");
|
||||
if (is_null($id)) {
|
||||
throw new Exception("Missing parameter 'id'");
|
||||
throw new Exception("Missing parameter 'id'");
|
||||
}
|
||||
|
||||
|
||||
$webstream = CcWebstreamQuery::create()->findPK($id);
|
||||
if ($webstream) {
|
||||
Application_Model_Library::changePlaylist($id, "stream");
|
||||
|
@ -80,9 +80,10 @@ class WebstreamController extends Zend_Controller_Action
|
|||
|
||||
if (!$this->isAuthorized($id)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$type = "stream";
|
||||
Application_Model_Library::changePlaylist(null, $type);
|
||||
|
||||
|
@ -105,7 +106,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
if (!$hasPermission && $user->isHost()) {
|
||||
if ($webstream_id != -1) {
|
||||
$webstream = CcWebstreamQuery::create()->findPK($webstream_id);
|
||||
//we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission.
|
||||
//we are updating a playlist. Ensure that if the user is a host/dj, that he has the correct permission.
|
||||
$user = Application_Model_User::getCurrentUser();
|
||||
|
||||
if ($webstream->getDbCreatorId() == $user->getId()) {
|
||||
|
@ -135,12 +136,13 @@ class WebstreamController extends Zend_Controller_Action
|
|||
|
||||
if (!$this->isAuthorized($id)) {
|
||||
header("Status: 401 Not Authorized");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
list($analysis, $mime, $mediaUrl, $di) = Application_Model_Webstream::analyzeFormData($parameters);
|
||||
try {
|
||||
try {
|
||||
if (Application_Model_Webstream::isValid($analysis)) {
|
||||
$streamId = Application_Model_Webstream::save($parameters, $mime, $mediaUrl, $di);
|
||||
|
||||
|
@ -153,7 +155,7 @@ class WebstreamController extends Zend_Controller_Action
|
|||
}
|
||||
} catch (Exception $e) {
|
||||
Logging::debug($e->getMessage());
|
||||
$this->view->statusMessage = "<div class='errors'>Invalid form values.</div>";
|
||||
$this->view->statusMessage = "<div class='errors'>Invalid form values.</div>";
|
||||
$this->view->streamId = -1;
|
||||
$this->view->analysis = $analysis;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue