website annotate lib/get-feeds.php @ rev 1093

Added Bosnian main page
author Adnan Sinanovic <sinanovicha@gmail.com>
date Fri Oct 12 13:41:49 2012 +0000 (2012-10-12)
parents 8585804d4b9a
children 7d0c505926c6
rev   line source
pankso@808 1 <?php
pankso@808 2
al@1019 3 function updated() {
al@1019 4 $addr = explode('/', $_SERVER['REQUEST_URI']);
al@1019 5 $lang = $addr[1];
al@1019 6 $native = array(
al@1019 7 "cn"=>"- 更新于: ",
al@1019 8 "da"=>"- Opdateret den: ",
al@1019 9 "de"=>"- Aktualisiert am: ",
al@1019 10 "en"=>"- Updated: ",
al@1019 11 "es"=>"- Actualizado el: ",
al@1019 12 "fr"=>"- Mis à jour le: ",
al@1019 13 "id"=>"- Diperbarui pada: ",
al@1019 14 "it"=>"- Aggiornato il: ",
al@1019 15 "pt"=>"- Atualizado em: ",
al@1019 16 "ru"=>"— Обновлено: "
al@1019 17 );
pascal@1079 18 if (!isset($native[$lang]))
pascal@1079 19 $lang = "en";
al@1019 20 return $native[$lang];
al@1019 21 }
al@1019 22
pankso@808 23 // Read RSS Feed
pankso@808 24 function get_feed($feed) {
pankso@808 25 $cache = '/var/cache/slitaz/website';
pankso@808 26 $entries = 4;
al@1071 27 // no follow all links, but hg commits
al@1073 28 if ($feed == "wok.xml")
al@1073 29 $nofollow = "";
al@1073 30 else
al@1073 31 $nofollow = " rel='nofollow'";
pankso@808 32 // have the page displayed even if any xml file
pankso@808 33 if ( ! file_exists("$cache/$feed")) {
pankso@808 34 echo "</p>\n<div>\n";
al@1019 35 echo "Missing feed: $cache/$feed\n";
pankso@808 36 }
pankso@808 37 else {
pankso@808 38 $content = file_get_contents("$cache/$feed");
pankso@808 39 $x = new SimpleXmlElement($content);
pankso@808 40 $count = 0;
pankso@808 41 // We look for last item, channel may not have a PubDate*
pankso@808 42 $up = ($x->channel->item->pubDate);
al@1019 43 echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
pankso@808 44 echo "</p>\n<div>\n<ul>\n";
pankso@808 45 foreach($x->channel->item as $entry) {
pankso@808 46 $count = $count + 1;
al@1073 47 echo " <li><a href='$entry->guid'" . $nofollow . ">" .
pankso@808 48 $entry->title . "</a></li>\n";
pankso@808 49 if ($count == $entries) {
pankso@808 50 break;
pankso@808 51 }
pankso@808 52 }
pankso@808 53 echo "</ul>\n";
pankso@808 54 }
pankso@808 55 }
pankso@808 56
pankso@808 57 // Read Blog RSS Feed
pankso@808 58 function get_feed_blog($feed) {
pankso@808 59 $cache = '/var/cache/slitaz/website';
pankso@808 60 $entries = 4;
pankso@808 61 // have the page displayed even if any xml file
pankso@808 62 if ( ! file_exists("$cache/$feed")) {
pankso@1060 63 echo "<div>\n";
al@1019 64 echo "Missing feed: $cache/$feed\n";
pankso@1060 65 echo "</div>\n";
pankso@808 66 }
pankso@808 67 else {
pankso@808 68 $content = file_get_contents("$cache/$feed");
pankso@808 69 $x = new SimpleXmlElement($content);
pankso@808 70 $count = 0;
pankso@808 71 // We look for last item, channel may not have a PubDate*
pankso@808 72 $up = ($x->channel->item->pubDate);
al@1038 73
pankso@808 74 echo "<ul>\n";
pankso@808 75 foreach($x->channel->item as $entry) {
pankso@808 76 $count = $count + 1;
al@1038 77 echo " <li><a href='$entry->link'><strong>" .
pankso@808 78 $entry->title . "</strong></a>\n";
pankso@809 79 echo "<span>- " . substr("$entry->pubDate", 5, 17) . "</span>\n";
pankso@808 80 echo "<p>$entry->description</p>\n</li>";
pankso@808 81 if ($count == $entries) {
pankso@808 82 break;
pankso@808 83 }
pankso@808 84 }
pankso@808 85 echo "</ul>\n";
pankso@808 86 }
pankso@808 87 }
pankso@808 88
pankso@946 89 // Read Forum Feed
pankso@946 90 function get_feed_forum($feed) {
pankso@946 91 $cache = '/var/cache/slitaz/website';
pankso@946 92 $entries = 4;
pankso@946 93 // have the page displayed even if any xml file
pankso@946 94 if ( ! file_exists("$cache/$feed")) {
pankso@946 95 echo "</p>\n<div>\n";
al@1019 96 echo "Missing feed: $cache/$feed\n";
pankso@946 97 }
pankso@946 98 else {
pankso@946 99 $content = file_get_contents("$cache/$feed");
pankso@946 100 $x = new SimpleXmlElement($content);
pankso@946 101 $count = 0;
pankso@946 102 // We look for last item, channel may not have a PubDate*
pankso@946 103 $up = ($x->channel->item->pubDate);
al@1019 104 echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
pankso@946 105 echo "</p>\n<div>\n<ul>\n";
pankso@946 106 foreach($x->channel->item as $entry) {
pankso@946 107 $count = $count + 1;
al@1071 108 echo " <li><a href='$entry->link' rel='nofollow'>" .
pankso@946 109 $entry->title . "</a></li>\n";
pankso@946 110 if ($count == $entries) {
pankso@946 111 break;
pankso@946 112 }
pankso@946 113 }
pankso@946 114 echo "</ul>\n";
pankso@946 115 }
pankso@946 116 }
pankso@946 117
pankso@808 118 ?>