Accueil/modules/rssblogs/Rssblogs.php

37 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2010-09-20 18:14:20 +02:00
<?php
class rssblogs extends Module {
protected $moduleTitle = 'Lecteur de flux RSS';
protected $paramsList = array(
2010-09-20 18:14:20 +02:00
'visibility',
'x',
'y'
);
public $params = array();
public function __construct($params){
parent::__construct(__CLASS__, $params);
}
public function build(){
2010-09-27 12:48:53 +02:00
echo '<script type="text/javascript" src="'.$this->pathToModule.'js/'.$this->moduleName.'.js"></script>
<link rel="stylesheet" href="'.$this->pathToModule.'css/'.$this->moduleName.'.css" type="text/css" />';
2010-09-20 18:14:20 +02:00
require('class/lastRSS.php');
$rss = new lastRSS;
// options lastRSS
$rss->cache_dir = './cache'; // dossier pour le cache
$rss->cache_time = 3600; // fr<66>quence de mise <20> jour du cache (en secondes)
$rss->date_format = 'd/m/y'; // format de la date (voir fonction date() pour syntaxe)
$rss->CDATA = 'content'; // on retire les tags CDATA en conservant leur contenu
echo '<div id="rssblogs" style="top:' . $this->getParam('y') . '; left: ' . $this->getParam('x') . ';">';
2010-09-27 12:48:53 +02:00
if($linksXML = simplexml_load_file($this->pathToModule.'db/rss.xml')){
2010-09-20 18:14:20 +02:00
foreach($linksXML->link as $individualLink){
if ($rs = $rss->get($individualLink->url))
echo '<span class="date">'.$rs['items'][0]['pubDate'].'</span> <a href="'.$rs['items'][0]['link'].'">'.$rs['items'][0]['title'].'</a><br />';
else
echo 'Flux RSS non trouv<75>';
}
}
echo '</div>';
}
}