Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / newest.php
blob12d92616919709fe824bc9acd2bd46ad6545204f
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Language.php');
5 $Spotter = new Spotter();
7 if (isset($_POST['category']))
9 $category = filter_input(INPUT_POST,'category',FILTER_SANITIZE_STRING);
10 header('Location: '.$globalURL.'/newest/'.$category);
13 $title = _("Newest");
14 require_once('header.php');
16 //calculuation for the pagination
17 if(!isset($_GET['limit']))
19 $limit_start = 0;
20 $limit_end = 25;
21 $absolute_difference = 25;
22 } else {
23 $limit_explode = explode(",", $_GET['limit']);
24 $limit_start = $limit_explode[0];
25 $limit_end = $limit_explode[1];
28 $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
30 $absolute_difference = abs($limit_start - $limit_end);
31 $limit_next = $limit_end + $absolute_difference;
32 $limit_previous_1 = $limit_start - $absolute_difference;
33 $limit_previous_2 = $limit_end - $absolute_difference;
35 if (!isset($_GET['category']))
37 $category = "aircraft";
38 } else {
39 $category = filter_input(INPUT_GET,'category',FILTER_SANITIZE_STRING);
42 $page_url = $globalURL.'/newest/'.$category;
44 print '<div class="select-item">';
45 print '<form action="'.$globalURL.'/newest" method="post">';
46 print '<select name="category" class="selectpicker" data-live-search="true">';
48 if ($category == "aircraft")
50 print '<option value="aircraft" selected="selected">'._("Aircraft Type").'</option>';
51 } else {
52 print '<option value="aircraft">'._("Aircraft Type").'</option>';
55 if ($category == "registration")
57 print '<option value="registration" selected="selected">'._("Aircraft Registration").'</option>';
58 } else {
59 print '<option value="registration">'._("Aircraft Registration").'</option>';
62 if ($category == "airline")
64 print '<option value="airline" selected="selected">'._("Airline").'</option>';
65 } else {
66 print '<option value="airline">'._("Airline").'</option>';
69 if ($category == "departure_airport")
71 print '<option value="departure_airport" selected="selected">'._("Departure Airport").'</option>';
72 } else {
73 print '<option value="departure_airport">'._("Departure Airport").'</option>';
76 if ($category == "arrival_airport")
78 print '<option value="arrival_airport" selected="selected">'._("Arrival Airport").'</option>';
79 } else {
80 print '<option value="arrival_airport">'._("Arrival Airport").'</option>';
83 print '</select>';
85 print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
86 print '</form>';
87 print '</div>';
89 print '<div class="info column">';
90 if ($category == "aircraft")
92 print '<h1>'._("Newest Aircraft Type").'</h1>';
93 } else if ($category == "registration")
95 print '<h1>'._("Newest Aircraft Registration").'</h1>';
96 } else if ($category == "airline")
98 print '<h1>'._("Newest Airline").'</h1>';
99 } else if ($category == "departure_airport")
101 print '<h1>'._("Newest Departure Airport").'</h1>';
102 } else if ($category == "arrival_airport")
104 print '<h1>'._("Newest Arrival Airport").'</h1>';
106 print '</div>';
108 print '<div class="table column">';
109 if ($category == "aircraft")
111 print '<p>'._("The table below shows the detailed information sorted by the newest recorded aircraft type. Each aircraft type is grouped and is shown only once, the first time it flew nearby.").'</p>';
112 } else if ($category == "registration")
114 print '<p>'._("The table below shows the detailed information sorted by the newest recorded aircraft by registration. Each aircraft registration is grouped and is shown only once, the first time it flew nearby.").'</p>';
115 } else if ($category == "airline")
117 print '<p>'._("The table below shows the detailed information sorted by the newest recorded airline. Each airline is grouped and is shown only once, the first time it flew nearby.").'</p>';
118 } else if ($category == "departure_airport")
120 print '<p>'._("The table below shows the detailed information sorted by the newest recorded departure airport. Each departure airport is grouped and is shown only once, the first time an aircraft flew nearby from the airport.").'</p>';
121 } else if ($category == "arrival_airport")
123 print '<p>'._("The table below shows the detailed information sorted by the newest recorded arrival airport. Each arrival airport is grouped and is shown only once, the first time an aircraft flew nearby to the airport.").'</p>';
126 if ($category == "aircraft")
128 $spotter_array = $Spotter->getNewestSpotterDataSortedByAircraftType($limit_start.",".$absolute_difference, $sort);
129 } else if ($category == "registration")
131 $spotter_array = $Spotter->getNewestSpotterDataSortedByAircraftRegistration($limit_start.",".$absolute_difference, $sort);
132 } else if ($category == "airline")
134 $spotter_array = $Spotter->getNewestSpotterDataSortedByAirline($limit_start.",".$absolute_difference, $sort);
135 } else if ($category == "departure_airport")
137 $spotter_array = $Spotter->getNewestSpotterDataSortedByDepartureAirport($limit_start.",".$absolute_difference, $sort);
138 } else if ($category == "arrival_airport")
140 $spotter_array = $Spotter->getNewestSpotterDataSortedByArrivalAirport($limit_start.",".$absolute_difference, $sort);
143 if (!empty($spotter_array))
145 include('table-output.php');
146 print '<div class="pagination">';
147 if ($limit_previous_1 >= 0)
149 print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">&laquo;'._("Previous Page").'</a>';
151 if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
153 print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'&raquo;</a>';
155 print '</div>';
156 print '</div>';
159 require_once('footer.php');