Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / news.php
blob1d1f4f3384754a799440f0897a8174f6df85d653
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/libs/SimplePie.compiled.php');
4 require_once('require/class.Language.php');
5 $SimplePie = new SimplePie();
7 $title = _("News");
8 require_once('header.php');
10 if (isset($_GET['tracker'])) $type = 'tracker';
11 elseif (isset($_GET['marine'])) $type = 'marine';
12 elseif (isset($_GET['aircraft'])) $type = 'aircraft';
13 elseif (isset($_GET['satellite'])) $type = 'satellite';
14 else $type = 'global';
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 $page_url = $globalURL.'/news';
37 print '<div class="info column">';
38 print '<h1>'._("News").'</h1>';
39 print '</div>';
41 print '<div class="table column">';
42 //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>';
43 print '<p>'._("This page show latest news.").'</p>';
44 if (count($globalNewsFeeds[$type]) == count($globalNewsFeeds[$type], COUNT_RECURSIVE))
46 $feeds = $globalNewsFeeds[$type];
47 } else {
48 $lg = $lang[1];
49 if (isset($globalNewsFeeds[$type][$lg])) $feeds = $globalNewsFeeds[$type][$lg];
50 else $feeds = array_shift($globalNewsFeeds[$type]);
53 $SimplePie->set_feed_url($feeds);
54 $SimplePie->set_cache_duration(3600);
55 $SimplePie->enable_cache(true);
56 $SimplePie->init();
57 $anews = $SimplePie->get_items();
59 if (!empty($anews))
61 $j = 0;
62 foreach($anews as $news) {
63 if ($j > 10) break;
64 $j++;
65 print '<div class="news">';
66 print '<h4><a href="'.$news->get_permalink().'">'.$news->get_title().'</a> <span>('.$news->get_date('j M Y, g:i a').')</span></h4>'."\n";
67 print $news->get_content()."\n";
68 print '</div>';
69 print '<br/>'."\n";
71 //include('table-output.php');
73 print '<div class="pagination">';
74 if ($limit_previous_1 >= 0)
76 print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$sort.'">&laquo;'._("Previous Page").'</a>';
78 if ($spotter_array[0]['query_number_rows'] == $absolute_difference)
80 print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$sort.'">'._("Next Page").'&raquo;</a>';
82 print '</div>';
83 print '</div>';
86 require_once('footer.php');