CC-3174 : showbuilder

improving playlist functionality/error checking like the showbuilder.
will send last modified ts to make sure user has a current copy of the open playlist.
This commit is contained in:
Naomi Aro 2012-02-20 18:24:04 +01:00
parent 17c3cdcfb2
commit c0f16fac3c
3 changed files with 524 additions and 430 deletions
airtime_mvc
application
public/js/airtime/library

View File

@ -30,6 +30,12 @@ class PlaylistController extends Zend_Controller_Action
if (isset($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;
}
@ -51,6 +57,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
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()
{
global $CC_CONFIG;
$request = $this->getRequest();
$baseUrl = $request->getBaseUrl();
@ -81,18 +111,16 @@ class PlaylistController extends Zend_Controller_Action
$this->_helper->viewRenderer->setResponseSegment('spl');
try {
$pl = $this->getPlaylist();
if (isset($pl)) {
$this->view->pl = $pl;
if (isset($this->pl_sess->id)) {
$pl = new Application_Model_Playlist($this->pl_sess->id);
$this->view->pl = $pl;
}
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -119,20 +147,15 @@ class PlaylistController extends Zend_Controller_Action
}
try {
$pl = $this->getPlaylist();
$pl = new Application_Model_Playlist($id);
$this->createFullResponse($pl);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist {$id} not found");
$this->changePlaylist(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->changePlaylist(null);
$this->playlistUnknownError($e);
}
$this->createFullResponse($pl);
}
public function deleteAction()
@ -150,23 +173,18 @@ class PlaylistController extends Zend_Controller_Action
}
else {
Logging::log("Not deleting currently active playlist");
$pl = new Application_Model_Playlist($this->pl_sess->id);
}
Application_Model_Playlist::DeletePlaylists($ids);
$pl = $this->getPlaylist();
$this->createFullResponse($pl);
}
catch(PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$pl = null;
catch (PlaylistNotFoundException $e) {
$this->playlistNotFound();
}
catch(Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
catch (Exception $e) {
$this->playlistUnknownError($e);
}
$this->createFullResponse($pl);
}
public function addItemsAction()
@ -176,24 +194,20 @@ class PlaylistController extends Zend_Controller_Action
$afterItem = $this->_getParam('afterItem', null);
$addType = $this->_getParam('type', 'after');
Logging::log("type is ".$addType);
try {
$pl = $this->getPlaylist();
$pl->addAudioClips($ids, $afterItem, $addType);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function moveItemsAction()
@ -201,46 +215,44 @@ class PlaylistController extends Zend_Controller_Action
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$afterItem = $this->_getParam('afterItem', null);
$modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->moveAudioClips($ids, $afterItem);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function deleteItemsAction()
{
$ids = $this->_getParam('ids');
$ids = (!is_array($ids)) ? array($ids) : $ids;
$modified = $this->_getParam('modified');
try {
$pl = $this->getPlaylist();
$pl->delAudioClips($ids);
$this->createUpdateResponse($pl);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
$this->createUpdateResponse($pl);
}
public function setCueAction()
@ -253,21 +265,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeClipLength($id, $cueIn, $cueOut);
$this->view->response = $response;
if(!isset($response["error"])) {
if (!isset($response["error"])) {
$this->view->response = $response;
$this->createUpdateResponse($pl);
}
else {
$this->view->cue_error = $response["error"];
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -281,21 +294,22 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
$this->view->response = $response;
if (!isset($response["error"])) {
$this->createUpdateResponse($pl);
$this->view->response = $response;
}
else {
$this->view->fade_error = $response["error"];
}
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -309,15 +323,14 @@ class PlaylistController extends Zend_Controller_Action
$fades = $pl->getFadeInfo($pl->getSize()-1);
$this->view->fadeOut = $fades[1];
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -335,15 +348,14 @@ class PlaylistController extends Zend_Controller_Action
$pl = $this->getPlaylist();
$pl->setPlaylistfades($fadeIn, $fadeOut);
}
catch (PlaylistOutDatedException $e) {
$this->playlistOutdated($pl, $e);
}
catch (PlaylistNotFoundException $e) {
Logging::log("Playlist not found");
$this->changePlaylist(null);
$this->createFullResponse(null);
$this->playlistNotFound();
}
catch (Exception $e) {
Logging::log("{$e->getFile()}");
Logging::log("{$e->getLine()}");
Logging::log("{$e->getMessage()}");
$this->playlistUnknownError($e);
}
}
@ -351,33 +363,42 @@ class PlaylistController extends Zend_Controller_Action
{
$name = $this->_getParam('name', 'Unknown Playlist');
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
try {
$pl = $this->getPlaylist();
$pl->setName($name);
$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()
{
$description = $this->_getParam('description', false);
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$description = $this->_getParam('description', "");
if($description != false) {
try {
$pl = $this->getPlaylist();
$pl->setDescription($description);
$this->view->description = $pl->getDescription();
$this->view->modified = $pl->getLastModified("U");
}
else {
$description = $pl->getDescription();
catch (PlaylistOutDatedException $e) {
$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)
{
$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);
}
@ -106,7 +106,7 @@ class Application_Model_Playlist {
public function setDescription($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);
}
@ -123,7 +123,7 @@ class Application_Model_Playlist {
public function setCreator($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);
}
@ -218,13 +218,18 @@ class Application_Model_Playlist {
{
$file = CcFilesQuery::create()->findPK($p_item, $this->con);
$entry = $this->plItem;
$entry["id"] = $file->getDbId();
$entry["pos"] = $pos;
$entry["cliplength"] = $file->getDbLength();
$entry["cueout"] = $file->getDbLength();
if (isset($file) && $file->getDbFileExists()) {
$entry = $this->plItem;
$entry["id"] = $file->getDbId();
$entry["pos"] = $pos;
$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;
}
$this->pl->setDbMtime(new DateTime("now"), new DateTimeZone("UTC"));
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$this->con->commit();
@ -383,7 +388,7 @@ class Application_Model_Playlist {
$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);
}
@ -415,7 +420,7 @@ class Application_Model_Playlist {
$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->con->commit();
@ -462,47 +467,52 @@ class Application_Model_Playlist {
$fadeIn = $fadeIn?'00:00:'.$fadeIn:$fadeIn;
$fadeOut = $fadeOut?'00:00:'.$fadeOut:$fadeOut;
$this->con->beginTransaction();
$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 {
$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) {
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) {
@ -512,7 +522,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition(0)
->findOne();
->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), $fadein, null);
}
@ -521,7 +531,7 @@ class Application_Model_Playlist {
$row = CcPlaylistcontentsQuery::create()
->filterByDbPlaylistId($this->id)
->filterByDbPosition($this->getSize()-1)
->findOne();
->findOne($this->con);
$this->changeFadeInfo($row->getDbId(), null, $fadeout);
}
@ -540,126 +550,135 @@ class Application_Model_Playlist {
*/
public function changeClipLength($id, $cueIn, $cueOut)
{
$this->con->beginTransaction();
$errArray= array();
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"]="Cue in and cue out are null.";
return $errArray;
}
$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.";
try {
if (is_null($cueIn) && is_null($cueOut)) {
$errArray["error"] = "Cue in and cue out are null.";
return $errArray;
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$errArray["error"] = "Can't set cue out to be greater than file length.";
return $errArray;
$row = CcPlaylistcontentsQuery::create()
->joinWith(CcFilesPeer::OM_CLASS)
->filterByPrimaryKey($id)
->findOne($this->con);
if (is_null($row)) {
throw new Exception("Playlist item does not exist.");
}
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$cueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$oldCueIn = $row->getDBCuein();
$oldCueOut = $row->getDbCueout();
$fadeIn = $row->getDbFadein();
$fadeOut = $row->getDbFadeout();
$row->setDbCuein($cueIn);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
$file = $row->getCcFiles($this->con);
$origLength = $file->getDbLength();
}
else if(!is_null($cueIn)) {
if (!is_null($cueIn) && !is_null($cueOut)){
$sql = "SELECT INTERVAL '{$cueIn}' > INTERVAL '{$oldCueOut}'";
$r = $con->query($sql);
if($r->fetchColumn(0)) {
$errArray["error"] = "Can't set cue in to be larger than cue out.";
return $errArray;
if ($cueOut === ""){
$cueOut = $origLength;
}
$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}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$cliplength = $row->getDbCliplength();
$row->setDbCuein($cueIn);
$row->setDBCliplength($cliplength);
}
else if(!is_null($cueOut)) {
if($cueOut === ""){
$cueOut = $origLength;
$sql = "SELECT INTERVAL '{$fadeIn}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeIn = $cliplength;
$row->setDbFadein($fadeIn);
}
$sql = "SELECT INTERVAL '{$cueOut}' < INTERVAL '{$oldCueIn}'";
$r = $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 '{$fadeOut}' > INTERVAL '{$cliplength}'";
$r = $this->con->query($sql);
if ($r->fetchColumn(0)){
$fadeOut = $cliplength;
$row->setDbFadein($fadeOut);
}
$sql = "SELECT INTERVAL '{$cueOut}' > INTERVAL '{$origLength}'";
$r = $con->query($sql);
if($r->fetchColumn(0)){
$errArray["error"] ="Can't set cue out to be greater than file length.";
return $errArray;
}
$row->save($this->con);
$this->pl->setDbMtime(new DateTime("now", new DateTimeZone("UTC")));
$this->pl->save($this->con);
$sql = "SELECT INTERVAL '{$cueOut}' - INTERVAL '{$oldCueIn}'";
$r = $con->query($sql);
$cliplength = $r->fetchColumn(0);
$row->setDbCueout($cueOut);
$row->setDBCliplength($cliplength);
$this->con->commit();
}
catch (Exception $e) {
$this->con->rollback();
throw $e;
}
$cliplength = $row->getDbCliplength();
$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);
return array("cliplength"=> $cliplength, "cueIn"=> $cueIn, "cueOut"=> $cueOut, "length"=> $this->getLength(),
"fadeIn"=> $fadeIn, "fadeOut"=> $fadeOut);
}
public function getAllPLMetaData()

View File

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