--- a/include/common-transit.inc.php +++ b/include/common-transit.inc.php @@ -23,21 +23,41 @@ function service_period($date = "") { - if (isset($_SESSION['service_period'])) - return $_SESSION['service_period']; + if (isset($_REQUEST['service_period'])) { + return $_REQUEST['service_period']; + } + $override = getServiceOverride($date); - if ($override['service_id']) { - return $override['service_id']; - } - - switch (date('w', ($date != "" ? $date : time()))) { - case 0: - return 'sunday'; - case 6: - return 'saturday'; + if (isset($override['service_id'])) { + return strtolower($override['service_id']); + } + $date = ($date != "" ? $date : time()); + $dow = date('w', $date); + + 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"); + case 'saturday': + return Array("Saturday", "Saturday"); default: - return 'weekday'; - } + //return 'weekday'; + return Array("Weekday", "Weekday-SchoolVacation"); + } +} + +function valid_service_ids() { + return array_merge(service_ids(""), service_ids('saturday'), service_ids('sunday')); } function midnight_seconds($time = "") { @@ -87,7 +107,7 @@ "UNKNOWN_EFFECT" => "Unknown effect", "STOP_MOVED" => "Stop moved"); - set_include_path(get_include_path() . PATH_SEPARATOR . $labsPath . "lib/Protobuf-PHP/library/DrSlump/"); + set_include_path(get_include_path() . PATH_SEPARATOR . ($basePath . "lib/Protobuf-PHP/library/DrSlump/")); include_once("Protobuf.php"); include_once("Protobuf/Message.php"); @@ -95,7 +115,7 @@ include_once("Protobuf/Descriptor.php"); include_once("Protobuf/Field.php"); - include_once($labsPath . "lib/Protobuf-PHP/gtfs-realtime.php"); + include_once($basePath . "lib/Protobuf-PHP/gtfs-realtime.php"); include_once("Protobuf/CodecInterface.php"); include_once("Protobuf/Codec/PhpArray.php"); include_once("Protobuf/Codec/Binary.php");