From 829b9bcd5bc6b32acd124b7ff473e09983d74df7 Mon Sep 17 00:00:00 2001 From: jo Date: Thu, 7 Jul 2022 23:32:43 +0200 Subject: [PATCH] chore(legacy): use Config::getPublicUrl helper Replace Application_Common_HTTPHelper::getStationUrl with Config::getPublicUrl. --- legacy/application/common/FileDataHelper.php | 2 +- legacy/application/common/HTTPHelper.php | 25 ------------------- legacy/application/common/WidgetHelper.php | 5 +--- .../application/controllers/ApiController.php | 4 +-- .../controllers/EmbedController.php | 2 +- .../controllers/IndexController.php | 2 +- .../controllers/PreferenceController.php | 2 +- .../controllers/ThirdPartyController.php | 2 +- legacy/application/forms/Player.php | 2 +- legacy/application/models/Preference.php | 2 +- legacy/application/models/Schedule.php | 2 +- legacy/application/models/airtime/CcFiles.php | 2 +- .../models/airtime/PodcastEpisodes.php | 2 +- .../services/PodcastEpisodeService.php | 4 +-- .../application/services/PodcastService.php | 10 ++++---- .../scripts/embeddablewidgets/facebook.phtml | 2 +- .../scripts/embeddablewidgets/schedule.phtml | 4 +-- 17 files changed, 23 insertions(+), 51 deletions(-) diff --git a/legacy/application/common/FileDataHelper.php b/legacy/application/common/FileDataHelper.php index f64c60e4c..a5846daf0 100644 --- a/legacy/application/common/FileDataHelper.php +++ b/legacy/application/common/FileDataHelper.php @@ -82,7 +82,7 @@ class FileDataHelper */ public static function getArtworkData($file, $size, $filepath = false) { - $baseUrl = Application_Common_HTTPHelper::getStationUrl(); + $baseUrl = Config::getPublicUrl(); $default = $baseUrl . 'css/images/no-cover.jpg'; if ($filepath != false) { diff --git a/legacy/application/common/HTTPHelper.php b/legacy/application/common/HTTPHelper.php index ff4aa5972..1db6eed4b 100644 --- a/legacy/application/common/HTTPHelper.php +++ b/legacy/application/common/HTTPHelper.php @@ -1,7 +1,5 @@ $CC_CONFIG['protocol'], - 'host' => $CC_CONFIG['baseUrl'], - 'port' => $CC_CONFIG['basePort'], - 'path' => $CC_CONFIG['baseDir'], - ] - ); - - return rtrim($url, '/') . '/'; - } - /** * Execute a cURL POST. * diff --git a/legacy/application/common/WidgetHelper.php b/legacy/application/common/WidgetHelper.php index f35564bcf..72334d4a0 100644 --- a/legacy/application/common/WidgetHelper.php +++ b/legacy/application/common/WidgetHelper.php @@ -161,14 +161,11 @@ class WidgetHelper */ public static function findAndConvertPaths(&$arr) { - $CC_CONFIG = Config::getConfig(); - $baseDir = Application_Common_OsPath::formatDirectoryWithDirectorySeparators($CC_CONFIG['baseDir']); - foreach ($arr as &$a) { if (is_array($a)) { if (array_key_exists('image_path', $a)) { $a['image_path'] = $a['image_path'] && $a['image_path'] !== '' ? - Application_Common_HTTPHelper::getStationUrl() . 'api/show-logo?id=' . $a['id'] : ''; + Config::getPublicUrl() . 'api/show-logo?id=' . $a['id'] : ''; } else { self::findAndConvertPaths($a); } diff --git a/legacy/application/controllers/ApiController.php b/legacy/application/controllers/ApiController.php index 6b66ef63c..29f9a87fb 100644 --- a/legacy/application/controllers/ApiController.php +++ b/legacy/application/controllers/ApiController.php @@ -313,7 +313,7 @@ class ApiController extends Zend_Controller_Action $this->returnJsonOrJsonp($request, []); } - $stationUrl = Application_Common_HTTPHelper::getStationUrl(); + $stationUrl = Config::getPublicUrl(); if (isset($result['previous'])) { if ( @@ -701,7 +701,7 @@ class ApiController extends Zend_Controller_Action $request = $this->getRequest(); $result['name'] = Application_Model_Preference::GetStationName(); - $result['logo'] = Application_Common_HTTPHelper::getStationUrl() . 'api/station-logo'; + $result['logo'] = Config::getPublicUrl() . 'api/station-logo'; $result['description'] = Application_Model_Preference::GetStationDescription(); $result['timezone'] = Application_Model_Preference::GetDefaultTimezone(); $result['locale'] = Application_Model_Preference::GetDefaultLocale(); diff --git a/legacy/application/controllers/EmbedController.php b/legacy/application/controllers/EmbedController.php index 0af4ef8d3..8015f6364 100644 --- a/legacy/application/controllers/EmbedController.php +++ b/legacy/application/controllers/EmbedController.php @@ -79,7 +79,7 @@ class EmbedController extends Zend_Controller_Action $request = $this->getRequest(); - $this->view->angular = Application_Common_HTTPHelper::getStationUrl() . 'js/libs/angular.min.js?' . $CC_CONFIG['airtime_version']; + $this->view->angular = Config::getPublicUrl() . 'js/libs/angular.min.js?' . $CC_CONFIG['airtime_version']; $widgetStyle = $request->getParam('style'); if ($widgetStyle == 'premium') { $this->view->widgetStyle = 'premium'; diff --git a/legacy/application/controllers/IndexController.php b/legacy/application/controllers/IndexController.php index 5d9f97f10..88dfe151f 100644 --- a/legacy/application/controllers/IndexController.php +++ b/legacy/application/controllers/IndexController.php @@ -46,7 +46,7 @@ class IndexController extends Zend_Controller_Action $stationDescription = Application_Model_Preference::GetStationDescription(); $this->view->stationDescription = $stationDescription; - $this->view->stationUrl = Application_Common_HTTPHelper::getStationUrl(); + $this->view->stationUrl = Config::getPublicUrl(); $displayRadioPageLoginButtonValue = Application_Model_Preference::getRadioPageDisplayLoginButton(); if ($displayRadioPageLoginButtonValue == '') { diff --git a/legacy/application/controllers/PreferenceController.php b/legacy/application/controllers/PreferenceController.php index c28a587e6..6c22592e1 100644 --- a/legacy/application/controllers/PreferenceController.php +++ b/legacy/application/controllers/PreferenceController.php @@ -99,7 +99,7 @@ class PreferenceController extends Zend_Controller_Action // Append sharing token (download key) to Station podcast URL $stationPodcast = PodcastQuery::create()->findOneByDbId(Application_Model_Preference::getStationPodcastId()); $key = Application_Model_Preference::getStationPodcastDownloadKey(); - $url = Application_Common_HTTPHelper::getStationUrl() . + $url = Config::getPublicUrl() . (((int) $values->stationPodcastPrivacy) ? "feeds/station-rss?sharing_token={$key}" : 'feeds/station-rss'); $stationPodcast->setDbUrl($url)->save(); Application_Model_Preference::setStationPodcastPrivacy($values->stationPodcastPrivacy); diff --git a/legacy/application/controllers/ThirdPartyController.php b/legacy/application/controllers/ThirdPartyController.php index 11b6cac97..bcda8326b 100644 --- a/legacy/application/controllers/ThirdPartyController.php +++ b/legacy/application/controllers/ThirdPartyController.php @@ -20,7 +20,7 @@ abstract class ThirdPartyController extends Zend_Controller_Action */ public function init() { - $this->_baseUrl = Application_Common_HTTPHelper::getStationUrl(); + $this->_baseUrl = Config::getPublicUrl(); $this->view->layout()->disableLayout(); // Don't inject the standard Now Playing header. $this->_helper->viewRenderer->setNoRender(true); // Don't use (phtml) templates diff --git a/legacy/application/forms/Player.php b/legacy/application/forms/Player.php index a97435b71..5719dd24c 100644 --- a/legacy/application/forms/Player.php +++ b/legacy/application/forms/Player.php @@ -70,7 +70,7 @@ class Application_Form_Player extends Zend_Form_SubForm ->setAttrib('rows', '4'); $embedSrc->setLabel(_('Embeddable code:')); $embedSrc->setDescription(_("Copy this code and paste it into your website's HTML to embed the player in your site.")); - $embedSrc->setValue(''); + $embedSrc->setValue(''); $this->addElement($embedSrc); $previewLabel = new Zend_Form_Element_Text('player_preview_label'); diff --git a/legacy/application/models/Preference.php b/legacy/application/models/Preference.php index 85e1a8481..2e96cdd3b 100644 --- a/legacy/application/models/Preference.php +++ b/legacy/application/models/Preference.php @@ -626,7 +626,7 @@ class Application_Model_Preference } // We return the Airtime logo if no logo is set in the database. // airtime_logo.png is stored under the public directory - $image = @file_get_contents(Application_Common_HTTPHelper::getStationUrl() . DEFAULT_LOGO_FILE); + $image = @file_get_contents(Config::getPublicUrl() . DEFAULT_LOGO_FILE); return base64_encode($image); } diff --git a/legacy/application/models/Schedule.php b/legacy/application/models/Schedule.php index 02b3ff4e4..85f34c6cf 100644 --- a/legacy/application/models/Schedule.php +++ b/legacy/application/models/Schedule.php @@ -1050,7 +1050,7 @@ SQL; $file = $storedFile->getPropelOrm(); // Even local files are downloaded through the REST API in case we need to transform // their filenames (eg. in the case of a bad file extension, because Liquidsoap won't play them) - $uri = Application_Common_HTTPHelper::getStationUrl() . 'rest/media/' . $media_id; + $uri = Config::getPublicUrl() . 'rest/media/' . $media_id; // $uri = $file->getAbsoluteFilePath(); $filesize = $file->getFileSize(); diff --git a/legacy/application/models/airtime/CcFiles.php b/legacy/application/models/airtime/CcFiles.php index dac12fb23..a66ca1622 100644 --- a/legacy/application/models/airtime/CcFiles.php +++ b/legacy/application/models/airtime/CcFiles.php @@ -168,7 +168,7 @@ class CcFiles extends BaseCcFiles $file->setDbHidden(true); $file->save(); - $callbackUrl = Application_Common_HTTPHelper::getStationUrl() . 'rest/media/' . $file->getPrimaryKey(); + $callbackUrl = Config::getPublicUrl() . 'rest/media/' . $file->getPrimaryKey(); Application_Service_MediaService::importFileToLibrary( $callbackUrl, diff --git a/legacy/application/models/airtime/PodcastEpisodes.php b/legacy/application/models/airtime/PodcastEpisodes.php index f80c43554..0723ea458 100644 --- a/legacy/application/models/airtime/PodcastEpisodes.php +++ b/legacy/application/models/airtime/PodcastEpisodes.php @@ -30,7 +30,7 @@ class PodcastEpisodes extends BasePodcastEpisodes $ext = FileDataHelper::getAudioMimeTypeArray()[$file->getDbMime()]; $key = Application_Model_Preference::getStationPodcastDownloadKey(); - return Application_Common_HTTPHelper::getStationUrl() . "rest/media/{$fileId}/download/{$key}.{$ext}"; + return Config::getPublicUrl() . "rest/media/{$fileId}/download/{$key}.{$ext}"; } return parent::getDbDownloadUrl(); diff --git a/legacy/application/services/PodcastEpisodeService.php b/legacy/application/services/PodcastEpisodeService.php index 60343497f..df6e680fc 100644 --- a/legacy/application/services/PodcastEpisodeService.php +++ b/legacy/application/services/PodcastEpisodeService.php @@ -181,7 +181,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir private function _download($id, $url, $title, $album_override, $track_title = null) { $CC_CONFIG = Config::getConfig(); - $stationUrl = Application_Common_HTTPHelper::getStationUrl(); + $stationUrl = Config::getPublicUrl(); $data = [ 'id' => $id, 'url' => $url, @@ -249,7 +249,7 @@ class Application_Service_PodcastEpisodeService extends Application_Service_Thir public function publish($fileId) { $id = Application_Model_Preference::getStationPodcastId(); - $url = $guid = Application_Common_HTTPHelper::getStationUrl() . "rest/media/{$fileId}/download"; + $url = $guid = Config::getPublicUrl() . "rest/media/{$fileId}/download"; if (!PodcastEpisodesQuery::create() ->filterByDbPodcastId($id) ->findOneByDbFileId($fileId)) { // Don't allow duplicate episodes diff --git a/legacy/application/services/PodcastService.php b/legacy/application/services/PodcastService.php index 799edd932..6b92f2713 100644 --- a/legacy/application/services/PodcastService.php +++ b/legacy/application/services/PodcastService.php @@ -199,14 +199,14 @@ class Application_Service_PodcastService public static function createStationPodcast() { $podcast = new Podcast(); - $podcast->setDbUrl(Application_Common_HTTPHelper::getStationUrl() . 'feeds/station-rss'); + $podcast->setDbUrl(Config::getPublicUrl() . '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()); + $podcast->setDbLink(Config::getPublicUrl()); $podcast->setDbLanguage(explode('_', Application_Model_Preference::GetLocale())[0]); $podcast->setDbCreator(Application_Model_Preference::GetStationName()); $podcast->setDbOwner(self::getOwnerId()); @@ -430,15 +430,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() . 'feeds/station-rss'); + $atomLink->addAttribute('href', Config::getPublicUrl() . 'feeds/station-rss'); $atomLink->addAttribute('rel', 'self'); $atomLink->addAttribute('type', 'application/rss+xml'); - $imageUrl = Application_Common_HTTPHelper::getStationUrl() . 'api/station-logo'; + $imageUrl = Config::getPublicUrl() . 'api/station-logo'; $image = $channel->addChild('image'); $image->addChild('title', htmlspecialchars($podcast->getDbTitle())); self::addEscapedChild($image, 'url', $imageUrl); - self::addEscapedChild($image, 'link', Application_Common_HTTPHelper::getStationUrl()); + self::addEscapedChild($image, 'link', Config::getPublicUrl()); $xml->addAttribute('xmlns:xmlns:itunes', ITUNES_XML_NAMESPACE_URL); self::addEscapedChild($channel, 'xmlns:itunes:author', $podcast->getDbItunesAuthor()); diff --git a/legacy/application/views/scripts/embeddablewidgets/facebook.phtml b/legacy/application/views/scripts/embeddablewidgets/facebook.phtml index f56760898..690d0cd75 100644 --- a/legacy/application/views/scripts/embeddablewidgets/facebook.phtml +++ b/legacy/application/views/scripts/embeddablewidgets/facebook.phtml @@ -16,7 +16,7 @@

- +
diff --git a/legacy/application/views/scripts/embeddablewidgets/schedule.phtml b/legacy/application/views/scripts/embeddablewidgets/schedule.phtml index 17042f5aa..8ad1038a0 100644 --- a/legacy/application/views/scripts/embeddablewidgets/schedule.phtml +++ b/legacy/application/views/scripts/embeddablewidgets/schedule.phtml @@ -13,12 +13,12 @@
weekly_schedule_error_msg)) echo "style=display:none"; ?>>
- +
-