diff --git a/.zfproject.xml b/.zfproject.xml index 62dfcf68a..14ac9840c 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -67,6 +67,13 @@ + + + + + + + @@ -209,6 +216,15 @@ + + + + + + + + + @@ -251,6 +267,8 @@ + + diff --git a/application/configs/ACL.php b/application/configs/ACL.php index 01d482666..c625fd01e 100644 --- a/application/configs/ACL.php +++ b/application/configs/ACL.php @@ -14,6 +14,7 @@ $ccAcl->add(new Zend_Acl_Resource('library')) ->add(new Zend_Acl_Resource('error')) ->add(new Zend_Acl_Resource('login')) ->add(new Zend_Acl_Resource('playlist')) + ->add(new Zend_Acl_Resource('sideplaylist')) ->add(new Zend_Acl_Resource('plupload')) ->add(new Zend_Acl_Resource('schedule')) ->add(new Zend_Acl_Resource('api')) @@ -28,6 +29,7 @@ $ccAcl->allow('guest', 'index') ->allow('guest', 'api') ->allow('host', 'plupload') ->allow('host', 'playlist') + ->allow('host', 'sideplaylist') ->allow('host', 'schedule') ->allow('admin', 'user'); diff --git a/application/configs/propel-config.php b/application/configs/propel-config.php index 22571384c..768c5b151 100644 --- a/application/configs/propel-config.php +++ b/application/configs/propel-config.php @@ -1,6 +1,6 @@ array ( diff --git a/application/controllers/LibraryController.php b/application/controllers/LibraryController.php index a36941194..7f575669b 100644 --- a/application/controllers/LibraryController.php +++ b/application/controllers/LibraryController.php @@ -55,23 +55,24 @@ class LibraryController extends Zend_Controller_Action $file = StoredFile::Recall($id); if (PEAR::isError($file)) { - die('{"jsonrpc" : "2.0", "error" : {"message": ' + $file->getMessage() + '}}'); + $this->view->message = $file->getMessage(); + return; } else if(is_null($file)) { - die('{"jsonrpc" : "2.0", "error" : {"message": "file doesn\'t exist"}}'); + $this->view->message = "file doesn\'t exist"; + return; } $res = $file->delete(); if (PEAR::isError($res)) { - die('{"jsonrpc" : "2.0", "error" : {"message": ' + $res->getMessage() + '}}'); + $this->view->message = $res->getMessage(); + return; } } - else { - die('{"jsonrpc" : "2.0", "error" : {"message": "file doesn\'t exist"}}'); - } - die('{"jsonrpc" : "2.0"}'); + $this->view->message = "file doesn\'t exist"; + } public function contentsAction() @@ -80,6 +81,8 @@ class LibraryController extends Zend_Controller_Action $query["order"] = $this->_getParam('order', "asc"); $this->view->files = StoredFile::getFiles($query); + + $this->_helper->actionStack('index', 'sideplaylist'); } public function searchAction() diff --git a/application/controllers/PlaylistController.php b/application/controllers/PlaylistController.php index 1df677114..c05ef7f35 100644 --- a/application/controllers/PlaylistController.php +++ b/application/controllers/PlaylistController.php @@ -14,10 +14,10 @@ class PlaylistController extends Zend_Controller_Action $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('add-item', 'json') - ->addActionContext('delete-item', 'html') + ->addActionContext('delete-item', 'json') ->addActionContext('set-fade', 'json') ->addActionContext('set-cue', 'json') - ->addActionContext('move-item', 'html') + ->addActionContext('move-item', 'json') ->initContext(); $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); @@ -78,7 +78,12 @@ class PlaylistController extends Zend_Controller_Action 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; } @@ -97,15 +102,20 @@ class PlaylistController extends Zend_Controller_Action $res = $pl->addAudioClip($id); if (PEAR::isError($res)) { - die('{"jsonrpc" : "2.0", "error" : {"message": ' + $res->getMessage() + '}}'); + $this->view->message = $res->getMessage(); } - die('{"jsonrpc" : "2.0"}'); - } - die('{"jsonrpc" : "2.0", "error" : {"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(); - die('{"jsonrpc" : "2.0", "error" : {"message": "a file is not chosen"}}'); + unset($this->view->pl); + return; + } + $this->view->message = "no open playlist"; + } + $this->view->message = "a file is not chosen"; } public function moveItemAction() @@ -121,7 +131,18 @@ class PlaylistController extends Zend_Controller_Action $pl->moveAudioClip($oldPos, $newPos); - $this->view->playlistcontents = $pl->getContents(); + $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; } @@ -134,9 +155,14 @@ class PlaylistController extends Zend_Controller_Action if(isset($pl_sess->id)) { - $positions = $this->_getParam('pos', array()); - $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'); if (!is_array($positions)) $positions = array($positions); @@ -149,7 +175,18 @@ class PlaylistController extends Zend_Controller_Action $pl->delAudioClip($pos); } - $this->view->playlistcontents = $pl->getContents(); + $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; } diff --git a/application/controllers/SideplaylistController.php b/application/controllers/SideplaylistController.php new file mode 100644 index 000000000..3469dbb4e --- /dev/null +++ b/application/controllers/SideplaylistController.php @@ -0,0 +1,43 @@ +hasIdentity()) + { + $this->_redirect('login/index'); + } + + //$ajaxContext = $this->_helper->getHelper('AjaxContext'); + //$ajaxContext->addActionContext('event-feed', 'json') + // ->initContext(); + + $this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME); + } + + public function indexAction() + { + $this->_helper->layout->setLayout('sidebar'); + $this->_helper->viewRenderer->setResponseSegment('sidebar'); + + $pl_sess = $this->pl_sess; + + if(isset($pl_sess->id)) { + + $pl = Playlist::Recall($pl_sess->id); + if($pl === FALSE) { + unset($pl_sess->id); + return; + } + + $this->view->pl = $pl; + } + } +} + + + diff --git a/application/layouts/scripts/sidebar.phtml b/application/layouts/scripts/sidebar.phtml new file mode 100644 index 000000000..7c9e1284d --- /dev/null +++ b/application/layouts/scripts/sidebar.phtml @@ -0,0 +1,19 @@ + +doctype() ?> + + + + Campcaster + headScript() ?> + headLink() ?> + + + + + +
layout()->content ?>
+ + + + + diff --git a/application/views/scripts/playlist/edit.phtml b/application/views/scripts/playlist/edit.phtml index 63bab601c..765e1a4cf 100644 --- a/application/views/scripts/playlist/edit.phtml +++ b/application/views/scripts/playlist/edit.phtml @@ -1,4 +1,6 @@
+
pl->getName() ?>
+
pl->getLength() ?>
Title @@ -10,9 +12,9 @@
    - playlistcontents)) { - echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->playlistcontents); + pl->getContents())) { + echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->pl->getContents()); } else { echo '
  • Empty playlist
  • '; diff --git a/application/views/scripts/playlist/move-item.ajax.phtml b/application/views/scripts/playlist/move-item.ajax.phtml deleted file mode 100644 index 08da3f559..000000000 --- a/application/views/scripts/playlist/move-item.ajax.phtml +++ /dev/null @@ -1,8 +0,0 @@ -playlistcontents)) { - echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->playlistcontents); - } - else { - echo '
    Empty playlist
    '; - } -?> diff --git a/application/views/scripts/playlist/delete-item.ajax.phtml b/application/views/scripts/playlist/update.phtml similarity index 67% rename from application/views/scripts/playlist/delete-item.ajax.phtml rename to application/views/scripts/playlist/update.phtml index 08da3f559..3643c73ab 100644 --- a/application/views/scripts/playlist/delete-item.ajax.phtml +++ b/application/views/scripts/playlist/update.phtml @@ -1,6 +1,6 @@ playlistcontents)) { - echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->playlistcontents); + if (count($this->pl->getContents())) { + echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->pl->getContents()); } else { echo '
    Empty playlist
    '; diff --git a/application/views/scripts/sideplaylist/index.phtml b/application/views/scripts/sideplaylist/index.phtml new file mode 100644 index 000000000..ef40af72c --- /dev/null +++ b/application/views/scripts/sideplaylist/index.phtml @@ -0,0 +1,37 @@ + +
    + New + Delete +
    +
    pl)) { echo $this->pl->getName(); } ?>
    +
    pl)) { echo $this->pl->getLength(); } ?>
    +
    + pl)) { + + echo '
    '; + echo ''; + echo 'Title'; + echo 'Creator'; + echo 'Playlength'; + echo '
    '; + + echo '
      '; + + if (count($this->pl->getContents())) { + echo $this->partialLoop('sideplaylist/sidebarcontent.phtml', $this->pl->getContents()); + } + else { + echo '
    • Empty playlist
    • '; + } + + echo '
    '; + } + else { + echo '
    No open playlist
    '; + } + ?> + + diff --git a/application/views/scripts/sideplaylist/sidebarcontent.phtml b/application/views/scripts/sideplaylist/sidebarcontent.phtml new file mode 100644 index 000000000..b9c57eac4 --- /dev/null +++ b/application/views/scripts/sideplaylist/sidebarcontent.phtml @@ -0,0 +1,14 @@ +
  • + + + + + CcFiles['track_title'] ?> + + + CcFiles['artist_name'] ?> + + + cliplength ?> + +
  • diff --git a/application/views/scripts/sideplaylist/update.phtml b/application/views/scripts/sideplaylist/update.phtml new file mode 100644 index 000000000..46231963f --- /dev/null +++ b/application/views/scripts/sideplaylist/update.phtml @@ -0,0 +1,7 @@ +pl->getContents())) { + echo $this->partialLoop('sideplaylist/sidebarcontent.phtml', $this->pl->getContents()); +} +else { + echo '
  • Empty playlist
  • '; +} diff --git a/public/js/campcaster/library/library.js b/public/js/campcaster/library/library.js index 41ea59630..addd11204 100644 --- a/public/js/campcaster/library/library.js +++ b/public/js/campcaster/library/library.js @@ -15,11 +15,10 @@ function contextMenu(action, el, pos) { } function deleteItem(json){ - var j = jQuery.parseJSON(json), - id; + var id; - if(j.error !== undefined) { - alert(j.error.message); + if(json.message) { + alert(j.message); return; } @@ -28,12 +27,18 @@ function deleteItem(json){ } function addToPlaylist(json){ - var j = jQuery.parseJSON(json); - - if(j.error !== undefined) { - alert(j.error.message); + + if(json.message) { + alert(json.message); return; - } + } + + $('#spl_name').empty() + .append(json.name); + $('#spl_length').empty() + .append(json.length); + $('#spl_sortable').empty() + .append(json.html); } function setLibraryContents(data){ @@ -45,6 +50,53 @@ function setLibraryContents(data){ ); } +//-------------------------------------------------------------------------------------------------------------------------------- +//Side Playlist Functions +//-------------------------------------------------------------------------------------------------------------------------------- + +function setSPLContent(json) { + + $('#spl_name').empty() + .append(json.name); + $('#spl_length').empty() + .append(json.length); + $('#spl_sortable').empty() + .append(json.html); +} + +function deleteSPLItem(){ + + var url, pos; + + url = '/Playlist/delete-item/format/json/view/spl'; + + pos = $('form[name="SPL"]').find(':checked').not('input[name="all"]').map(function() { + return "/pos/" + $(this).attr('name'); + }).get().join(""); + + url = url + pos; + + $.post(url, setSPLContent); +} + +function moveSPLItem(event, ui) { + var li, newPos, oldPos, url; + + li = ui.item; + + newPos = li.index(); + oldPos = li.attr('id').split("_").pop(); + + url = '/Playlist/move-item' + url = url + '/format/json'; + url = url + '/view/spl'; + url = url + '/oldPos/' + oldPos; + url = url + '/newPos/' + newPos; + + $.post(url, setSPLContent); +} + + $(document).ready(function() { $("#library_display tr:first-child span.title").data({'ob': 'dc:title', 'order' : 'asc'}); @@ -78,4 +130,12 @@ $(document).ready(function() { {menu: 'myMenu'}, contextMenu ); + $("#spl_sortable").sortable(); + $("#spl_sortable" ).bind( "sortstop", moveSPLItem); + $("#spl_remove_selected").click(deleteSPLItem); + + $('input[name="all"]').click(function(){ + $('form[name="SPL"]').find('input').attr("checked", $(this).attr("checked")); + }); + }); diff --git a/public/js/campcaster/playlist/playlist.js b/public/js/campcaster/playlist/playlist.js index 113e400c0..901b25a97 100644 --- a/public/js/campcaster/playlist/playlist.js +++ b/public/js/campcaster/playlist/playlist.js @@ -192,11 +192,14 @@ function addTextInput(){ } -function setPLContent(html) { - var ul = $("#pl_sortable"); - - ul.empty(); - ul.append(html); +function setPLContent(json) { + + $('#pl_name').empty() + .append(json.name); + $('#pl_length').empty() + .append(json.length); + $('#pl_sortable').empty() + .append(json.html); $(".pl_time").click(addTextInput); } @@ -205,7 +208,7 @@ function deletePLItem(){ var url, pos; - url = '/Playlist/delete-item/format/html'; + url = '/Playlist/delete-item/format/json/view/pl'; pos = $('form[name="PL"]').find(':checked').not('input[name="all"]').map(function() { return "/pos/" + $(this).attr('name'); @@ -225,7 +228,8 @@ function movePLItem(event, ui) { oldPos = li.attr('id').split("_").pop(); url = '/Playlist/move-item' - url = url + '/format/html'; + url = url + '/format/json'; + url = url + '/view/pl'; url = url + '/oldPos/' + oldPos; url = url + '/newPos/' + newPos; diff --git a/tests/application/controllers/SidePlaylistControllerTest.php b/tests/application/controllers/SidePlaylistControllerTest.php new file mode 100644 index 000000000..c9f3c9040 --- /dev/null +++ b/tests/application/controllers/SidePlaylistControllerTest.php @@ -0,0 +1,20 @@ +