CC-5450 : Refactor Media Management (Classes/DB) in Airtime
creating context menus for the media in their own services.
This commit is contained in:
parent
86b5f68c67
commit
2feac41af7
|
@ -94,25 +94,15 @@ class ApiController extends Zend_Controller_Action
|
|||
clearstatcache();
|
||||
|
||||
if (is_file($filepath)) {
|
||||
//$full_path = $media->getPropelOrm()->getDbFilepath();
|
||||
|
||||
//$file_base_name = strrchr($full_path, '/');
|
||||
/* If $full_path does not contain a '/', strrchr will return false,
|
||||
* in which case we can use $full_path as the base name.
|
||||
*/
|
||||
//if (!$file_base_name) {
|
||||
// $file_base_name = $full_path;
|
||||
//} else {
|
||||
// $file_base_name = substr($file_base_name, 1);
|
||||
//}
|
||||
|
||||
|
||||
//Download user left clicks a track and selects Download.
|
||||
if ("true" == $this->_getParam('download')) {
|
||||
//path_info breaks up a file path into seperate pieces of informaiton.
|
||||
//We just want the basename which is the file name with the path
|
||||
//information stripped away. We are using Content-Disposition to specify
|
||||
//to the browser what name the file should be saved as.
|
||||
header('Content-Disposition: attachment; filename="'.$info.'"');
|
||||
$filename = basename($filepath);
|
||||
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||
} else {
|
||||
//user clicks play button for track and downloads it.
|
||||
header('Content-Disposition: inline; filename="'.$info.'"');
|
||||
|
|
|
@ -75,24 +75,8 @@ class LibraryController extends Zend_Controller_Action
|
|||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||
$id = intval($this->_getParam('id'));
|
||||
|
||||
$menu = array();
|
||||
|
||||
/*
|
||||
$menu["pl_add"] = array(
|
||||
"name" => _("Add to Playlist"),
|
||||
"requestUrl" => $baseUrl."playlist/add-items",
|
||||
"requestType" => "POST",
|
||||
"requestData" => array("ids" => array($id)),
|
||||
"callback" => "AIRTIME.playlist.redrawPlaylist"
|
||||
);
|
||||
*/
|
||||
|
||||
$menu["preview"] = array(
|
||||
"name" => _("Preview"),
|
||||
"icon" => "play",
|
||||
"id" => $id,
|
||||
"callback" => "previewMedia"
|
||||
);
|
||||
$mediaService = new Application_Service_MediaService();
|
||||
$menu = $mediaService->createContextMenu($id);
|
||||
|
||||
if (empty($menu)) {
|
||||
$menu["noaction"] = array("name"=>_("No action available"));
|
||||
|
|
|
@ -464,4 +464,28 @@ class Application_Service_AudioFileService
|
|||
|
||||
return ($rv == 0 && !$isError);
|
||||
}
|
||||
|
||||
public function createContextMenu($audioFile) {
|
||||
|
||||
$id = $audioFile->getId();
|
||||
|
||||
$menu = array();
|
||||
|
||||
$menu["preview"] = array(
|
||||
"name" => _("Preview"),
|
||||
"icon" => "play",
|
||||
"id" => $id,
|
||||
"callback" => "previewMedia"
|
||||
);
|
||||
|
||||
$url = $audioFile->getFileUrl().'/download/true';
|
||||
$menu["download"] = array(
|
||||
"name" => _("Download"),
|
||||
"icon" => "download",
|
||||
"url" => $url,
|
||||
"callback" => "downloadMedia"
|
||||
);
|
||||
|
||||
return $menu;
|
||||
}
|
||||
}
|
|
@ -734,6 +734,16 @@ class Application_Service_MediaService
|
|||
return new $serviceClass();
|
||||
}
|
||||
|
||||
public function createContextMenu($mediaId) {
|
||||
|
||||
$mediaItem = MediaItemQuery::create()->findPK($mediaId);
|
||||
$obj = $mediaItem->getChildObject();
|
||||
|
||||
$service = self::locateServiceType($mediaItem);
|
||||
|
||||
return $service->createContextMenu($obj);
|
||||
}
|
||||
|
||||
public function getJPlayerPreviewPlaylist($mediaId) {
|
||||
|
||||
$mediaItem = MediaItemQuery::create()->findPK($mediaId);
|
||||
|
|
|
@ -90,4 +90,20 @@ class Application_Service_WebstreamService
|
|||
|
||||
WebstreamQuery::create()->findPks($ids)->delete();
|
||||
}
|
||||
|
||||
public function createContextMenu($webstream) {
|
||||
|
||||
$id = $webstream->getId();
|
||||
|
||||
$menu = array();
|
||||
|
||||
$menu["preview"] = array(
|
||||
"name" => _("Preview"),
|
||||
"icon" => "play",
|
||||
"id" => $id,
|
||||
"callback" => "previewMedia"
|
||||
);
|
||||
|
||||
return $menu;
|
||||
}
|
||||
}
|
|
@ -55,7 +55,15 @@ var AIRTIME = (function(AIRTIME) {
|
|||
table.fnSetFilteringDelay(350);
|
||||
}
|
||||
|
||||
mod.previewMedia = function(mediaId) {
|
||||
mod.downloadMedia = function(data) {
|
||||
console.log("downloading media " + data.id);
|
||||
|
||||
document.location.href = data.url;
|
||||
};
|
||||
|
||||
mod.previewMedia = function(data) {
|
||||
var mediaId = data.id;
|
||||
|
||||
console.log("previewing media " + mediaId);
|
||||
|
||||
AIRTIME.playerPreview.previewMedia(mediaId);
|
||||
|
@ -64,35 +72,10 @@ var AIRTIME = (function(AIRTIME) {
|
|||
function sendContextMenuRequest(data) {
|
||||
|
||||
console.log(data);
|
||||
mod[data.callback](data.id);
|
||||
|
||||
/*
|
||||
var callback = data.callback;
|
||||
|
||||
data.requestData["format"] = "json";
|
||||
|
||||
$.ajax({
|
||||
url: data.requestUrl,
|
||||
type: data.requestType,
|
||||
data: data.requestData,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
|
||||
var f = callback.split("."),
|
||||
i,
|
||||
len,
|
||||
obj = window;
|
||||
|
||||
for (i = 0, len = f.length; i < len; i++) {
|
||||
|
||||
obj = obj[f[i]];
|
||||
}
|
||||
|
||||
obj(json);
|
||||
}
|
||||
});
|
||||
*/
|
||||
if (data.callback !== undefined) {
|
||||
mod[data.callback](data);
|
||||
}
|
||||
}
|
||||
|
||||
function getActiveTabId() {
|
||||
|
|
Loading…
Reference in New Issue