Esempio n. 1
0
function staticmap($mapPoints, $collapsible = true, $twotone = false, $path = false, $numbered = false, $encpolyline = false)
{
    $markers = '';
    $height = 300;
    $width = $height;
    $index = 0;
    if (sizeof($mapPoints) < 1) {
        if ($encpolyline === false) {
            return 'map error';
        } else {
            $markers .= 'path=' . ($encpolyline === false ? "" : 'enc:' . $encpolyline);
        }
    } else {
        if (sizeof($mapPoints) === 1) {
            if ($encpolyline === false) {
                $markers = 'markers=' . $mapPoints[0][0] . ',' . $mapPoints[0][1];
            } else {
                $markers = 'markers=' . $mapPoints[0][0] . ',' . $mapPoints[0][1] . '&amp;path=' . ($encpolyline === false ? "" : 'enc:' . $encpolyline);
            }
        } else {
            if (!$numbered) {
                $markers = 'markers=';
            }
            foreach ($mapPoints as $index => $mapPoint) {
                if ($twotone && $index == 0) {
                    $markers = 'markerd=color:red|' . $mapPoint[0] . ',' . $mapPoint[1] . '&amp;markers=';
                } else {
                    if ($numbered) {
                        $label = $index > 9 ? 9 : $index;
                        $markers .= 'markers=label:' . $label . '|' . $mapPoint[0] . ',' . $mapPoint[1];
                        if ($index + 1 != sizeof($mapPoints)) {
                            $markers .= '&amp;';
                        }
                    } else {
                        $markers .= $mapPoint[0] . ',' . $mapPoint[1];
                        if ($index + 1 != sizeof($mapPoints)) {
                            $markers .= '|';
                        }
                    }
                    $index++;
                }
            }
            if ($path) {
                $markers .= '&amp;path=' . ($encpolyline === false ? "" : 'enc:' . $encpolyline);
            }
        }
    }
    $output = '';
    if ($collapsible) {
        $output .= '<div class="map geo" itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates" data-role="collapsible" data-collapsed="true"><h3>Open Map...</h3>
                <meta itemprop="latitude" content="' . $mapPoints[0][0] . '" />
                 <abbr class="latitude" title="' . $mapPoints[0][0] . '"></abbr>
 <abbr class="longitude" title="' . $mapPoints[0][1] . '"></abbr>
    <meta itemprop="longitude" content="' . $mapPoints[0][1] . '" />';
    }
    if (sizeof($mapPoints) === 1) {
        $output .= '<a href="https://maps.google.com.au/?ll=' . $mapPoints[0][0] . ',' . $mapPoints[0][1] . '">';
    }
    if (isIOSDevice()) {
        $output .= '<img class="hiresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&amp;' . $markers . '&amp;scale=2&amp;sensor=true" width=' . $width . ' height=' . $height . ' alt="map of stop location">';
    } else {
        $output .= '<img class="lowresmap" src="http://maps.googleapis.com/maps/api/staticmap?size=' . $width . 'x' . $height . '&amp;' . $markers . '&amp;scale=1&amp;format=jpg&amp;sensor=true" width=' . $width . ' height=' . $height . ' alt="map of stop location">';
    }
    if (sizeof($mapPoints) === 1) {
        $output .= '</a>';
    }
    if ($collapsible) {
        $output .= '</div>';
    }
    return $output;
}
function include_header($pageTitle, $pageType, $opendiv = true, $geolocate = false, $datepicker = false)
{
    global $basePath, $GTFSREnabled, $stopid, $routeid;
    echo '
<!DOCTYPE html> 
<html lang="en">
	<head>
        <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> 	
<title>' . $pageTitle . ' - Canberra Bus Timetable</title>
        <meta name="google-site-verification" content="-53T5Qn4TB_de1NyfR_ZZkEVdUNcNFSaYKSFkWKx-sY" />
<link rel="dns-prefetch" href="//code.jquery.com"/>
<link rel="dns-prefetch" href="//ajax.googleapis.com"/>
<link rel="profile" href="http://microformats.org/profile/hcalendar"/>
<link rel="profile" href="http://microformats.org/profile/geo"/>
	<link rel="stylesheet"  href="' . $basePath . 'css/jquery-ui-1.8.12.custom.css" />';
    $jqmVersion = "1.1.1";
    if (isDebugServer()) {
        $jqmcss = $basePath . "css/jquery.mobile-{$jqmVersion}.min.css";
        $jqjs = $basePath . "js/jquery-1.8.0.min.js";
        $jqmjs = $basePath . "js/jquery.mobile-{$jqmVersion}.min.js";
    } else {
        $jqmcss = "//code.jquery.com/mobile/{$jqmVersion}/jquery.mobile-{$jqmVersion}.min.css";
        $jqjs = "//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js";
        $jqmjs = "//code.jquery.com/mobile/{$jqmVersion}/jquery.mobile-{$jqmVersion}.min.js";
    }
    echo '<link rel="stylesheet"  href="' . $jqmcss . '" />
	<script type="text/javascript" src="' . $jqjs . '"></script>
		 <script type="text/javascript">$(document).bind("mobileinit", function(){
  $.mobile.ajaxEnabled = false;
});
</script> 
	<script type="text/javascript" src="' . $jqmjs . '"></script>

<script type="text/javascript" src="' . $basePath . 'js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="' . $basePath . 'js/jquery.ui.position.min.js"></script>
<script type="text/javascript" src="' . $basePath . 'js/jquery.ui.widget.min.js"></script>
  <script type="text/javascript" src="' . $basePath . 'js/jquery.ui.autocomplete.min.js"></script>
  <script type="text/javascript">
	$(function() {
		$( "#geolocate" ).autocomplete({
			source: "lib/autocomplete.php",
			minLength: 3
		});
		$( "#from" ).autocomplete({
			source: "lib/autocomplete.php",
			minLength: 3
		});
		$( "#to" ).autocomplete({
			source: "lib/autocomplete.php",
			minLength: 3
		});
	});
	</script>';
    echo '<style type="text/css">';
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'Android')) {
        echo '.ui-shadow,.ui-btn-up-a,.ui-btn-hover-a,.ui-btn-down-a,.ui-body-b,.ui-btn-up-b,.ui-btn-hover-b,
.ui-btn-down-b,.ui-bar-c,.ui-body-c,.ui-btn-up-c,.ui-btn-hover-c,.ui-btn-down-c,.ui-bar-c,.ui-body-d,
.ui-btn-up-d,.ui-btn-hover-d,.ui-btn-down-d,.ui-bar-d,.ui-body-e,.ui-btn-up-e,.ui-btn-hover-e,
.ui-btn-down-e,.ui-bar-e,.ui-overlay-shadow,.ui-shadow,.ui-btn-active,.ui-body-a,.ui-bar-a {
 text-shadow: none;
 box-shadow: none;
 -webkit-box-shadow: none;
}';
    }
    echo '</style>';
    echo '<link rel="stylesheet"  href="' . $basePath . 'css/local.css.php" />';
    if (isIOSDevice()) {
        echo '<meta name="apple-mobile-web-app-capable" content="yes" />
 <meta name="apple-mobile-web-app-status-bar-style" content="black" />
 <link rel="apple-touch-startup-image" href="startup.png" />
 <link rel="apple-touch-icon" href="apple-touch-icon.png" />';
    }
    if ($geolocate) {
        echo "<script type=\"text/javascript\">\n\nfunction success(position) {\n\$('#error').val('Location now detected. Please wait for data to load.');\n\$('#geolocate').val(position.coords.latitude+','+position.coords.longitude);\n\$.ajax({ async: false, \nsuccess: function(){\n\tlocation.reload(true);\n  },\nurl: \"include/common.inc.php?geolocate=yes&lat=\"+position.coords.latitude+\"&lon=\"+position.coords.longitude });\n}\nfunction error(msg) {\n\$('#error').val('Error: '+msg);\n}\n\nfunction geolocate() {\nif (navigator.geolocation) {\nvar options = {\n      enableHighAccuracy: true,\n      timeout: 60000,\n      maximumAge: 10000\n}\n  navigator.geolocation.getCurrentPosition(success, error, options);\n}\n}\n\$(document).ready(function() {\n        \$('#here').click(function(event) { \$('#geolocate').val(geolocate()); return false;});\n        \$('#here').show();\n});\n";
        if (!isset($_SESSION['lat']) || $_SESSION['lat'] == "") {
            echo "geolocate();";
        }
        echo "</script> ";
    }
    if (isAnalyticsOn()) {
        echo '
<script type="text/javascript">' . "\n\n  var _gaq = _gaq || [];\n  _gaq.push(['_setAccount', 'UA-22173039-1']);\n  _gaq.push(['_trackPageview']);\n   _gaq.push(['_trackPageLoadTime']);\n</script>";
    }
    echo '</head>
