From 38f3d6bfb06f3f2ecc8ac8a4441c4c7ce6f00d9c Mon Sep 17 00:00:00 2001 From: Naomi Aro Date: Sat, 4 Feb 2012 19:27:26 +0100 Subject: [PATCH] CC-3174: showbuilder/library refactoring adding new context menu files, playlist is working except for editing fades. --- .../controllers/PlaylistController.php | 47 +- airtime_mvc/application/models/Playlist.php | 49 +- .../views/scripts/playlist/set-cue.phtml | 4 +- .../views/scripts/playlist/update.phtml | 2 +- .../public/css/contextmenu/images/cut.png | Bin 0 -> 648 bytes .../public/css/contextmenu/images/door.png | Bin 0 -> 412 bytes .../contextmenu/images/page_white_copy.png | Bin 0 -> 309 bytes .../contextmenu/images/page_white_delete.png | Bin 0 -> 536 bytes .../contextmenu/images/page_white_edit.png | Bin 0 -> 618 bytes .../contextmenu/images/page_white_paste.png | Bin 0 -> 620 bytes .../css/contextmenu/jquery.contextMenu.css | 134 ++ .../library/events/library_playlistbuilder.js | 2 +- airtime_mvc/public/js/airtime/library/spl.js | 975 +++++------ .../js/contextmenu/jquery.contextMenu.js | 1449 +++++++++++++++++ 14 files changed, 2124 insertions(+), 538 deletions(-) create mode 100755 airtime_mvc/public/css/contextmenu/images/cut.png create mode 100755 airtime_mvc/public/css/contextmenu/images/door.png create mode 100755 airtime_mvc/public/css/contextmenu/images/page_white_copy.png create mode 100755 airtime_mvc/public/css/contextmenu/images/page_white_delete.png create mode 100755 airtime_mvc/public/css/contextmenu/images/page_white_edit.png create mode 100755 airtime_mvc/public/css/contextmenu/images/page_white_paste.png create mode 100755 airtime_mvc/public/css/contextmenu/jquery.contextMenu.css create mode 100755 airtime_mvc/public/js/contextmenu/jquery.contextMenu.js diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index c508f5037..04915c07b 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -165,15 +165,18 @@ class PlaylistController extends Zend_Controller_Action $ids = $this->_getParam('ids'); $ids = (!is_array($ids)) ? array($ids) : $ids; $afterItem = $this->_getParam('afterItem', null); - //$afterItem = (!is_numeric($afterItem)) ? null : intval($afterItem); + $addType = $this->_getParam('type', 'after'); + + Logging::log("type is ".$addType); try { $pl = $this->getPlaylist(); - $pl->addAudioClips($ids, $afterItem); + $pl->addAudioClips($ids, $afterItem, $addType); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist {$pl_id} not found"); + Logging::log("Playlist not found"); $this->changePlaylist(null); + $this->createFullResponse(null); } catch (Exception $e) { Logging::log("{$e->getFile()}"); @@ -189,15 +192,15 @@ class PlaylistController extends Zend_Controller_Action $ids = $this->_getParam('ids'); $ids = (!is_array($ids)) ? array($ids) : $ids; $afterItem = $this->_getParam('afterItem', null); - //$afterItem = (!is_numeric($afterItem)) ? null : intval($afterItem); try { $pl = $this->getPlaylist(); $pl->moveAudioClips($ids, $afterItem); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist {$pl_id} not found"); + Logging::log("Playlist not found"); $this->changePlaylist(null); + $this->createFullResponse(null); } catch (Exception $e) { Logging::log("{$e->getFile()}"); @@ -218,8 +221,9 @@ class PlaylistController extends Zend_Controller_Action $pl->delAudioClips($ids); } catch (PlaylistNotFoundException $e) { - Logging::log("Playlist {$pl_id} not found"); + Logging::log("Playlist not found"); $this->changePlaylist(null); + $this->createFullResponse(null); } catch (Exception $e) { Logging::log("{$e->getFile()}"); @@ -232,23 +236,30 @@ class PlaylistController extends Zend_Controller_Action public function setCueAction() { - $pos = $this->_getParam('pos'); - $pl = $this->getPlaylist(); - if ($pl === false){ - $this->view->playlist_error = true; - return false; - } - + $id = $this->_getParam('id'); $cueIn = $this->_getParam('cueIn', null); $cueOut = $this->_getParam('cueOut', null); - $response = $pl->changeClipLength($pos, $cueIn, $cueOut); + try { + $pl = $this->getPlaylist(); + $response = $pl->changeClipLength($id, $cueIn, $cueOut); - $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 setFadeAction() diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 2023da474..f88053ff8 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -209,8 +209,10 @@ class Application_Model_Playlist { * an array of audioclips to add to the playlist * @param int|null $p_afterItem * item which to add the new items after in the playlist, null if added to the end. + * @param string (before|after) $addAfter + * whether to add the clips before or after the selected item. */ - public function addAudioClips($p_items, $p_afterItem=NULL) + public function addAudioClips($p_items, $p_afterItem=NULL, $addType = 'after') { $this->con->beginTransaction(); $contentsToUpdate = array(); @@ -221,11 +223,14 @@ class Application_Model_Playlist { Logging::log("Finding playlist content item {$p_afterItem}"); $afterItem = CcPlaylistcontentsQuery::create()->findPK($p_afterItem); - $pos = $afterItem->getDbPosition() + 1; + + $index = $afterItem->getDbPosition(); + Logging::log("index is {$index}"); + $pos = ($addType == 'after') ? $index + 1 : $index; $contentsToUpdate = CcPlaylistcontentsQuery::create() ->filterByDbPlaylistId($this->id) - ->filterByDbPosition($pos-1, Criteria::GREATER_THAN) + ->filterByDbPosition($pos, Criteria::GREATER_EQUAL) ->orderByDbPosition() ->find($this->con); @@ -234,8 +239,9 @@ class Application_Model_Playlist { } else { - $pos = $this->getSize(); - Logging::log("Adding to end of playlist"); + $pos = ($addType == 'after') ? $this->getSize() : 0; + + Logging::log("Adding to playlist"); Logging::log("at position {$pos}"); } @@ -449,22 +455,6 @@ class Application_Model_Playlist { return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); } - public function getCueInfo($pos) { - - $row = CcPlaylistcontentsQuery::create() - ->joinWith(CcFilesPeer::OM_CLASS) - ->filterByDbPlaylistId($this->id) - ->filterByDbPosition($pos) - ->findOne(); - - $file = $row->getCcFiles(); - $origLength = $file->getDbLength(); - $cueIn = $row->getDBCuein(); - $cueOut = $row->getDbCueout(); - - return array($cueIn, $cueOut, $origLength); - } - /** * Change cueIn/cueOut values for playlist element * @@ -476,27 +466,26 @@ class Application_Model_Playlist { * new value in ss.ssssss or extent format * @return boolean or pear error object */ - public function changeClipLength($pos, $cueIn, $cueOut) + public function changeClipLength($id, $cueIn, $cueOut) { $errArray= array(); $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); - if(is_null($cueIn) && is_null($cueOut)) { + if (is_null($cueIn) && is_null($cueOut)) { $errArray["error"]="Cue in and cue out are null."; return $errArray; } - if(is_null($pos) || $pos < 0 || $pos >= $this->getNextPos()) { - $errArray["error"]="Invalid position."; - return $errArray; - } - $row = CcPlaylistcontentsQuery::create() ->joinWith(CcFilesPeer::OM_CLASS) - ->filterByDbPlaylistId($this->id) - ->filterByDbPosition($pos) + ->filterByPrimaryKey($id) ->findOne(); + if (is_null($row)) { + $errArray["error"]="Playlist item does not exist!."; + return $errArray; + } + $oldCueIn = $row->getDBCuein(); $oldCueOut = $row->getDbCueout(); $fadeIn = $row->getDbFadein(); diff --git a/airtime_mvc/application/views/scripts/playlist/set-cue.phtml b/airtime_mvc/application/views/scripts/playlist/set-cue.phtml index eb35d17fc..4b44e51ac 100644 --- a/airtime_mvc/application/views/scripts/playlist/set-cue.phtml +++ b/airtime_mvc/application/views/scripts/playlist/set-cue.phtml @@ -1,11 +1,11 @@
Cue In:
-
+
cueIn; ?>
Cue Out:
-
+
cueOut; ?>
diff --git a/airtime_mvc/application/views/scripts/playlist/update.phtml b/airtime_mvc/application/views/scripts/playlist/update.phtml index 464f6a58a..ff45eb417 100644 --- a/airtime_mvc/application/views/scripts/playlist/update.phtml +++ b/airtime_mvc/application/views/scripts/playlist/update.phtml @@ -30,7 +30,7 @@ if (count($items)) : ?>