From: Maxious Date: Wed, 28 Dec 2011 02:51:57 +0000 Subject: Beginnings of Christmas 2011 support X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=cd15a1a76a6971ff90204a4f1e284db43d4fd79d --- Beginnings of Christmas 2011 support --- --- a/include/common-template.inc.php +++ b/include/common-template.inc.php @@ -175,7 +175,7 @@
'; if ($GTFSREnabled) { $overrides = getServiceOverride(); - if ($overrides['service_id']) { + if (isset($overrides['service_id'])) { if ($overrides['service_id'] == "noservice") { echo '
Buses are not running today due to industrial action/public holiday. See http://www.action.act.gov.au for details.
'; --- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -18,43 +18,63 @@ $service_periods = Array( 'sunday', 'saturday', - 'weekday' + 'weekday', + "Christmas2011","EndOfYearHolidays" ); -function service_period_day ($spid) { - $idParts = explode("-",$spid); - return strtolower($idParts[2]); -} + function service_period($date = "") { - if (isset($_REQUEST['service_period'])) + if (isset($_REQUEST['service_period'])) { return $_REQUEST['service_period']; + } + $override = getServiceOverride($date); - if ($override['service_id']) { - return service_period_day ($override['service_id']); - } - - switch (date('w', ($date != "" ? $date : time()))) { - case 0: - return 'sunday'; - case 6: - return 'saturday'; - default: - return 'weekday'; - } -} + if (isset($override['service_id'])) { + return strtolower($override['service_id']); + } + $date = ($date != "" ? $date : time()); +// christmas special cases + $ymd = date('Ymd', $date); + $dow = date('w', $date); + if ($ymd == "20111225") { + return "Christmas2011"; + } if ($ymd == "20111228" || $ymd == "20111229" || $ymd == "20111230") { + return "EndOfYearHolidays"; + } else if (intval($ymd) < "20120203" && $dow != 0 && $dow != 6) { + return "Weekday-SchoolVacation"; + } else { + switch ($dow) { + case 0: + return 'sunday'; + case 6: + return 'saturday'; + default: + return 'weekday'; + } + } +} + function service_ids($service_period) { switch ($service_period) { case 'sunday': - return Array("Sunday","Sunday"); + return Array("Sunday", "Sunday"); case 'saturday': - return Array("Saturday","Saturday"); + return Array("Saturday", "Saturday"); + case "Christmas2011": + return Array("Christmas2011", "Christmas2011"); + case "EndOfYearHolidays": + return Array("Weekday-EndOfYearHolidays", "Weekday-EndOfYearHolidays"); + case "Weekday-SchoolVacation": + return Array("Weekday", "Weekday-SchoolVacation"); default: //return 'weekday'; - return Array("Weekday","Weekday"); - } -} + return Array("Weekday", "Weekday"); + } +} + function valid_service_ids() { - return array_merge(service_ids(""),service_ids('saturday'),service_ids('sunday')); + return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday'), + Array("Christmas2011","Weekday-EndOfYearHolidays","Weekday-SchoolVacation")); } function midnight_seconds($time = "") { --- a/index.php +++ b/index.php @@ -20,7 +20,7 @@
-

busness time


Canberra Bus Timetables and Trip Planner +

busness time


Canberra Bus Timetables and Trip Planner
Launch Trip Planner... @@ -38,8 +38,12 @@
  • Nearby Routes
  • Busness R&D'; echo ' MyWay Balance and Timeliness Survey Results'; + include_footer(true) ?> --- a/stop.php +++ b/stop.php @@ -133,7 +133,7 @@ echo '
  • '; $destination = getTripDestination($trip['trip_id']); - echo '

    ' . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "

    "; + echo '

    '. (service_period() == "Christmas2011" ? $trip['route_long_name'] : "") . $trip['route_short_name'] . " towards " . $destination['stop_name'] . "

    "; $viaPoints = viaPointNames($trip['trip_id'], $trip['stop_sequence']); if ($viaPoints != "") echo '
    Via: ' . $viaPoints . ''; --- a/trip.php +++ b/trip.php @@ -27,7 +27,7 @@ $tripid = $trip['trip_id']; } else { $trip = getTrip($tripid); - $similarRoutes = getRoutesByNumber($trip['route_short_name'], $trip['direction_id'], service_period_day($trip["service_id"])); + $similarRoutes = getRoutesByNumber($trip['route_short_name'], $trip['direction_id'], strtolower($trip["service_id"])); $routeids = Array(); foreach ($similarRoutes as $similarRoute) { $routeids[] = $similarRoute['route_id']; @@ -35,7 +35,7 @@ $routeids = array_unique($routeids); } $directionid = $trip['direction_id']; -$service_period = service_period_day($trip["service_id"]); +$service_period = strtolower($trip["service_id"]); $destination = getTripDestination($trip['trip_id']); include_header("Stops on " . $trip['route_short_name'] . ' ' . $destination['stop_name'], "trip"); trackEvent("Route/Trip View", "View Route", $trip['route_short_name'] . ' ' . $destination['stop_name'], $routeid); @@ -64,11 +64,11 @@ foreach (getRoutesByNumber($trip['route_short_name']) as $row) { foreach (getRouteHeadsigns($row['route_id']) as $headsign) { - if ( $headsign['direction_id'] != $directionid || service_period_day($headsign['service_id']) != $service_period) { - echo "{$headsign['direction_id']} != $directionid || ".service_period_day($headsign['service_id'])." != $service_period
    "; + if ( $headsign['direction_id'] != $directionid || strtolower($headsign['service_id']) != $service_period) { + echo "{$headsign['direction_id']} != $directionid || ".strtolower($headsign['service_id'])." != $service_period
    "; $start = $headsign['stop_name']; - $serviceday = service_period_day($headsign['service_id']); + $serviceday = strtolower($headsign['service_id']); $key = $row['route_short_name'] . "." . $headsign['direction_id']; if (isset($filteredRoutes[$key])) { $filteredRoutes[$key]['route_ids'][] = $row['route_id']; @@ -102,7 +102,7 @@ echo '