|
|
|
@ -133,28 +133,53 @@
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// APIデータを取得
|
|
|
|
|
$content = file_get_contents("https://svc.metrotransit.org/NexTrip/$stop?format=json");
|
|
|
|
|
$content = file_get_contents("https://svc.metrotransit.org/nextripv2/$stop");
|
|
|
|
|
$json = json_decode($content);
|
|
|
|
|
|
|
|
|
|
if(isset($json)) {
|
|
|
|
|
// 情報をプリント
|
|
|
|
|
echo "<h2>停留所{$stop}のNexTrip情報</h2>";
|
|
|
|
|
$stop_name = str_replace(' & ', 'と', $json->stops[0]->description);
|
|
|
|
|
echo "<h2>停留所{$stop} – $stop_name</h2>";
|
|
|
|
|
|
|
|
|
|
echo '<div class="row row-cols-2 row-cols-sm-4 row-cols-md-6">';
|
|
|
|
|
foreach($json as $bus) {
|
|
|
|
|
if(strchr($bus->DepartureText, ':')) {
|
|
|
|
|
preg_match("/(\d+)000/", $bus->DepartureTime, $matches);
|
|
|
|
|
$time = date('H:i', $matches[1]);
|
|
|
|
|
foreach($json->departures as $bus) {
|
|
|
|
|
if($bus->actual) {
|
|
|
|
|
$time = str_replace(" Min", "分", $bus->departure_text);
|
|
|
|
|
$time = str_replace("Due", "今すぐ", $time);
|
|
|
|
|
} else {
|
|
|
|
|
$time = preg_replace("/ Min/", "分", $bus->DepartureText);
|
|
|
|
|
$time = preg_replace("/Due/", "今すぐ", $time);
|
|
|
|
|
$time = date('H:i', $bus->departure_time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo '<div class="col">';
|
|
|
|
|
echo "<p><strong>$bus->Route{$bus->Terminal}({$directions[$bus->RouteDirection]})</strong><br>$time</p>";
|
|
|
|
|
echo '</div>';
|
|
|
|
|
$warn = "";
|
|
|
|
|
$warnClass = "";
|
|
|
|
|
if($bus->schedule_relationship == "Skipped") {
|
|
|
|
|
$warn = "キャンセル";
|
|
|
|
|
$warnClass = 'text-danger';
|
|
|
|
|
} else if($bus->schedule_relationship == "NoData") {
|
|
|
|
|
$warn = "データなし";
|
|
|
|
|
$warnClass = 'text-warning';
|
|
|
|
|
} else if($bus->schedule_relationship != "Scheduled") {
|
|
|
|
|
$warn = $bus->schedule_relationship;
|
|
|
|
|
$warnClass = 'text-warning';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<div class=\"col\"><p>";
|
|
|
|
|
$route_name = str_replace(' Line', '線', $bus->route_short_name) . $bus->terminal;
|
|
|
|
|
echo "<strong>{$route_name}({$directions[$bus->direction_text]})</strong>";
|
|
|
|
|
echo "<br><span class=\"$warnClass\">$time";
|
|
|
|
|
if($warn)
|
|
|
|
|
echo "<br>$warn";
|
|
|
|
|
echo '</span></p></div>';
|
|
|
|
|
}
|
|
|
|
|
echo '</div>';
|
|
|
|
|
|
|
|
|
|
if($json->alerts)
|
|
|
|
|
echo '<h3>アラート</h3>';
|
|
|
|
|
foreach($json->alerts as $alert) {
|
|
|
|
|
$alertClass = $alert->stop_closed ? "alert-danger" : "alert-warning";
|
|
|
|
|
echo "<div lang=\"en\" class=\"alert $alertClass\">$alert->alert_text</div>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($key)) {
|
|
|
|
|
// お気に入りフォームをプリント
|
|
|
|
|
$query = 'SELECT description FROM favorites WHERE favorites.key=$1 AND favorites.stop=$2 LIMIT 1';
|
|
|
|
|