<?php
class EFAPlugin implements IPlugin
{
private $dbconn = NULL;
private $config = NULL;
public function __construct ($dbconn, $config)
{
$this->dbconn = $dbconn;
$this->config = $config;
}
public function doUpdate ()
{
}
public function doOutput ($image, $style, $updateData, &$yoffset)
{
$opt_linie = array (
'width' => 100,
'line_height' => 30,
'height' => 30,
'align' => ALIGN_CENTER);
$opt_route = array (
'width' => 530,
'line_height' => 10,
'height' => 10,
'align' => ALIGN_LEFT);
$opt_dest = array (
'width' => 430,
'line_height' => 16,
'height' => 16,
'align' => ALIGN_LEFT);
$opt_time = array (
'width' => 150,
'line_height' => 12,
'height' => 12,
'align' => ALIGN_RIGHT);
$opt_countdown = array (
'width' => 150,
'line_height' => 16,
'height' => 16,
'align' => ALIGN_RIGHT);
$t1 = urlencode ($this->config['EFA_City']);
$t2 = urlencode ($this->config['EFA_Station']);
$max_items = $this->config['EFA_max_lines'];
$url = 'http://vrrf.finalrewind.org/' . $t1 . '/' . $t2 . '.html?frontend=infoscreen&template=infoscreen';
$html = file_get_contents ($url);
$sta = strpos ($html, '<ul>') + 5;
$len = strpos ($html, '</ul>') - $sta;
$html = substr ($html, $sta, $len);
$end_next_line = strpos ($html, "</li>");
$count = 0;
while ($end_next_line > 1)
{
$count += 1;
$data_set = substr ($html, 5, $end_next_line - 5);
$data_set = str_replace ("<span class=\"", "", $data_set);
$data_set = str_replace ("\">", "",$data_set);
$data_set = str_replace ("</span>\n", "",$data_set);
$data_set = str_replace ("line \n", "line sonst\n",$data_set);
$data_set = str_replace ("line ", "",$data_set);
$data_set = str_replace ("route\n", "",$data_set);
$data_set = str_replace ("dest\n", "",$data_set);
$data_set = str_replace ("countdown\n", "",$data_set);
$data_set = str_replace ("time\n", "",$data_set);
$data_set = str_replace ("delay ", "",$data_set);
$lines = preg_split("/\n/", $data_set);
if ($yoffset >= imagesy ($image) - 40 || $count > $max_items)
{
break;
}
imagettftextboxopt ($image, 30, 0, 20, $yoffset, $style['textcolor'], $style['font'], $lines[1], $opt_linie);
imagettftextboxopt ($image, 10, 0, 120, $yoffset + 22, $style['textcolor'], $style['font'], $lines[2], $opt_route);
imagettftextboxopt ($image, 16, 0, 120, $yoffset, $style['textcolor'], $style['fontb'], $lines[3], $opt_dest);
imagettftextboxopt ($image, 16, 0, 600, $yoffset + 16, $style['textcolor'], $style['font'], $lines[4], $opt_countdown);
imagettftextboxopt ($image, 12, 0, 600, $yoffset, $style['textcolor'], $style['font'], $lines[5], $opt_time);
$yoffset += 40;
$html = substr ($html, $end_next_line + 6);
$end_next_line = strpos ($html, "</li>");
}
}
}