close working on side playlist

This commit is contained in:
naomiaro 2010-12-22 12:42:46 -05:00
parent 498a8c6823
commit 8f088abaea
6 changed files with 145 additions and 148 deletions

View file

@ -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"/>

View file

@ -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()
{
@ -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,32 +102,19 @@ class PlaylistController extends Zend_Controller_Action
{
$this->view->headScript()->appendFile('/js/campcaster/playlist/playlist.js','text/javascript');
$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');
}
$pl = $this->getPlaylist();
$this->view->pl = $pl;
$this->view->playlistcontents = $pl->getContents();
return;
}
$this->_helper->redirector('index');
}
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);
$pl = $this->getPlaylist();
$res = $pl->addAudioClip($id);
if (PEAR::isError($res)) {
@ -113,21 +129,15 @@ class PlaylistController extends Zend_Controller_Action
unset($this->view->pl);
return;
}
$this->view->message = "no open playlist";
}
$this->view->message = "a file is not chosen";
}
public function moveItemAction()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$oldPos = $this->_getParam('oldPos');
$newPos = $this->_getParam('newPos');
$pl = Playlist::Recall($pl_sess->id);
$pl = $this->getPlaylist();
$pl->moveAudioClip($oldPos, $newPos);
@ -143,24 +153,10 @@ class PlaylistController extends Zend_Controller_Action
$this->view->length = $pl->getLength();
unset($this->view->pl);
return;
}
$this->_helper->redirector('index');
}
public function deleteItemAction()
{
$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');
}
$positions = $this->_getParam('pos', array());
$display = $this->_getParam('view');
@ -171,6 +167,8 @@ class PlaylistController extends Zend_Controller_Action
sort($positions);
$positions = array_reverse($positions);
$pl = $this->getPlaylist();
foreach ($positions as $pos) {
$pl->delAudioClip($pos);
}
@ -187,52 +185,33 @@ class PlaylistController extends Zend_Controller_Action
$this->view->length = $pl->getLength();
unset($this->view->pl);
return;
}
$this->_helper->redirector('index');
}
public function setCueAction()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pos = $this->_getParam('pos');
$cueIn = $this->_getParam('cueIn', null);
$cueOut = $this->_getParam('cueOut', null);
$pl = Playlist::Recall($pl_sess->id);
$pl = $this->getPlaylist();
$response = $pl->changeClipLength($pos, $cueIn, $cueOut);
die(json_encode($response));
}
$this->_helper->redirector('index');
}
public function setFadeAction()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pos = $this->_getParam('pos');
$fadeIn = $this->_getParam('fadeIn', null);
$fadeOut = $this->_getParam('fadeOut', null);
$pl = Playlist::Recall($pl_sess->id);
$pl = $this->getPlaylist();
$response = $pl->changeFadeInfo($pos, $fadeIn, $fadeOut);
die(json_encode($response));
}
$this->_helper->redirector('index');
}
public function deleteAction()
{
$id = $this->_getParam('id', null);
@ -246,11 +225,7 @@ class PlaylistController extends Zend_Controller_Action
public function deleteActiveAction()
{
$pl_sess = $this->pl_sess;
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
$pl = $this->getPlaylist();
$this->closePlaylist($pl);
Playlist::Delete($pl_sess->id);
@ -258,14 +233,19 @@ class PlaylistController extends Zend_Controller_Action
unset($pl_sess->id);
}
$this->_helper->redirector('index');
public function closeAction()
{
$display = $this->_getParam('view');
$pl = $this->getPlaylist();
$this->closePlaylist($pl);
if($display === 'spl') {
$this->view->html = $this->view->render('sideplaylist/index.phtml');
return;
}
public function closePlaylist($pl)
{
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$res = $pl->unlock($userInfo->id);
return $res;
$this->_helper->redirector('index');
}
}
@ -287,6 +267,8 @@ class PlaylistController extends Zend_Controller_Action

View file

@ -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
*/

View file

@ -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(

View file

@ -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>

View file

@ -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);