CC-3817 : Should use soundcloud icon for recorded & uploaded shows in timeline for past shows to match calendar

This commit is contained in:
Naomi Aro 2013-05-28 14:27:59 -04:00
parent 51573d36c9
commit 4d1a15b7ca
4 changed files with 68 additions and 73 deletions

View File

@ -30,7 +30,7 @@ AND file_id is not null
SQL; SQL;
$files = Application_Common_Database::prepareAndExecute( $sql, array()); $files = Application_Common_Database::prepareAndExecute( $sql, array());
$real_files = array(); $real_files = array();
foreach ($files as $f) { foreach ($files as $f) {
$real_files[] = $f['file_id']; $real_files[] = $f['file_id'];
@ -48,7 +48,7 @@ WHERE ends > now() AT TIME ZONE 'UTC'
AND stream_id is not null AND stream_id is not null
SQL; SQL;
$streams = Application_Common_Database::prepareAndExecute( $sql, array()); $streams = Application_Common_Database::prepareAndExecute( $sql, array());
$real_streams = array(); $real_streams = array();
foreach ($streams as $s) { foreach ($streams as $s) {
$real_streams[] = $s['stream_id']; $real_streams[] = $s['stream_id'];
@ -322,7 +322,8 @@ SQL;
ft.album_title AS file_album_title, ft.album_title AS file_album_title,
ft.length AS file_length, ft.length AS file_length,
ft.file_exists AS file_exists, ft.file_exists AS file_exists,
ft.mime AS file_mime ft.mime AS file_mime,
ft.soundcloud_id AS soundcloud_id
SQL; SQL;
$filesJoin = <<<SQL $filesJoin = <<<SQL
cc_schedule AS sched cc_schedule AS sched
@ -357,7 +358,8 @@ SQL;
ws.description AS file_album_title, ws.description AS file_album_title,
ws.length AS file_length, ws.length AS file_length,
't'::BOOL AS file_exists, 't'::BOOL AS file_exists,
ws.mime as file_mime ws.mime AS file_mime,
(SELECT NULL::integer AS soundcloud_id)
SQL; SQL;
$streamJoin = <<<SQL $streamJoin = <<<SQL
cc_schedule AS sched cc_schedule AS sched
@ -391,17 +393,17 @@ SQL;
$showPredicate = ""; $showPredicate = "";
if (count($p_shows) > 0) { if (count($p_shows) > 0) {
$params = array(); $params = array();
$map = array(); $map = array();
for ($i = 0, $len = count($p_shows); $i < $len; $i++) { for ($i = 0, $len = count($p_shows); $i < $len; $i++) {
$holder = "show_".$i; $holder = "show_".$i;
$params[] = $holder; $params[] = $holder;
$map[$holder] = $p_shows[$i]; $map[$holder] = $p_shows[$i];
} }
$showPredicate = " AND show_id IN (".implode(",", $params).")"; $showPredicate = " AND show_id IN (".implode(",", $params).")";
$paramMap = $paramMap + $map; $paramMap = $paramMap + $map;
} else if (count($p_show_instances) > 0) { } else if (count($p_show_instances) > 0) {
@ -448,13 +450,13 @@ SQL;
":ts_6" => $p_end_str, ":ts_6" => $p_end_str,
); );
$paramMap = $paramMap + $map; $paramMap = $paramMap + $map;
$rows = Application_Common_Database::prepareAndExecute( $rows = Application_Common_Database::prepareAndExecute(
$sql, $sql,
$paramMap, $paramMap,
Application_Common_Database::ALL Application_Common_Database::ALL
); );
return $rows; return $rows;
} }
@ -475,7 +477,7 @@ SQL;
$sql .= " WHERE id=:pid"; $sql .= " WHERE id=:pid";
$map = array(":pid" => $p_id); $map = array(":pid" => $p_id);
Application_Common_Database::prepareAndExecute($sql, $map, Application_Common_Database::prepareAndExecute($sql, $map,
Application_Common_Database::EXECUTE); Application_Common_Database::EXECUTE);
} }
@ -501,9 +503,9 @@ SQL;
{ {
$sql = "SELECT count(*) as cnt FROM cc_schedule"; $sql = "SELECT count(*) as cnt FROM cc_schedule";
$res = Application_Common_Database::prepareAndExecute($sql, array(), $res = Application_Common_Database::prepareAndExecute($sql, array(),
Application_Common_Database::COLUMN); Application_Common_Database::COLUMN);
return $res; return $res;
} }
@ -706,7 +708,7 @@ SQL;
$key = "{$time}_{$i}"; $key = "{$time}_{$i}";
$i++; $i++;
} }
$data["media"][$key] = $item; $data["media"][$key] = $item;
} }
@ -755,7 +757,7 @@ SQL;
$replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"]; $replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"];
$replay_gain += Application_Model_Preference::getReplayGainModifier(); $replay_gain += Application_Model_Preference::getReplayGainModifier();
if ( !Application_Model_Preference::GetEnableReplayGain() ) { if ( !Application_Model_Preference::GetEnableReplayGain() ) {
$replay_gain = 0; $replay_gain = 0;
} }
@ -775,7 +777,7 @@ SQL;
'replay_gain' => $replay_gain, 'replay_gain' => $replay_gain,
'independent_event' => $independent_event, 'independent_event' => $independent_event,
); );
if ($schedule_item['cue_in'] > $schedule_item['cue_out']) { if ($schedule_item['cue_in'] > $schedule_item['cue_out']) {
$schedule_item['cue_in'] = $schedule_item['cue_out']; $schedule_item['cue_in'] = $schedule_item['cue_out'];
} }
@ -915,10 +917,10 @@ SQL;
} else { } else {
throw new Exception("Unknown schedule type: ".print_r($item, true)); throw new Exception("Unknown schedule type: ".print_r($item, true));
} }
} }
} }
/* Check if two events are less than or equal to 1 second apart /* Check if two events are less than or equal to 1 second apart
*/ */
public static function areEventsLinked($event1, $event2) { public static function areEventsLinked($event1, $event2) {
@ -996,7 +998,7 @@ SQL;
public static function deleteAll() public static function deleteAll()
{ {
$sql = "TRUNCATE TABLE cc_schedule"; $sql = "TRUNCATE TABLE cc_schedule";
Application_Common_Database::prepareAndExecute($sql, array(), Application_Common_Database::prepareAndExecute($sql, array(),
Application_Common_Database::EXECUTE); Application_Common_Database::EXECUTE);
} }
@ -1279,14 +1281,14 @@ SQL;
$update=false, $instanceId=null, $showId=null) $update=false, $instanceId=null, $showId=null)
{ {
$overlapping = false; $overlapping = false;
$params = array( $params = array(
':show_end1' => $show_end->format('Y-m-d H:i:s'), ':show_end1' => $show_end->format('Y-m-d H:i:s'),
':show_end2' => $show_end->format('Y-m-d H:i:s'), ':show_end2' => $show_end->format('Y-m-d H:i:s'),
':show_end3' => $show_end->format('Y-m-d H:i:s') ':show_end3' => $show_end->format('Y-m-d H:i:s')
); );
/* If a show is being edited, exclude it from the query /* If a show is being edited, exclude it from the query
* In both cases (new and edit) we only grab shows that * In both cases (new and edit) we only grab shows that
* are scheduled 2 days prior * are scheduled 2 days prior
@ -1357,18 +1359,18 @@ SQL;
return 'file'; return 'file';
} }
} }
public static function GetFileId($p_scheduleId) public static function GetFileId($p_scheduleId)
{ {
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId); $scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
return $scheduledItem->getDbFileId(); return $scheduledItem->getDbFileId();
} }
public static function GetStreamId($p_scheduleId) public static function GetStreamId($p_scheduleId)
{ {
$scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId); $scheduledItem = CcScheduleQuery::create()->findPK($p_scheduleId);
return $scheduledItem->getDbStreamId(); return $scheduledItem->getDbStreamId();
} }
} }

View File

@ -150,7 +150,7 @@ class Application_Model_StoredFile
} }
} }
$dbMd[constant($mdConst)] = $mdValue; $dbMd[constant($mdConst)] = $mdValue;
} }
} }
$this->setDbColMetadata($dbMd); $this->setDbColMetadata($dbMd);
@ -214,7 +214,7 @@ class Application_Model_StoredFile
if (isset($this->_dbMD[$dbColumn])) { if (isset($this->_dbMD[$dbColumn])) {
$propelColumn = $this->_dbMD[$dbColumn]; $propelColumn = $this->_dbMD[$dbColumn];
$method = "set$propelColumn"; $method = "set$propelColumn";
/* We need to set track_number to null if it is an empty string /* We need to set track_number to null if it is an empty string
* because propel defaults empty strings to zeros */ * because propel defaults empty strings to zeros */
if ($dbColumn == "track_number" && empty($mdValue)) $mdValue = null; if ($dbColumn == "track_number" && empty($mdValue)) $mdValue = null;
@ -330,7 +330,7 @@ SQL;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT); $stmt->bindParam(':file_id', $this->id, PDO::PARAM_INT);
if ($stmt->execute()) { if ($stmt->execute()) {
$ids = $stmt->fetchAll(); $ids = $stmt->fetchAll();
} else { } else {
@ -386,7 +386,7 @@ SQL;
// set hidden flag to true // set hidden flag to true
$this->_file->setDbHidden(true); $this->_file->setDbHidden(true);
$this->_file->save(); $this->_file->save();
// need to explicitly update any playlist's and block's length // need to explicitly update any playlist's and block's length
// that contains the file getting deleted // that contains the file getting deleted
$fileId = $this->_file->getDbId(); $fileId = $this->_file->getDbId();
@ -396,7 +396,7 @@ SQL;
$pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME))); $pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME)));
$pl->save(); $pl->save();
} }
$blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find(); $blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find();
foreach ($blRows as $row) { foreach ($blRows as $row) {
$bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne(); $bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne();
@ -506,19 +506,19 @@ SQL;
public function getFileUrl() public function getFileUrl()
{ {
$CC_CONFIG = Config::getConfig(); $CC_CONFIG = Config::getConfig();
$protocol = empty($_SERVER['HTTPS']) ? "http" : "https"; $protocol = empty($_SERVER['HTTPS']) ? "http" : "https";
$serverName = $_SERVER['SERVER_NAME']; $serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT']; $serverPort = $_SERVER['SERVER_PORT'];
$subDir = $CC_CONFIG['baseDir']; $subDir = $CC_CONFIG['baseDir'];
if ($subDir[0] === "/") { if ($subDir[0] === "/") {
$subDir = substr($subDir, 1, strlen($subDir) - 1); $subDir = substr($subDir, 1, strlen($subDir) - 1);
} }
$baseUrl = "{$protocol}://{$serverName}:{$serverPort}/{$subDir}"; $baseUrl = "{$protocol}://{$serverName}:{$serverPort}/{$subDir}";
return $this->getRelativeFileUrl($baseUrl); return $this->getRelativeFileUrl($baseUrl);
} }
@ -641,7 +641,7 @@ SQL;
public static function searchLibraryFiles($datatables) public static function searchLibraryFiles($datatables)
{ {
$baseUrl = Application_Common_OsPath::getBaseDir(); $baseUrl = Application_Common_OsPath::getBaseDir();
$con = Propel::getConnection(CcFilesPeer::DATABASE_NAME); $con = Propel::getConnection(CcFilesPeer::DATABASE_NAME);
$displayColumns = self::getLibraryColumns(); $displayColumns = self::getLibraryColumns();
@ -796,7 +796,7 @@ SQL;
//soundcloud status //soundcloud status
$file = Application_Model_StoredFile::RecallById($row['id']); $file = Application_Model_StoredFile::RecallById($row['id']);
$row['soundcloud_status'] = $file->getSoundCloudId(); $row['soundcloud_id'] = $file->getSoundCloudId();
// for audio preview // for audio preview
$row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION); $row['audioFile'] = $row['id'].".".pathinfo($row['filepath'], PATHINFO_EXTENSION);
@ -1028,7 +1028,7 @@ SQL;
$LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.'); $LIQUIDSOAP_ERRORS = array('TagLib: MPEG::Properties::read() -- Could not find a valid last MPEG frame in the stream.');
// Ask Liquidsoap if file is playable // Ask Liquidsoap if file is playable
$ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1', $ls_command = sprintf('/usr/bin/airtime-liquidsoap -v -c "output.dummy(audio_to_stereo(single(%s)))" 2>&1',
escapeshellarg($audio_file)); escapeshellarg($audio_file));
$command = "export PATH=/usr/local/bin:/usr/bin:/bin/usr/bin/ && $ls_command"; $command = "export PATH=/usr/local/bin:/usr/bin:/bin/usr/bin/ && $ls_command";
@ -1068,14 +1068,14 @@ SQL;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindParam(':dir_id', $dir_id); $stmt->bindParam(':dir_id', $dir_id);
if ($stmt->execute()) { if ($stmt->execute()) {
$rows = $stmt->fetchAll(); $rows = $stmt->fetchAll();
} else { } else {
$msg = implode(',', $stmt->errorInfo()); $msg = implode(',', $stmt->errorInfo());
throw new Exception("Error: $msg"); throw new Exception("Error: $msg");
} }
$results = array(); $results = array();
foreach ($rows as $row) { foreach ($rows as $row) {
$results[] = $row["fp"]; $results[] = $row["fp"];
@ -1111,10 +1111,10 @@ SQL;
return $rows; return $rows;
} }
public static function getAllFilesWithoutSilan() { public static function getAllFilesWithoutSilan() {
$con = Propel::getConnection(); $con = Propel::getConnection();
$sql = <<<SQL $sql = <<<SQL
SELECT f.id, SELECT f.id,
m.directory || f.filepath AS fp m.directory || f.filepath AS fp
@ -1124,14 +1124,14 @@ WHERE file_exists = 'TRUE'
AND silan_check IS FALSE Limit 100 AND silan_check IS FALSE Limit 100
SQL; SQL;
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
if ($stmt->execute()) { if ($stmt->execute()) {
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else { } else {
$msg = implode(',', $stmt->errorInfo()); $msg = implode(',', $stmt->errorInfo());
throw new Exception("Error: $msg"); throw new Exception("Error: $msg");
} }
return $rows; return $rows;
} }
@ -1227,7 +1227,7 @@ SQL;
->save(); ->save();
} }
// This method seems to be unsued everywhere so I've commented it out // This method seems to be unsued everywhere so I've commented it out
// If it's absence does not have any effect then it will be completely // If it's absence does not have any effect then it will be completely
// removed soon // removed soon
@ -1284,7 +1284,7 @@ SQL;
} }
} }
} }
public static function setIsPlaylist($p_playlistItems, $p_type, $p_status) { public static function setIsPlaylist($p_playlistItems, $p_type, $p_status) {
foreach ($p_playlistItems as $item) { foreach ($p_playlistItems as $item) {
$file = self::RecallById($item->getDbFileId()); $file = self::RecallById($item->getDbFileId());
@ -1302,7 +1302,7 @@ SQL;
} }
} }
} }
public static function setIsScheduled($p_scheduleItem, $p_status, public static function setIsScheduled($p_scheduleItem, $p_status,
$p_fileId=null) { $p_fileId=null) {

View File

@ -593,12 +593,12 @@ var AIRTIME = (function(AIRTIME) {
"fnRowCallback": AIRTIME.library.fnRowCallback, "fnRowCallback": AIRTIME.library.fnRowCallback,
"fnCreatedRow": function( nRow, aData, iDataIndex ) { "fnCreatedRow": function( nRow, aData, iDataIndex ) {
//add soundcloud icon //add soundcloud icon
if (aData.soundcloud_status !== undefined) { if (aData.soundcloud_id !== undefined) {
if (aData.soundcloud_status === "-2") { if (aData.soundcloud_id === "-2") {
$(nRow).find("td.library_title").append('<span class="small-icon progress"/>'); $(nRow).find("td.library_title").append('<span class="small-icon progress"/>');
} else if (aData.soundcloud_status === "-3") { } else if (aData.soundcloud_id === "-3") {
$(nRow).find("td.library_title").append('<span class="small-icon sc-error"/>'); $(nRow).find("td.library_title").append('<span class="small-icon sc-error"/>');
} else if (aData.soundcloud_status !== null) { } else if (aData.soundcloud_id !== null) {
$(nRow).find("td.library_title").append('<span class="small-icon soundcloud"/>'); $(nRow).find("td.library_title").append('<span class="small-icon soundcloud"/>');
} }
} }
@ -1140,10 +1140,13 @@ function checkLibrarySCUploadStatus(){
setTimeout(checkLibrarySCUploadStatus, 5000); setTimeout(checkLibrarySCUploadStatus, 5000);
} }
function addQtipToSCIcons(){ function addQtipToSCIcons() {
$(".progress, .soundcloud, .sc-error").live('mouseover', function(){ $("#content")
.on('mouseover', ".progress, .soundcloud, .sc-error", function() {
var id = $(this).parent().parent().data("aData").id; var aData = $(this).parents("tr").data("aData"),
id = aData.id,
sc_id = aData.soundcloud_id;
if ($(this).hasClass("progress")){ if ($(this).hasClass("progress")){
$(this).qtip({ $(this).qtip({
@ -1163,24 +1166,15 @@ function addQtipToSCIcons(){
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long"
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover ready: true // Needed to make it show on first mouseover event
// event
} }
}); });
} }
else if($(this).hasClass("soundcloud")){ else if ($(this).hasClass("soundcloud")){
var sc_id = $(this).parent().parent().data("aData").soundcloud_id;
$(this).qtip({ $(this).qtip({
content: { content: {
text: $.i18n._("Retrieving data from the server..."), text: $.i18n._("The soundcloud id for this file is: ") + sc_id
ajax: {
url: baseUrl+"Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', $.i18n._("The soundcloud id for this file is: ")+json.sc_id);
}
}
}, },
position:{ position:{
adjust: { adjust: {
@ -1195,11 +1189,11 @@ function addQtipToSCIcons(){
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long"
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover ready: true // Needed to make it show on first mouseover event
// event
} }
}); });
}else if($(this).hasClass("sc-error")){ }
else if ($(this).hasClass("sc-error")) {
$(this).qtip({ $(this).qtip({
content: { content: {
text: $.i18n._("Retreiving data from the server..."), text: $.i18n._("Retreiving data from the server..."),
@ -1227,8 +1221,7 @@ function addQtipToSCIcons(){
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long"
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover ready: true // Needed to make it show on first mouseover event
// event
} }
}); });
} }

View File

@ -546,7 +546,7 @@ var AIRTIME = (function(AIRTIME){
cl = 'sb-footer'; cl = 'sb-footer';
//check the show's content status. //check the show's content status.
if (aData.runtime > 0) { if (aData.runtime >= 0) {
$node.html('<span class="ui-icon ui-icon-check"></span>'); $node.html('<span class="ui-icon ui-icon-check"></span>');
cl = cl + ' ui-state-highlight'; cl = cl + ' ui-state-highlight';
} }