Fix for radio page when station podcast does not exist yet

This commit is contained in:
drigato 2015-11-03 11:40:22 -05:00
parent 51ec5a0df5
commit 335c2fea11
1 changed files with 14 additions and 5 deletions

View File

@ -41,13 +41,22 @@ class IndexController extends Zend_Controller_Action
$this->view->displayLoginButton = $displayRadioPageLoginButtonValue;
//station feed episodes
$podcastEpisodesService = new Application_Service_PodcastEpisodeService();
$stationPodcastId = Application_Model_Preference::getStationPodcastId();
$episodes = $podcastEpisodesService->getPodcastEpisodes($stationPodcastId);
foreach ($episodes as $e => $v) {
$episodes[$e]["track_metadata"]["track_title"] = htmlspecialchars($v["track_metadata"]["track_title"], ENT_QUOTES);
$episodes[$e]["track_metadata"]["artist_name"] = htmlspecialchars($v["track_metadata"]["artist_name"], ENT_QUOTES);
if (!empty($stationPodcastId)) {
$podcastEpisodesService = new Application_Service_PodcastEpisodeService();
$episodes = $podcastEpisodesService->getPodcastEpisodes($stationPodcastId);
foreach ($episodes as $e => $v) {
$episodes[$e]["track_metadata"]["track_title"] = htmlspecialchars($v["track_metadata"]["track_title"], ENT_QUOTES);
$episodes[$e]["track_metadata"]["artist_name"] = htmlspecialchars($v["track_metadata"]["artist_name"], ENT_QUOTES);
}
} else {
// Station podcast does not exist yet
// (creation is implicitly done when a new podcast is created in the dashboard)
// return empty list of episodes
$episodes = [];
}
$this->view->episodes = json_encode($episodes);
$this->view->displayRssTab = (!Application_Model_Preference::getStationPodcastPrivacy());