Line 1... |
Line 1... |
1 |
<?php
|
1 |
<?php
|
Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
define('MAGPIE_DIR', GEN_CHEMIN_API.'syndication_rss/magpierss/');
|
3 |
define('MAGPIE_DIR', GEN_CHEMIN_API.'syndication_rss/magpierss/');
|
4 |
define('MAGPIE_CACHE_DIR', '/tmp/magpie_cache');
|
4 |
define('MAGPIE_CACHE_DIR', MAGPIE_DIR.'tmp/magpie_cache');
|
5 |
define('OUVRIR_LIEN_RSS_NOUVELLE_FENETRE', 1);
|
5 |
define('OUVRIR_LIEN_RSS_NOUVELLE_FENETRE', 1);
|
6 |
define('FORMAT_DATE', 'jma');
|
6 |
define('FORMAT_DATE', 'jma');
|
Line 7... |
Line 7... |
7 |
require_once(MAGPIE_DIR.'rss_fetch.inc');
|
7 |
require_once(MAGPIE_DIR.'rss_fetch.inc');
|
Line 11... |
Line 11... |
11 |
if ( $url!='' ) {
|
11 |
if ( $url!='' ) {
|
12 |
$rss = fetch_rss( $url );
|
12 |
$rss = fetch_rss( $url );
|
13 |
if ($template != "") {
|
13 |
if ($template != "") {
|
14 |
$res = ""; $i = 0 ;
|
14 |
$res = ""; $i = 0 ;
|
15 |
foreach ($rss->items as $item) {
|
15 |
foreach ($rss->items as $item) {
|
- |
|
16 |
// Le test suivant pour savoir s il faut reduire l excendent de description
|
- |
|
17 |
// Si {all} est present dans le template on ne reduit pas
|
- |
|
18 |
if (preg_match ('/{all}/', $template)) {
|
- |
|
19 |
$template = str_replace('{all}', '', $template);
|
- |
|
20 |
$all = true ;
|
- |
|
21 |
}
|
16 |
if (strlen($item['description']) > 200) {
|
22 |
if (strlen($item['description']) > 200 && !$all) {
|
17 |
$item['description'] = substr ($item['description'] , 0, 300).'... <a href="'.$item['link'].'">Lire la suite</a>';
|
23 |
$item['description'] = substr ($item['description'] , 0, 300).'... <a href="'.$item['link'].'">Lire la suite</a>';
|
18 |
}
|
24 |
}
|
19 |
$res .= str_replace ('{num}', ++$i,
|
25 |
$res .= str_replace ('{num}', ++$i,
|
20 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.$item['title'].'</a>',
|
26 |
str_replace ('{item}', '<a href="'.$item['link'].'" target="_top">'.$item['title'].'</a>',
|
- |
|
27 |
str_replace ('{date}', strftime('%d.%m.%Y',strtotime($item['pubdate'])),
|
21 |
str_replace ('{description}', $item['description'], $template))) ;
|
28 |
str_replace ('{description}', $item['description'], $template)))) ;
|
22 |
$res .= "\n";
|
29 |
$res .= "\n";
|
23 |
if ($i >= $nb) break;
|
30 |
if ($i >= $nb) break;
|
- |
|
31 |
|
24 |
}
|
32 |
}
|
25 |
return $res ;
|
33 |
return $res ;
|
26 |
}
|
34 |
}
|
27 |
if ( $titre=='' ) {$res .= '<h2>'.$rss->channel['title'].'</h2>'."\n";}
|
35 |
if ( $titre=='' ) {$res .= '<h2>'.$rss->channel['title'].'</h2>'."\n";}
|
28 |
elseif ( $titre!='0' ) {$res .= '<h2>'.$titre.'</h2>'."\n";}
|
36 |
elseif ( $titre!='0' ) {$res .= '<h2>'.$titre.'</h2>'."\n";}
|