CC-3174 : showbuilder

refactoring playlists for the group add/delete
This commit is contained in:
Naomi Aro 2012-02-03 18:15:10 +01:00
parent 3b172f9c0c
commit 0afa904ffe
10 changed files with 320 additions and 915 deletions

View File

@ -73,7 +73,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
//scripts for now playing bar
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/helperfunctions.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
//$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/playlist.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/dashboard/versiontooltip.js','text/javascript');
$view->headScript()->appendFile($baseUrl.'/js/airtime/common/common.js','text/javascript');
@ -132,16 +132,6 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
'controller' => 'auth',
'action' => 'password-change',
)));
/*
$router->addRoute(
'show-builder',
new Zend_Controller_Router_Route('show/builder/:show_instance_id/:user_id', array(
'module' => 'default',
'controller' => 'showbuilder',
'action' => 'index',
)));
*/
}
}

View File

@ -134,43 +134,6 @@ class LibraryController extends Zend_Controller_Action
}
public function deleteAction()
{
$id = $this->_getParam('id');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
if ($user->isAdmin()) {
if (!is_null($id)) {
$file = Application_Model_StoredFile::Recall($id);
if (PEAR::isError($file)) {
$this->view->message = $file->getMessage();
return;
}
else if(is_null($file)) {
$this->view->message = "file doesn't exist";
return;
}
$res = $file->delete();
if (PEAR::isError($res)) {
$this->view->message = $res->getMessage();
return;
}
else {
$res = settype($res, "integer");
$data = array("filepath" => $file->getFilePath(), "delete" => $res);
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
}
}
$this->view->id = $id;
}
}
public function deleteGroupAction()
{
$ids = $this->_getParam('ids');
$userInfo = Zend_Auth::getInstance()->getStorage()->read();

View File

@ -7,17 +7,14 @@ class PlaylistController extends Zend_Controller_Action
public function init()
{
$ajaxContext = $this->_helper->getHelper('AjaxContext');
$ajaxContext->addActionContext('add-item', 'json')
$ajaxContext->addActionContext('add-items', 'json')
->addActionContext('add-item', 'json')
->addActionContext('move-item', 'json')
->addActionContext('delete-item', 'json')
->addActionContext('add-group', 'json')
->addActionContext('delete-group', 'json')
->addActionContext('set-fade', 'json')
->addActionContext('set-cue', 'json')
->addActionContext('move-item', 'json')
->addActionContext('close', 'json')
->addActionContext('new', 'json')
->addActionContext('edit', 'json')
->addActionContext('delete-active', 'json')
->addActionContext('delete', 'json')
->addActionContext('set-playlist-fades', 'json')
->addActionContext('set-playlist-name', 'json')
@ -48,33 +45,36 @@ class PlaylistController extends Zend_Controller_Action
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Application_Model_Playlist::Recall($pl_sess->id);
if($pl !== FALSE) {
$this->closePlaylist($pl);
}
}
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = Application_Model_Playlist::Recall($pl_id);
if($pl === FALSE) {
return FALSE;
}
$pl->lock($userInfo->id);
$pl_sess->id = $pl_id;
}
private function closePlaylist($pl)
private function createUpdateResponse($pl)
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$res = $pl->unlock($userInfo->id);
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
$pl_sess = $this->pl_sess;
unset($pl_sess->id);
unset($this->view->pl);
}
return $res;
private function createFullResponse($pl = null)
{
if (isset($pl)) {
$this->view->pl = $pl;
$this->view->pl_id = $pl->getId();
$this->view->html = $this->view->render('playlist/index.phtml');
unset($this->view->pl);
}
else {
$this->view->html = $this->view->render('playlist/index.phtml');
}
}
public function indexAction()
@ -103,10 +103,7 @@ class PlaylistController extends Zend_Controller_Action
$this->changePlaylist($pl->getId());
$this->view->pl = $pl;
$this->view->pl_id = $pl->getId();
$this->view->html = $this->view->render('playlist/index.phtml');
unset($this->view->pl);
$this->createFullResponse($pl);
}
public function editAction()
@ -123,10 +120,7 @@ class PlaylistController extends Zend_Controller_Action
return false;
}
$this->view->pl = $pl;
$this->view->pl_id = $pl->getId();
$this->view->html = $this->view->render('playlist/index.phtml');
unset($this->view->pl);
$this->createFullResponse($pl);
}
public function addItemAction()
@ -147,13 +141,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->message = $res->getMessage();
}
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
unset($this->view->pl);
$this->createUpdateResponse($pl);
return;
}
$this->view->message = "a file is not chosen";
@ -172,13 +160,7 @@ class PlaylistController extends Zend_Controller_Action
$pl->moveAudioClip($oldPos, $newPos);
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
unset($this->view->pl);
$this->createUpdateResponse($pl);
}
public function deleteItemAction()
@ -202,16 +184,10 @@ class PlaylistController extends Zend_Controller_Action
$pl->delAudioClip($pos);
}
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
unset($this->view->pl);
$this->createUpdateResponse($pl);
}
public function addGroupAction()
public function addItemsAction()
{
$ids = $this->_getParam('ids');
$pos = $this->_getParam('pos', null);
@ -222,7 +198,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->playlist_error = true;
return false;
}
foreach ($ids as $key => $value) {
$res = $pl->addAudioClip($value);
if (PEAR::isError($res)) {
@ -231,20 +207,21 @@ class PlaylistController extends Zend_Controller_Action
}
}
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
$this->createUpdateResponse($pl);
return;
}
$this->view->message = "a file is not chosen";
}
public function deleteGroupAction()
public function deleteAction()
{
$ids = $this->_getParam('ids', null);
$ids = $this->_getParam('ids', array());
$active = $this->_getParam('active', false);
if ($active === true) {
$ids = array_merge($ids, array($pl_sess->id));
}
foreach ($ids as $key => $id) {
$pl = Application_Model_Playlist::Recall($id);
@ -259,11 +236,10 @@ class PlaylistController extends Zend_Controller_Action
return false;
}
}
$this->view->ids = $ids;
$this->view->html = $this->view->render('playlist/index.phtml');
$this->createFullResponse(null);
}
public function setCueAction()
{
$pos = $this->_getParam('pos');
@ -281,13 +257,7 @@ class PlaylistController extends Zend_Controller_Action
$this->view->response = $response;
if(!isset($response["error"])) {
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
unset($this->view->pl);
$this->createUpdateResponse($pl);
}
}
@ -308,66 +278,10 @@ class PlaylistController extends Zend_Controller_Action
$this->view->response = $response;
if(!isset($response["error"])) {
$this->view->pl = $pl;
$this->view->html = $this->view->render('playlist/update.phtml');
$this->view->name = $pl->getName();
$this->view->length = $pl->getLength();
$this->view->description = $pl->getDescription();
unset($this->view->pl);
$this->createUpdateResponse($pl);
}
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
$pl = Application_Model_Playlist::Recall($id);
if ($pl !== FALSE) {
Application_Model_Playlist::Delete($id);
$pl_sess = $this->pl_sess;
if($pl_sess->id === $id){
unset($pl_sess->id);
}
}else{
$this->view->playlist_error = true;
return false;
}
$this->view->id = $id;
$this->view->html = $this->view->render('playlist/index.phtml');
}
public function deleteActiveAction()
{
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
Application_Model_Playlist::Delete($pl->getId());
$pl_sess = $this->pl_sess;
unset($pl_sess->id);
$this->view->html = $this->view->render('playlist/index.phtml');
}
public function closeAction()
{
$pl = $this->getPlaylist();
if($pl === false){
$this->view->playlist_error = true;
return false;
}
$this->closePlaylist($pl);
$this->view->html = $this->view->render('playlist/index.phtml');
}
public function setPlaylistFadesAction()
{
$request = $this->getRequest();

File diff suppressed because it is too large Load Diff

View File

@ -83,6 +83,7 @@ class Application_Model_Scheduler {
$id = intval($schedule["id"]);
Logging::log("scheduling after scheduled item: ".$id);
Logging::log("in show: ".intval($schedule["instance"]));
if ($id !== 0) {
$schedItem = CcScheduleQuery::create()->findPK($id, $this->con);

View File

@ -825,7 +825,7 @@ class Application_Model_StoredFile {
$sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
}
Logging::log($sql);
//Logging::log($sql);
$results = $CC_DBC->getAll($sql);

View File

@ -5,7 +5,7 @@
/**
* Skeleton subclass for representing a row from the 'cc_playlist' table.
*
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
@ -16,33 +16,4 @@
class CcPlaylist extends BaseCcPlaylist {
public function computeLastPosition()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT MAX('.CcPlaylistcontentsPeer::POSITION.') AS pos'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
public function computeLength()
{
$con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME);
$sql = 'SELECT SUM('.CcPlaylistcontentsPeer::CLIPLENGTH.') AS length'
. ' FROM ' .CcPlaylistcontentsPeer::TABLE_NAME
. ' WHERE ' .CcPlaylistcontentsPeer::PLAYLIST_ID. ' = :p1';
$stmt = $con->prepare($sql);
$stmt->bindValue(':p1', $this->getDbId());
$stmt->execute();
return $stmt->fetchColumn();
}
} // CcPlaylist

View File

@ -5,7 +5,7 @@ require_once('Common.php');
/**
* Skeleton subclass for representing a row from the 'cc_playlistcontents' table.
*
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
@ -15,67 +15,5 @@ require_once('Common.php');
*/
class CcPlaylistcontents extends BaseCcPlaylistcontents {
public function getDbFadein()
{
return $this->fadein;
}
public function setDbFadein($time)
{
$this->fadein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEIN;
Common::setTimeInSub($this, 'FADEIN', $time);
}
public function getDbFadeout()
{
return $this->fadeout;
}
public function setDbFadeout($time)
{
$this->fadeout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::FADEOUT;
Common::setTimeInSub($this, 'FADEOUT', $time);
}
public function getDbCuein()
{
return $this->cuein;
}
public function setDbCuein($time)
{
$this->cuein = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEIN;
Common::setTimeInSub($this, 'CUEIN', $time);
}
public function getDbCueout()
{
return $this->cueout;
}
public function setDbCueout($time)
{
$this->cueout = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CUEOUT;
Common::setTimeInSub($this, 'CUEOUT', $time);
}
public function getDbCliplength()
{
return $this->cliplength;
}
public function setDbCliplength($time)
{
$this->cliplength = $time;
//$this->modifiedColumns[] = CcPlaylistcontentsPeer::CLIPLENGTH;
Common::setTimeInSub($this, 'CLIPLENGTH', $time);
}
} // CcPlaylistcontents

View File

@ -3,15 +3,18 @@
----------------------------------------------------------------------------------
DROP FUNCTION calculate_position() CASCADE;
/* remove this trigger for group adds/delete */
/*
CREATE FUNCTION calculate_position() RETURNS trigger AS
'
BEGIN
IF(TG_OP=''INSERT'') THEN
UPDATE cc_playlistcontents SET position = (position + 1)
UPDATE cc_playlistcontents SET position = (position + 1)
WHERE (playlist_id = new.playlist_id AND position >= new.position AND id != new.id);
END IF;
IF(TG_OP=''DELETE'') THEN
UPDATE cc_playlistcontents SET position = (position - 1)
UPDATE cc_playlistcontents SET position = (position - 1)
WHERE (playlist_id = old.playlist_id AND position > old.position);
END IF;
RETURN NULL;
@ -21,4 +24,5 @@ CREATE FUNCTION calculate_position() RETURNS trigger AS
CREATE TRIGGER calculate_position AFTER INSERT OR DELETE ON cc_playlistcontents
FOR EACH ROW EXECUTE PROCEDURE calculate_position();
*/

View File

@ -332,9 +332,9 @@ function deleteSPL() {
stopAudioPreview();
url = '/Playlist/delete-active/format/json';
url = '/Playlist/delete';
$.post(url, function(json){
$.post(url, {"format": "json", "active": true}, function(json){
if(json.playlist_error == true){
alertPlaylistErrorAndReload();
}
@ -351,7 +351,8 @@ function openDiffSPL(json) {
}
$("#side_playlist")
.empty()
.append(json.html);
.append(json.html)
.data("id", json.pl_id);
currentlyOpenedSplId = json.pl_id;
setUpSPL();