2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
2012-02-27 12:23:22 +01:00
|
|
|
require_once 'formatters/LengthFormatter.php';
|
|
|
|
require_once 'formatters/SamplerateFormatter.php';
|
|
|
|
require_once 'formatters/BitrateFormatter.php';
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
class LibraryController extends Zend_Controller_Action
|
|
|
|
{
|
2011-01-05 01:18:44 +01:00
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2012-03-12 15:32:24 +01:00
|
|
|
$ajaxContext->addActionContext('contents-feed', 'json')
|
2011-04-18 18:43:04 +02:00
|
|
|
->addActionContext('delete', 'json')
|
2012-12-28 22:17:58 +01:00
|
|
|
->addActionContext('duplicate', 'json')
|
2012-01-08 05:37:37 +01:00
|
|
|
->addActionContext('delete-group', 'json')
|
2011-04-18 18:43:04 +02:00
|
|
|
->addActionContext('context-menu', 'json')
|
2012-07-31 03:48:04 +02:00
|
|
|
->addActionContext('get-file-metadata', 'html')
|
2011-09-22 17:47:24 +02:00
|
|
|
->addActionContext('upload-file-soundcloud', 'json')
|
2011-09-22 20:01:05 +02:00
|
|
|
->addActionContext('get-upload-to-soundcloud-status', 'json')
|
2011-10-18 16:10:35 +02:00
|
|
|
->addActionContext('set-num-entries', 'json')
|
2012-12-05 19:16:25 +01:00
|
|
|
->addActionContext('edit-file-md', 'json')
|
2010-12-07 20:19:27 +01:00
|
|
|
->initContext();
|
|
|
|
}
|
|
|
|
|
2012-08-21 17:12:33 +02:00
|
|
|
public function indexAction()
|
|
|
|
{
|
2013-01-14 22:16:14 +01:00
|
|
|
$CC_CONFIG = Config::getConfig();
|
2012-08-21 17:12:33 +02:00
|
|
|
|
|
|
|
$request = $this->getRequest();
|
2012-10-19 17:09:34 +02:00
|
|
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
2012-08-21 17:12:33 +02:00
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/blockui/jquery.blockUI.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$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/datatables/plugin/dataTables.columnFilter.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($baseUrl.'js/airtime/library/events/library_playlistbuilder.js?'.$CC_CONFIG['airtime_version'], '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']);
|
2013-05-13 22:01:06 +02:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/waveform.css?'.$CC_CONFIG['airtime_version']);
|
2013-01-14 22:00:38 +01:00
|
|
|
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2013-04-16 20:37:08 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/observer/observer.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/config.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/curves.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/fades.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/local_storage.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/controls.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/playout.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/track_render.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/track.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/time_scale.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'js/waveformplaylist/playlist.js?'.$CC_CONFIG['airtime_version'], 'text/javascript');
|
|
|
|
|
|
|
|
//arbitrary attributes need to be allowed to set an id for the templates.
|
|
|
|
$this->view->headScript()->setAllowArbitraryAttributes(true);
|
2013-08-20 05:19:13 +02:00
|
|
|
//$this->view->headScript()->appendScript(file_get_contents(APPLICATION_PATH.'/../public/js/waveformplaylist/templates/bottombar.tpl'),
|
2013-04-16 20:37:08 +02:00
|
|
|
// 'text/template', array('id' => 'tpl_playlist_cues', 'noescape' => true));
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);
|
2012-08-21 17:12:33 +02:00
|
|
|
|
|
|
|
try {
|
2012-08-21 22:54:14 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
|
|
|
if (isset($obj_sess->id)) {
|
2012-08-23 16:19:00 +02:00
|
|
|
$objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
|
2012-09-14 20:51:50 +02:00
|
|
|
|
|
|
|
$objInfo = Application_Model_Library::getObjInfo($obj_sess->type);
|
|
|
|
$obj = new $objInfo['className']($obj_sess->id);
|
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
|
|
|
$user = new Application_Model_User($userInfo->id);
|
2012-08-21 17:12:33 +02:00
|
|
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-21 17:12:33 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $userInfo->id) {
|
|
|
|
$this->view->obj = $obj;
|
2012-08-22 20:03:11 +02:00
|
|
|
if ($obj_sess->type == "block") {
|
2012-08-21 17:12:33 +02:00
|
|
|
$form = new Application_Form_SmartBlockCriteria();
|
2012-08-22 20:03:11 +02:00
|
|
|
$form->startForm($obj_sess->id);
|
2012-08-21 17:12:33 +02:00
|
|
|
$this->view->form = $form;
|
|
|
|
}
|
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-21 17:12:33 +02:00
|
|
|
$formatter = new LengthFormatter($obj->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
2012-08-22 20:03:11 +02:00
|
|
|
$this->view->type = $obj_sess->type;
|
2012-08-21 17:12:33 +02:00
|
|
|
}
|
2013-02-19 17:37:22 +01:00
|
|
|
|
|
|
|
//get user settings and determine if we need to hide
|
|
|
|
// or show the playlist editor
|
|
|
|
$showPlaylist = false;
|
|
|
|
$data = Application_Model_Preference::getLibraryScreenSettings();
|
|
|
|
if (!is_null($data)) {
|
|
|
|
if ($data["playlist"] == "true") {
|
|
|
|
$showPlaylist = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->view->showPlaylist = $showPlaylist;
|
2012-08-21 17:12:33 +02:00
|
|
|
} catch (PlaylistNotFoundException $e) {
|
2012-08-22 20:03:11 +02:00
|
|
|
$this->playlistNotFound($obj_sess->type);
|
2012-08-21 17:12:33 +02:00
|
|
|
} catch (Exception $e) {
|
2012-08-22 20:03:11 +02:00
|
|
|
$this->playlistNotFound($obj_sess->type);
|
2012-08-22 21:56:18 +02:00
|
|
|
Logging::info($e->getMessage());
|
2012-08-22 20:03:11 +02:00
|
|
|
//$this->playlistUnknownError($e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function playlistNotFound($p_type)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
2012-11-15 18:55:45 +01:00
|
|
|
$this->view->error = sprintf(_("%s not found"), $p_type);
|
2012-08-22 20:03:11 +02:00
|
|
|
|
2012-09-14 21:13:08 +02:00
|
|
|
Logging::info("$p_type not found");
|
2012-08-22 20:03:11 +02:00
|
|
|
Application_Model_Library::changePlaylist(null, $p_type);
|
|
|
|
$this->createFullResponse(null);
|
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function playlistUnknownError($e)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
2012-11-15 18:55:45 +01:00
|
|
|
$this->view->error = _("Something went wrong.");
|
2012-09-13 18:15:51 +02:00
|
|
|
Logging::info($e->getMessage());
|
2012-08-22 20:03:11 +02:00
|
|
|
}
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
protected function createFullResponse($obj = null, $isJson = false)
|
2012-08-22 20:03:11 +02:00
|
|
|
{
|
|
|
|
$isBlock = false;
|
|
|
|
$viewPath = 'playlist/playlist.phtml';
|
|
|
|
if ($obj instanceof Application_Model_Block) {
|
|
|
|
$isBlock = true;
|
|
|
|
$viewPath = 'playlist/smart-block.phtml';
|
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
if (isset($obj)) {
|
|
|
|
$formatter = new LengthFormatter($obj->getLength());
|
|
|
|
$this->view->length = $formatter->format();
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
if ($isBlock) {
|
|
|
|
$form = new Application_Form_SmartBlockCriteria();
|
|
|
|
$form->removeDecorator('DtDdWrapper');
|
|
|
|
$form->startForm($obj->getId());
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 20:03:11 +02:00
|
|
|
$this->view->form = $form;
|
|
|
|
$this->view->obj = $obj;
|
|
|
|
$this->view->id = $obj->getId();
|
|
|
|
if ($isJson) {
|
|
|
|
return $this->view->render($viewPath);
|
|
|
|
} else {
|
|
|
|
$this->view->html = $this->view->render($viewPath);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->view->obj = $obj;
|
|
|
|
$this->view->id = $obj->getId();
|
|
|
|
$this->view->html = $this->view->render($viewPath);
|
|
|
|
unset($this->view->obj);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$this->view->html = $this->view->render($viewPath);
|
2012-08-21 17:12:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function contextMenuAction()
|
|
|
|
{
|
2012-10-19 20:42:01 +02:00
|
|
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
2010-12-30 23:26:44 +01:00
|
|
|
$id = $this->_getParam('id');
|
2011-04-18 18:43:04 +02:00
|
|
|
$type = $this->_getParam('type');
|
2012-02-05 18:19:22 +01:00
|
|
|
//playlist||timeline
|
|
|
|
$screen = $this->_getParam('screen');
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-02-08 12:53:46 +01:00
|
|
|
$menu = array();
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2011-07-18 19:48:20 +02:00
|
|
|
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
2011-09-23 23:00:55 +02:00
|
|
|
$user = new Application_Model_User($userInfo->id);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
//Open a jPlayer window and play the audio clip.
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["play"] = array("name"=> _("Preview"), "icon" => "play", "disabled" => false);
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-06-06 23:31:51 +02:00
|
|
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-08-22 22:08:51 +02:00
|
|
|
$obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
|
|
|
|
|
2012-02-02 15:51:15 +01:00
|
|
|
if ($type === "audioclip") {
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-09-12 23:32:19 +02:00
|
|
|
$menu["play"]["mime"] = $file->getPropelOrm()->getDbMime();
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
if (isset($obj_sess->id) && $screen == "playlist") {
|
2012-07-25 23:08:22 +02:00
|
|
|
// if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->type == 'playlist') {
|
|
|
|
$obj = new Application_Model_Playlist($obj_sess->id);
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($obj_sess->type == 'block') {
|
2012-08-22 21:34:59 +02:00
|
|
|
$obj = new Application_Model_Block($obj_sess->id);
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->type === "playlist") {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["pl_add"] = array("name"=> _("Add to Playlist"), "icon" => "add-playlist", "icon" => "copy");
|
2012-11-06 20:33:34 +01:00
|
|
|
} elseif ($obj_sess->type === "block" && $obj->isStatic()) {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["pl_add"] = array("name"=> _("Add to Smart Block"), "icon" => "add-playlist", "icon" => "copy");
|
2012-07-26 19:16:29 +02:00
|
|
|
}
|
2012-06-06 23:31:51 +02:00
|
|
|
}
|
2012-02-24 15:07:04 +01:00
|
|
|
}
|
2012-10-31 21:01:17 +01:00
|
|
|
if ($isAdminOrPM || $file->getFileOwnerId() == $user->getId()) {
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."library/delete");
|
|
|
|
$menu["edit"] = array("name"=> _("Edit Metadata"), "icon" => "edit", "url" => $baseUrl."library/edit-file-md/id/{$id}");
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
|
|
|
|
2013-01-17 19:37:32 +01:00
|
|
|
$url = $file->getRelativeFileUrl($baseUrl).'/download/true';
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["download"] = array("name" => _("Download"), "icon" => "download", "url" => $url);
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type === "playlist" || $type === "block") {
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($type === 'playlist') {
|
|
|
|
$obj = new Application_Model_Playlist($id);
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["duplicate"] = array("name" => _("Duplicate Playlist"), "icon" => "edit", "url" => $baseUrl."library/duplicate");
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type === 'block') {
|
2012-07-25 23:08:22 +02:00
|
|
|
$obj = new Application_Model_Block($id);
|
2012-08-10 18:40:28 +02:00
|
|
|
if (!$obj->isStatic()) {
|
2012-08-02 22:36:12 +02:00
|
|
|
unset($menu["play"]);
|
|
|
|
}
|
2012-08-02 22:50:35 +02:00
|
|
|
if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") {
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->type === "playlist") {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["pl_add"] = array("name"=> _("Add to Playlist"), "icon" => "add-playlist", "icon" => "copy");
|
2012-07-26 19:16:29 +02:00
|
|
|
}
|
2012-07-26 18:45:31 +02:00
|
|
|
}
|
2012-07-25 23:08:22 +02:00
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->id !== $id && $screen == "playlist") {
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["edit"] = array("name"=> _("Edit"), "icon" => "edit");
|
2012-06-06 23:31:51 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-19 17:09:34 +02:00
|
|
|
|
2012-07-25 23:08:22 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."library/delete");
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type == "stream") {
|
2012-08-10 18:40:28 +02:00
|
|
|
$webstream = CcWebstreamQuery::create()->findPK($id);
|
|
|
|
$obj = new Application_Model_Webstream($webstream);
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2013-01-02 22:09:32 +01:00
|
|
|
$menu["play"]["mime"] = $webstream->getDbMime();
|
|
|
|
|
2012-08-22 21:34:59 +02:00
|
|
|
if (isset($obj_sess->id) && $screen == "playlist") {
|
2012-07-31 03:48:04 +02:00
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2012-08-22 21:34:59 +02:00
|
|
|
if ($obj_sess->type === "playlist") {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["pl_add"] = array("name"=> _("Add to Playlist"), "icon" => "add-playlist", "icon" => "copy");
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
2012-08-13 20:58:11 +02:00
|
|
|
if ($screen == "playlist") {
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["edit"] = array("name"=> _("Edit"), "icon" => "edit", "url" => $baseUrl."library/edit-file-md/id/{$id}");
|
2012-10-19 17:09:34 +02:00
|
|
|
}
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["del"] = array("name"=> _("Delete"), "icon" => "delete", "url" => $baseUrl."library/delete");
|
2012-08-13 20:58:11 +02:00
|
|
|
}
|
2011-04-18 18:43:04 +02:00
|
|
|
}
|
2010-12-30 00:43:17 +01:00
|
|
|
|
2012-05-14 12:36:57 +02:00
|
|
|
//SOUNDCLOUD MENU OPTIONS
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($type === "audioclip" && Application_Model_Preference::GetUploadToSoundcloudOption()) {
|
|
|
|
|
|
|
|
//create a menu separator
|
|
|
|
$menu["sep1"] = "-----------";
|
|
|
|
|
|
|
|
//create a sub menu for Soundcloud actions.
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["soundcloud"] = array("name" => _("Soundcloud"), "icon" => "soundcloud", "items" => array());
|
2012-07-16 03:17:13 +02:00
|
|
|
|
2012-05-14 15:48:09 +02:00
|
|
|
$scid = $file->getSoundCloudId();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
if ($scid > 0) {
|
|
|
|
$url = $file->getSoundCloudLinkToFile();
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["soundcloud"]["items"]["view"] = array("name" => _("View on Soundcloud"), "icon" => "soundcloud", "url" => $url);
|
2012-07-16 03:17:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_null($scid)) {
|
2012-11-15 18:55:45 +01:00
|
|
|
$text = _("Re-upload to SoundCloud");
|
2012-07-16 03:17:13 +02:00
|
|
|
} else {
|
2012-11-15 18:55:45 +01:00
|
|
|
$text = _("Upload to SoundCloud");
|
2012-07-16 03:17:13 +02:00
|
|
|
}
|
|
|
|
|
2013-01-14 22:00:38 +01:00
|
|
|
$menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => $baseUrl."library/upload-file-soundcloud/id/{$id}");
|
2012-05-14 12:36:57 +02:00
|
|
|
}
|
2012-08-29 16:54:36 +02:00
|
|
|
|
2012-08-09 23:50:43 +02:00
|
|
|
if (empty($menu)) {
|
2012-11-15 18:55:45 +01:00
|
|
|
$menu["noaction"] = array("name"=>_("No action available"));
|
2012-08-09 23:50:43 +02:00
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-02-05 13:56:07 +01:00
|
|
|
$this->view->items = $menu;
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteAction()
|
|
|
|
{
|
2012-02-05 18:19:22 +01:00
|
|
|
//array containing id and type of media to delete.
|
|
|
|
$mediaItems = $this->_getParam('media', null);
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-07-11 00:51:32 +02:00
|
|
|
$user = Application_Model_User::getCurrentUser();
|
2012-09-13 16:32:33 +02:00
|
|
|
//$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-08-29 20:50:10 +02:00
|
|
|
$files = array();
|
2012-02-05 18:19:22 +01:00
|
|
|
$playlists = array();
|
2012-08-29 20:50:10 +02:00
|
|
|
$blocks = array();
|
|
|
|
$streams = array();
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
$message = null;
|
2012-11-15 18:55:45 +01:00
|
|
|
$noPermissionMsg = _("You don't have permission to delete selected items.");
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
foreach ($mediaItems as $media) {
|
2011-07-18 19:48:20 +02:00
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
if ($media["type"] === "audioclip") {
|
|
|
|
$files[] = intval($media["id"]);
|
2012-07-16 03:17:13 +02:00
|
|
|
} elseif ($media["type"] === "playlist") {
|
2012-02-05 18:19:22 +01:00
|
|
|
$playlists[] = intval($media["id"]);
|
2012-07-25 23:08:22 +02:00
|
|
|
} elseif ($media["type"] === "block") {
|
|
|
|
$blocks[] = intval($media["id"]);
|
2012-07-31 03:48:04 +02:00
|
|
|
} elseif ($media["type"] === "stream") {
|
|
|
|
$streams[] = intval($media["id"]);
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
2012-02-05 18:19:22 +01:00
|
|
|
}
|
2011-04-18 18:43:04 +02:00
|
|
|
|
2012-07-10 23:24:57 +02:00
|
|
|
try {
|
2012-07-31 03:48:04 +02:00
|
|
|
Application_Model_Playlist::deletePlaylists($playlists, $user->getId());
|
2012-07-10 23:24:57 +02:00
|
|
|
} catch (PlaylistNoPermissionException $e) {
|
2012-10-31 22:19:27 +01:00
|
|
|
$message = $noPermissionMsg;
|
2012-02-05 18:19:22 +01:00
|
|
|
}
|
2012-01-16 09:56:57 +01:00
|
|
|
|
2012-07-31 03:48:04 +02:00
|
|
|
try {
|
|
|
|
Application_Model_Block::deleteBlocks($blocks, $user->getId());
|
2012-10-31 22:19:27 +01:00
|
|
|
} catch (BlockNoPermissionException $e) {
|
|
|
|
$message = $noPermissionMsg;
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
2012-08-09 22:59:18 +02:00
|
|
|
//TODO: warn user that not all blocks could be deleted.
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Application_Model_Webstream::deleteStreams($streams, $user->getId());
|
2012-10-31 22:19:27 +01:00
|
|
|
} catch (WebstreamNoPermissionException $e) {
|
|
|
|
$message = $noPermissionMsg;
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
|
|
|
//TODO: warn user that not all streams could be deleted.
|
2012-08-22 00:55:38 +02:00
|
|
|
Logging::info($e);
|
2012-07-31 03:48:04 +02:00
|
|
|
}
|
|
|
|
|
2012-02-05 18:19:22 +01:00
|
|
|
foreach ($files as $id) {
|
|
|
|
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2012-02-05 18:19:22 +01:00
|
|
|
|
|
|
|
if (isset($file)) {
|
|
|
|
try {
|
2012-11-02 22:49:32 +01:00
|
|
|
$res = $file->delete();
|
2012-10-31 21:51:29 +01:00
|
|
|
} catch (FileNoPermissionException $e) {
|
2012-10-31 22:19:27 +01:00
|
|
|
$message = $noPermissionMsg;
|
2012-07-31 03:48:04 +02:00
|
|
|
} catch (Exception $e) {
|
|
|
|
//could throw a scheduled in future exception.
|
2012-11-15 18:55:45 +01:00
|
|
|
$message = _("Could not delete some scheduled files.");
|
2012-09-13 18:33:15 +02:00
|
|
|
Logging::debug($e->getMessage());
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-05 18:19:22 +01:00
|
|
|
|
|
|
|
if (isset($message)) {
|
|
|
|
$this->view->message = $message;
|
|
|
|
}
|
2012-01-08 05:37:37 +01:00
|
|
|
}
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
// duplicate playlist
|
|
|
|
public function duplicateAction(){
|
|
|
|
$params = $this->getRequest()->getParams();
|
|
|
|
$id = $params['id'];
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$originalPl = new Application_Model_Playlist($id);
|
|
|
|
$newPl = new Application_Model_Playlist();
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$contents = $originalPl->getContents();
|
|
|
|
foreach ($contents as &$c) {
|
|
|
|
if ($c['type'] == '0') {
|
|
|
|
$c[1] = 'audioclip';
|
|
|
|
} else if ($c['type'] == '2') {
|
|
|
|
$c[1] = 'block';
|
|
|
|
} else if ($c['type'] == '1') {
|
|
|
|
$c[1] = 'stream';
|
|
|
|
}
|
|
|
|
$c[0] = $c['item_id'];
|
|
|
|
}
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2013-05-30 21:36:55 +02:00
|
|
|
$newPl->addAudioClips($contents, null, 'before');
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$newPl->setCreator(Application_Model_User::getCurrentUser()->getId());
|
|
|
|
$newPl->setDescription($originalPl->getDescription());
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
list($plFadeIn, ) = $originalPl->getFadeInfo(0);
|
2013-01-02 17:41:33 +01:00
|
|
|
list(, $plFadeOut) = $originalPl->getFadeInfo($originalPl->getSize()-1);
|
2013-08-20 05:19:13 +02:00
|
|
|
|
2012-12-28 22:17:58 +01:00
|
|
|
$newPl->setfades($plFadeIn, $plFadeOut);
|
2013-01-14 19:42:17 +01:00
|
|
|
$newPl->setName(sprintf(_("Copy of %s"), $originalPl->getName()));
|
2012-12-28 22:17:58 +01:00
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
|
2012-03-12 15:32:24 +01:00
|
|
|
public function contentsFeedAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-01-27 21:06:04 +01:00
|
|
|
$params = $this->getRequest()->getParams();
|
2012-07-25 23:08:22 +02:00
|
|
|
|
2012-11-20 21:18:18 +01:00
|
|
|
# terrible name for the method below. it does not only search files.
|
2012-03-12 15:32:24 +01:00
|
|
|
$r = Application_Model_StoredFile::searchLibraryFiles($params);
|
2012-01-16 09:56:57 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
$this->view->sEcho = $r["sEcho"];
|
|
|
|
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
|
|
|
|
$this->view->iTotalRecords = $r["iTotalRecords"];
|
2012-03-12 15:32:24 +01:00
|
|
|
$this->view->files = $r["aaData"];
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
public function editFileMdAction()
|
2010-12-07 20:19:27 +01:00
|
|
|
{
|
2012-07-11 00:51:32 +02:00
|
|
|
$user = Application_Model_User::getCurrentUser();
|
2012-06-06 23:31:51 +02:00
|
|
|
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
$request = $this->getRequest();
|
2011-11-29 16:20:09 +01:00
|
|
|
|
2013-06-06 23:02:01 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-24 17:06:19 +01:00
|
|
|
$file_id = $this->_getParam('id', null);
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($file_id);
|
2012-10-31 21:01:17 +01:00
|
|
|
|
|
|
|
if (!$isAdminOrPM && $file->getFileOwnerId() != $user->getId()) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-05 19:16:25 +01:00
|
|
|
|
2012-10-31 21:01:17 +01:00
|
|
|
$form = new Application_Form_EditAudioMD();
|
2012-12-05 19:16:25 +01:00
|
|
|
$form->startForm($file_id);
|
2011-08-30 22:50:46 +02:00
|
|
|
$form->populate($file->getDbColMetadata());
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
if ($request->isPost()) {
|
2013-06-06 23:02:01 +02:00
|
|
|
|
|
|
|
$js = $this->_getParam('data');
|
|
|
|
$serialized = array();
|
|
|
|
//need to convert from serialized jQuery array.
|
|
|
|
foreach ($js as $j) {
|
|
|
|
$serialized[$j["name"]] = $j["value"];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($form->isValid($serialized)) {
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2012-12-05 19:16:25 +01:00
|
|
|
$formValues = $this->_getParam('data', null);
|
|
|
|
$formdata = array();
|
|
|
|
foreach ($formValues as $val) {
|
2013-02-04 17:06:46 +01:00
|
|
|
$formdata[$val["name"]] = $val["value"];
|
2012-12-05 19:16:25 +01:00
|
|
|
}
|
2011-06-09 11:50:03 +02:00
|
|
|
$file->setDbColMetadata($formdata);
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2011-06-15 14:20:14 +02:00
|
|
|
$data = $file->getMetadata();
|
2011-11-29 16:20:09 +01:00
|
|
|
|
2011-10-03 20:10:47 +02:00
|
|
|
// set MDATA_KEY_FILEPATH
|
|
|
|
$data['MDATA_KEY_FILEPATH'] = $file->getFilePath();
|
2012-08-22 00:55:38 +02:00
|
|
|
Logging::info($data['MDATA_KEY_FILEPATH']);
|
2011-09-26 21:19:04 +02:00
|
|
|
Application_Model_RabbitMq::SendMessageToMediaMonitor("md_update", $data);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2012-08-21 17:12:33 +02:00
|
|
|
$this->_redirect('Library');
|
2010-12-30 23:26:44 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 17:06:19 +01:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
$this->view->form = $form;
|
2012-12-05 19:16:25 +01:00
|
|
|
$this->view->dialog = $this->view->render('library/edit-file-md.phtml');
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
2011-02-04 06:15:56 +01:00
|
|
|
|
2012-07-31 03:48:04 +02:00
|
|
|
public function getFileMetadataAction()
|
2011-02-04 06:15:56 +01:00
|
|
|
{
|
2011-02-04 07:28:55 +01:00
|
|
|
$id = $this->_getParam('id');
|
|
|
|
$type = $this->_getParam('type');
|
2011-02-04 06:15:56 +01:00
|
|
|
|
2012-02-06 11:59:20 +01:00
|
|
|
try {
|
|
|
|
if ($type == "audioclip") {
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2012-02-06 11:59:20 +01:00
|
|
|
$this->view->type = $type;
|
2012-02-27 12:23:22 +01:00
|
|
|
$md = $file->getMetadata();
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-05-02 22:52:49 +02:00
|
|
|
foreach ($md as $key => $value) {
|
|
|
|
if ($key == 'MDATA_KEY_DIRECTORY') {
|
|
|
|
$musicDir = Application_Model_MusicDir::getDirByPK($value);
|
2012-05-03 15:59:31 +02:00
|
|
|
$md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
|
2012-05-02 22:52:49 +02:00
|
|
|
}
|
|
|
|
}
|
2012-07-11 00:53:06 +02:00
|
|
|
|
2012-02-27 12:23:22 +01:00
|
|
|
$formatter = new SamplerateFormatter($md["MDATA_KEY_SAMPLERATE"]);
|
|
|
|
$md["MDATA_KEY_SAMPLERATE"] = $formatter->format();
|
|
|
|
|
|
|
|
$formatter = new BitrateFormatter($md["MDATA_KEY_BITRATE"]);
|
|
|
|
$md["MDATA_KEY_BITRATE"] = $formatter->format();
|
|
|
|
|
|
|
|
$formatter = new LengthFormatter($md["MDATA_KEY_DURATION"]);
|
|
|
|
$md["MDATA_KEY_DURATION"] = $formatter->format();
|
|
|
|
|
|
|
|
$this->view->md = $md;
|
|
|
|
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type == "playlist") {
|
2012-02-06 11:59:20 +01:00
|
|
|
|
|
|
|
$file = new Application_Model_Playlist($id);
|
|
|
|
$this->view->type = $type;
|
2012-02-27 12:23:22 +01:00
|
|
|
$md = $file->getAllPLMetaData();
|
|
|
|
|
|
|
|
$formatter = new LengthFormatter($md["dcterms:extent"]);
|
|
|
|
$md["dcterms:extent"] = $formatter->format();
|
|
|
|
|
|
|
|
$this->view->md = $md;
|
2012-02-06 11:59:20 +01:00
|
|
|
$this->view->contents = $file->getContents();
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type == "block") {
|
2012-08-02 22:36:12 +02:00
|
|
|
$block = new Application_Model_Block($id);
|
2012-08-01 18:04:48 +02:00
|
|
|
$this->view->type = $type;
|
2012-08-02 22:36:12 +02:00
|
|
|
$md = $block->getAllPLMetaData();
|
2012-08-01 18:04:48 +02:00
|
|
|
|
|
|
|
$formatter = new LengthFormatter($md["dcterms:extent"]);
|
|
|
|
$md["dcterms:extent"] = $formatter->format();
|
|
|
|
|
|
|
|
$this->view->md = $md;
|
2012-08-02 22:36:12 +02:00
|
|
|
if ($block->isStatic()) {
|
2013-01-17 22:19:35 +01:00
|
|
|
$this->view->blType = 'Static';
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->contents = $block->getContents();
|
2012-08-01 18:04:48 +02:00
|
|
|
} else {
|
2013-01-17 22:19:35 +01:00
|
|
|
$this->view->blType = 'Dynamic';
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->contents = $block->getCriteria();
|
2012-08-01 18:04:48 +02:00
|
|
|
}
|
2012-08-02 22:36:12 +02:00
|
|
|
$this->view->block = $block;
|
2012-08-29 16:54:36 +02:00
|
|
|
} elseif ($type == "stream") {
|
2012-08-10 18:40:28 +02:00
|
|
|
$webstream = CcWebstreamQuery::create()->findPK($id);
|
2012-08-10 20:37:32 +02:00
|
|
|
$ws = new Application_Model_Webstream($webstream);
|
2012-07-31 03:48:04 +02:00
|
|
|
|
2012-08-10 20:37:32 +02:00
|
|
|
$md = $ws->getMetadata();
|
2012-07-31 03:48:04 +02:00
|
|
|
|
|
|
|
$this->view->md = $md;
|
|
|
|
$this->view->type = $type;
|
2012-02-06 11:59:20 +01:00
|
|
|
}
|
2012-07-16 03:17:13 +02:00
|
|
|
} catch (Exception $e) {
|
2012-08-22 00:55:38 +02:00
|
|
|
Logging::info($e->getMessage());
|
2011-02-04 06:15:56 +01:00
|
|
|
}
|
|
|
|
}
|
2011-11-29 16:20:09 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public function uploadFileSoundcloudAction()
|
|
|
|
{
|
2011-09-22 17:47:24 +02:00
|
|
|
$id = $this->_getParam('id');
|
2012-09-17 21:24:02 +02:00
|
|
|
Application_Model_Soundcloud::uploadSoundcloud($id);
|
2011-09-22 17:47:24 +02:00
|
|
|
// we should die with ui info
|
2013-08-20 05:19:13 +02:00
|
|
|
$this->_helper->json->sendJson(null);
|
2011-09-22 17:47:24 +02:00
|
|
|
}
|
2011-11-29 16:20:09 +01:00
|
|
|
|
2012-07-16 03:17:13 +02:00
|
|
|
public function getUploadToSoundcloudStatusAction()
|
|
|
|
{
|
2011-09-22 17:47:24 +02:00
|
|
|
$id = $this->_getParam('id');
|
|
|
|
$type = $this->_getParam('type');
|
2012-02-05 18:19:22 +01:00
|
|
|
|
|
|
|
if ($type == "show") {
|
2011-09-23 16:54:20 +02:00
|
|
|
$show_instance = new Application_Model_ShowInstance($id);
|
2011-09-22 17:47:24 +02:00
|
|
|
$this->view->sc_id = $show_instance->getSoundCloudFileId();
|
|
|
|
$file = $show_instance->getRecordedFile();
|
|
|
|
$this->view->error_code = $file->getSoundCloudErrorCode();
|
|
|
|
$this->view->error_msg = $file->getSoundCloudErrorMsg();
|
2012-07-16 03:17:13 +02:00
|
|
|
} elseif ($type == "file") {
|
2013-04-20 02:24:05 +02:00
|
|
|
$file = Application_Model_StoredFile::RecallById($id);
|
2012-09-17 18:45:33 +02:00
|
|
|
$this->view->sc_id = $file->getSoundCloudId();
|
2011-09-22 17:47:24 +02:00
|
|
|
$this->view->error_code = $file->getSoundCloudErrorCode();
|
2012-09-17 18:45:33 +02:00
|
|
|
$this->view->error_msg = $file->getSoundCloudErrorMsg();
|
|
|
|
} else {
|
|
|
|
Logging::warn("Trying to upload unknown type: $type with id: $id");
|
2011-09-22 17:47:24 +02:00
|
|
|
}
|
|
|
|
}
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|