From db3134cea88eec1d99f3d7b920dccb2983faf7e1 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 30 Mar 2011 14:54:31 -0400 Subject: [PATCH 1/4] -Preference page now shows a green confirmation success message similar to Manage Users page. --- application/controllers/PreferenceController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index 61508bb1c..9f96979ff 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -35,7 +35,8 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); - $this->view->statusMsg = "Preferences Updated."; + $this->view->statusMsg = "
Preferences updated.
"; + } $this->view->form = $form; From 32c28046ef2a1edde3ae8714d2e6b013cf3cec73 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 30 Mar 2011 15:34:35 -0400 Subject: [PATCH 2/4] CC-1990: Widget to display schedule and "Now Playing" on any website -admin can now enable/disable access to scheduling information to remote widgets via the preferences page. --- application/controllers/ApiController.php | 70 +++++++++++-------- .../controllers/PreferenceController.php | 2 +- application/forms/Preferences.php | 7 ++ application/models/Preference.php | 13 ++++ 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index aac57fbbb..ef52aaf51 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -103,41 +103,55 @@ class ApiController extends Zend_Controller_Action exit; } - public function liveInfoAction(){ - // disable the view and the layout - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); + public function liveInfoAction() + { + if (Application_Model_Preference::GetAllow3rdPartyApi()){ + // 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; - $timeNow = $date->getDate(); - $result = array("env"=>APPLICATION_ENV, - "schedulerTime"=>gmdate("Y-m-d H:i:s"), - "currentShow"=>Show_DAL::GetCurrentShow($timeNow), - "nextShow"=>Show_DAL::GetNextShows($timeNow, 5), - "timezone"=> date("T"), - "timezoneOffset"=> date("Z")); - - //echo json_encode($result); - header("Content-type: text/javascript"); - echo $_GET['callback'].'('.json_encode($result).')'; + $date = new Application_Model_DateHelper; + $timeNow = $date->getDate(); + $result = array("env"=>APPLICATION_ENV, + "schedulerTime"=>gmdate("Y-m-d H:i:s"), + "currentShow"=>Show_DAL::GetCurrentShow($timeNow), + "nextShow"=>Show_DAL::GetNextShows($timeNow, 5), + "timezone"=> date("T"), + "timezoneOffset"=> date("Z")); + + //echo json_encode($result); + 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; + } } - public function weekInfoAction(){ - // disable the view and the layout - $this->view->layout()->disableLayout(); - $this->_helper->viewRenderer->setNoRender(true); + public function weekInfoAction() + { + if (Application_Model_Preference::GetAllow3rdPartyApi()){ + // 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(); - for ($i=0; $i<7; $i++){ - $result[$dow[$i]] = Show_DAL::GetShowsByDayOfWeek($i); + $result = array(); + for ($i=0; $i<7; $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() diff --git a/application/controllers/PreferenceController.php b/application/controllers/PreferenceController.php index 9f96979ff..46d82054f 100644 --- a/application/controllers/PreferenceController.php +++ b/application/controllers/PreferenceController.php @@ -30,13 +30,13 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetHeadTitle($values["stationName"], $this->view); Application_Model_Preference::SetDefaultFade($values["stationDefaultFade"]); Application_Model_Preference::SetStreamLabelFormat($values["streamFormat"]); + Application_Model_Preference::SetAllow3rdPartyApi($values["thirdPartyApi"]); Application_Model_Preference::SetDoSoundCloudUpload($values["UseSoundCloud"]); Application_Model_Preference::SetSoundCloudUser($values["SoundCloudUser"]); Application_Model_Preference::SetSoundCloudPassword($values["SoundCloudPassword"]); Application_Model_Preference::SetSoundCloudTags($values["SoundCloudTags"]); $this->view->statusMsg = "
Preferences updated.
"; - } $this->view->form = $form; diff --git a/application/forms/Preferences.php b/application/forms/Preferences.php index eaaff98a6..a319476a2 100644 --- a/application/forms/Preferences.php +++ b/application/forms/Preferences.php @@ -42,6 +42,13 @@ class Application_Form_Preferences extends Zend_Form $stream_format->setValue(Application_Model_Preference::GetStreamLabelFormat()); $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( 'label' => 'Automatically Upload Recorded Shows To SoundCloud', diff --git a/application/models/Preference.php b/application/models/Preference.php index 948b29645..9efd2fd10 100644 --- a/application/models/Preference.php +++ b/application/models/Preference.php @@ -132,5 +132,18 @@ class Application_Model_Preference 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; + } + } + } From f184cc596a2c75946523becb26bd148936a3af76 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 30 Mar 2011 15:42:01 -0400 Subject: [PATCH 3/4] CC-2110 : Soundcloud file metadata --- application/controllers/ApiController.php | 3 ++- application/models/Soundcloud.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/application/controllers/ApiController.php b/application/controllers/ApiController.php index aac57fbbb..e501e11f1 100644 --- a/application/controllers/ApiController.php +++ b/application/controllers/ApiController.php @@ -272,10 +272,11 @@ class ApiController extends Zend_Controller_Action $show = new Show($show_inst->getShowId()); $description = $show->getDescription(); + $hosts = $show->getHosts(); try { $soundcloud = new ATSoundcloud(); - $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description); + $soundcloud->uploadTrack($file->getRealFilePath(), $file->getName(), $description, $hosts); break; } catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) { diff --git a/application/models/Soundcloud.php b/application/models/Soundcloud.php index 1fc5efa99..c47e4fae8 100644 --- a/application/models/Soundcloud.php +++ b/application/models/Soundcloud.php @@ -45,7 +45,9 @@ class ATSoundcloud { 'track[title]' => $filename, 'track[asset_data]' => '@' . $filepath, 'track[tag_list]' => $tags, - 'track[description]' => $description + 'track[description]' => $description, + 'track[downloadable]' => true, + ); From 2924da4bd4456a72e33e6d216ecc27cb628046bd Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 30 Mar 2011 17:06:04 -0400 Subject: [PATCH 4/4] CC-1990:Widget to display schedule and "Now Playing" on any website -added internationalization support for all WADR widgets --- plugins/jquery.showinfo.js | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/jquery.showinfo.js b/plugins/jquery.showinfo.js index 87b5c1ad8..bda16ce29 100644 --- a/plugins/jquery.showinfo.js +++ b/plugins/jquery.showinfo.js @@ -4,6 +4,7 @@ var defaults = { updatePeriod: 20, //seconds sourceDomain: "http://localhost/", //where to get show status from + text: {onAirToday:"On air today"} }; var options = $.extend(defaults, options); options.sourceDomain = addEndingBackslash(options.sourceDomain); @@ -30,7 +31,7 @@ } tableString = ""; - tableString += "