<body>
    <div id="skip">
    <a href="#maincontent">Skip to content</a>
    </div>
 ';
    if ($opendiv) {
        echo '<div data-role="page" ' . (isset($stopid) ? 'itemscope itemtype="http://schema.org/BusStop"' : '') . '>';
        echo '<div data-role="header" data-position="inline">
	<a href="' . (isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : "javascript:history.go(-1)") . '" data-icon="arrow-l" data-rel="back" class="ui-btn-left">Back</a> 
		<h1 itemprop="name">' . $pageTitle . '</h1>
		<a href="' . $basePath . '/index.php" data-icon="home" class="ui-btn-right" rel="home">Home</a>
	</div><!-- /header -->
        <a name="maincontent" id="maincontent"></a>
        <div data-role="content"> ';
        if ($GTFSREnabled) {
            $overrides = getServiceOverride();
            if (isset($overrides['service_id'])) {
                if ($overrides['service_id'] == "noservice") {
                    echo '<div class="servicewarning">Buses are <strong>not running today</strong> 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>';
                } else {
                    echo '<div class="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>';
                }
            }
            $serviceAlerts = array();
            $globalAlerts = getServiceAlertsAsArray("agency", "0");
            if ($globalAlerts != null) {
                // echo "getting alerts due to network wide";
                $serviceAlerts = array_merge($serviceAlerts, $globalAlerts);
            }
            if (isset($stopid)) {
                $stopAlerts = getServiceAlertsAsArray("stop", $stopid);
                if ($stopAlerts != null) {
                    // echo "getting alerts due to stop $stopid";
                    $serviceAlerts = array_merge($serviceAlerts, $stopAlerts);
                }
            }
            if (isset($routeid)) {
                $routeAlerts = getServiceAlertsAsArray("route", $routeid);
                if ($routeAlerts != null) {
                    //    echo "getting alerts due to route $routeid";
                    $serviceAlerts = array_merge($serviceAlerts, $routeAlerts);
                }
            }
            if (isset($serviceAlerts['entity']) && sizeof($serviceAlerts['entity']) > 0) {
                foreach ($serviceAlerts['entity'] as $entity) {
                    echo "<div class='servicewarning'><b>{$entity['alert']['header_text']['translation'][0]['text']}</b>&nbsp;<small>" . date("F jS Y, g:i a", $entity['alert']['active_period'][0]['start']) . " to " . date("F jS Y, g:i a", $entity['alert']['active_period'][0]['end']) . "</small>\n                            <br>Warning: {$entity['alert']['description_text']['translation'][0]['text']} \n                            <br><a href='{$entity['alert']['url']['translation'][0]['text']}'>Source</a>  </div>";
                }
            }
        }
    }
}