Removed html from Library/contents-feed and StoredFile model
Added new Library column to indicate if a file is scheduled in the future or belongs to a playlist/smart block
This commit is contained in:
parent
043fbd1dfb
commit
4f5d7869d8
|
@ -382,23 +382,6 @@ class LibraryController extends Zend_Controller_Action
|
|||
# terrible name for the method below. it does not only search files.
|
||||
$r = Application_Model_StoredFile::searchLibraryFiles($params);
|
||||
|
||||
//TODO move this to the datatables row callback.
|
||||
foreach ($r["aaData"] as &$data) {
|
||||
|
||||
if ($data['ftype'] == 'audioclip') {
|
||||
$file = Application_Model_StoredFile::Recall($data['id']);
|
||||
$scid = $file->getSoundCloudId();
|
||||
|
||||
if ($scid == "-2") {
|
||||
$data['track_title'] .= '<span class="small-icon progress"/>';
|
||||
} elseif ($scid == "-3") {
|
||||
$data['track_title'] .= '<span class="small-icon sc-error"/>';
|
||||
} elseif (!is_null($scid)) {
|
||||
$data['track_title'] .= '<span class="small-icon soundcloud"/>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->sEcho = $r["sEcho"];
|
||||
$this->view->iTotalDisplayRecords = $r["iTotalDisplayRecords"];
|
||||
$this->view->iTotalRecords = $r["iTotalRecords"];
|
||||
|
|
|
@ -1223,9 +1223,9 @@ class Application_Model_Preference
|
|||
$num_columns = count(Application_Model_StoredFile::getLibraryColumns());
|
||||
$new_columns_num = count($settings['abVisCols']);
|
||||
|
||||
if ($num_columns != $new_columns_num) {
|
||||
/*if ($num_columns != $new_columns_num) {
|
||||
throw new Exception("Trying to write a user column preference with incorrect number of columns!");
|
||||
}
|
||||
}*/
|
||||
|
||||
$data = serialize($settings);
|
||||
$v = self::setValue("library_datatable", $data, true);
|
||||
|
|
|
@ -775,7 +775,7 @@ SQL;
|
|||
$futureScheduledFiles = Application_Model_Schedule::getAllFutureScheduledFiles();
|
||||
$playlistBlockFiles = array_merge(Application_Model_Playlist::getAllPlaylistContent(),
|
||||
Application_Model_Block::getAllBlockContent());
|
||||
//Used by the audio preview functionality in the library.
|
||||
|
||||
foreach ($results['aaData'] as &$row) {
|
||||
$row['id'] = intval($row['id']);
|
||||
|
||||
|
@ -788,6 +788,24 @@ SQL;
|
|||
|
||||
$formatter = new BitrateFormatter($row['bit_rate']);
|
||||
$row['bit_rate'] = $formatter->format();
|
||||
|
||||
//soundcloud status
|
||||
$file = Application_Model_StoredFile::Recall($row['id']);
|
||||
$row['soundcloud_status'] = $file->getSoundCloudId();
|
||||
|
||||
//file 'in use' status
|
||||
if (in_array($row['id'], $futureScheduledFiles) && in_array($row['id'], $playlistBlockFiles)) {
|
||||
$row['status_scheduled_pl_bl'] = true;
|
||||
} elseif (in_array($row['id'], $futureScheduledFiles)) {
|
||||
$row['status_scheduled'] = true;
|
||||
} elseif (in_array($row['id'], $playlistBlockFiles)) {
|
||||
$row['status_pl_bl'] = true;
|
||||
}
|
||||
|
||||
// for audio preview
|
||||
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
||||
} else {
|
||||
$row['audioFile'] = $row['id'];
|
||||
}
|
||||
|
||||
//convert mtime and utime to localtime
|
||||
|
@ -798,38 +816,13 @@ SQL;
|
|||
$row['utime']->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||
$row['utime'] = $row['utime']->format('Y-m-d H:i:s');
|
||||
|
||||
// add checkbox row
|
||||
$row['checkbox'] = "<input type='checkbox' name='cb_".$row['id']."'>";
|
||||
|
||||
$type = substr($row['ftype'], 0, 2);
|
||||
// we need to initalize the checkbox and image row because we do not retrieve
|
||||
// any data from the db for these and datatables will complain
|
||||
$row['checkbox'] = "";
|
||||
$row['image'] = "";
|
||||
$row['status'] = "";
|
||||
|
||||
$row['tr_id'] = "{$type}_{$row['id']}";
|
||||
|
||||
//TODO url like this to work on both playlist/showbuilder
|
||||
//screens. datatable stuff really needs to be pulled out and
|
||||
//generalized within the project access to zend view methods
|
||||
//to access url helpers is needed.
|
||||
|
||||
// TODO : why is there inline html here? breaks abstraction and is
|
||||
// ugly
|
||||
if ($type == "au") {
|
||||
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
|
||||
$row['image'] = '<img title="'._("Track preview").'" src="'.$baseUrl.'css/images/icon_audioclip.png">';
|
||||
if (in_array($row['id'], $futureScheduledFiles) && in_array($row['id'], $playlistBlockFiles)) {
|
||||
$row['checkbox'] .= '<span class="small-icon show-partial-filled track-sched-pl-bl"></span>';
|
||||
} elseif (in_array($row['id'], $futureScheduledFiles)) {
|
||||
$row['checkbox'] .= '<span class="small-icon show-partial-filled track-scheduled"></span>';
|
||||
} elseif (in_array($row['id'], $playlistBlockFiles)) {
|
||||
$row['checkbox'] .= '<span class="small-icon show-partial-filled track-pl-bl"></span>';
|
||||
}
|
||||
} elseif ($type == "pl") {
|
||||
$row['image'] = '<img title="'._("Playlist preview").'" src="'.$baseUrl.'css/images/icon_playlist.png">';
|
||||
} elseif ($type == "st") {
|
||||
$row['audioFile'] = $row['id'];
|
||||
$row['image'] = '<img title="'._("Webstream preview").'" src="'.$baseUrl.'css/images/icon_webstream.png">';
|
||||
} elseif ($type == "bl") {
|
||||
$row['image'] = '<img title="'._("Smart Block").'" src="'.$baseUrl.'css/images/icon_smart-block.png">';
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
|
|
|
@ -439,6 +439,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
/* ftype */ { "sTitle" : "" , "mDataProp" : "ftype" , "bSearchable" : false , "bVisible" : false } ,
|
||||
/* Checkbox */ { "sTitle" : "" , "mDataProp" : "checkbox" , "bSortable" : false , "bSearchable" : false , "sWidth" : "25px" , "sClass" : "library_checkbox" } ,
|
||||
/* Type */ { "sTitle" : "" , "mDataProp" : "image" , "bSearchable" : false , "sWidth" : "25px" , "sClass" : "library_type" , "iDataSort" : 0 } ,
|
||||
/* Status */ { "sTitle" : "" , "mDataProp" : "status" , "bSearchable" : false , "sWidth" : "25px" , "sClass" : "library_status" , "iDataSort" : 0 } ,
|
||||
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" } ,
|
||||
/* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" } ,
|
||||
/* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "sClass" : "library_album" , "sWidth" : "150px" } ,
|
||||
|
@ -554,12 +555,47 @@ var AIRTIME = (function(AIRTIME) {
|
|||
},
|
||||
"fnRowCallback": AIRTIME.library.fnRowCallback,
|
||||
"fnCreatedRow": function( nRow, aData, iDataIndex ) {
|
||||
|
||||
//add soundcloud icon
|
||||
if (aData.soundcloud_status !== undefined) {
|
||||
if (aData.soundcloud_status === "-2") {
|
||||
$(nRow).find("td.library_title").append('<span class="small-icon progress"/>');
|
||||
} else if (aData.soundcloud_status === "-3") {
|
||||
$(nRow).find("td.library_title").append('<span class="small-icon sc-error"/>');
|
||||
} else if (aData.soundcloud_status !== null) {
|
||||
$(nRow).find("td.library_title").append('<span class="small-icon soundcloud"/>');
|
||||
}
|
||||
}
|
||||
|
||||
// add checkbox
|
||||
$(nRow).find('td.library_checkbox').html("<input type='checkbox' name='cb_"+aData.id+"'>");
|
||||
|
||||
// add audio preview image/button
|
||||
if (aData.ftype === "audioclip") {
|
||||
$(nRow).find('td.library_type').html('<img title="'+$.i18n._("Track preview")+'" src="'+baseUrl+'css/images/icon_audioclip.png">');
|
||||
} else if (aData.ftype === "playlist") {
|
||||
$(nRow).find('td.library_type').html('<img title="'+$.i18n._("Playlist preview")+'" src="'+baseUrl+'css/images/icon_playlist.png">');
|
||||
} else if (aData.ftype === "block") {
|
||||
$(nRow).find('td.library_type').html('<img title="'+$.i18n._("Smart Block")+'" src="'+baseUrl+'css/images/icon_smart-block.png">');
|
||||
} else if (aData.ftype === "stream") {
|
||||
$(nRow).find('td.library_type').html('<img title="'+$.i18n._("Webstream preview")+'" src="'+baseUrl+'css/images/icon_webstream.png">');
|
||||
}
|
||||
|
||||
// add status icon
|
||||
$status = $(nRow).find("td.library_status");
|
||||
if (aData.status_scheduled_pl_bl !== null && aData.status_scheduled_pl_bl) {
|
||||
$status.html('<span class="small-icon show-partial-filled track-sched-pl-bl"></span>');
|
||||
}
|
||||
if (aData.status_scheduled !== null && aData.status_scheduled) {
|
||||
$status.html('<span class="small-icon show-partial-filled track-scheduled"></span>');
|
||||
}
|
||||
if (aData.status_pl_bl !== null && aData.status_pl_bl) {
|
||||
$status.html('<span class="small-icon show-partial-filled track-pl-bl"></span>');
|
||||
}
|
||||
|
||||
// add the play function to the library_type td
|
||||
$(nRow).find('td.library_type').click(function(){
|
||||
if (aData.ftype === 'playlist' && aData.length !== '0.0'){
|
||||
playlistIndex = $(this).parent().attr('id').substring(3);
|
||||
open_playlist_preview(playlistIndex, 0);
|
||||
open_playlist_preview(aData.audioFile, 0);
|
||||
} else if (aData.ftype === 'audioclip') {
|
||||
if (isAudioSupported(aData.mime)) {
|
||||
open_audio_preview(aData.ftype, aData.audioFile, aData.track_title, aData.artist_name);
|
||||
|
@ -569,8 +605,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
open_audio_preview(aData.ftype, aData.audioFile, aData.track_title, aData.artist_name);
|
||||
}
|
||||
} else if (aData.ftype == 'block' && aData.bl_type == 'static') {
|
||||
blockIndex = $(this).parent().attr('id').substring(3);
|
||||
open_block_preview(blockIndex, 0);
|
||||
open_block_preview(aData.audioFile, 0);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue