'; print albumHeader(array( 'id' => 'somafmlist', 'Image' => 'newimages/somafmlogo.svg', 'Searched' => 1, 'AlbumUri' => null, 'Year' => null, 'Artistname' => '', 'Albumname' => get_int_text('label_somafm'), 'why' => null, 'ImgKey' => 'none', 'class' => 'radio', 'expand' => true )); print '
'; print '
'.get_int_text('label_loading').'
'; print ''; } public function doStationList() { directoryControlHeader('somafmlist', get_int_text('label_somafm')); print '
'; print ''.get_int_text("label_soma_beg").''; print '
'; $d = new url_downloader(array('url' => "http://api.somafm.com/channels.xml")); if ($d->get_data_to_string()) { $this->doAllStations($d->get_data()); } else { print 'There was an error getting the channels from Soma FM - status code '.$d->get_status(); } } // -- Private Functions -- // private function getimage($c) { $img = (string) $c->xlimage; if (!$img) { $img = (string) $c->largeimage; } if (!$img) { $img = (string) $c->image; } return 'getRemoteImage.php?url='.$img; } private function format_listenlink($c, $p, $label) { $img = $this->getimage($c); print ''; } private function doAllStations($content) { logger::trace("SOMAFM", "Loaded Soma FM channels list"); $x = simplexml_load_string($content); $count = 0; foreach ($x->channel as $channel) { $this->doChannel($count, $channel); $count++; } } private function doChannel($count, $channel) { logger::log("SOMAFM", "Channel :",$channel->title); if ($channel->highestpls) { $pls = (string) $channel->highestpls; } else { $pls = (string) $channel->fastpls[0]; } print albumHeader(array( 'id' => 'somafm_'.$count, 'Image' => $this->getimage($channel), 'Searched' => 1, 'AlbumUri' => null, 'Year' => null, 'Artistname' => utf8_encode($channel->genre), 'Albumname' => utf8_encode($channel->title), 'why' => 'whynot', 'ImgKey' => 'none', 'streamuri' => $pls, 'streamname' => (string) $channel->title, 'streamimg' => $this->getimage($channel), 'class' => 'radiochannel' )); print '
'; trackControlHeader('','','somafm_'.$count, array(array('Image' => $this->getimage($channel)))); if ($channel->description) { print '
'.utf8_encode($channel->description).'
'; } if ($channel->listeners) { print '
'; print '
'.$channel->listeners.' '.trim(get_int_text("lastfm_listeners"),':').'
'; print '
'; } print '
'; print '
Listen:
'; if ($channel->highestpls) { $this->format_listenlink($channel, $channel->highestpls, "High Quality"); } foreach ($channel->fastpls as $h) { $this->format_listenlink($channel, $h, "Standard Quality"); } foreach ($channel->slowpls as $h) { $this->format_listenlink($channel, $h, "Low Quality"); } print '
'; if ($channel->twitter && $channel->dj) { print ''; print ''; } if ($channel->lastPlaying) { print ''; } print '
'; } } if (array_key_exists('populate', $_REQUEST)) { chdir('..'); include ("includes/vars.php"); include ("includes/functions.php"); include ("international.php"); include ("skins/".$skin."/ui_elements.php"); $soma = new somafmplugin(); $soma->doStationList(); } else { $soma = new somafmplugin(); $soma->doHeader(); } ?>