} } else { $stop_times = ShuttleSchedule::get_next_scheduled_loop($route_id, $row['start_time']); foreach ($stop_times as $stop_time) { if ($stop_time['nextBusId'] == $stop_id) { $source = 'schedule'; $next_time = $stop_time['nextScheduled']; $next_seconds = $next_time - $time; $stopname = $stop_time['title']; break; } } } if ($next_seconds > 0 && $next_seconds < SHUTTLE_NOTIFY_THRESHOLD) { $shuttle = ShuttleSchedule::get_title($route_id); $minutes = intval($next_seconds / 60); $timestr = date('g:ia', $next_time); switch ($source) { case 'nextbus': $stopname = ShuttleSchedule::get_stop_title($route_id, $stop_id); $message = "$shuttle arriving at $stopname in $minutes minutes ($timestr)"; break; case 'schedule': // $stopname was defined earlier $message = "$shuttle (NOT GPS TRACKED) scheduled to arrive at $stopname in $minutes minutes ($timestr)"; break; }
function get_route_metadata($route) { $metadata = Array(); $metadata['route_id'] = $route; $metadata['title'] = ShuttleSchedule::get_title($route); $metadata['interval'] = ShuttleSchedule::get_interval($route) / 60; $metadata['isSafeRide'] = ShuttleSchedule::is_safe_ride($route); $metadata['isRunning'] = ShuttleSchedule::is_running($route); $metadata['summary'] = ShuttleSchedule::get_summary($route); return $metadata; }
<? require_once "mobi_lib_constants.php"; require_once(LIB_ROOT . 'ShuttleSchedule.php'); //print_r(ShuttleSchedule::get_route_list()); $routes = ShuttleSchedule::get_active_routes(); //$routes = Array('boston_all'); //print_r($routes); //$routes = Array('boston_east'); foreach ($routes as $route) { echo ShuttleSchedule::get_title($route) . '(' . $route . ")\n"; //print_r(ShuttleSchedule::get_next_scheduled_loop($route)); //echo 'is running: ' . ShuttleSchedule::is_running($route) . "\n"; } ?>
<?php require_once "../config/mobi_web_constants.php"; require_once PAGE_HEADER; require_once "shuttle_lib.php"; $route = $_REQUEST['route']; if (!in_array($route, ShuttleSchedule::get_active_routes())) { $routeName = ucwords(str_replace('_', ' ', $_REQUEST['route'])); $not_found_text = '<p>The route ' . $routeName . ' is not currently in service. Please update your bookmarks accordingly. For more information see the <a href="help.php">help page</a>.</p>'; $page->prepare_error_page('Shuttle Schedule', 'shuttle', $not_found_text); } else { $now = time(); $routeName = ShuttleSchedule::get_title($route); $interval = ShuttleSchedule::get_interval($route); $loop_time = $interval / 60; $summary = ShuttleSchedule::get_summary($route); if ($page->branch != 'Basic') { // format: 9:05AM -> 9:05<span class="ampm">AM</span> $summary = preg_replace('/(\\d)(AM|PM)/', '$1<span class="ampm">$2</span>', $summary); } $gps_active = ShuttleSchedule::is_running($route) && NextBusReader::gps_active($route); $stops = list_stop_times($route, $now, $gps_active); $upcoming_stops = array(); foreach ($stops as $index => $stop) { if ($stop['upcoming']) { $upcoming_stops[] = $index; } } // determine size of route map to display on each device switch ($page->branch) { case 'Webkit':