Merge branch 'CC-3174' into devel

This commit is contained in:
Naomi Aro 2012-02-20 20:09:49 +01:00
commit a633d69c8d
7 changed files with 584 additions and 474 deletions

View file

@ -30,6 +30,12 @@ class PlaylistController extends Zend_Controller_Action
if (isset($this->pl_sess->id)) { if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id); $pl = new Application_Model_Playlist($this->pl_sess->id);
$modified = $this->_getParam('modified', null);
if ($pl->getLastModified("U") !== $modified) {
$this->createFullResponse($pl);
throw new PlaylistOutDatedException("You are viewing an older version of {$pl->getName()}");
}
} }
return $pl; return $pl;
} }
@ -51,6 +57,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->name = $pl->getName(); $this->view->name = $pl->getName();
$this->view->length = $pl->getLength(); $this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription(); $this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
unset($this->view->pl); unset($this->view->pl);
} }
@ -68,10 +75,33 @@ class PlaylistController extends Zend_Controller_Action
} }
} }
private function playlistOutdated($pl, $e)
{
$this->view->error = $e->getMessage();
}
private function playlistNotFound()
{
$this->view->error = "Playlist not found";
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
}
private function playlistUnknownError($e)
{
$this->view->error = "Something went wrong.";
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
}
public function indexAction() public function indexAction()
{ {
global $CC_CONFIG; global $CC_CONFIG;
$request = $this->getRequest(); $request = $this->getRequest();
$baseUrl = $request->getBaseUrl(); $baseUrl = $request->getBaseUrl();
@ -81,18 +111,16 @@ class PlaylistController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('spl'); $this->_helper->viewRenderer->setResponseSegment('spl');
try { try {
$pl = $this->getPlaylist(); if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
if (isset($pl)) { $this->view->pl = $pl;
$this->view->pl = $pl;
} }
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getMessage()}"); $this->playlistUnknownError($e);
} }
} }
@ -119,20 +147,15 @@ class PlaylistController extends Zend_Controller_Action
} }
try { try {
$pl = $this->getPlaylist(); $pl = new Application_Model_Playlist($id);
$this->createFullResponse($pl);
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist {$id} not found"); $this->playlistNotFound();
$this->changePlaylist(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->changePlaylist(null);
} }
$this->createFullResponse($pl);
} }
public function deleteAction() public function deleteAction()
@ -150,23 +173,18 @@ class PlaylistController extends Zend_Controller_Action
} }
else { else {
Logging::log("Not deleting currently active playlist"); Logging::log("Not deleting currently active playlist");
$pl = new Application_Model_Playlist($this->pl_sess->id);
} }
Application_Model_Playlist::DeletePlaylists($ids); Application_Model_Playlist::DeletePlaylists($ids);
$pl = $this->getPlaylist(); $this->createFullResponse($pl);
} }
catch(PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$pl = null;
} }
catch(Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
$this->createFullResponse($pl);
} }
public function addItemsAction() public function addItemsAction()
@ -176,24 +194,20 @@ class PlaylistController extends Zend_Controller_Action
$afterItem = $this->_getParam('afterItem', null); $afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after'); $addType = $this->_getParam('type', 'after');
Logging::log("type is ".$addType);
try { try {
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$pl->addAudioClips($ids, $afterItem, $addType); $pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
$this->createUpdateResponse($pl);
} }
public function moveItemsAction() public function moveItemsAction()
@ -201,46 +215,44 @@ class PlaylistController extends Zend_Controller_Action
$ids = $this->_getParam('ids'); $ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids; $ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null); $afterItem = $this->_getParam('afterItem', null);
$modified = $this->_getParam('modified');
try { try {
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$pl->moveAudioClips($ids, $afterItem); $pl->moveAudioClips($ids, $afterItem);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
$this->createUpdateResponse($pl);
} }
public function deleteItemsAction() public function deleteItemsAction()
{ {
$ids = $this->_getParam('ids'); $ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids; $ids = (!is_array($ids)) ? array($ids) : $ids;
$modified = $this->_getParam('modified');
try { try {
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$pl->delAudioClips($ids); $pl->delAudioClips($ids);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
$this->createUpdateResponse($pl);
} }
public function setCueAction() public function setCueAction()
@ -253,21 +265,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$response = $pl->changeClipLength($id, $cueIn, $cueOut); $response = $pl->changeClipLength($id, $cueIn, $cueOut);
$this->view->response = $response; if (!isset($response["error"])) {
$this->view->response = $response;
if(!isset($response["error"])) {
$this->createUpdateResponse($pl); $this->createUpdateResponse($pl);
} }
else {
$this->view->cue_error = $response["error"];
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
} }
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
} }
@ -281,21 +294,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut); $response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
$this->view->response = $response;
if (!isset($response["error"])) { if (!isset($response["error"])) {
$this->createUpdateResponse($pl); $this->createUpdateResponse($pl);
$this->view->response = $response;
}
else {
$this->view->fade_error = $response["error"];
} }
} }
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
} }
@ -309,15 +323,14 @@ class PlaylistController extends Zend_Controller_Action
$fades = $pl->getFadeInfo($pl->getSize()-1); $fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1]; $this->view->fadeOut = $fades[1];
} }
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
} }
@ -335,15 +348,14 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist(); $pl = $this->getPlaylist();
$pl->setPlaylistfades($fadeIn, $fadeOut); $pl->setPlaylistfades($fadeIn, $fadeOut);
} }
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) { catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found"); $this->playlistNotFound();
$this->changePlaylist(null);
$this->createFullResponse(null);
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log("{$e->getFile()}"); $this->playlistUnknownError($e);
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
} }
} }
@ -351,33 +363,42 @@ class PlaylistController extends Zend_Controller_Action
{ {
$name = $this->_getParam('name', 'Unknown Playlist'); $name = $this->_getParam('name', 'Unknown Playlist');
$pl = $this->getPlaylist(); try {
if($pl === false){ $pl = $this->getPlaylist();
$this->view->playlist_error = true; $pl->setName($name);
return false; $this->view->playlistName = $name;
$this->view->modified = $pl->getLastModified("U");
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
} }
$pl->setName($name);
$this->view->playlistName = $name;
} }
public function setPlaylistDescriptionAction() public function setPlaylistDescriptionAction()
{ {
$description = $this->_getParam('description', false); $description = $this->_getParam('description', "");
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
if($description != false) { try {
$pl = $this->getPlaylist();
$pl->setDescription($description); $pl->setDescription($description);
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
} }
else { catch (PlaylistOutDatedException $e) {
$description = $pl->getDescription(); $this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch (Exception $e) {
$this->playlistUnknownError($e);
} }
$this->view->playlistDescription = $description;
} }
} }

