website diff lib/get-feeds.php @ rev 1019

a lot of small improvements, code cleaning etc.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Mar 31 17:05:27 2012 +0300 (2012-03-31)
parents e2a0a816a8c6
children 47055e938c85
line diff
     1.1 --- a/lib/get-feeds.php	Tue Mar 13 20:28:01 2012 +0100
     1.2 +++ b/lib/get-feeds.php	Sat Mar 31 17:05:27 2012 +0300
     1.3 @@ -1,5 +1,23 @@
     1.4  <?php
     1.5  
     1.6 +function updated() {
     1.7 +	$addr = explode('/', $_SERVER['REQUEST_URI']);
     1.8 +	$lang = $addr[1];
     1.9 +	$native = array(
    1.10 +	"cn"=>"- 更新于: ",
    1.11 +	"da"=>"- Opdateret den: ",
    1.12 +	"de"=>"- Aktualisiert am: ",
    1.13 +	"en"=>"- Updated: ",
    1.14 +	"es"=>"- Actualizado el: ",
    1.15 +	"fr"=>"- Mis à jour le: ",
    1.16 +	"id"=>"- Diperbarui pada: ",
    1.17 +	"it"=>"- Aggiornato il: ",
    1.18 +	"pt"=>"- Atualizado em: ",
    1.19 +	"ru"=>"— Обновлено: "
    1.20 +	);
    1.21 +	return $native[$lang];
    1.22 +}
    1.23 +
    1.24  // Read RSS Feed
    1.25  function get_feed($feed) {
    1.26  	$cache = '/var/cache/slitaz/website';
    1.27 @@ -7,7 +25,7 @@
    1.28  	// have the page displayed even if any xml file
    1.29  	if ( ! file_exists("$cache/$feed")) {
    1.30  		echo "</p>\n<div>\n";
    1.31 -		echo "Missing feed: $cache/$feed\n" . "</div>\n";
    1.32 +		echo "Missing feed: $cache/$feed\n";
    1.33  	}
    1.34  	else {
    1.35  		$content = file_get_contents("$cache/$feed");
    1.36 @@ -15,11 +33,11 @@
    1.37  		$count = 0;
    1.38  		// We look for last item, channel may not have a PubDate*
    1.39  		$up = ($x->channel->item->pubDate);
    1.40 -		echo "<span>- Updated: " . substr("$up", 5, 17) . "</span>\n";
    1.41 +		echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
    1.42  		echo "</p>\n<div>\n<ul>\n";
    1.43  		foreach($x->channel->item as $entry) {
    1.44  			$count = $count + 1;
    1.45 -			echo "	<li><a href='$entry->guid' title='$entry->title'>" . 
    1.46 +			echo "	<li><a href='$entry->guid'>" . 
    1.47  				$entry->title . "</a></li>\n";
    1.48  			if ($count == $entries) {
    1.49  				break;
    1.50 @@ -35,7 +53,8 @@
    1.51  	$entries = 4;
    1.52  	// have the page displayed even if any xml file
    1.53  	if ( ! file_exists("$cache/$feed")) {
    1.54 -		echo "Missing feed: $cache/$feed\n" . "</div>\n";
    1.55 +		echo "</p>\n<div>\n";
    1.56 +		echo "Missing feed: $cache/$feed\n";
    1.57  	}
    1.58  	else {
    1.59  		$content = file_get_contents("$cache/$feed");
    1.60 @@ -47,7 +66,7 @@
    1.61  		echo "<ul>\n";
    1.62  		foreach($x->channel->item as $entry) {
    1.63  			$count = $count + 1;
    1.64 -			echo "	<li><strong><a href='$entry->link' title='$entry->title'>" . 
    1.65 +			echo "	<li><strong><a href='$entry->link'>" . 
    1.66  				$entry->title . "</strong></a>\n";
    1.67  			echo "<span>- " . substr("$entry->pubDate", 5, 17) . "</span>\n";
    1.68  			echo "<p>$entry->description</p>\n</li>";
    1.69 @@ -66,7 +85,7 @@
    1.70  	// have the page displayed even if any xml file
    1.71  	if ( ! file_exists("$cache/$feed")) {
    1.72  		echo "</p>\n<div>\n";
    1.73 -		echo "Missing feed: $cache/$feed\n" . "</div>\n";
    1.74 +		echo "Missing feed: $cache/$feed\n";
    1.75  	}
    1.76  	else {
    1.77  		$content = file_get_contents("$cache/$feed");
    1.78 @@ -74,11 +93,11 @@
    1.79  		$count = 0;
    1.80  		// We look for last item, channel may not have a PubDate*
    1.81  		$up = ($x->channel->item->pubDate);
    1.82 -		echo "<span>- Updated: " . substr("$up", 5, 17) . "</span>\n";
    1.83 +		echo "<span>" . updated() . substr("$up", 5, 17) . "</span>\n";
    1.84  		echo "</p>\n<div>\n<ul>\n";
    1.85  		foreach($x->channel->item as $entry) {
    1.86  			$count = $count + 1;
    1.87 -			echo "	<li><a href='$entry->link' title='$entry->title'>" . 
    1.88 +			echo "	<li><a href='$entry->link'>" . 
    1.89  				$entry->title . "</a></li>\n";
    1.90  			if ($count == $entries) {
    1.91  				break;