Subversion Repositories Applications.papyrus

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
770 florian 1
<?php
2
 
3
define('MAGPIE_DIR', 'magpierss/');
4
define('MAGPIE_CACHE_DIR', '/tmp/magpie_cache');
5
require_once(MAGPIE_DIR.'rss_fetch.inc');
6
 
7
function voir_rss($titre='', $url='', $nb=0, $nouvelle_fenetre=1, $formatdate='') {
8
	$res= '';
9
	if ( $url!='' ) {
10
		$rss = fetch_rss( $url );
11
		if ( $titre=='' ) {$res .= '<h2>'.$rss->channel['title'].'</h2>'."\n";}
12
		elseif ( $titre!='0' ) {$res .= '<h2>'.$titre.'</h2>'."\n";}
13
		$res .= '<ul class="liste_rss">'."\n";
14
		$i=0;
15
                $nb_item=count($rss->items);
16
		if (($nb==0)or($nb_item<=$nb)) {
17
			foreach ($rss->items as $item) {
18
				$href = $item['link'];
19
				$title = $item['title'];
20
				$res .= '<li class="titre_rss"><a class="lien_rss" href="'.$href;
21
        	               	if ($nouvelle_fenetre==1) $res .=  '" onclick="window.open(this.href); return false;';
22
				$res .= '">'.$title.'</a></li>'."\n";
23
			}
24
		}
25
		else {
26
			$i=0;
27
			foreach ($rss->items as $item) {
28
				$href = $item['link'];
29
				$title = $item['title'];
30
				$res .= '<li class="titre_rss">';
31
				if (isset($item['pubdate'])) $date=$item['pubdate'];
32
				elseif ((!isset($item['pubdate']))and(isset($item['date_timestamp']))) $date=$item['date_timestamp'];
33
				else $formatdate='';
34
				if ($formatdate=='jm') {$res .= strftime('%d.%m',strtotime($date)).': ';}
35
				if ($formatdate=='jma') {$res .= strftime('%d.%m.%Y',strtotime($date)).': ';}
36
				if ($formatdate=='jmh') {$res .= strftime('%d.%m %H:%M',strtotime($date)).': ';}
37
				if ($formatdate=='jmah') {$res .= strftime('%d.%m.%Y %H:%M',strtotime($date)).': ';}
38
                                $res .= '<a class="lien_rss" href="'.$href;
39
        	               	if ($nouvelle_fenetre==1) $res .=  '" onclick="window.open(this.href); return false;';
40
				$res .= '">'.$title.'</a></li>'."\n";
41
				$i++;
42
				if ($i>=$nb) break;
43
			}
44
		}
45
		$res .= '</ul>'."\n";
46
	}
47
        //echo '<pre>'.var_dump($rss->items).'</pre><br /><br />';
48
	return $res;
49
}
50
?>