2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 if (!isset($_GET['country'])) {
6 header('Location: '.$globalURL.'/country');
9 $Spotter = new Spotter();
10 $country = ucwords(str_replace("-", " ", urldecode(filter_input(INPUT_GET
,'country',FILTER_SANITIZE_STRING
))));
11 $sort = filter_input(INPUT_GET
,'sort',FILTER_SANITIZE_STRING
);
13 if (isset($_GET['sort'])) {
14 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", $sort);
16 $spotter_array = $Spotter->getSpotterDataByCountry($country, "0,1", '');
19 if (!empty($spotter_array))
21 $title = sprintf(_("Most Common Arrival Airports by Country from %s"),$country);
22 require_once('header.php');
23 print '<div class="select-item">';
24 print '<form action="'.$globalURL.'/country" method="post">';
25 print '<select name="country" class="selectpicker" data-live-search="true">';
26 print '<option></option>';
27 $all_countries = $Spotter->getAllCountries();
28 foreach($all_countries as $all_country)
30 if($country == $all_country['country'])
32 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'" selected="selected">'.$all_country['country'].'</option>';
34 print '<option value="'.strtolower(str_replace(" ", "-", $all_country['country'])).'">'.$all_country['country'].'</option>';
38 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
42 if ($_GET['country'] != "NA")
44 print '<div class="info column">';
45 print '<h1>'.sprintf(_("Airports & Airlines from %s"),$country).'</h1>';
48 print '<div class="alert alert-warning">'._("This special country profile shows all flights that do <u>not</u> have a country of a airline or departure/arrival airport associated with them.").'</div>';
51 include('country-sub-menu.php');
52 print '<div class="column">';
53 print '<h2>'._("Most Common Arrival Airports by Country").'</h2>';
54 print '<p>'.sprintf(_("The statistic below shows all arrival airports by Country of origin of flights of airports & airlines from <strong>%s</strong>."),$country).'</p>';
56 $airport_country_array = $Spotter->countAllArrivalAirportCountriesByCountry($country);
57 print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
58 print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
59 print '<script type="text/javascript" src="'.$globalURL.'/js/datamaps.world.min.js"></script>';
61 print '<div id="chartCountry" class="chart" width="100%"></div><script>';
62 print 'var series = [';
64 foreach($airport_country_array as $airport_item)
66 $country_data .= '[ "'.$airport_item['arrival_airport_country_iso3'].'",'.$airport_item['airport_arrival_country_count'].'],';
68 $country_data = substr($country_data, 0, -1);
71 print 'var dataset = {};var onlyValues = series.map(function(obj){ return obj[1]; });var minValue = Math.min.apply(null, onlyValues), maxValue = Math.max.apply(null, onlyValues);';
72 print 'var paletteScale = d3.scale.log().domain([minValue,maxValue]).range(["#EFEFFF","#001830"]);';
73 print 'series.forEach(function(item){var iso = item[0], value = item[1]; dataset[iso] = { numberOfThings: value, fillColor: paletteScale(value) };});';
75 element: document.getElementById("chartCountry"),
76 projection: "mercator", // big world map
77 fills: { defaultFill: "#F5F5F5" },
81 borderColor: "#DEDEDE",
82 highlightBorderWidth: 2,
83 highlightFillColor: function(geo) {
84 return geo["fillColor"] || "#F5F5F5";
86 highlightBorderColor: "#B7B7B7",
87 done: function(datamap) {
88 datamap.svg.call(d3.behavior.zoom().on("zoom", redraw));
90 datamap.svg.selectAll("g").attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
93 popupTemplate: function(geo, data) {
94 if (!data) { return ; }
95 return ['."'".'<div class="hoverinfo">'."','<strong>', geo.properties.name, '</strong>','<br>Count: <strong>', data.numberOfThings, '</strong>','</div>'].join('');
101 if (!empty($airport_country_array))
103 print '<div class="table-responsive">';
104 print '<table class="common-country table-striped">';
107 print '<th>'._("Country").'</th>';
108 print '<th>'._("# of times").'</th>';
112 foreach($airport_country_array as $airport_item)
115 print '<td><strong>'.$i.'</strong></td>';
117 print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airport_item['arrival_airport_country'])).'">'.$airport_item['arrival_airport_country'].'</a>';
120 print $airport_item['airport_arrival_country_count'];
131 $title = _("Country");
132 require_once('header.php');
133 print '<h1>'._("Error").'</h1>';
134 print '<p>'._("Sorry, the country does not exist in this database. :(").'</p>';
137 require_once('footer.php');