2010-12-07 20:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class LibraryController extends Zend_Controller_Action
|
|
|
|
{
|
2011-01-05 01:18:44 +01:00
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
protected $pl_sess = null;
|
2011-02-10 04:37:18 +01:00
|
|
|
protected $search_sess = null;
|
2011-01-05 01:18:44 +01:00
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
2011-02-01 21:57:12 +01:00
|
|
|
$ajaxContext->addActionContext('contents', 'json')
|
2011-04-18 18:43:04 +02:00
|
|
|
->addActionContext('delete', 'json')
|
|
|
|
->addActionContext('context-menu', 'json')
|
2011-02-04 06:15:56 +01:00
|
|
|
->addActionContext('get-file-meta-data', 'html')
|
2010-12-07 20:19:27 +01:00
|
|
|
->initContext();
|
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->pl_sess = new Zend_Session_Namespace(UI_PLAYLIST_SESSNAME);
|
|
|
|
$this->search_sess = new Zend_Session_Namespace("search");
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function indexAction()
|
|
|
|
{
|
2011-04-18 17:02:09 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$baseUrl = $request->getBaseUrl();
|
|
|
|
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jjmenu.js','text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/jplayer/jquery.jplayer.min.js');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js','text/javascript');
|
2011-04-27 21:14:24 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js','text/javascript');
|
2011-06-17 20:41:57 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.js','text/javascript');
|
2011-04-18 17:02:09 +02:00
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js','text/javascript');
|
|
|
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/advancedsearch.js','text/javascript');
|
|
|
|
|
2011-05-17 23:30:17 +02:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css');
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/contextmenu.css');
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->_helper->layout->setLayout('library');
|
2011-02-01 21:57:12 +01:00
|
|
|
$this->_helper->viewRenderer->setResponseSegment('library');
|
2011-02-10 04:37:18 +01:00
|
|
|
|
|
|
|
$form = new Application_Form_AdvancedSearch();
|
|
|
|
$form->addGroup(1, 1);
|
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->search_sess->next_group = 2;
|
|
|
|
$this->search_sess->next_row[1] = 2;
|
|
|
|
$this->view->form = $form;
|
2011-02-10 04:37:18 +01:00
|
|
|
$this->view->md = $this->search_sess->md;
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->_helper->actionStack('index', 'playlist');
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function contextMenuAction()
|
|
|
|
{
|
2011-05-04 22:07:29 +02:00
|
|
|
global $CC_CONFIG;
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
$id = $this->_getParam('id');
|
2011-04-18 18:43:04 +02:00
|
|
|
$type = $this->_getParam('type');
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$params = '/format/json/id/#id#/type/#type#';
|
|
|
|
|
|
|
|
$paramsPop = str_replace('#id#', $id, $params);
|
|
|
|
$paramsPop = str_replace('#type#', $type, $paramsPop);
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
$pl_sess = $this->pl_sess;
|
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
if($type === "au") {
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
if(isset($pl_sess->id)) {
|
2011-05-17 23:30:17 +02:00
|
|
|
$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/add-item'.$params, 'callback' => 'window["setSPLContent"]'),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Add to Playlist');
|
|
|
|
}
|
|
|
|
|
2011-05-17 23:30:17 +02:00
|
|
|
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Edit Metadata');
|
|
|
|
|
2011-05-04 22:07:29 +02:00
|
|
|
// added for downlaod
|
|
|
|
$id = $this->_getParam('id');
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-05-04 22:07:29 +02:00
|
|
|
$file_id = $this->_getParam('id', null);
|
|
|
|
$file = StoredFile::Recall($file_id);
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-06-22 22:50:58 +02:00
|
|
|
$url = $file->getRelativeFileUrl().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
|
2011-05-04 22:07:29 +02:00
|
|
|
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
|
|
|
|
'title' => 'Download');
|
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$menu[] = array('action' => array('type' => 'fn',
|
2011-05-17 23:30:17 +02:00
|
|
|
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Delete');
|
|
|
|
}
|
|
|
|
else if($type === "pl") {
|
|
|
|
|
|
|
|
if(!isset($pl_sess->id) || $pl_sess->id !== $id) {
|
2011-05-17 23:30:17 +02:00
|
|
|
$menu[] = array('action' =>
|
|
|
|
array('type' => 'ajax',
|
|
|
|
'url' => '/Playlist/edit'.$params,
|
|
|
|
'callback' => 'window["openDiffSPL"]'),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Edit');
|
|
|
|
}
|
|
|
|
else if(isset($pl_sess->id) && $pl_sess->id === $id) {
|
2011-05-17 23:30:17 +02:00
|
|
|
$menu[] = array('action' =>
|
|
|
|
array('type' => 'ajax',
|
|
|
|
'url' => '/Playlist/close'.$params,
|
|
|
|
'callback' => 'window["noOpenPL"]'),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Close');
|
|
|
|
}
|
2010-12-30 00:43:17 +01:00
|
|
|
|
2011-05-17 23:30:17 +02:00
|
|
|
//$menu[] = array('action' => array('type' => 'ajax', 'url' => '/Playlist/metadata/format/json/id/#id#', 'callback' => 'window["createPlaylistMetaForm"]'), 'title' => 'Edit Metadata');
|
2010-12-30 21:10:05 +01:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$menu[] = array('action' => array('type' => 'fn',
|
2011-05-17 23:30:17 +02:00
|
|
|
'callback' => "window['confirmDeletePlaylist']('$paramsPop')"),
|
2011-04-18 18:43:04 +02:00
|
|
|
'title' => 'Delete');
|
|
|
|
|
|
|
|
}
|
2010-12-30 00:43:17 +01:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
//returns format jjmenu is looking for.
|
|
|
|
die(json_encode($menu));
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function deleteAction()
|
|
|
|
{
|
|
|
|
$id = $this->_getParam('id');
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
if (!is_null($id)) {
|
|
|
|
$file = StoredFile::Recall($id);
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
if (PEAR::isError($file)) {
|
|
|
|
$this->view->message = $file->getMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if(is_null($file)) {
|
|
|
|
$this->view->message = "file doesn't exist";
|
|
|
|
return;
|
2011-05-17 23:30:17 +02:00
|
|
|
}
|
2011-04-18 18:43:04 +02:00
|
|
|
|
|
|
|
$res = $file->delete();
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
if (PEAR::isError($res)) {
|
|
|
|
$this->view->message = $res->getMessage();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->view->id = $id;
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function contentsAction()
|
|
|
|
{
|
2011-05-17 23:30:17 +02:00
|
|
|
$post = $this->getRequest()->getPost();
|
2011-04-18 18:43:04 +02:00
|
|
|
$datatables = StoredFile::searchFilesForPlaylistBuilder($post);
|
2010-12-22 05:33:58 +01:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
die(json_encode($datatables));
|
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
|
|
|
{
|
2010-12-30 23:26:44 +01:00
|
|
|
$request = $this->getRequest();
|
2011-05-17 23:30:17 +02:00
|
|
|
$form = new Application_Form_EditAudioMD();
|
2010-12-30 23:26:44 +01:00
|
|
|
|
2011-02-24 17:06:19 +01:00
|
|
|
$file_id = $this->_getParam('id', null);
|
2011-04-18 18:43:04 +02:00
|
|
|
$file = StoredFile::Recall($file_id);
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
if ($request->isPost()) {
|
2011-05-17 23:30:17 +02:00
|
|
|
if ($form->isValid($request->getPost())) {
|
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$formdata = $form->getValues();
|
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-06-10 16:43:30 +02:00
|
|
|
|
2011-06-17 17:54:36 +02:00
|
|
|
RabbitMq::SendMessageToMediaMonitor("md_update", $data);
|
2011-05-05 16:55:14 +02:00
|
|
|
|
2011-04-18 18:43:04 +02:00
|
|
|
$this->_helper->redirector('index');
|
2010-12-30 23:26:44 +01:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 17:06:19 +01:00
|
|
|
|
2011-06-09 11:50:03 +02:00
|
|
|
$form->populate($file->getDbColMetadata());
|
2010-12-30 23:26:44 +01:00
|
|
|
$this->view->form = $form;
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
2011-02-04 06:15:56 +01:00
|
|
|
|
|
|
|
public function getFileMetaDataAction()
|
|
|
|
{
|
2011-02-04 07:28:55 +01:00
|
|
|
$id = $this->_getParam('id');
|
|
|
|
$type = $this->_getParam('type');
|
2011-02-04 06:15:56 +01:00
|
|
|
|
2011-02-04 07:28:55 +01:00
|
|
|
if($type == "au") {
|
|
|
|
$file = StoredFile::Recall($id);
|
|
|
|
$this->view->type = $type;
|
2011-02-04 06:15:56 +01:00
|
|
|
$this->view->md = $file->md;
|
|
|
|
}
|
2011-02-04 07:28:55 +01:00
|
|
|
else if($type == "pl") {
|
|
|
|
$file = Playlist::Recall($id);
|
|
|
|
$this->view->type = $type;
|
2011-02-04 06:15:56 +01:00
|
|
|
$this->view->md = $file->getAllPLMetaData();
|
|
|
|
$this->view->contents = $file->getContents();
|
|
|
|
}
|
2011-05-17 23:30:17 +02:00
|
|
|
|
2011-02-04 06:15:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-07 20:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-30 23:26:44 +01:00
|
|
|
|
|
|
|
|
2011-01-05 01:18:44 +01:00
|
|
|
|
|
|
|
|
2011-02-04 06:15:56 +01:00
|
|
|
|
|
|
|
|