From eae8c7b6385ed18e5b164636f7a97ac370ea26ab Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Tue, 17 Nov 2015 21:06:51 -0500 Subject: [PATCH 1/4] Temporary fix to make enclosure urls iTunes compatible --- .../application/controllers/ApiController.php | 6 +++--- .../models/airtime/PodcastEpisodes.php | 5 ++++- .../application/modules/rest/Bootstrap.php | 20 ++++++++++++++++--- .../scripts/form/preferences_general.phtml | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index deac3f998..daba2e524 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -535,13 +535,13 @@ class ApiController extends Zend_Controller_Action $mime_type = finfo_buffer($f, $blob, FILEINFO_MIME_TYPE); finfo_close($f); - header("Content-type: " . $mime_type); + header("Content-Type: " . $mime_type); echo $blob; } else { header('HTTP/1.0 401 Unauthorized'); - print _('You are not allowed to access this resource. '); + print _('You are not allowed to access this resource.'); exit; - } + } } public function scheduleAction() diff --git a/airtime_mvc/application/models/airtime/PodcastEpisodes.php b/airtime_mvc/application/models/airtime/PodcastEpisodes.php index eea1f7311..6f47b6e48 100644 --- a/airtime_mvc/application/models/airtime/PodcastEpisodes.php +++ b/airtime_mvc/application/models/airtime/PodcastEpisodes.php @@ -31,8 +31,11 @@ class PodcastEpisodes extends BasePodcastEpisodes $podcast = StationPodcastQuery::create()->findOneByDbPodcastId($podcastId); if ($podcast) { $fileId = $this->getDbFileId(); + // FIXME: this is an interim solution until we can do better... + $file = CcFilesQuery::create()->findPk($fileId); + $ext = FileDataHelper::getAudioMimeTypeArray()[$file->getDbMime()]; $key = Application_Model_Preference::getStationPodcastDownloadKey(); - return Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download/$key"; + return Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download/$key.$ext"; } return parent::getDbDownloadUrl(); } diff --git a/airtime_mvc/application/modules/rest/Bootstrap.php b/airtime_mvc/application/modules/rest/Bootstrap.php index 11a9b2fae..016c94017 100644 --- a/airtime_mvc/application/modules/rest/Bootstrap.php +++ b/airtime_mvc/application/modules/rest/Bootstrap.php @@ -60,19 +60,33 @@ class Rest_Bootstrap extends Zend_Application_Module_Bootstrap /** MediaController Routes **/ $downloadRoute = new Zend_Controller_Router_Route( - 'rest/media/:id/download/:download_key', + 'rest/media/:id/download', array( 'controller' => 'media', 'action' => 'download', 'module' => 'rest' ), array( - 'id' => '\d+', - 'download_key' => '\w*' + 'id' => '\d+' ) ); $router->addRoute('download', $downloadRoute); + $podcastEpisodeDownloadRoute = new Zend_Controller_Router_Route_Regex( + 'rest/media/(?\d+)/download/(?.+)\.(?\w+)', + array( + 'controller' => 'media', + 'action' => 'download', + 'module' => 'rest' + ), + array( + 1 => "id", + 2 => "download_key", + 3 => "file_ext" + ) + ); + $router->addRoute('podcast-episode-download', $podcastEpisodeDownloadRoute); + $clearLibraryRoute = new Zend_Controller_Router_Route( 'rest/media/clear', array( diff --git a/airtime_mvc/application/views/scripts/form/preferences_general.phtml b/airtime_mvc/application/views/scripts/form/preferences_general.phtml index 4ef93aaa5..205d6d65a 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_general.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_general.phtml @@ -16,7 +16,7 @@ $logoImg = $this->element->getView()->logoImg; $src = "data:image/png;base64,".$logoImg; ?> - + element->getElement('locale')->render() ?> From 9a8e80f74bbaca739a15c79bf2b4a5e35fa80c66 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 18 Nov 2015 11:10:14 -0500 Subject: [PATCH 2/4] Change station podcast RSS links back to https; style fix for menu in some browsers --- .../application/models/airtime/PodcastEpisodes.php | 2 +- .../application/services/PodcastEpisodeService.php | 2 +- airtime_mvc/application/services/PodcastService.php | 10 +++++----- airtime_mvc/public/css/styles.css | 8 ++++++++ 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/airtime_mvc/application/models/airtime/PodcastEpisodes.php b/airtime_mvc/application/models/airtime/PodcastEpisodes.php index 6f47b6e48..f1ea44b59 100644 --- a/airtime_mvc/application/models/airtime/PodcastEpisodes.php +++ b/airtime_mvc/application/models/airtime/PodcastEpisodes.php @@ -35,7 +35,7 @@ class PodcastEpisodes extends BasePodcastEpisodes $file = CcFilesQuery::create()->findPk($fileId); $ext = FileDataHelper::getAudioMimeTypeArray()[$file->getDbMime()]; $key = Application_Model_Preference::getStationPodcastDownloadKey(); - return Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download/$key.$ext"; + return Application_Common_HTTPHelper::getStationUrl()."rest/media/$fileId/download/$key.$ext"; } return parent::getDbDownloadUrl(); } diff --git a/airtime_mvc/application/services/PodcastEpisodeService.php b/airtime_mvc/application/services/PodcastEpisodeService.php index 3927e05ef..56298e467 100644 --- a/airtime_mvc/application/services/PodcastEpisodeService.php +++ b/airtime_mvc/application/services/PodcastEpisodeService.php @@ -193,7 +193,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir */ public function publish($fileId) { $id = Application_Model_Preference::getStationPodcastId(); - $url = $guid = Application_Common_HTTPHelper::getStationUrl(false)."rest/media/$fileId/download"; + $url = $guid = Application_Common_HTTPHelper::getStationUrl()."rest/media/$fileId/download"; if (!PodcastEpisodesQuery::create() ->filterByDbPodcastId($id) ->findOneByDbFileId($fileId)) { // Don't allow duplicate episodes diff --git a/airtime_mvc/application/services/PodcastService.php b/airtime_mvc/application/services/PodcastService.php index a7c0411a1..5f0236306 100644 --- a/airtime_mvc/application/services/PodcastService.php +++ b/airtime_mvc/application/services/PodcastService.php @@ -152,14 +152,14 @@ class Application_Service_PodcastService public static function createStationPodcast() { $podcast = new Podcast(); - $podcast->setDbUrl(Application_Common_HTTPHelper::getStationUrl(false) . "feeds/station-rss"); + $podcast->setDbUrl(Application_Common_HTTPHelper::getStationUrl() . "feeds/station-rss"); $title = Application_Model_Preference::GetStationName(); $title = empty($title) ? "My Station's Podcast" : $title; $podcast->setDbTitle($title); $podcast->setDbDescription(Application_Model_Preference::GetStationDescription()); - $podcast->setDbLink(Application_Common_HTTPHelper::getStationUrl(false)); + $podcast->setDbLink(Application_Common_HTTPHelper::getStationUrl()); $podcast->setDbLanguage(explode('_', Application_Model_Preference::GetLocale())[0]); $podcast->setDbCreator(Application_Model_Preference::GetStationName()); $podcast->setDbOwner(self::getOwnerId()); @@ -371,15 +371,15 @@ class Application_Service_PodcastService $xml->addAttribute('xmlns:xmlns:atom', "http://www.w3.org/2005/Atom"); $atomLink = $channel->addChild("xmlns:atom:link"); - $atomLink->addAttribute("href", Application_Common_HTTPHelper::getStationUrl(false) . "feeds/station-rss"); + $atomLink->addAttribute("href", Application_Common_HTTPHelper::getStationUrl() . "feeds/station-rss"); $atomLink->addAttribute("rel", "self"); $atomLink->addAttribute("type", "application/rss+xml"); - $imageUrl = Application_Common_HTTPHelper::getStationUrl(false)."api/station-logo"; + $imageUrl = Application_Common_HTTPHelper::getStationUrl()."api/station-logo"; $image = $channel->addChild("image"); $image->addChild("title", $podcast->getDbTitle()); self::addEscapedChild($image, "url", $imageUrl); - self::addEscapedChild($image, "link", Application_Common_HTTPHelper::getStationUrl(false)); + self::addEscapedChild($image, "link", Application_Common_HTTPHelper::getStationUrl()); $xml->addAttribute('xmlns:xmlns:itunes', ITUNES_XML_NAMESPACE_URL); self::addEscapedChild($channel, "xmlns:itunes:author", $podcast->getDbItunesAuthor()); diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 528079997..23b4f8eae 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -3590,6 +3590,14 @@ button.btn-icon-text > i.icon-white { overflow: auto; } +#media_type_nav > div:not(#nav) { + -webkit-flex: 0 1 auto; + -moz-flex: 0 1 auto; + -ms-flex: 0 1 auto; + -o-flex: 0 1 auto; + flex: 0 1 auto; +} + #media_type_nav .icon-white { opacity: 0.8; } From ceafccd685eec9b099b29db834cd7f4dcaf7a650 Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 18 Nov 2015 12:12:57 -0500 Subject: [PATCH 3/4] Hide podcast from radio page for hobbyist plans --- airtime_mvc/application/models/Preference.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 05bc43f8f..82731f524 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1573,6 +1573,11 @@ class Application_Model_Preference } public static function getStationPodcastPrivacy() { + if (!Billing::isStationPodcastAllowed()) { + // return private setting + return 1; + } + return self::getValue("station_podcast_privacy"); } From dc6c2893b4f678e40c8dc8b947728d9790f2ba9e Mon Sep 17 00:00:00 2001 From: drigato Date: Wed, 18 Nov 2015 12:31:31 -0500 Subject: [PATCH 4/4] Hide Soundcloud options from preferences for hobbyist plans --- .../application/controllers/PreferenceController.php | 6 ++++-- .../application/views/scripts/form/preferences.phtml | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 5ab4c5071..5d00bd1a8 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -66,8 +66,10 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::setTuneinPartnerId($values["tunein_partner_id"]); // SoundCloud Preferences - Application_Model_Preference::setDefaultSoundCloudLicenseType($values["SoundCloudLicense"]); - Application_Model_Preference::setDefaultSoundCloudSharingType($values["SoundCloudSharing"]); + if (Billing::isStationPodcastAllowed()) { + Application_Model_Preference::setDefaultSoundCloudLicenseType($values["SoundCloudLicense"]); + Application_Model_Preference::setDefaultSoundCloudSharingType($values["SoundCloudSharing"]); + } $this->view->statusMsg = "
". _("Preferences updated.")."
"; $form = new Application_Form_Preferences(); diff --git a/airtime_mvc/application/views/scripts/form/preferences.phtml b/airtime_mvc/application/views/scripts/form/preferences.phtml index 58fd10ea2..d2fa6494f 100644 --- a/airtime_mvc/application/views/scripts/form/preferences.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences.phtml @@ -8,10 +8,14 @@ element->getSubform('preferences_tunein') ?> +

element->getSubform('preferences_soundcloud') ?> +
+