These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | require_once('require/class.Connection.php'); |
||
3 | require_once('require/class.Stats.php'); |
||
4 | require_once('require/class.Language.php'); |
||
5 | $Stats = new Stats(); |
||
6 | $title = _("Statistics").' - '._("Most common Airline by Country"); |
||
7 | require_once('header.php'); |
||
8 | include('statistics-sub-menu.php'); |
||
9 | |||
10 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script> |
||
11 | <div class="info"> |
||
12 | <h1>'._("Most common Airline by Country").'</h1> |
||
13 | </div> |
||
14 | <p>'._("Below are the <strong>Top 10</strong> countries that an airline belongs to.").'</p>'; |
||
15 | |||
16 | $airline_array = $Stats->countAllAirlineCountries(); |
||
17 | View Code Duplication | if (count($airline_array) > 0) { |
|
1 ignored issue
–
show
|
|||
18 | print '<div id="chartCountry" class="chart" width="100%"></div> |
||
19 | <script> |
||
20 | google.load("visualization", "1", {packages:["geochart"]}); |
||
21 | google.setOnLoadCallback(drawChart); |
||
22 | function drawChart() { |
||
23 | var data = google.visualization.arrayToDataTable([ |
||
24 | ["'._("Country").'", "'._("# of times").'"], '; |
||
25 | $country_data = ''; |
||
26 | foreach($airline_array as $airline_item) |
||
27 | { |
||
28 | $country_data .= '[ "'.$airline_item['airline_country'].'",'.$airline_item['airline_country_count'].'],'; |
||
29 | } |
||
30 | $country_data = substr($country_data, 0, -1); |
||
31 | print $country_data; |
||
32 | print ']); |
||
33 | |||
34 | var options = { |
||
35 | legend: {position: "none"}, |
||
36 | chartArea: {"width": "80%", "height": "60%"}, |
||
37 | height:500, |
||
38 | colors: ["#8BA9D0","#1a3151"] |
||
39 | }; |
||
40 | |||
41 | var chart = new google.visualization.GeoChart(document.getElementById("chartCountry")); |
||
42 | chart.draw(data, options); |
||
43 | } |
||
44 | $(window).resize(function(){ |
||
45 | drawChart(); |
||
46 | }); |
||
47 | </script>'; |
||
48 | } |
||
49 | if (!empty($airline_array)) |
||
50 | { |
||
51 | print '<div class="table-responsive">'; |
||
52 | print '<table class="common-country table-striped">'; |
||
53 | print '<thead>'; |
||
54 | print '<th></th>'; |
||
55 | print '<th>'._("Country").'</th>'; |
||
56 | print '<th>'._("# of times").'</th>'; |
||
57 | print '</thead>'; |
||
58 | print '<tbody>'; |
||
59 | $i = 1; |
||
60 | foreach($airline_array as $airline_item) |
||
61 | { |
||
62 | print '<tr>'; |
||
63 | print '<td><strong>'.$i.'</strong></td>'; |
||
64 | print '<td>'; |
||
65 | print '<a href="'.$globalURL.'/country/'.strtolower(str_replace(" ", "-", $airline_item['airline_country'])).'">'.$airline_item['airline_country'].'</a>'; |
||
66 | print '</td>'; |
||
67 | print '<td>'.$airline_item['airline_country_count'].'</td>'; |
||
68 | print '</tr>'; |
||
69 | $i++; |
||
70 | } |
||
71 | print '<tbody>'; |
||
72 | print '</table>'; |
||
73 | print '</div>'; |
||
74 | } |
||
75 | |||
76 | require_once('footer.php'); |
||
77 | ?> |
||
1 ignored issue
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.