';
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 '';
}
public function doStationList() {
directoryControlHeader('somafmlist', get_int_text('label_somafm'));
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 '';
}
}
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();
}
?>