function getTripUpdates($filter_class = '', $filter_id = '') { $fm = new transit_realtime\FeedMessage(); $fh = new transit_realtime\FeedHeader(); $fh->setGtfsRealtimeVersion(1); $fh->setTimestamp(time()); $fm->setHeader($fh); foreach (getCurrentAlerts() as $alert) { $informedEntities = getInformedAlerts($alert['id'], $_REQUEST['filter_class'], $_REQUEST['filter_id']); $stops = array(); $routestrips = array(); if (sizeof($informedEntities) > 0) { if ($informedEntity['informed_class'] == 'stop' && $informed['x-action'] == 'remove') { $stops[] = $informedEntity['informed_id']; } if (($informedEntity['informed_class'] == 'route' || $informedEntity['informed_class'] == 'trip') && $informed['x-action'] == 'patch') { $routestrips[] = array('id' => $informedEntity['informed_id'], 'type' => $informedEntity['informed_class']); } } foreach ($routestrips as $routetrip) { $fe = new transit_realtime\FeedEntity(); $fe->setId($alert['id'] . $routetrip['id']); $fe->setIsDeleted(false); $tu = new transit_realtime\TripUpdate(); $td = new transit_realtime\TripDescriptor(); if ($routetrip['type'] == 'route') { $td->setRouteId($routetrip['id']); } else { if ($routetrip['type'] == 'trip') { $td->setTripId($routetrip['id']); } } $tu->setTrip($td); foreach ($stops as $stop) { $stu = new transit_realtime\TripUpdate\StopTimeUpdate(); $stu->setStopId($stop); $stu->setScheduleRelationship(transit_realtime\TripUpdate\StopTimeUpdate\ScheduleRelationship::SKIPPED); $tu->addStopTimeUpdate($stu); } $fe->setTripUpdate($tu); $fm->addEntity($fe); } } return $fm; }
/** dashboardAlerts() * display alerts on each dashboard page * @param int $width screen width * @return string $html on success, False otherwise */ function dashboardAlerts($width = NULL) { $alerts = getCurrentAlerts(); if (!$alerts) { return FALSE; } if ($width && is_int($width) === FALSE) { $width = NULL; } $style = (string) "background-image:url(/images/alert_background.png);height:30px;margin-top:-5px;padding-bottom:5px;text-align:center;width:" . ($width ? $width - 10 . "px" : "99.2%") . ";"; if (array_key_exists("REQUEST_URI", $_SERVER) && preg_match("/displaymaindash/", $_SERVER["REQUEST_URI"])) { $style = (string) "background-image:url(/images/alert_background.png);font-weight:bold;height:16px;margin-top:-5px;padding-bottom:5px;padding-top:14px;text-align:center;width:" . ($width ? $width - 10 . "px" : "100%") . ";"; } $html = (string) "<div class=\"alert\" style=\"" . $style . "\">"; if (is_array($alerts) && count($alerts) > 1) { $html .= "<script type=\"text/javascript\">"; $html .= "var a=" . json_encode($alerts) . ",ca=1;"; $html .= "function changeAlert() {var d=document.getElementsByClassName(\"alert\"),i;for (i=0;i<d.length; i++) {while(d[i].firstChild){d[i].removeChild(d[i].firstChild);}d[i].appendChild(document.createTextNode(a[ca].message));}ca++;if (ca >= a.length) {ca=0;}}"; $html .= "var dta=window.setInterval(changeAlert, 10000);"; $html .= "</script>"; } $html .= $alerts[0]["message"]; $html .= "</div>"; return $html; }
/** findPageDimensionFactor(array $dimensions) * find out what percent to multiply by * @param array $dimensions * @return array $factor * @example findPageDimensionFactor(array( * 'width'=>1280 * )); */ function findPageDimensionFactor(array $dimensions) { //: Tests if (!isset($dimensions["width"])) { return FALSE; } //: End //: Function Content //: wide screen displays $wide = (bool) FALSE; $ratios = (array) array(1.6, 1.6667, 1.7778, 1.8889); if (isset($dimensions["height"]["screen"]) && $dimensions["height"]["screen"]) { $ratio = $dimensions["width"] / $dimensions["height"]["screen"]; if (in_array($ratio, $ratios)) { $wide = TRUE; } } $factor = (double) ($wide ? 1.3 : 1.4); //: Alerts $a = getCurrentAlerts(FALSE); if (count($a) > 0) { $factor = (double) $factor - 51 / 1080; } //: End //: Browser top bar if ($wide) { $factor = (double) $factor - ($dimensions["height"]["screen"] - $dimensions["height"]["window"]) / 1080; } //: End return round($dimensions["width"] / 1920 * $factor, 2); //: End }