Merge branch 'master' of dev.sourcefabric.org:airtime
This commit is contained in:
commit
94dc54638a
|
@ -103,41 +103,55 @@ class ApiController extends Zend_Controller_Action
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function liveInfoAction(){
|
public function liveInfoAction()
|
||||||
// disable the view and the layout
|
{
|
||||||
$this->view->layout()->disableLayout();
|
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
// disable the view and the layout
|
||||||
|
$this->view->layout()->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
$result = Schedule::GetPlayOrderRange(0, 1);
|
$result = Schedule::GetPlayOrderRange(0, 1);
|
||||||
|
|
||||||
$date = new Application_Model_DateHelper;
|
$date = new Application_Model_DateHelper;
|
||||||
$timeNow = $date->getDate();
|
$timeNow = $date->getDate();
|
||||||
$result = array("env"=>APPLICATION_ENV,
|
$result = array("env"=>APPLICATION_ENV,
|
||||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||||
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
|
"currentShow"=>Show_DAL::GetCurrentShow($timeNow),
|
||||||
"nextShow"=>Show_DAL::GetNextShows($timeNow, 5),
|
"nextShow"=>Show_DAL::GetNextShows($timeNow, 5),
|
||||||
"timezone"=> date("T"),
|
"timezone"=> date("T"),
|
||||||
"timezoneOffset"=> date("Z"));
|
"timezoneOffset"=> date("Z"));
|
||||||
|
|
||||||
//echo json_encode($result);
|
//echo json_encode($result);
|
||||||
header("Content-type: text/javascript");
|
header("Content-type: text/javascript");
|
||||||
echo $_GET['callback'].'('.json_encode($result).')';
|
echo $_GET['callback'].'('.json_encode($result).')';
|
||||||
|
} else {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
print 'You are not allowed to access this resource. ';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function weekInfoAction(){
|
public function weekInfoAction()
|
||||||
// disable the view and the layout
|
{
|
||||||
$this->view->layout()->disableLayout();
|
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||||
$this->_helper->viewRenderer->setNoRender(true);
|
// disable the view and the layout
|
||||||
|
$this->view->layout()->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender(true);
|
||||||
|
|
||||||
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
|
$dow = array("sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday");
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
for ($i=0; $i<7; $i++){
|
for ($i=0; $i<7; $i++){
|
||||||
$result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i);
|
$result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i);
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Content-type: text/javascript");
|
||||||
|
echo $_GET['callback'].'('.json_encode($result).')';
|
||||||
|
} else {
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
print 'You are not allowed to access this resource. ';
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-type: text/javascript");
|
|
||||||
echo $_GET['callback'].'('.json_encode($result).')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scheduleAction()
|
public function scheduleAction()
|
||||||
|
@ -272,10 +286,11 @@ class ApiController extends Zend_Controller_Action
|
||||||
|
|
||||||
$show = new Show($show_inst->getShowId());
|
$show = new Show($show_inst->getShowId());
|
||||||
$description = $show->getDescription();
|
$description = $show->getDescription();
|
||||||
|
$hosts = $show->getHosts();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$soundcloud = new ATSoundcloud();
|
$soundcloud = new ATSoundcloud();
|
||||||
$soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description);
|
$soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $hosts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
|
catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
|
||||||
|
|
|
@ -30,12 +30,13 @@ class PreferenceController extends Zend_Controller_Action
|
||||||
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
|
Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view);
|
||||||
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
|
Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]);
|
||||||
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
|
Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]);
|
||||||
|
Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]);
|
||||||
Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]);
|
Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]);
|
||||||
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
|
Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]);
|
||||||
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
|
Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]);
|
||||||
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
|
Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]);
|
||||||
|
|
||||||
$this->view->statusMsg = "Preferences Updated.";
|
$this->view->statusMsg = "<div class='success'>Preferences updated.</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
|
|
|
@ -42,6 +42,13 @@ class Application_Form_Preferences extends Zend_Form
|
||||||
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
|
$stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat());
|
||||||
$this->addElement($stream_format);
|
$this->addElement($stream_format);
|
||||||
|
|
||||||
|
$third_party_api = new Zend_Form_Element_Radio('thirdPartyApi');
|
||||||
|
$third_party_api->setLabel('Allow Remote Websites To Access Show Schedule Info');
|
||||||
|
$third_party_api->setMultiOptions(array("Disabled",
|
||||||
|
"Enabled"));
|
||||||
|
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
||||||
|
$this->addElement($third_party_api);
|
||||||
|
|
||||||
|
|
||||||
$this->addElement('checkbox', 'UseSoundCloud', array(
|
$this->addElement('checkbox', 'UseSoundCloud', array(
|
||||||
'label' => 'Automatically Upload Recorded Shows To SoundCloud',
|
'label' => 'Automatically Upload Recorded Shows To SoundCloud',
|
||||||
|
|
|
@ -132,5 +132,18 @@ class Application_Model_Preference
|
||||||
return Application_Model_Preference::GetValue("soundcloud_tags");
|
return Application_Model_Preference::GetValue("soundcloud_tags");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function SetAllow3rdPartyApi($bool) {
|
||||||
|
Application_Model_Preference::SetValue("third_party_api", $bool);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function GetAllow3rdPartyApi() {
|
||||||
|
$val = Application_Model_Preference::GetValue("third_party_api");
|
||||||
|
if (strlen($val) == 0){
|
||||||
|
return "0";
|
||||||
|
} else {
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,9 @@ class ATSoundcloud {
|
||||||
'track[title]' => $filename,
|
'track[title]' => $filename,
|
||||||
'track[asset_data]' => '@' . $filepath,
|
'track[asset_data]' => '@' . $filepath,
|
||||||
'track[tag_list]' => $tags,
|
'track[tag_list]' => $tags,
|
||||||
'track[description]' => $description
|
'track[description]' => $description,
|
||||||
|
'track[downloadable]' => true,
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
var defaults = {
|
var defaults = {
|
||||||
updatePeriod: 20, //seconds
|
updatePeriod: 20, //seconds
|
||||||
sourceDomain: "http://localhost/", //where to get show status from
|
sourceDomain: "http://localhost/", //where to get show status from
|
||||||
|
text: {onAirToday:"On air today"}
|
||||||
};
|
};
|
||||||
var options = $.extend(defaults, options);
|
var options = $.extend(defaults, options);
|
||||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||||
|
@ -30,7 +31,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
tableString = "";
|
tableString = "";
|
||||||
tableString += "<h3>On air today</h3>";
|
tableString += "<h3>"+options.text.onAirToday+"</h3>";
|
||||||
tableString += "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='widget widget no-playing-list small'>"+
|
tableString += "<table width='100%' border='0' cellspacing='0' cellpadding='0' class='widget widget no-playing-list small'>"+
|
||||||
"<tbody>";
|
"<tbody>";
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
tableString +=
|
tableString +=
|
||||||
"<tr>" +
|
"<tr>" +
|
||||||
"<td class='time'>"+shows[i].getRange()+"</td>" +
|
"<td class='time'>"+shows[i].getRange()+"</td>" +
|
||||||
"<td><a href='#'>"+shows[i].getName()+"</a> <a href='#' class='listen'>Listen</a></td>" +
|
"<td><a href='#'>"+shows[i].getName()+"</a></td>" +
|
||||||
"</tr>";
|
"</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,10 +56,13 @@
|
||||||
updateWidget();
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -72,7 +76,8 @@
|
||||||
var defaults = {
|
var defaults = {
|
||||||
updatePeriod: 5, //seconds
|
updatePeriod: 5, //seconds
|
||||||
sourceDomain: "http://localhost/", //where to get show status from
|
sourceDomain: "http://localhost/", //where to get show status from
|
||||||
audioStreamSource: "http://localhost:8000/airtime.mp3" //where to get audio stream from
|
audioStreamSource: "http://localhost:8000/airtime.mp3", //where to get audio stream from
|
||||||
|
text: {listenLive:"Listen WADR Live", onAirNow:"On Air Now", offline:"Offline", current:"Current", next:"Next"}
|
||||||
};
|
};
|
||||||
var options = $.extend(defaults, options);
|
var options = $.extend(defaults, options);
|
||||||
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
options.sourceDomain = addEndingBackslash(options.sourceDomain);
|
||||||
|
@ -86,7 +91,7 @@
|
||||||
var currentShow = sd.getCurrentShow();
|
var currentShow = sd.getCurrentShow();
|
||||||
var nextShows = sd.getNextShows();
|
var nextShows = sd.getNextShows();
|
||||||
|
|
||||||
var showStatus = "Offline";
|
var showStatus = options.text.offline;
|
||||||
var currentShowName = "";
|
var currentShowName = "";
|
||||||
var timeElapsed = "";
|
var timeElapsed = "";
|
||||||
var timeRemaining = "";
|
var timeRemaining = "";
|
||||||
|
@ -95,7 +100,7 @@
|
||||||
var nextShowRange = "";
|
var nextShowRange = "";
|
||||||
|
|
||||||
if (currentShow.length > 0){
|
if (currentShow.length > 0){
|
||||||
showStatus = "On Air Now";
|
showStatus = options.text.onAirNow;
|
||||||
currentShowName = currentShow[0].getName();
|
currentShowName = currentShow[0].getName();
|
||||||
|
|
||||||
timeElapsed = sd.getShowTimeElapsed(currentShow[0]);
|
timeElapsed = sd.getShowTimeElapsed(currentShow[0]);
|
||||||
|
@ -108,14 +113,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.empty();
|
obj.empty();
|
||||||
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>Listen WADR Live</span></a>");
|
obj.append("<a id='listenWadrLive' href='"+options.audioStreamSource+"'><span>"+options.text.listenLive+"</span></a>");
|
||||||
obj.append("<h4>"+showStatus+" >></h4>");
|
obj.append("<h4>"+showStatus+" >></h4>");
|
||||||
obj.append("<ul class='widget no-playing-bar'>" +
|
obj.append("<ul class='widget no-playing-bar'>" +
|
||||||
"<li class='current'>Current: "+currentShowName+
|
"<li class='current'>"+options.text.current+": "+currentShowName+
|
||||||
"<span id='time-elapsed' class='time-elapsed'>"+timeElapsed+"</span>" +
|
"<span id='time-elapsed' class='time-elapsed'>"+timeElapsed+"</span>" +
|
||||||
"<span id='time-remaining' class='time-remaining'>"+timeRemaining+"</span>"+
|
"<span id='time-remaining' class='time-remaining'>"+timeRemaining+"</span>"+
|
||||||
"</li>" +
|
"</li>" +
|
||||||
"<li class='next'>Next: "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
"<li class='next'>"+options.text.next+": "+nextShowName+"<span>"+nextShowRange+"</span></li>" +
|
||||||
"</ul>");
|
"</ul>");
|
||||||
|
|
||||||
//refresh the UI to update the elapsed/remaining time
|
//refresh the UI to update the elapsed/remaining time
|
||||||
|
@ -127,10 +132,13 @@
|
||||||
updateWidget();
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -220,10 +228,13 @@
|
||||||
updateWidget(data);
|
updateWidget(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){
|
||||||
|
}
|
||||||
|
|
||||||
function getServerData(){
|
function getServerData(){
|
||||||
$.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){
|
$.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){
|
||||||
processData(data);
|
processData(data);
|
||||||
}, error:function(jqXHR, textStatus, errorThrown){}});
|
}, error:airtimeScheduleJsonpError});
|
||||||
setTimeout(getServerData, options.updatePeriod*1000);
|
setTimeout(getServerData, options.updatePeriod*1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue