side playlist almost done, just need to do drag and drop.

This commit is contained in:
naomiaro 2010-12-21 16:45:36 -05:00
parent 707bb2b183
commit 9fd60932bd
17 changed files with 327 additions and 49 deletions

View File

@ -67,6 +67,13 @@
<actionMethod actionName="index"/>
<actionMethod actionName="addUser"/>
</controllerFile>
<controllerFile controllerName="SidePlaylist">
<actionMethod actionName="index"/>
</controllerFile>
<controllerFile controllerName="Sideplaylist">
<actionMethod actionName="index"/>
<actionMethod actionName="addItem"/>
</controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="Login"/>
@ -209,6 +216,15 @@
<viewControllerScriptsDirectory forControllerName="User">
<viewScriptFile forActionName="addUser"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="SidePlaylist">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Sideplaylist">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Sideplaylist">
<viewScriptFile forActionName="addItem"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
@ -251,6 +267,8 @@
<testApplicationControllerFile filesystemName="ScheduleControllerTest.php"/>
<testApplicationControllerFile filesystemName="ApiControllerTest.php"/>
<testApplicationControllerFile filesystemName="UserControllerTest.php"/>
<testApplicationControllerFile filesystemName="SidePlaylistControllerTest.php"/>
<testApplicationControllerFile filesystemName="SideplaylistControllerTest.php"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory>

View File

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

View File

@ -1,6 +1,6 @@
<?php
// This file generated by Propel 1.5.2 convert-conf target
// from XML runtime conf file /home/naomi/dev-campcaster/campcaster/build/runtime-conf.xml
// from XML runtime conf file /home/naomiaro/dev-campcaster/campcaster/build/runtime-conf.xml
$conf = array (
'datasources' =>
array (

View File

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

View File

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

View File

@ -0,0 +1,43 @@
<?php
class SideplaylistController extends Zend_Controller_Action
{
protected $pl_sess = null;
public function init()
{
if(!Zend_Auth::getInstance()->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;
}
}
}

View File

@ -0,0 +1,19 @@
<!-- application/layouts/scripts/layout.phtml -->
<?php echo $this->doctype() ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Campcaster</title>
<?php echo $this->headScript() ?>
<?php echo $this->headLink() ?>
</head>
<body>
<div id="nav"><?php echo $this->navigation()->menu()->setRenderInvisible(true) ?></div>
<div id="content"><?php echo $this->layout()->content ?></div>
<div id="sidebar"><?php echo $this->layout()->sidebar ?></div>
</body>
</html>

View File

@ -1,4 +1,6 @@
<form name="PL">
<div id="pl_name"><?php echo $this->pl->getName() ?></div>
<div id="pl_length"><?php echo $this->pl->getLength() ?></div>
<div class="pl_head">
<span class="pl_input"><input type="checkbox" name="all"></span>
<span class="pl_title">Title</span>
@ -10,9 +12,9 @@
</div>
<div class="pl_main">
<ul id="pl_sortable">
<?php
if (count($this->playlistcontents)) {
echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->playlistcontents);
<?php
if (count($this->pl->getContents())) {
echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->pl->getContents());
}
else {
echo '<li class="pl_empty">Empty playlist</li>';

View File

@ -1,8 +0,0 @@
<?php
if (count($this->playlistcontents)) {
echo $this->partialLoop('playlist/playlistEditorTable.phtml', $this->playlistcontents);
}
else {
echo '<div class="pl_empty">Empty playlist</div>';
}
?>

View File

@ -1,6 +1,6 @@
<?php
if (count($this->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 '<div class="pl_empty">Empty playlist</div>';

View File

@ -0,0 +1,37 @@
<form name="SPL">
<div>
<span id="spl_new">New</span>
<span id="spl_delete">Delete</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>
<div class="spl_main">
<?php
if (isset($this->pl)) {
echo '<div class="spl_head">';
echo '<span class="spl_input"><input type="checkbox" name="all"></span>';
echo '<span class="spl_title">Title</span>';
echo '<span class="spl_artist">Creator</span>';
echo '<span class="spl_playlength">Playlength</span>';
echo '</div>';
echo '<ul id="spl_sortable">';
if (count($this->pl->getContents())) {
echo $this->partialLoop('sideplaylist/sidebarcontent.phtml', $this->pl->getContents());
}
else {
echo '<li class="spl_empty">Empty playlist</li>';
}
echo '</ul></div>';
}
else {
echo '<div>No open playlist</div>';
}
?>
</form>
<div class="spl_footer">
<span id="spl_remove_selected">Remove</span>
</div>

View File

@ -0,0 +1,14 @@
<li class="spl_row" id="spl_<?php echo $this->partialCounter-1 ?>">
<span class="spl_input">
<input type="checkbox" class="checkbox" name="<?php echo $this->partialCounter-1 ?>"/>
</span>
<span class="spl_title">
<?php echo $this->CcFiles['track_title'] ?>
</span>
<span class="spl_artist">
<?php echo $this->CcFiles['artist_name'] ?>
</span>
<span class="spl_playlength">
<?php echo $this->cliplength ?>
</span>
</li>

View File

@ -0,0 +1,7 @@
<?php
if (count($this->pl->getContents())) {
echo $this->partialLoop('sideplaylist/sidebarcontent.phtml', $this->pl->getContents());
}
else {
echo '<li class="pl_empty">Empty playlist</li>';
}

View File

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

View File

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

View File

@ -0,0 +1,20 @@
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class SidePlaylistControllerTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
/* Setup Routine */
}
public function tearDown()
{
/* Tear Down Routine */
}
}

View File

@ -0,0 +1,20 @@
<?php
require_once 'PHPUnit/Framework/TestCase.php';
class SideplaylistControllerTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
/* Setup Routine */
}
public function tearDown()
{
/* Tear Down Routine */
}
}