This repository has been archived by the owner on Jan 25, 2021. It is now read-only.
/
content.php
66 lines (43 loc) · 1.45 KB
/
content.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
error_reporting("E_ALL & ~E_NOTICE");
ini_set('display_errors', 1);
header("Content-Type: text/html");
require_once("StationMonitor.class.php");
require_once("Config.class.php");
Config::init();
//how many rows to show
$getshow = intval($_GET['show']);
$showmax = ($getshow >= 1) ? $getshow : Config::$pref['showmax'];
foreach(Config::$pref['stations'] AS $station){
echo "<td>";
$sm = new StationMonitor($station);
$journeys = $sm->getJourneys();
$tabletpl = Config::getTemplate("plantable");
$rowtpl = Config::getTemplate("planrow");
//decide how many rows to show
if(count($journeys) > $showmax){
$count = $showmax;
}else{
$count = count($journeys);
}
$planrows = array();
//go through journeys
for($i = 0; $i < $count; $i++){
$jo = $journeys[$i];
//cut away "Leipzig" from the beginning of the label
if(substr($jo->label, 0, 9) == "Leipzig, "){
$jo->label = substr($jo->label, 9);
}
//only show timediff if not null
$jo->timeDiff = ($jo->timeDiffValue) ? $jo->timeDiff : "";
$search = array("{BGCOLOR}","{LINENUM}","{LABEL}","{TIME}","{TIMEDIFF}");
$replace = array("#".$jo->color, $jo->shortLabel, $jo->label, $jo->time, $jo->timeDiff);
$planrows[] = str_replace($search, $replace, $rowtpl);
}
$search = array("{STATIONNAME}", "{PLANROWS}");
$replace = array($sm->getStationName(), implode("\n", $planrows));
$table = str_replace($search, $replace, $tabletpl);
echo $table;
echo "</td>";
}
?>