close working on side playlist
This commit is contained in:
parent
498a8c6823
commit
8f088abaea
6 changed files with 145 additions and 148 deletions
|
@ -27,6 +27,7 @@
|
|||
<actionMethod actionName="setFade"/>
|
||||
<actionMethod actionName="delete"/>
|
||||
<actionMethod actionName="deleteActive"/>
|
||||
<actionMethod actionName="close"/>
|
||||
</controllerFile>
|
||||
<controllerFile controllerName="Library">
|
||||
<actionMethod actionName="index"/>
|
||||
|
@ -225,6 +226,9 @@
|
|||
<viewControllerScriptsDirectory forControllerName="Sideplaylist">
|
||||
<viewScriptFile forActionName="addItem"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
<viewControllerScriptsDirectory forControllerName="Playlist">
|
||||
<viewScriptFile forActionName="close"/>
|
||||
</viewControllerScriptsDirectory>
|
||||
</viewScriptsDirectory>
|
||||
<viewHelpersDirectory/>
|
||||
<viewFiltersDirectory enabled="false"/>
|
||||
|
|
|
@ -7,7 +7,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
public function init()
|
||||
{
|
||||
if(!Zend_Auth::getInstance()->hasIdentity())
|
||||
if(!Zend_Auth::getInstance()->hasIdentity())
|
||||
{
|
||||
$this->_redirect('login/index');
|
||||
}
|
||||
|
@ -18,11 +18,41 @@ class PlaylistController extends Zend_Controller_Action
|
|||
->addActionContext('set-fade', 'json')
|
||||
->addActionContext('set-cue', 'json')
|
||||
->addActionContext('move-item', 'json')
|
||||
->addActionContext('close', 'json')
|
||||
->initContext();
|
||||
|
||||
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
||||
}
|
||||
|
||||
private function getPlaylist()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
if($pl === FALSE) {
|
||||
unset($pl_sess->id);
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
|
||||
return $pl;
|
||||
}
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
|
||||
private function closePlaylist($pl)
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$res = $pl->unlock($userInfo->id);
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
unset($pl_sess->id);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
|
||||
|
@ -30,7 +60,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
public function newAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$pl_sess = $this->pl_sess;
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
|
||||
$pl = new Playlist();
|
||||
|
@ -46,7 +76,6 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
public function metadataAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
|
||||
$request = $this->getRequest();
|
||||
$form = new Application_Form_PlaylistMetadata();
|
||||
|
@ -56,7 +85,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
$formdata = $form->getValues();
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
$pl = $this->getPlaylist();
|
||||
$pl->setPLMetaData(UI_MDATA_KEY_TITLE, $formdata["title"]);
|
||||
|
||||
if(isset($formdata["description"]))
|
||||
|
@ -73,164 +102,114 @@ class PlaylistController extends Zend_Controller_Action
|
|||
{
|
||||
$this->view->headScript()->appendFile('/js/campcaster/playlist/playlist.js','text/javascript');
|
||||
|
||||
$pl_sess = $this->pl_sess;
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
if($pl === FALSE) {
|
||||
unset($pl_sess->id);
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->playlistcontents = $pl->getContents();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
$this->view->pl = $pl;
|
||||
$this->view->playlistcontents = $pl->getContents();
|
||||
}
|
||||
|
||||
public function addItemAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$id = $this->_getParam('id');
|
||||
|
||||
if (!is_null($id)) {
|
||||
if(isset($pl_sess->id)) {
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
$res = $pl->addAudioClip($id);
|
||||
|
||||
if (PEAR::isError($res)) {
|
||||
$this->view->message = $res->getMessage();
|
||||
}
|
||||
$pl = $this->getPlaylist();
|
||||
$res = $pl->addAudioClip($id);
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
return;
|
||||
if (PEAR::isError($res)) {
|
||||
$this->view->message = $res->getMessage();
|
||||
}
|
||||
$this->view->message = "no open playlist";
|
||||
|
||||
$this->view->pl = $pl;
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
return;
|
||||
}
|
||||
$this->view->message = "a file is not chosen";
|
||||
}
|
||||
|
||||
public function moveItemAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$oldPos = $this->_getParam('oldPos');
|
||||
$newPos = $this->_getParam('newPos');
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
$oldPos = $this->_getParam('oldPos');
|
||||
$newPos = $this->_getParam('newPos');
|
||||
$pl->moveAudioClip($oldPos, $newPos);
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
$this->view->pl = $pl;
|
||||
|
||||
$pl->moveAudioClip($oldPos, $newPos);
|
||||
|
||||
$this->view->pl = $pl;
|
||||
|
||||
if($display === 'pl') {
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
}
|
||||
else {
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
}
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
return;
|
||||
if($display === 'pl') {
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
}
|
||||
else {
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
}
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
unset($this->view->pl);
|
||||
}
|
||||
|
||||
public function deleteItemAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$positions = $this->_getParam('pos', array());
|
||||
$display = $this->_getParam('view');
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
if (!is_array($positions))
|
||||
$positions = array($positions);
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
if($pl === FALSE) {
|
||||
unset($pl_sess->id);
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
//so the automatic updating of playlist positioning doesn't affect removal.
|
||||
sort($positions);
|
||||
$positions = array_reverse($positions);
|
||||
|
||||
$positions = $this->_getParam('pos', array());
|
||||
$display = $this->_getParam('view');
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
if (!is_array($positions))
|
||||
$positions = array($positions);
|
||||
foreach ($positions as $pos) {
|
||||
$pl->delAudioClip($pos);
|
||||
}
|
||||
|
||||
//so the automatic updating of playlist positioning doesn't affect removal.
|
||||
sort($positions);
|
||||
$positions = array_reverse($positions);
|
||||
$this->view->pl = $pl;
|
||||
|
||||
foreach ($positions as $pos) {
|
||||
$pl->delAudioClip($pos);
|
||||
}
|
||||
|
||||
$this->view->pl = $pl;
|
||||
|
||||
if($display === 'pl') {
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
}
|
||||
else {
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
}
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
unset($this->view->pl);
|
||||
return;
|
||||
if($display === 'pl') {
|
||||
$this->view->html = $this->view->render('playlist/update.phtml');
|
||||
}
|
||||
else {
|
||||
$this->view->html = $this->view->render('sideplaylist/update.phtml');
|
||||
}
|
||||
$this->view->name = $pl->getName();
|
||||
$this->view->length = $pl->getLength();
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
unset($this->view->pl);
|
||||
}
|
||||
|
||||
public function setCueAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$pos = $this->_getParam('pos');
|
||||
$cueIn = $this->_getParam('cueIn', null);
|
||||
$cueOut = $this->_getParam('cueOut', null);
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
$pl = $this->getPlaylist();
|
||||
$response = $pl->changeClipLength($pos, $cueIn, $cueOut);
|
||||
|
||||
$pos = $this->_getParam('pos');
|
||||
$cueIn = $this->_getParam('cueIn', null);
|
||||
$cueOut = $this->_getParam('cueOut', null);
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
|
||||
$response = $pl->changeClipLength($pos, $cueIn, $cueOut);
|
||||
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function setFadeAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$pos = $this->_getParam('pos');
|
||||
$fadeIn = $this->_getParam('fadeIn', null);
|
||||
$fadeOut = $this->_getParam('fadeOut', null);
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
$pl = $this->getPlaylist();
|
||||
|
||||
$pos = $this->_getParam('pos');
|
||||
$fadeIn = $this->_getParam('fadeIn', null);
|
||||
$fadeOut = $this->_getParam('fadeOut', null);
|
||||
$response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut);
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
|
||||
$response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut);
|
||||
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function deleteAction()
|
||||
|
@ -246,28 +225,29 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
public function deleteActiveAction()
|
||||
{
|
||||
$pl_sess = $this->pl_sess;
|
||||
$pl = $this->getPlaylist();
|
||||
$this->closePlaylist($pl);
|
||||
|
||||
if(isset($pl_sess->id)) {
|
||||
Playlist::Delete($pl_sess->id);
|
||||
|
||||
$pl = Playlist::Recall($pl_sess->id);
|
||||
$this->closePlaylist($pl);
|
||||
unset($pl_sess->id);
|
||||
}
|
||||
|
||||
Playlist::Delete($pl_sess->id);
|
||||
public function closeAction()
|
||||
{
|
||||
$display = $this->_getParam('view');
|
||||
|
||||
unset($pl_sess->id);
|
||||
$pl = $this->getPlaylist();
|
||||
$this->closePlaylist($pl);
|
||||
|
||||
if($display === 'spl') {
|
||||
$this->view->html = $this->view->render('sideplaylist/index.phtml');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_helper->redirector('index');
|
||||
}
|
||||
|
||||
public function closePlaylist($pl)
|
||||
{
|
||||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$res = $pl->unlock($userInfo->id);
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -287,6 +267,8 @@ class PlaylistController extends Zend_Controller_Action
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -415,8 +415,6 @@ class Playlist {
|
|||
/**
|
||||
* Lock playlist for edit
|
||||
*
|
||||
* @param string $sessid
|
||||
* session id
|
||||
* @param int $subjid
|
||||
* local subject (user) id
|
||||
* @param boolean $val
|
||||
|
@ -439,8 +437,6 @@ class Playlist {
|
|||
/**
|
||||
* Unlock playlist
|
||||
*
|
||||
* @param sessId
|
||||
* reference to GreenBox object
|
||||
* @return boolean
|
||||
* previous state or error object
|
||||
*/
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
</form>
|
||||
<div class="pl_footer">
|
||||
<span id="pl_remove_selected">Remove Selected</span>
|
||||
<span id="pl_close">Close Playlist</span>
|
||||
<span id="pl_delete">
|
||||
<a href="<?php echo $this->url(
|
||||
array(
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
'default',
|
||||
true) ?>">New</a>
|
||||
</span>
|
||||
<span id="spl_delete">Delete</span>
|
||||
<?php if (isset($this->pl)) { echo '<span id="spl_delete">Delete</span>';} ?>
|
||||
<?php if (isset($this->pl)) { echo '<span id="spl_close">Close</span>';} ?>
|
||||
<div>
|
||||
<div id="spl_name"><?php if (isset($this->pl)) { echo $this->pl->getName(); } ?></div>
|
||||
<div id="spl_length"><?php if (isset($this->pl)) { echo $this->pl->getLength(); } ?></div>
|
||||
|
@ -41,5 +42,5 @@
|
|||
?>
|
||||
</form>
|
||||
<div class="spl_footer">
|
||||
<span id="spl_remove_selected">Remove</span>
|
||||
<?php if (isset($this->pl)) { echo '<span id="spl_remove_selected">Remove</span>';} ?>
|
||||
</div>
|
||||
|
|
|
@ -68,11 +68,24 @@ function moveSPLItem(event, ui) {
|
|||
$.post(url, setSPLContent);
|
||||
}
|
||||
|
||||
function closeSPL() {
|
||||
var url;
|
||||
|
||||
url = '/Playlist/close/format/json/view/spl';
|
||||
|
||||
$.post(url, function(json){
|
||||
$("#side_playlist")
|
||||
.empty()
|
||||
.append(json.html);
|
||||
});
|
||||
}
|
||||
|
||||
function setUpSPL() {
|
||||
|
||||
$("#spl_sortable").sortable();
|
||||
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
||||
$("#spl_remove_selected").click(deleteSPLItem);
|
||||
$("#spl_close").click(closeSPL);
|
||||
|
||||
$("#spl_sortable").droppable();
|
||||
$("#spl_sortable" ).bind( "drop", addSPLItem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue