diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index 229ddad0f..b5edfbfb4 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -74,7 +74,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap //scripts for now playing bar $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript'); - //$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript'); $view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript'); diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 68ae26f61..8c08ae866 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -16,6 +16,7 @@ class PlaylistController extends Zend_Controller_Action ->addActionContext('edit', 'json') ->addActionContext('delete', 'json') ->addActionContext('set-playlist-fades', 'json') + ->addActionContext('get-playlist-fades', 'json') ->addActionContext('set-playlist-name', 'json') ->addActionContext('set-playlist-description', 'json') ->initContext(); @@ -265,52 +266,73 @@ class PlaylistController extends Zend_Controller_Action public function setFadeAction() { - $pos = $this->_getParam('pos'); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; - } - + $id = $this->_getParam('id'); $fadeIn = $this->_getParam('fadeIn', null); $fadeOut = $this->_getParam('fadeOut', null); - $response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut); + try { + $pl = $this->getPlaylist(); + $response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut); - $this->view->response = $response; + $this->view->response = $response; - if(!isset($response["error"])) { - $this->createUpdateResponse($pl); + if (!isset($response["error"])) { + $this->createUpdateResponse($pl); + } + } + catch (PlaylistNotFoundException $e) { + Logging::log("Playlist not found"); + $this->changePlaylist(null); + $this->createFullResponse(null); + } + catch (Exception $e) { + Logging::log("{$e->getFile()}"); + Logging::log("{$e->getLine()}"); + Logging::log("{$e->getMessage()}"); + } + } + + public function getPlaylistFadesAction() + { + try { + $pl = $this->getPlaylist(); + $fades = $pl->getFadeInfo(0); + $this->view->fadeIn = $fades[0]; + + $fades = $pl->getFadeInfo($pl->getSize()-1); + $this->view->fadeOut = $fades[1]; + } + catch (PlaylistNotFoundException $e) { + Logging::log("Playlist not found"); + $this->changePlaylist(null); + $this->createFullResponse(null); + } + catch (Exception $e) { + Logging::log("{$e->getFile()}"); + Logging::log("{$e->getLine()}"); + Logging::log("{$e->getMessage()}"); } } public function setPlaylistFadesAction() { - $request = $this->getRequest(); - $pl = $this->getPlaylist(); - if($pl === false){ - $this->view->playlist_error = true; - return false; + $fadeIn = $this->_getParam('fadeIn', null); + $fadeOut = $this->_getParam('fadeOut', null); + + try { + $pl = $this->getPlaylist(); + $pl->setPlaylistfades($fadeIn, $fadeOut); + } + catch (PlaylistNotFoundException $e) { + Logging::log("Playlist not found"); + $this->changePlaylist(null); + $this->createFullResponse(null); + } + catch (Exception $e) { + Logging::log("{$e->getFile()}"); + Logging::log("{$e->getLine()}"); + Logging::log("{$e->getMessage()}"); } - - if($request->isPost()) { - $fadeIn = $this->_getParam('fadeIn', null); - $fadeOut = $this->_getParam('fadeOut', null); - - if($fadeIn) - $response = $pl->changeFadeInfo(0, $fadeIn, $fadeOut); - else if($fadeOut) - $response = $pl->changeFadeInfo($pl->getSize(), $fadeIn, $fadeOut); - - $this->view->response = $response; - return; - } - - $fades = $pl->getFadeInfo(0); - $this->view->fadeIn = $fades[0]; - - $fades = $pl->getFadeInfo($pl->getSize()); - $this->view->fadeOut = $fades[1]; } public function setPlaylistNameAction() diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 89d7a32f4..a2653e9e5 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -389,6 +389,8 @@ class Application_Model_Playlist { public function getFadeInfo($pos) { + Logging::log("Getting fade info for pos {$pos}"); + $row = CcPlaylistcontentsQuery::create() ->joinWith(CcFilesPeer::OM_CLASS) ->filterByDbPlaylistId($this->id) @@ -412,21 +414,18 @@ class Application_Model_Playlist { * new value in ss.ssssss or extent format * @return boolean */ - public function changeFadeInfo($pos, $fadeIn, $fadeOut) + public function changeFadeInfo($id, $fadeIn, $fadeOut) { $errArray= array(); $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); - if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) { - $errArray["error"]="Invalid position."; + $row = CcPlaylistcontentsQuery::create()->findPK($id); + + if (is_null($row)) { + $errArray["error"]="Playlist item does not exist."; return $errArray; } - $row = CcPlaylistcontentsQuery::create() - ->filterByDbPlaylistId($this->id) - ->filterByDbPosition($pos) - ->findOne(); - $clipLength = $row->getDbCliplength(); if(!is_null($fadeIn)) { @@ -457,6 +456,28 @@ class Application_Model_Playlist { return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); } + public function setPlaylistfades($fadein, $fadeout) { + + if (isset($fadein)) { + Logging::log("Setting playlist fade in {$fadein}"); + $row = CcPlaylistcontentsQuery::create() + ->filterByDbPlaylistId($this->id) + ->filterByDbPosition(0) + ->findOne(); + + $this->changeFadeInfo($row->getDbId(), $fadein, null); + } + + if (isset($fadeout)) { + $row = CcPlaylistcontentsQuery::create() + ->filterByDbPlaylistId($this->id) + ->filterByDbPosition($this->getSize()-1) + ->findOne(); + + $this->changeFadeInfo($row->getDbId(), null, $fadeout); + } + } + /** * Change cueIn/cueOut values for playlist element * diff --git a/airtime_mvc/application/views/scripts/playlist/set-fade.phtml b/airtime_mvc/application/views/scripts/playlist/set-fade.phtml index 1c9135323..4a55fb2db 100644 --- a/airtime_mvc/application/views/scripts/playlist/set-fade.phtml +++ b/airtime_mvc/application/views/scripts/playlist/set-fade.phtml @@ -1,11 +1,11 @@
Fade out:
-
+
fadeOut; ?>
Fade in:
-
+
fadeIn; ?>
diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index ff45eb417..fb80db6a8 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -43,7 +43,8 @@ if (count($items)) : ?> ?> diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 1b891528c..3f3bb8b33 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -215,7 +215,6 @@ function fnCreatedRow( nRow, aData, iDataIndex ) { //call the context menu so we can prevent the event from propagating. $(nRow).find('td:not(.library_checkbox):not(.library_type)').click(function(e){ - var x; $(this).contextMenu(); @@ -390,7 +389,7 @@ $(document).ready(function() { setInterval( checkSCUploadStatus, 5000 ); addQtipToSCIcons(); - + $.contextMenu({ selector: '#library_display td:not(.library_checkbox):not(.library_type)', trigger: "left", diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 553e42196..d5363c65a 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -114,10 +114,10 @@ var AIRTIME = (function(AIRTIME){ function changeFadeIn(event) { event.stopPropagation(); - var pos, url, fadeIn, li, unqid; + var id, url, fadeIn, li, unqid; span = $(this); - pos = span.parent().attr("id").split("_").pop(); + id = span.parent().attr("id").split("_").pop(); url = "/Playlist/set-fade"; fadeIn = $.trim(span.text()); li = span.parent().parent().parent().parent(); @@ -128,7 +128,7 @@ var AIRTIME = (function(AIRTIME){ return; } - $.post(url, {format: "json", fadeIn: fadeIn, pos: pos}, function(json){ + $.post(url, {format: "json", fadeIn: fadeIn, id: id}, function(json){ if(json.response !== undefined && json.response.error) { showError(span, json.response.error); @@ -146,10 +146,10 @@ var AIRTIME = (function(AIRTIME){ function changeFadeOut(event) { event.stopPropagation(); - var pos, url, fadeOut, li, unqid; + var id, url, fadeOut, li, unqid; span = $(this); - pos = span.parent().attr("id").split("_").pop(); + id = span.parent().attr("id").split("_").pop(); url = "/Playlist/set-fade"; fadeOut = $.trim(span.text()); li = span.parent().parent().parent().parent(); @@ -160,7 +160,7 @@ var AIRTIME = (function(AIRTIME){ return; } - $.post(url, {format: "json", fadeOut: fadeOut, pos: pos}, function(json){ + $.post(url, {format: "json", fadeOut: fadeOut, id: id}, function(json){ if(json.response !== undefined && json.response.error) { showError(span, json.response.error); return; @@ -341,7 +341,7 @@ var AIRTIME = (function(AIRTIME){ else { $(this).addClass("ui-state-active"); - var url = '/Playlist/set-playlist-fades'; + var url = '/Playlist/get-playlist-fades'; $.get(url, {format: "json"}, function(json){ if(json.playlist_error == true){ @@ -425,21 +425,15 @@ var AIRTIME = (function(AIRTIME){ } $.post(url, {format: "json", fadeIn: fadeIn}, function(json){ - if(json.playlist_error == true){ - alertPlaylistErrorAndReload(); - } - if(json.response.error) { - return; - } - - hideError(span); + + hideError(span); }); }); - playlist.find("#spl_fade_out_main span:first").on("blur", function(event){ + playlist.find("#spl_fade_out_main span:last").on("blur", function(event){ event.stopPropagation(); - var url, fadeIn, span; + var url, fadeOut, span; span = $(this); url = "/Playlist/set-playlist-fades"; @@ -451,14 +445,8 @@ var AIRTIME = (function(AIRTIME){ } $.post(url, {format: "json", fadeOut: fadeOut}, function(json){ - if(json.playlist_error == true){ - alertPlaylistErrorAndReload(); - } - if(json.response.error) { - return; - } - - hideError(span); + + hideError(span); }); });