channel = $channel;
$this->cachefile = "cache-{$channel}.txt";
$this->cachetime = 900;
$this->generate();
}
function generate()
{
$fetch = file_get_html(
"http://www.basso.fi/radio/".$this->channel
);
$this->showinfo = $this->get_showinfo($fetch);
$this->showtimes = $this->get_showtimes($fetch);
#$this->ical_feed();
}
function get_showtimes($fetch)
{
foreach($fetch->find('div.column_entry') as $m) {
$div = $m->innertext;
$items[] = $div;
}
$finnish_dates = array(
"Maanantai", "Tiistai", "Keskiviikko",
"Torstai", "Perjantai", "Lauantai", "Sunnuntai"
);
$items = $items[1];
$items = str_replace("
", "|", $items);
$items = str_replace("Tulevia lähetysaikoja", "", $items);
$items = explode("|", strip_tags($items));
foreach ($items as $n => $item) {
$item = trim($item);
if( !empty($item) && strlen($item) > 2 ) {
$item = str_replace($finnish_dates, "", $item);
$dates = explode("-", trim($item));
$dates2 = explode(" ", $dates[0]);
$dates_from = $dates[0];
$dates_to = $dates2[0]." ".$dates[1];
$date = $dates2[0];
list($day, $month, $year) = explode(".", $date);
$date = "20{$year}-$month-$day";
$time_f = strtotime($date." ".$dates2[1]);
$time_t = strtotime($date." ".$dates[1]);
// We take -2 as timezone info 'coz the times are in +2
$date_f = $this->unixToiCal( $time_f, -2 );
$date_t = $this->unixToiCal( $time_t, -2 );
$stuff[$n]["time_f"] = $time_f;
$stuff[$n]["time_t"] = $time_t;
$stuff[$n]["date_f"] = $date_f;
$stuff[$n]["date_t"] = $date_t;
// int mktime ([ int $hour = date("H") [, int $minute = date("i") [, int $second = date("s") [, int $month = date("n") [, int $day = date("j") [, int $year = date("Y") [, int $is_dst = -1 ]]]]]]] )
}
}
return $stuff;
}
function get_showinfo($fetch)
{
foreach($fetch->find('div#main_column_1') as $m) {
$div = $m->innertext;
$items[] = $div;
}
$title = $fetch->find("h1", 0);
$title = $title->plaintext;
$cleaned = $items[0];
$cleaned = str_replace(" ", " ", $cleaned);
$cleaned = strip_tags($cleaned, "