cc-2188: Download action for all media file.

Download action were added in two placese.

1. Playlist Builder. jjmenu now showing 'Download'.
2. Calendar-> Show Content. Click on the file, you will see
Downlaod menu.

Limitation:

File name is set to original file name.
On the ticket it said, file format should be like
"show_name-12012011-2130.mp3". However, in my opinion,
this is only possible, if a user downloads it from
calender->show content. We know what the show names and etc,
but, if the user downloads it from Playlist Builder, we cannot
retrive such information. To be consistent in both area, I just
set the file name to original file name. This can be easily
modified in the future.
This commit is contained in:
James Moon 2011-05-04 13:07:29 -07:00 committed by mkonecny
parent ed0f24831d
commit 95613f40f1
6 changed files with 58 additions and 4 deletions

View file

@ -62,6 +62,8 @@ class ApiController extends Zend_Controller_Action
$this->_helper->viewRenderer->setNoRender(true);
$api_key = $this->_getParam('api_key');
$downlaod = $this->_getParam('download');
if(!in_array($api_key, $CC_CONFIG["apiKey"]))
{
header('HTTP/1.0 401 Unauthorized');
@ -92,8 +94,9 @@ class ApiController extends Zend_Controller_Action
header("Content-Type: audio/ogg");
else if ($ext == "mp3")
header("Content-Type: audio/mpeg");
if ($downlaod){
header('Content-Disposition: attachment; filename="'.$media->getName().'"');
}
header("Content-Length: " . filesize($filepath));
fpassthru($fp);
return;

View file

@ -50,6 +50,8 @@ class LibraryController extends Zend_Controller_Action
public function contextMenuAction()
{
global $CC_CONFIG;
$id = $this->_getParam('id');
$type = $this->_getParam('type');
@ -70,6 +72,16 @@ class LibraryController extends Zend_Controller_Action
$menu[] = array('action' => array('type' => 'gourl', 'url' => '/Library/edit-file-md/id/#id#'),
'title' => 'Edit Metadata');
// added for downlaod
$id = $this->_getParam('id');
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
$url = 'api/get-media/file/'.$file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => 'Download');
$menu[] = array('action' => array('type' => 'fn',
'callback' => "window['confirmDeleteAudioClip']('$paramsPop')"),
'title' => 'Delete');

View file

@ -27,6 +27,7 @@ class ScheduleController extends Zend_Controller_Action
->addActionContext('cancel-show', 'json')
->addActionContext('get-form', 'json')
->addActionContext('upload-to-sound-cloud', 'json')
->addActionContext('content-context-menu', 'json')
->initContext();
$this->sched_sess = new Zend_Session_Namespace("schedule");
@ -703,6 +704,29 @@ class ScheduleController extends Zend_Controller_Action
$show->deleteShow();
}
}
public function contentContextMenuAction(){
global $CC_CONFIG;
$id = $this->_getParam('id');
$params = '/format/json/id/#id#/';
$paramsPop = str_replace('#id#', $id, $params);
// added for downlaod
$id = $this->_getParam('id');
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
$url = 'api/get-media/file/'.$file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
'title' => 'Download');
//returns format jjmenu is looking for.
die(json_encode($menu));
}
}