View file

@ -89,7 +89,7 @@ class Application_Model_Playlist {
public function setName($p_newname) public function setName($p_newname)
{ {
$this->pl->setDbName($p_newname); $this->pl->setDbName($p_newname);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
} }
@ -106,7 +106,7 @@ class Application_Model_Playlist {
public function setDescription($p_description) public function setDescription($p_description)
{ {
$this->pl->setDbDescription($p_description); $this->pl->setDbDescription($p_description);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
} }
@ -123,7 +123,7 @@ class Application_Model_Playlist {
public function setCreator($p_id) { public function setCreator($p_id) {
$this->pl->setDbCreatorId($p_id); $this->pl->setDbCreatorId($p_id);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
} }
@ -218,13 +218,18 @@ class Application_Model_Playlist {
{ {
$file = CcFilesQuery::create()->findPK($p_item, $this->con); $file = CcFilesQuery::create()->findPK($p_item, $this->con);
$entry = $this->plItem; if (isset($file) && $file->getDbFileExists()) {
$entry["id"] = $file->getDbId(); $entry = $this->plItem;
$entry["pos"] = $pos; $entry["id"] = $file->getDbId();
$entry["cliplength"] = $file->getDbLength(); $entry["pos"] = $pos;
$entry["cueout"] = $file->getDbLength(); $entry["cliplength"] = $file->getDbLength();
$entry["cueout"] = $file->getDbLength();
return $entry; return $entry;
}
else {
throw new Exception("trying to add a file that does not exist.");
}
} }
/* /*
@ -300,7 +305,7 @@ class Application_Model_Playlist {
$pos = $pos + 1; $pos = $pos + 1;
} }
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
$this->con->commit(); $this->con->commit();
@ -383,7 +388,7 @@ class Application_Model_Playlist {
$this->pl = CcPlaylistQuery::create()->findPK($this->id); $this->pl = CcPlaylistQuery::create()->findPK($this->id);
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
} }
@ -415,7 +420,7 @@ class Application_Model_Playlist {
$contents[$i]->save($this->con); $contents[$i]->save($this->con);
} }
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC")); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con); $this->pl->save($this->con);
$this->con->commit(); $this->con->commit();
@ -462,47 +467,52 @@ class Application_Model_Playlist {
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn; $fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut; $fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
$this->con->beginTransaction();
$errArray= array(); $errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$row = CcPlaylistcontentsQuery::create()->findPK($id);
if (is_null($row)) {
$errArray["error"]="Playlist item does not exist.";
return $errArray;
}
$clipLength = $row->getDbCliplength();
if(!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
//"Fade In can't be larger than overall playlength.";
$fadeIn = $clipLength;
}
$row->setDbFadein($fadeIn);
}
if(!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
//Fade Out can't be larger than overall playlength.";
$fadeOut = $clipLength;
}
$row->setDbFadeout($fadeOut);
}
try { try {
$row->save(); $row = CcPlaylistcontentsQuery::create()->findPK($id);
if (is_null($row)) {
throw new Exception("Playlist item does not exist.");
}
$clipLength = $row->getDbCliplength();
if (!is_null($fadeIn)) {
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//"Fade In can't be larger than overall playlength.";
$fadeIn = $clipLength;
}
$row->setDbFadein($fadeIn);
}
if (!is_null($fadeOut)){
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$clipLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
//Fade Out can't be larger than overall playlength.";
$fadeOut = $clipLength;
}
$row->setDbFadeout($fadeOut);
}
$row->save($this->con);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
} }
catch (Exception $e) { catch (Exception $e) {
Logging::log($e->getMessage()); $this->con->rollback();
throw $e;
} }
return array("fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut); return array("fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
} }
public function setPlaylistfades($fadein, $fadeout) { public function setPlaylistfades($fadein, $fadeout) {
@ -512,7 +522,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create() $row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id) ->filterByDbPlaylistId($this->id)
->filterByDbPosition(0) ->filterByDbPosition(0)
->findOne(); ->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), $fadein, null); $this->changeFadeInfo($row->getDbId(), $fadein, null);
} }
@ -521,7 +531,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create() $row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id) ->filterByDbPlaylistId($this->id)
->filterByDbPosition($this->getSize()-1) ->filterByDbPosition($this->getSize()-1)
->findOne(); ->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), null, $fadeout); $this->changeFadeInfo($row->getDbId(), null, $fadeout);
} }
@ -540,126 +550,135 @@ class Application_Model_Playlist {
*/ */
public function changeClipLength($id, $cueIn, $cueOut) public function changeClipLength($id, $cueIn, $cueOut)
{ {
$this->con->beginTransaction();
$errArray= array(); $errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
if (is_null($cueIn) && is_null($cueOut)) { try {
$errArray["error"]="Cue in and cue out are null."; if (is_null($cueIn) && is_null($cueOut)) {
return $errArray; $errArray["error"] = "Cue in and cue out are null.";
}
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->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();
$fadeOut = $row->getDbFadeout();
$file = $row->getCcFiles();
$origLength = $file->getDbLength();
if(!is_null($cueIn) && !is_null($cueOut)){
if($cueOut === ""){
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
$errArray["error"]= "Can't set cue in to be larger than cue out.";
return $errArray; return $errArray;
} }
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; $row = CcPlaylistcontentsQuery::create()
$r = $con->query($sql); ->joinWith(CcFilesPeer::OM_CLASS)
if($r->fetchColumn(0)){ ->filterByPrimaryKey($id)
$errArray["error"] = "Can't set cue out to be greater than file length."; ->findOne($this->con);
return $errArray;
if (is_null($row)) {
throw new Exception("Playlist item does not exist.");
} }
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'"; $oldCueIn = $row->getDBCuein();
$r = $con->query($sql); $oldCueOut = $row->getDbCueout();
$cliplength = $r->fetchColumn(0); $fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
$row->setDbCuein($cueIn); $file = $row->getCcFiles($this->con);
$row->setDbCueout($cueOut); $origLength = $file->getDbLength();
$row->setDBCliplength($cliplength);
} if (!is_null($cueIn) && !is_null($cueOut)){
else if(!is_null($cueIn)) {
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'"; if ($cueOut === ""){
$r = $con->query($sql); $cueOut = $origLength;
if($r->fetchColumn(0)) { }
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray; $sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$cueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
}
else if (!is_null($cueIn)) {
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
}
else if (!is_null($cueOut)) {
if ($cueOut === ""){
$cueOut = $origLength;
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue out to be smaller than cue in.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
$r = $this->con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
} }
$sql = "SELECT INTERVAL '{$oldCueOut}' - INTERVAL '{$cueIn}'"; $cliplength = $row->getDbCliplength();
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCuein($cueIn); $sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$row->setDBCliplength($cliplength); $r = $this->con->query($sql);
} if ($r->fetchColumn(0)){
else if(!is_null($cueOut)) { $fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
if($cueOut === ""){
$cueOut = $origLength;
} }
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'"; $sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $con->query($sql); $r = $this->con->query($sql);
if($r->fetchColumn(0)) { if ($r->fetchColumn(0)){
$errArray["error"] ="Can't set cue out to be smaller than cue in."; $fadeOut = $cliplength;
return $errArray; $row->setDbFadein($fadeOut);
} }
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'"; $row->save($this->con);
$r = $con->query($sql); $this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
if($r->fetchColumn(0)){ $this->pl->save($this->con);
$errArray["error"] ="Can't set cue out to be greater than file length.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'"; $this->con->commit();
$r = $con->query($sql); }
$cliplength = $r->fetchColumn(0); catch (Exception $e) {
$this->con->rollback();
$row->setDbCueout($cueOut); throw $e;
$row->setDBCliplength($cliplength);
} }
$cliplength = $row->getDbCliplength(); return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(),
"fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);
}
$row->save();
return array("cliplength"=>$cliplength, "cueIn"=>$cueIn, "cueOut"=>$cueOut, "length"=>$this->getLength(),
"fadeIn"=>$fadeIn, "fadeOut"=>$fadeOut);
} }
public function getAllPLMetaData() public function getAllPLMetaData()

View file

@ -556,7 +556,7 @@ class Application_Model_StoredFile {
* *
* @return string $runtime * @return string $runtime
*/ */
private static function formatDuration($dt){ private static function formatDuration($dt) {
$hours = $dt->format("H"); $hours = $dt->format("H");
$min = $dt->format("i"); $min = $dt->format("i");
@ -569,7 +569,7 @@ class Application_Model_StoredFile {
$hours = $p_interval->format("%h"); $hours = $p_interval->format("%h");
$mins = $p_interval->format("%i"); $mins = $p_interval->format("%i");
if( $hours == 0) { if ( $hours == 0) {
$runtime = $p_interval->format("%i:%S"); $runtime = $p_interval->format("%i:%S");
} }
else { else {
@ -579,8 +579,7 @@ class Application_Model_StoredFile {
return $runtime; return $runtime;
} }
public static function searchFilesForPlaylistBuilder($datatables) public static function searchFilesForPlaylistBuilder($datatables) {
{
global $CC_CONFIG; global $CC_CONFIG;
$displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number"); $displayData = array("track_title", "artist_name", "album_title", "genre", "length", "year", "utime", "mtime", "ftype", "track_number");
@ -610,9 +609,6 @@ class Application_Model_StoredFile {
} else if ($key === "mtime") { } else if ($key === "mtime") {
$plSelect .= $key.", "; $plSelect .= $key.", ";
$fileSelect .= $key.", "; $fileSelect .= $key.", ";
} else if ($key === "track_number") {
$plSelect .= "NULL AS ".$key.", ";
$fileSelect .= $key.", ";
} else { } else {
$plSelect .= "NULL AS ".$key.", "; $plSelect .= "NULL AS ".$key.", ";
$fileSelect .= $key.", "; $fileSelect .= $key.", ";
@ -624,10 +620,10 @@ class Application_Model_StoredFile {
UNION UNION
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS"; (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES WHERE file_exists = 'TRUE')) AS RESULTS";
$results = Application_Model_StoredFile::searchFiles($fromTable, $datatables); $results = Application_Model_StoredFile::searchFiles($fromTable, $datatables);
foreach($results['aaData'] as &$row){ foreach ($results['aaData'] as &$row) {
$row['id'] = intval($row['id']); $row['id'] = intval($row['id']);
@ -649,7 +645,7 @@ class Application_Model_StoredFile {
//TODO url like this to work on both playlist/showbuilder screens. //TODO url like this to work on both playlist/showbuilder screens.
//datatable stuff really needs to be pulled out and generalized within the project //datatable stuff really needs to be pulled out and generalized within the project
//access to zend view methods to access url helpers is needed. //access to zend view methods to access url helpers is needed.
if($type == "au") { if ($type == "au") {
$row['image'] = '<img src="/css/images/icon_audioclip.png">'; $row['image'] = '<img src="/css/images/icon_audioclip.png">';
} }
else { else {
@ -738,7 +734,7 @@ class Application_Model_StoredFile {
} }
//display sql executed in airtime log for testing //display sql executed in airtime log for testing
//Logging::log($sql); Logging::log($sql);
$results = $CC_DBC->getAll($sql); $results = $CC_DBC->getAll($sql);

View file

@ -19,7 +19,16 @@ var AIRTIME = (function(AIRTIME){
mod.fnDrawCallback = function() { mod.fnDrawCallback = function() {
$('#library_display tr:not(:first)').draggable({ $('#library_display tr:not(:first)').draggable({
helper: 'clone', //helper: 'clone',
helper: function(){
var selected = $('#library_display input:checked').parents('tr');
if (selected.length === 0) {
selected = $(this);
}
var container = $('<div/>').attr('id', 'draggingContainer');
container.append(selected.clone());
return container;
},
cursor: 'pointer', cursor: 'pointer',
connectToSortable: '#show_builder_table' connectToSortable: '#show_builder_table'
}); });
@ -63,9 +72,7 @@ var AIRTIME = (function(AIRTIME){
} }
} }
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds, function(){ AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
oLibTT.fnSelectNone();
});
}; };
//[0] = button text //[0] = button text

View file

@ -300,18 +300,18 @@ function createDataTable(data) {
}, },
"aoColumns": [ "aoColumns": [
/* Checkbox */ {"sTitle": "<input type='checkbox' name='pl_cb_all'>", "bSortable": false, "bSearchable": false, "mDataProp": "checkbox", "sWidth": "25px", "sClass": "library_checkbox"}, /* Checkbox */ {"sTitle": "<input type='checkbox' name='pl_cb_all'>", "bSortable": false, "bSearchable": false, "mDataProp": "checkbox", "sWidth": "25px", "sClass": "library_checkbox"},
/* Type */ {"sName": "ftype", "bSearchable": false, "mDataProp": "image", "sWidth": "25px", "sClass": "library_type"}, /* Type */ {"sName": "ftype", "bSearchable": false, "mDataProp": "image", "sWidth": "25px", "sClass": "library_type"},
/* Title */ {"sTitle": "Title", "sName": "track_title", "mDataProp": "track_title", "sClass": "library_title"}, /* Title */ {"sTitle": "Title", "sName": "track_title", "mDataProp": "track_title", "sClass": "library_title"},
/* Creator */ {"sTitle": "Creator", "sName": "artist_name", "mDataProp": "artist_name", "sClass": "library_creator"}, /* Creator */ {"sTitle": "Creator", "sName": "artist_name", "mDataProp": "artist_name", "sClass": "library_creator"},
/* Album */ {"sTitle": "Album", "sName": "album_title", "mDataProp": "album_title", "sClass": "library_album"}, /* Album */ {"sTitle": "Album", "sName": "album_title", "mDataProp": "album_title", "sClass": "library_album"},
/* Genre */ {"sTitle": "Genre", "sName": "genre", "mDataProp": "genre", "sClass": "library_genre"}, /* Genre */ {"sTitle": "Genre", "sName": "genre", "mDataProp": "genre", "sClass": "library_genre"},
/* Year */ {"sTitle": "Year", "sName": "year", "mDataProp": "year", "sClass": "library_year"}, /* Year */ {"sTitle": "Year", "sName": "year", "mDataProp": "year", "sClass": "library_year"},
/* Length */ {"sTitle": "Length", "sName": "length", "mDataProp": "length", "sClass": "library_length"}, /* Length */ {"sTitle": "Length", "sName": "length", "mDataProp": "length", "sClass": "library_length"},
/* Upload Time */ {"sTitle": "Uploaded", "sName": "utime", "mDataProp": "utime", "sClass": "library_upload_time"}, /* Upload Time */ {"sTitle": "Uploaded", "sName": "utime", "mDataProp": "utime", "sClass": "library_upload_time"},
/* Last Modified */ {"sTitle": "Last Modified", "sName": "mtime", "bVisible": false, "mDataProp": "mtime", "sClass": "library_modified_time"}, /* Last Modified */ {"sTitle": "Last Modified", "sName": "mtime", "bVisible": false, "mDataProp": "mtime", "sClass": "library_modified_time"},
/* Track Number */ {"sTitle": "Track", "sName": "track", "bSearchable": false, "bVisible": false, "mDataProp": "track_number", "sClass": "library_track"} /* Track Number */ {"sTitle": "Track", "sName": "track_number", "bSearchable": false, "bVisible": false, "mDataProp": "track_number", "sClass": "library_track"}
], ],
"aaSorting": [[2,'asc']], "aaSorting": [[2,'asc']],
"sPaginationType": "full_numbers", "sPaginationType": "full_numbers",
"bJQueryUI": true, "bJQueryUI": true,

View file

@ -19,6 +19,10 @@ var AIRTIME = (function(AIRTIME){
return regExpr.test(fade); return regExpr.test(fade);
} }
function playlistError(json) {
alert(json.error);
openPlaylist(json);
}
function stopAudioPreview() { function stopAudioPreview() {
// stop any preview playing // stop any preview playing
@ -51,130 +55,151 @@ var AIRTIME = (function(AIRTIME){
function changeCueIn(event) { function changeCueIn(event) {
event.stopPropagation(); event.stopPropagation();
var id, url, cueIn, li, unqid; var span = $(this),
id = span.parent().attr("id").split("_").pop(),
url = "/Playlist/set-cue",
cueIn = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified();
span = $(this); if (!isTimeValid(cueIn)){
id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-cue";
cueIn = $.trim(span.text());
li = span.parent().parent().parent().parent();
unqid = li.attr("unqid");
if(!isTimeValid(cueIn)){
showError(span, "please put in a time '00:00:00 (.000000)'"); showError(span, "please put in a time '00:00:00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", cueIn: cueIn, id: id, type: event.type}, function(json){ $.post(url,
{format: "json", cueIn: cueIn, id: id, modified: lastMod},
function(json){
if(json.response !== undefined && json.response.error) { if (json.error !== undefined){
showError(span, json.response.error); playlistError(json);
return; return;
} }
if (json.cue_error !== undefined) {
setPlaylistContent(json); showError(span, json.cue_error);
return;
li = $('#side_playlist li[unqid='+unqid+']'); }
li.find(".cue-edit").toggle();
highlightActive(li); setPlaylistContent(json);
highlightActive(li.find('.spl_cue'));
}); li = $('#side_playlist li[unqid='+unqid+']');
li.find(".cue-edit").toggle();
highlightActive(li);
highlightActive(li.find('.spl_cue'));
});
} }
function changeCueOut(event) { function changeCueOut(event) {
event.stopPropagation(); event.stopPropagation();
var id, url, cueOut, li, unqid; var span = $(this),
id = span.parent().attr("id").split("_").pop(),
url = "/Playlist/set-cue",
cueOut = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified();
span = $(this); if (!isTimeValid(cueOut)){
id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-cue";
cueOut = $.trim(span.text());
li = span.parent().parent().parent().parent();
unqid = li.attr("unqid");
if(!isTimeValid(cueOut)){
showError(span, "please put in a time '00:00:00 (.000000)'"); showError(span, "please put in a time '00:00:00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", cueOut: cueOut, id: id}, function(json){ $.post(url,
{format: "json", cueOut: cueOut, id: id, modified: lastMod},
function(json){
if(json.response !== undefined && json.response.error) { if (json.error !== undefined){
showError(span, json.response.error); playlistError(json);
return; return;
} }
if (json.cue_error !== undefined) {
setPlaylistContent(json); showError(span, json.cue_error);
return;
li = $('#side_playlist li[unqid='+unqid+']'); }
li.find(".cue-edit").toggle();
highlightActive(li); setPlaylistContent(json);
highlightActive(li.find('.spl_cue'));
}); li = $('#side_playlist li[unqid='+unqid+']');
li.find(".cue-edit").toggle();
highlightActive(li);
highlightActive(li.find('.spl_cue'));
});
} }
function changeFadeIn(event) { function changeFadeIn(event) {
event.stopPropagation(); event.stopPropagation();
var id, url, fadeIn, li, unqid; var span = $(this),
id = span.parent().attr("id").split("_").pop(),
url = "/Playlist/set-fade",
fadeIn = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified();
span = $(this); if (!isFadeValid(fadeIn)){
id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-fade";
fadeIn = $.trim(span.text());
li = span.parent().parent().parent().parent();
unqid = li.attr("unqid");
if(!isFadeValid(fadeIn)){
showError(span, "please put in a time in seconds '00 (.000000)'"); showError(span, "please put in a time in seconds '00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", fadeIn: fadeIn, id: id}, function(json){ $.post(url,
{format: "json", fadeIn: fadeIn, id: id, modified: lastMod},
function(json){
if(json.response !== undefined && json.response.error) { if (json.error !== undefined){
showError(span, json.response.error); playlistError(json);
return; return;
} }
if (json.fade_error !== undefined) {
setPlaylistContent(json); showError(span, json.fade_error);
return;
li = $('#side_playlist li[unqid='+unqid+']'); }
li.find('.crossfade').toggle();
highlightActive(li.find('.spl_fade_control')); setPlaylistContent(json);
});
li = $('#side_playlist li[unqid='+unqid+']');
li.find('.crossfade').toggle();
highlightActive(li.find('.spl_fade_control'));
});
} }
function changeFadeOut(event) { function changeFadeOut(event) {
event.stopPropagation(); event.stopPropagation();
var id, url, fadeOut, li, unqid; var span = $(this),
id = span.parent().attr("id").split("_").pop(),
url = "/Playlist/set-fade",
fadeOut = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified();
span = $(this); if (!isFadeValid(fadeOut)){
id = span.parent().attr("id").split("_").pop();
url = "/Playlist/set-fade";
fadeOut = $.trim(span.text());
li = span.parent().parent().parent().parent();
unqid = li.attr("unqid");
if(!isFadeValid(fadeOut)){
showError(span, "please put in a time in seconds '00 (.000000)'"); showError(span, "please put in a time in seconds '00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", fadeOut: fadeOut, id: id}, function(json){ $.post(url,
if(json.response !== undefined && json.response.error) { {format: "json", fadeOut: fadeOut, id: id, modified: lastMod},
showError(span, json.response.error); function(json){
return;
} if (json.error !== undefined){
playlistError(json);
setPlaylistContent(json); return;
}
li = $('#side_playlist li[unqid='+unqid+']'); if (json.fade_error !== undefined) {
li.find('.crossfade').toggle(); showError(span, json.fade_error);
highlightActive(li.find('.spl_fade_control')); return;
}); }
setPlaylistContent(json);
li = $('#side_playlist li[unqid='+unqid+']');
li.find('.crossfade').toggle();
highlightActive(li.find('.spl_fade_control'));
});
} }
function submitOnEnter(event) { function submitOnEnter(event) {
@ -221,27 +246,33 @@ var AIRTIME = (function(AIRTIME){
} }
function editName() { function editName() {
var nameElement = $(this); var nameElement = $(this),
var playlistName = nameElement.text(); playlistName = nameElement.text(),
lastMod = getModified();
$("#playlist_name_input") $("#playlist_name_input")
.removeClass('element_hidden') .removeClass('element_hidden')
.val(playlistName) .val(playlistName)
.keydown(function(event){ .keydown(function(event){
if(event.keyCode === 13) { if (event.keyCode === 13) {
event.preventDefault(); event.preventDefault();
var input = $(this); var input = $(this),
var url; url = '/Playlist/set-playlist-name';
url = '/Playlist/set-playlist-name';
$.post(url, {format: "json", name: input.val()}, function(json){ $.post(url,
if(json.playlist_error == true){ {format: "json", name: input.val(), modified: lastMod},
alertPlaylistErrorAndReload(); function(json){
}
input.addClass('element_hidden'); if (json.error !== undefined) {
nameElement.text(json.playlistName); playlistError(json);
redrawLib(); }
}); else {
setModified(json.modified);
input.addClass('element_hidden');
nameElement.text(json.playlistName);
redrawLib();
}
});
} }
}) })
.focus(); .focus();
@ -269,7 +300,9 @@ var AIRTIME = (function(AIRTIME){
$('#spl_sortable') $('#spl_sortable')
.empty() .empty()
.append(json.html); .append(json.html);
setModified(json.modified);
redrawLib(); redrawLib();
} }
@ -281,6 +314,10 @@ var AIRTIME = (function(AIRTIME){
return parseInt($("#pl_lastMod").val(), 10); return parseInt($("#pl_lastMod").val(), 10);
} }
function setModified(modified) {
$("#pl_lastMod").val(modified);
}
function openPlaylist(json) { function openPlaylist(json) {
$("#side_playlist") $("#side_playlist")
@ -335,9 +372,11 @@ var AIRTIME = (function(AIRTIME){
function setUpPlaylist(playlist) { function setUpPlaylist(playlist) {
var playlist = $("#side_playlist"), var playlist = $("#side_playlist"),
sortableConf; sortableConf,
cachedDescription;
playlist.find("#spl_crossfade").on("click", function(){ playlist.find("#spl_crossfade").on("click", function() {
var lastMod = getModified();
if ($(this).hasClass("ui-state-active")) { if ($(this).hasClass("ui-state-active")) {
$(this).removeClass("ui-state-active"); $(this).removeClass("ui-state-active");
@ -348,19 +387,23 @@ var AIRTIME = (function(AIRTIME){
var url = '/Playlist/get-playlist-fades'; var url = '/Playlist/get-playlist-fades';
$.get(url, {format: "json"}, function(json){ $.get(url,
if(json.playlist_error == true){ {format: "json", modified: lastMod},
alertPlaylistErrorAndReload(); function(json){
} if (json.error !== undefined){
playlist.find("#spl_fade_in_main").find("span") playlistError(json);
.empty() }
.append(json.fadeIn); else {
playlist.find("#spl_fade_out_main").find("span") playlist.find("#spl_fade_in_main").find("span")
.empty() .empty()
.append(json.fadeOut); .append(json.fadeIn);
playlist.find("#spl_fade_out_main").find("span")
playlist.find("#crossfade_main").show(); .empty()
}); .append(json.fadeOut);
playlist.find("#crossfade_main").show();
}
});
} }
}); });
@ -369,7 +412,8 @@ var AIRTIME = (function(AIRTIME){
playlist.find("#fieldset-metadate_change > legend").on("click", function(){ playlist.find("#fieldset-metadate_change > legend").on("click", function(){
var descriptionElement = $(this).parent(); var descriptionElement = $(this).parent();
if(descriptionElement.hasClass("closed")) { if (descriptionElement.hasClass("closed")) {
cachedDescription = playlist.find("#fieldset-metadate_change textarea").val();
descriptionElement.removeClass("closed"); descriptionElement.removeClass("closed");
} }
else { else {
@ -380,77 +424,71 @@ var AIRTIME = (function(AIRTIME){
playlist.find("#description_save").on("click", function(){ playlist.find("#description_save").on("click", function(){
var textarea = playlist.find("#fieldset-metadate_change textarea"), var textarea = playlist.find("#fieldset-metadate_change textarea"),
description = textarea.val(), description = textarea.val(),
url; url,
lastMod = getModified();;
url = '/Playlist/set-playlist-description'; url = '/Playlist/set-playlist-description';
$.post(url, {format: "json", description: description}, function(json){ $.post(url,
if(json.playlist_error == true){ {format: "json", description: description, modified: lastMod},
alertPlaylistErrorAndReload(); function(json){
} if (json.error !== undefined){
else{ playlistError(json);
textarea.val(json.playlistDescription); }
} else{
setModified(json.modified);
playlist.find("#fieldset-metadate_change").addClass("closed"); textarea.val(json.description);
redrawLib(); playlist.find("#fieldset-metadate_change").addClass("closed");
}); redrawLib();
}
});
}); });
playlist.find("#description_cancel").on("click", function(){ playlist.find("#description_cancel").on("click", function(){
var textarea = playlist.find("#fieldset-metadate_change textarea"), var textarea = playlist.find("#fieldset-metadate_change textarea");
url;
url = '/Playlist/set-playlist-description'; textarea.val(cachedDescription);
playlist.find("#fieldset-metadate_change").addClass("closed");
$.post(url, {format: "json"}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
else{
textarea.val(json.playlistDescription);
}
playlist.find("#fieldset-metadate_change").addClass("closed");
});
}); });
playlist.find("#spl_fade_in_main span:first").on("blur", function(event){ playlist.find("#spl_fade_in_main span:first").on("blur", function(event){
event.stopPropagation(); event.stopPropagation();
var url, fadeIn, span; var url = "/Playlist/set-playlist-fades",
span = $(this); span = $(this),
url = "/Playlist/set-playlist-fades"; fadeIn = $.trim(span.text()),
fadeIn = $.trim(span.text()); lastMod = getModified();
if(!isFadeValid(fadeIn)){ if (!isFadeValid(fadeIn)){
showError(span, "please put in a time in seconds '00 (.000000)'"); showError(span, "please put in a time in seconds '00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", fadeIn: fadeIn}, function(json){ $.post(url,
{format: "json", fadeIn: fadeIn, modified: lastMod},
hideError(span); function(json){
}); hideError(span);
});
}); });
playlist.find("#spl_fade_out_main span:last").on("blur", function(event){ playlist.find("#spl_fade_out_main span:last").on("blur", function(event){
event.stopPropagation(); event.stopPropagation();
var url, fadeOut, span; var url = "/Playlist/set-playlist-fades",
span = $(this),
span = $(this); fadeOut = $.trim(span.text()),
url = "/Playlist/set-playlist-fades"; lastMod = getModified();
fadeOut = $.trim(span.text());
if(!isFadeValid(fadeOut)){ if(!isFadeValid(fadeOut)){
showError(span, "please put in a time in seconds '00 (.000000)'"); showError(span, "please put in a time in seconds '00 (.000000)'");
return; return;
} }
$.post(url, {format: "json", fadeOut: fadeOut}, function(json){ $.post(url,
hideError(span); {format: "json", fadeOut: fadeOut, modified: lastMod},
}); function(json){
hideError(span);
});
}); });
playlist.find("#spl_fade_in_main span:first, #spl_fade_out_main span:first") playlist.find("#spl_fade_in_main span:first, #spl_fade_out_main span:first")
@ -501,7 +539,7 @@ var AIRTIME = (function(AIRTIME){
return { return {
items: 'li', items: 'li',
placeholder: "placeholder lib-placeholder ui-state-highlight", placeholder: "placeholder ui-state-highlight",
forcePlaceholderSize: true, forcePlaceholderSize: true,
handle: 'div.list-item-container', handle: 'div.list-item-container',
start: function(event, ui) { start: function(event, ui) {
@ -518,30 +556,28 @@ var AIRTIME = (function(AIRTIME){
} }
mod.fnNew = function() { mod.fnNew = function() {
var url; var url = '/Playlist/new';
stopAudioPreview(); stopAudioPreview();
url = '/Playlist/new';
$.post(url,
$.post(url, {format: "json"}, function(json){ {format: "json"},
openPlaylist(json); function(json){
redrawLib(); openPlaylist(json);
}); redrawLib();
});
}; };
mod.fnEdit = function(id) { mod.fnEdit = function(id) {
var url; var url = '/Playlist/edit';;
stopAudioPreview(); stopAudioPreview();
url = '/Playlist/edit';
$.post(url, $.post(url,
{format: "json", id: id}, {format: "json", id: id},
function(json){ function(json){
openPlaylist(json); openPlaylist(json);
//redrawLib(); });
});
}; };
mod.fnDelete = function(plid) { mod.fnDelete = function(plid) {
@ -557,33 +593,51 @@ var AIRTIME = (function(AIRTIME){
function(json){ function(json){
openPlaylist(json); openPlaylist(json);
redrawLib(); redrawLib();
}); });
}; };
mod.fnAddItems = function(aItems, iAfter, sAddType) { mod.fnAddItems = function(aItems, iAfter, sAddType) {
var lastMod = getModified();
$.post("/playlist/add-items", $.post("/playlist/add-items",
{format: "json", "ids": aItems, "afterItem": iAfter, "type": sAddType}, {format: "json", "ids": aItems, "afterItem": iAfter, "type": sAddType, "modified": lastMod},
function(json){ function(json){
setPlaylistContent(json); if (json.error !== undefined) {
playlistError(json);
}
else {
setPlaylistContent(json);
}
}); });
}; };
mod.fnMoveItems = function(aIds, iAfter) { mod.fnMoveItems = function(aIds, iAfter) {
var lastMod = getModified();
$.post("/playlist/move-items", $.post("/playlist/move-items",
{format: "json", "ids": aIds, "afterItem": iAfter}, {format: "json", "ids": aIds, "afterItem": iAfter, "modified": lastMod},
function(json){ function(json){
setPlaylistContent(json); if (json.error !== undefined) {
playlistError(json);
}
else {
setPlaylistContent(json);
}
}); });
}; };
mod.fnDeleteItems = function(aItems) { mod.fnDeleteItems = function(aItems) {
var lastMod = getModified();
$.post("/playlist/delete-items", $.post("/playlist/delete-items",
{format: "json", "ids": aItems}, {format: "json", "ids": aItems, "modified": lastMod},
function(json){ function(json){
setPlaylistContent(json); if (json.error !== undefined) {
playlistError(json);
}
else {
setPlaylistContent(json);
}
}); });
}; };

View file

@ -13,17 +13,15 @@ var AIRTIME = (function(AIRTIME){
} }
} }
mod.fnAdd = function(aMediaIds, aSchedIds, callback) { mod.fnAdd = function(aMediaIds, aSchedIds) {
var oLibTT = TableTools.fnGetInstance('library_display');
$.post("/showbuilder/schedule-add", $.post("/showbuilder/schedule-add",
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds}, {"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
function(json){ function(json){
checkError(json); checkError(json);
oSchedTable.fnDraw(); oSchedTable.fnDraw();
oLibTT.fnSelectNone();
if ($.isFunction(callback)) {
callback();
}
}); });
}; };
@ -394,21 +392,26 @@ $(document).ready(function() {
}); });
var sortableConf = (function(){ var sortableConf = (function(){
var origRow, var origTrs,
oItemData, aItemData = [],
oPrevData, oPrevData,
fnAdd, fnAdd,
fnMove, fnMove,
fnReceive, fnReceive,
fnUpdate; fnUpdate,
i,
html;
fnAdd = function() { fnAdd = function() {
var aMediaIds = [], var aMediaIds = [],
aSchedIds = []; aSchedIds = [],
oLibTT = TableTools.fnGetInstance('library_display');
for(i=0; i < aItemData.length; i++) {
aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
}
aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp}); aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
aMediaIds.push({"id": oItemData.id, "type": oItemData.ftype});
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds); AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
}; };
@ -416,28 +419,38 @@ $(document).ready(function() {
var aSelect = [], var aSelect = [],
aAfter = []; aAfter = [];
aSelect.push({"id": oItemData.id, "instance": oItemData.instance, "timestamp": oItemData.timestamp}); aSelect.push({"id": aItemData[0].id, "instance": aItemData[0].instance, "timestamp": aItemData[0].timestamp});
aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp}); aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
AIRTIME.showbuilder.fnMove(aSelect, aAfter); AIRTIME.showbuilder.fnMove(aSelect, aAfter);
}; };
fnReceive = function(event, ui) { fnReceive = function(event, ui) {
origRow = ui.item; origTrs = ui.helper.find("tr");
html = ui.helper.html();
}; };
fnUpdate = function(event, ui) { fnUpdate = function(event, ui) {
aItemData = [];
oPrevData = ui.item.prev().data("aData"); oPrevData = ui.item.prev().data("aData");
//item was dragged in //item was dragged in
if (origRow !== undefined) { if (origTrs !== undefined) {
oItemData = origRow.data("aData");
origRow = undefined; $("#show_builder_table tr.ui-draggable")
.empty()
.after(html);
origTrs.each(function(i, el){
aItemData.push($("#"+$(el).attr("id")).data("aData"));
});
origTrs = undefined;
fnAdd(); fnAdd();
} }
//item was reordered. //item was reordered.
else { else {
oItemData = ui.item.data("aData"); aItemData.push(ui.item.data("aData"));
fnMove(); fnMove();
} }
}; };