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