On air today

"; + tableString += "

"+options.text.onAirToday+"

"; tableString += ""+ ""; @@ -41,7 +42,7 @@ tableString += "" + "" + - "" + + "" + ""; } @@ -55,10 +56,13 @@ updateWidget(); } + function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){ + } + function getServerData(){ $.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){ processData(data); - }, error:function(jqXHR, textStatus, errorThrown){}}); + }, error:airtimeScheduleJsonpError}); setTimeout(getServerData, options.updatePeriod*1000); } }); @@ -72,7 +76,8 @@ var defaults = { updatePeriod: 5, //seconds 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); options.sourceDomain = addEndingBackslash(options.sourceDomain); @@ -86,7 +91,7 @@ var currentShow = sd.getCurrentShow(); var nextShows = sd.getNextShows(); - var showStatus = "Offline"; + var showStatus = options.text.offline; var currentShowName = ""; var timeElapsed = ""; var timeRemaining = ""; @@ -95,7 +100,7 @@ var nextShowRange = ""; if (currentShow.length > 0){ - showStatus = "On Air Now"; + showStatus = options.text.onAirNow; currentShowName = currentShow[0].getName(); timeElapsed = sd.getShowTimeElapsed(currentShow[0]); @@ -108,14 +113,14 @@ } obj.empty(); - obj.append("Listen WADR Live"); + obj.append(""+options.text.listenLive+""); obj.append("

"+showStatus+" >>

"); obj.append("
    " + - "
  • Current: "+currentShowName+ + "
  • "+options.text.current+": "+currentShowName+ ""+timeElapsed+"" + ""+timeRemaining+""+ "
  • " + - "" + + "" + "
"); //refresh the UI to update the elapsed/remaining time @@ -127,10 +132,13 @@ updateWidget(); } + function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){ + } + function getServerData(){ $.ajax({ url: options.sourceDomain + "api/live-info/", dataType:"jsonp", success:function(data){ processData(data); - }, error:function(jqXHR, textStatus, errorThrown){}}); + }, error:airtimeScheduleJsonpError}); setTimeout(getServerData, options.updatePeriod*1000); } }); @@ -220,10 +228,13 @@ updateWidget(data); } + function airtimeScheduleJsonpError(jqXHR, textStatus, errorThrown){ + } + function getServerData(){ $.ajax({ url: options.sourceDomain + "api/week-info/", dataType:"jsonp", success:function(data){ processData(data); - }, error:function(jqXHR, textStatus, errorThrown){}}); + }, error:airtimeScheduleJsonpError}); setTimeout(getServerData, options.updatePeriod*1000); } });
"+shows[i].getRange()+""+shows[i].getName()+" Listen"+shows[i].getName()+"