2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PlaylistController extends Zend_Controller_Action
|
|
|
|
{
|
|
|
|
protected $pl_sess = null;
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2012-02-03 18:15:10 +01:00
|
|
|
$ajaxContext->addActionContext('add-items', 'json')
|
2012-02-04 15:52:31 +01:00
|
|
|
->addActionContext('move-items', 'json')
|
|
|
|
->addActionContext('delete-items', 'json')
|
2012-01-08 05:37:37 +01:00
|
|
|
->addActionContext('set-fade', 'json')
|
|
|
|
->addActionContext('set-cue', 'json')
|
|
|
|
->addActionContext('new', 'json')
|
|
|
|
->addActionContext('edit', 'json')
|
|
|
|
->addActionContext('delete', 'json')
|
2012-02-25 00:24:24 +01:00
|
|
|
->addActionContext('play', 'json')
|
2011-02-08 22:10:48 +01:00
|
|
|
->addActionContext('set-playlist-fades', 'json')
|
2012-02-05 23:38:12 +01:00
|
|
|
->addActionContext('get-playlist-fades', 'json')
|
2011-05-17 23:30:17 +02:00
|
|
|
->addActionContext('set-playlist-name', 'json')
|
2012-01-08 05:37:37 +01:00
|
|
|
->addActionContext('set-playlist-description', 'json')
|
2012-03-10 00:47:08 +01:00
|
|
|
->addActionContext('playlist-preview', 'json')
|
|
|
|
->addActionContext('get-playlist', 'json')
|
2010-12-07 20:19:27 +01:00
|
|
|
->initContext();
|
|
|
|
|
|
|
|
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
|
|
|
}
|
|
|
|
|
2011-02-08 22:10:48 +01:00
|
|
|
private function getPlaylist()
|
|
|
|
{
|
2012-02-04 00:12:06 +01:00
|
|
|
$pl = null;
|
2010-12-22 18:42:46 +01:00
|
|
|
|
2012-03-13 19:12:14 +01:00
|
|
|
if (isset($this->pl_sess->id)) {
|
2012-02-04 00:12:06 +01:00
|
|
|
$pl = new Application_Model_Playlist($this->pl_sess->id);
|
2012-02-20 18:24:04 +01:00
|
|
|
|
|
|
|
$modified = $this->_getParam('modified', null);
|
|
|
|
if ($pl->getLastModified("U") !== $modified) {
|
|
|
|
$this->createFullResponse($pl);
|
|
|
|
throw new PlaylistOutDatedException("You are viewing an older version of {$pl->getName()}");
|
|
|
|
}
|
2011-02-08 22:10:48 +01:00
|
|
|
}
|
2012-02-04 00:12:06 +01:00
|
|
|
return $pl;
|
2011-02-08 22:10:48 +01:00
|
|
|
}
|
2010-12-30 19:32:59 +01:00
|
|
|
|
2011-02-08 22:10:48 +01:00
|
|
|
private function changePlaylist($pl_id)
|
|
|
|
{
|
2012-02-07 18:42:34 +01:00
|
|
|
if (is_null($pl_id)) {
|
|
|
|
unset($this->pl_sess->id);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$this->pl_sess->id = intval($pl_id);
|
|
|
|
}
|
2011-02-08 22:10:48 +01:00
|
|
|
}
|
2010-12-30 19:32:59 +01:00
|
|
|
|
2012-02-03 18:15:10 +01:00
|
|
|
private function createUpdateResponse($pl)
|
2010-12-22 18:42:46 +01:00
|
|
|
{
|
2012-02-24 15:07:04 +01:00
|
|
|
$formatter = new LengthFormatter($pl->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
|
|
|
|
2012-02-03 18:15:10 +01:00
|
|
|
$this->view->pl = $pl;
|
|
|
|
$this->view->html = $this->view->render('playlist/update.phtml');
|
|
|
|
$this->view->name = $pl->getName();
|
|
|
|
$this->view->description = $pl->getDescription();
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->view->modified = $pl->getLastModified("U");
|
2010-12-22 18:42:46 +01:00
|
|
|
|
2012-02-03 18:15:10 +01:00
|
|
|
unset($this->view->pl);
|
|
|
|
}
|
2010-12-22 18:42:46 +01:00
|
|
|
|
2012-02-03 18:15:10 +01:00
|
|
|
private function createFullResponse($pl = null)
|
|
|
|
{
|
|
|
|
if (isset($pl)) {
|
2012-02-24 15:07:04 +01:00
|
|
|
$formatter = new LengthFormatter($pl->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
|
|
|
|
2012-02-03 18:15:10 +01:00
|
|
|
$this->view->pl = $pl;
|
2012-02-04 00:12:06 +01:00
|
|
|
$this->view->id = $pl->getId();
|
2012-03-29 15:34:58 +02:00
|
|
|
$this->view->html = $this->view->render('playlist/playlist.phtml');
|
2012-02-03 18:15:10 +01:00
|
|
|
unset($this->view->pl);
|
|
|
|
}
|
|
|
|
else {
|
2012-03-29 15:34:58 +02:00
|
|
|
$this->view->html = $this->view->render('playlist/playlist.phtml');
|
2012-02-03 18:15:10 +01:00
|
|
|
}
|
2010-12-22 18:42:46 +01:00
|
|
|
}
|
|
|
|
|
2012-02-20 18:24:04 +01:00
|
|
|
private function playlistOutdated($pl, $e)
|
|
|
|
{
|
|
|
|
$this->view->error = $e->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
private function playlistNotFound()
|
|
|
|
{
|
|
|
|
$this->view->error = "Playlist not found";
|
|
|
|
|
|
|
|
Logging::log("Playlist not found");
|
|
|
|
$this->changePlaylist(null);
|
|
|
|
$this->createFullResponse(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function playlistUnknownError($e)
|
|
|
|
{
|
|
|
|
$this->view->error = "Something went wrong.";
|
|
|
|
|
|
|
|
Logging::log("{$e->getFile()}");
|
|
|
|
Logging::log("{$e->getLine()}");
|
|
|
|
Logging::log("{$e->getMessage()}");
|
|
|
|
}
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2012-02-08 22:21:57 +01:00
|
|
|
global $CC_CONFIG;
|
2012-02-20 18:24:04 +01:00
|
|
|
|
2011-04-18 17:02:09 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$baseUrl = $request->getBaseUrl();
|
|
|
|
|
2012-05-04 15:00:18 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
2012-03-28 18:43:44 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_playlistbuilder.js'),'text/javascript');
|
|
|
|
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
|
|
|
|
|
2012-02-08 22:21:57 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
2012-02-25 00:24:24 +01:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
|
2011-01-16 21:35:00 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
2012-02-20 18:24:04 +01:00
|
|
|
if (isset($this->pl_sess->id)) {
|
|
|
|
$pl = new Application_Model_Playlist($this->pl_sess->id);
|
2012-07-10 21:11:59 +02:00
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
|
|
|
$user = new Application_Model_User($userInfo->id);
|
|
|
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
|
|
|
|
|
|
|
if($isAdminOrPM || $pl->getCreatorId() == $userInfo->id){
|
|
|
|
$this->view->pl = $pl;
|
|
|
|
}
|
2012-02-24 15:07:04 +01:00
|
|
|
|
|
|
|
$formatter = new LengthFormatter($pl->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function newAction()
|
|
|
|
{
|
2010-12-22 18:42:46 +01:00
|
|
|
$pl_sess = $this->pl_sess;
|
2010-12-07 20:19:27 +01:00
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
|
|
|
|
2011-09-22 18:24:17 +02:00
|
|
|
$pl = new Application_Model_Playlist();
|
2012-02-04 00:12:06 +01:00
|
|
|
$pl->setName("Untitled Playlist");
|
2012-02-04 21:26:21 +01:00
|
|
|
$pl->setPLMetaData('dc:creator', $userInfo->id);
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2011-03-31 20:40:55 +02:00
|
|
|
$this->changePlaylist($pl->getId());
|
2012-02-03 18:15:10 +01:00
|
|
|
$this->createFullResponse($pl);
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function editAction()
|
|
|
|
{
|
2012-02-05 18:19:22 +01:00
|
|
|
$id = $this->_getParam('id', null);
|
|
|
|
Logging::log("editing playlist {$id}");
|
2011-03-31 20:40:55 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
if (!is_null($id)) {
|
|
|
|
$this->changePlaylist($id);
|
2010-12-30 19:32:59 +01:00
|
|
|
}
|
2011-03-31 20:40:55 +02:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
2012-02-20 18:24:04 +01:00
|
|
|
$pl = new Application_Model_Playlist($id);
|
|
|
|
$this->createFullResponse($pl);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
public function deleteAction()
|
2011-02-08 22:10:48 +01:00
|
|
|
{
|
2012-02-04 00:12:06 +01:00
|
|
|
$ids = $this->_getParam('ids');
|
|
|
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
|
|
|
$pl = null;
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
2011-03-31 20:40:55 +02:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
Logging::log("Currently active playlist {$this->pl_sess->id}");
|
|
|
|
if (in_array($this->pl_sess->id, $ids)) {
|
|
|
|
Logging::log("Deleting currently active playlist");
|
|
|
|
$this->changePlaylist(null);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Logging::log("Not deleting currently active playlist");
|
2012-02-20 18:24:04 +01:00
|
|
|
$pl = new Application_Model_Playlist($this->pl_sess->id);
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
Application_Model_Playlist::DeletePlaylists($ids);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->createFullResponse($pl);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
catch (PlaylistNotFoundException $e) {
|
|
|
|
$this->playlistNotFound();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
catch (Exception $e) {
|
|
|
|
$this->playlistUnknownError($e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
2012-02-14 21:43:27 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
public function addItemsAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-02-28 23:52:20 +01:00
|
|
|
$ids = $this->_getParam('ids', array());
|
2012-02-04 00:12:06 +01:00
|
|
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
|
|
|
$afterItem = $this->_getParam('afterItem', null);
|
2012-02-04 19:27:26 +01:00
|
|
|
$addType = $this->_getParam('type', 'after');
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
2012-02-04 19:27:26 +01:00
|
|
|
$pl->addAudioClips($ids, $afterItem, $addType);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->createUpdateResponse($pl);
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-04 15:52:31 +01:00
|
|
|
public function moveItemsAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-02-04 00:12:06 +01:00
|
|
|
$ids = $this->_getParam('ids');
|
|
|
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
|
|
|
$afterItem = $this->_getParam('afterItem', null);
|
2012-02-20 18:24:04 +01:00
|
|
|
$modified = $this->_getParam('modified');
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$pl->moveAudioClips($ids, $afterItem);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->createUpdateResponse($pl);
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-04 00:12:06 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
public function deleteItemsAction()
|
2012-01-08 05:37:37 +01:00
|
|
|
{
|
|
|
|
$ids = $this->_getParam('ids');
|
2012-02-04 00:12:06 +01:00
|
|
|
$ids = (!is_array($ids)) ? array($ids) : $ids;
|
2012-02-20 18:24:04 +01:00
|
|
|
$modified = $this->_getParam('modified');
|
2012-01-08 05:37:37 +01:00
|
|
|
|
2012-02-04 00:12:06 +01:00
|
|
|
try {
|
2012-01-08 05:37:37 +01:00
|
|
|
$pl = $this->getPlaylist();
|
2012-02-04 00:12:06 +01:00
|
|
|
$pl->delAudioClips($ids);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->createUpdateResponse($pl);
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
2012-02-04 00:12:06 +01:00
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-03 18:15:10 +01:00
|
|
|
}
|
2012-02-04 00:12:06 +01:00
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
|
|
|
}
|
2012-02-03 18:15:10 +01:00
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function setCueAction()
|
|
|
|
{
|
2012-02-04 19:27:26 +01:00
|
|
|
$id = $this->_getParam('id');
|
2011-11-29 15:30:05 +01:00
|
|
|
$cueIn = $this->_getParam('cueIn', null);
|
|
|
|
$cueOut = $this->_getParam('cueOut', null);
|
2011-01-17 01:31:10 +01:00
|
|
|
|
2012-02-04 19:27:26 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$response = $pl->changeClipLength($id, $cueIn, $cueOut);
|
2011-01-17 01:31:10 +01:00
|
|
|
|
2012-02-20 18:24:04 +01:00
|
|
|
if (!isset($response["error"])) {
|
|
|
|
$this->view->response = $response;
|
2012-02-04 19:27:26 +01:00
|
|
|
$this->createUpdateResponse($pl);
|
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
else {
|
|
|
|
$this->view->cue_error = $response["error"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
2012-02-04 19:27:26 +01:00
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-04 19:27:26 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-02-04 19:27:26 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setFadeAction()
|
|
|
|
{
|
2012-02-05 23:38:12 +01:00
|
|
|
$id = $this->_getParam('id');
|
2011-11-29 15:30:05 +01:00
|
|
|
$fadeIn = $this->_getParam('fadeIn', null);
|
|
|
|
$fadeOut = $this->_getParam('fadeOut', null);
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-02-05 23:38:12 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$response = $pl->changeFadeInfo($id, $fadeIn, $fadeOut);
|
2011-01-17 19:55:43 +01:00
|
|
|
|
2012-02-05 23:38:12 +01:00
|
|
|
if (!isset($response["error"])) {
|
|
|
|
$this->createUpdateResponse($pl);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->view->response = $response;
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
else {
|
|
|
|
$this->view->fade_error = $response["error"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2011-11-29 15:30:05 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-05 23:38:12 +01:00
|
|
|
public function getPlaylistFadesAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-02-05 23:38:12 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$fades = $pl->getFadeInfo(0);
|
|
|
|
$this->view->fadeIn = $fades[0];
|
2010-12-30 00:43:17 +01:00
|
|
|
|
2012-02-05 23:38:12 +01:00
|
|
|
$fades = $pl->getFadeInfo($pl->getSize()-1);
|
|
|
|
$this->view->fadeOut = $fades[1];
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
|
|
|
}
|
2012-02-05 23:38:12 +01:00
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2012-02-05 23:38:12 +01:00
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2012-02-04 00:19:13 +01:00
|
|
|
/**
|
|
|
|
* The playlist fades are stored in the elements themselves.
|
|
|
|
* The fade in is set to the first elements fade in and
|
2012-03-19 14:09:05 +01:00
|
|
|
* the fade out is set to the last elements fade out.
|
2012-02-04 00:19:13 +01:00
|
|
|
**/
|
2011-02-08 22:10:48 +01:00
|
|
|
public function setPlaylistFadesAction()
|
|
|
|
{
|
2012-02-05 23:38:12 +01:00
|
|
|
$fadeIn = $this->_getParam('fadeIn', null);
|
|
|
|
$fadeOut = $this->_getParam('fadeOut', null);
|
2011-02-08 22:10:48 +01:00
|
|
|
|
2012-02-05 23:38:12 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$pl->setPlaylistfades($fadeIn, $fadeOut);
|
2012-03-19 14:09:05 +01:00
|
|
|
$this->view->modified = $pl->getLastModified("U");
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
|
|
|
}
|
2012-02-05 23:38:12 +01:00
|
|
|
catch (PlaylistNotFoundException $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistNotFound();
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->playlistUnknownError($e);
|
2012-02-05 23:38:12 +01:00
|
|
|
}
|
2011-02-08 22:10:48 +01:00
|
|
|
}
|
|
|
|
|
2011-05-17 23:30:17 +02:00
|
|
|
public function setPlaylistNameAction()
|
|
|
|
{
|
|
|
|
$name = $this->_getParam('name', 'Unknown Playlist');
|
|
|
|
|
2012-02-20 18:24:04 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
|
|
|
$pl->setName($name);
|
|
|
|
$this->view->playlistName = $name;
|
|
|
|
$this->view->modified = $pl->getLastModified("U");
|
|
|
|
}
|
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
|
|
|
$this->playlistNotFound();
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
$this->playlistUnknownError($e);
|
2011-11-10 21:35:27 +01:00
|
|
|
}
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setPlaylistDescriptionAction()
|
|
|
|
{
|
2012-02-20 18:24:04 +01:00
|
|
|
$description = $this->_getParam('description', "");
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2012-02-20 18:24:04 +01:00
|
|
|
try {
|
|
|
|
$pl = $this->getPlaylist();
|
2011-05-17 23:30:17 +02:00
|
|
|
$pl->setDescription($description);
|
2012-02-20 18:24:04 +01:00
|
|
|
$this->view->description = $pl->getDescription();
|
|
|
|
$this->view->modified = $pl->getLastModified("U");
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
2012-02-20 18:24:04 +01:00
|
|
|
catch (PlaylistOutDatedException $e) {
|
|
|
|
$this->playlistOutdated($pl, $e);
|
|
|
|
}
|
|
|
|
catch (PlaylistNotFoundException $e) {
|
|
|
|
$this->playlistNotFound();
|
|
|
|
}
|
|
|
|
catch (Exception $e) {
|
|
|
|
$this->playlistUnknownError($e);
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|