Upgrade to jquery.mobile-1.0rc1
[busui.git] / include / common-template.inc.php
blob:a/include/common-template.inc.php -> blob:b/include/common-template.inc.php
--- a/include/common-template.inc.php
+++ b/include/common-template.inc.php
@@ -27,7 +27,7 @@
     $url.= $GA_PIXEL . "?";
     $url.= "utmac=" . $GA_ACCOUNT;
     $url.= "&utmn=" . rand(0, 0x7fffffff);
-    $referer = $_SERVER["HTTP_REFERER"];
+    $referer = (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "");
     $query = $_SERVER["QUERY_STRING"];
     $path = $_SERVER["REQUEST_URI"];
     if (empty($referer)) {
@@ -54,15 +54,19 @@
 <link rel="dns-prefetch" href="//code.jquery.com">
 <link rel="dns-prefetch" href="//ajax.googleapis.com">
 	<link rel="stylesheet"  href="' . $basePath . 'css/jquery-ui-1.8.12.custom.css" />';
-    $jqmVersion = "1.0rc1";
+    $jqmVersion = "1.0";
     if (isDebugServer()) {
         $jqmcss = $basePath . "css/jquery.mobile-$jqmVersion.css";
-        $jqjs = $basePath . "js/jquery-1.6.2.min.js";
+        $jqjs = $basePath . "js/jquery-1.6.4.min.js";
         $jqmjs = $basePath . "js/jquery.mobile-$jqmVersion.js";
+        
+        $jqmcss = $basePath . "css/jquery.mobile-b90eab4935.css";
+        $jqmjs = $basePath . "js/jquery.mobile-b90eab4935.js";
     } else {
-        $jqmcss = "//code.jquery.com/mobile/1.0b3/jquery.mobile-$jqmVersion.min.css";
-        $jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js";
-        $jqmjs = "//code.jquery.com/mobile/1.0b3/jquery.mobile-$jqmVersion.min.js";
+        $jqmcss = "//code.jquery.com/mobile/$jqmVersion/jquery.mobile-$jqmVersion.min.css";
+        $jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js";
+        $jqmjs = "//code.jquery.com/mobile/$jqmVersion/jquery.mobile-$jqmVersion.min.js";
+
     }
     echo '<link rel="stylesheet"  href="' . $jqmcss . '" />
 	<script src="' . $jqjs . '"></script>
@@ -169,6 +173,7 @@
 	</div><!-- /header -->
         <a name="maincontent" id="maincontent"></a>
         <div data-role="content"> ';
+        if ($GTFSREnabled) {
         $overrides = getServiceOverride();
         if ($overrides['service_id']) {
             if ($overrides['service_id'] == "noservice") {
@@ -178,7 +183,6 @@
                 echo '<div id="servicewarning">Buses are running on an altered timetable today due to industrial action/public holiday. See <a href="http://www.action.act.gov.au">http://www.action.act.gov.au</a> for details.</div>';
             }
         }
-        if ($GTFSREnabled) {
             $serviceAlerts = getServiceAlertsAsArray("agency", "0");
             if (isset($serviceAlerts['entity']) && sizeof($serviceAlerts['entity']) > 0) {
                 foreach ($serviceAlerts['entity'] as $entity) {
@@ -241,5 +245,36 @@
     }
 }
 
+//stop list collapsing
+function stopCompare($stopName) {
+    return substr(trim(preg_replace("/\(Platform.*/", "", $stopName)),0,9);
+}
+function stopGroupTitle($stopName,$stopdesc) {
+    if (preg_match("/Dr |Cct |Cir |Av |St |Cr |Parade |Way |Bank /",$stopName)) {
+        $descParts =  explode("<br>",$stopdesc);
+         return trim(str_replace("Street: ","",$descParts[0]));
+    } else {
+        return trim(preg_replace("/\(Platform.*/", "",$stopName));
+    }
+}
+
+function viaPointNames($tripid, $stop_sequence = "") {
+    $viaPointNames = Array();
+    foreach (viaPoints($tripid, $stop_sequence) as $point) {
+        if (strstr($point['stop_name'], "Station")
+                || strstr($point['stop_name'], "Shops")
+                || strstr($point['stop_name'], "CIT")
+                || strstr($point['stop_name'], "School")
+                || strstr($point['stop_name'], "University")
+        ) {
+            $viaPointNames[] = $point['stop_name'];
+        }
+    }
+    if (sizeof($viaPointNames) > 0) {
+        return r_implode(", ", $viaPointNames);
+    } else {
+        return "";
+    }
+}
 ?>