84 lines
2.4 KiB
PHP
84 lines
2.4 KiB
PHP
|
<?php
|
|||
|
class rssblogs extends Module {
|
|||
|
//TODO rajouter les params en d<>tail
|
|||
|
protected static $paramsList = array(
|
|||
|
'visibility',
|
|||
|
'x',
|
|||
|
'y'
|
|||
|
);
|
|||
|
|
|||
|
public $params = array();
|
|||
|
|
|||
|
public function __construct($params){
|
|||
|
$this->setParams($params);
|
|||
|
echo '<link rel="stylesheet" type="text/css" href="css/rssblogs.css"><div id="rssblogs">';
|
|||
|
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
|
|||
|
if($linksXML = simplexml_load_file('db/rss.xml')){
|
|||
|
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>';
|
|||
|
}
|
|||
|
|
|||
|
private function setParams($params){
|
|||
|
$this->params = $params;
|
|||
|
}
|
|||
|
|
|||
|
public static function start($params){
|
|||
|
$rssblogs = new rssblogs($params);
|
|||
|
}
|
|||
|
|
|||
|
public function setX($x){
|
|||
|
// Saving the position and z-index of the note:
|
|||
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
$path = $xmla->xpath("//item[@id='weather']");
|
|||
|
$path[0]->x = $x;
|
|||
|
|
|||
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
echo "ok";
|
|||
|
}
|
|||
|
|
|||
|
public function setY($y){
|
|||
|
// Saving the position and z-index of the note:
|
|||
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
$path = $xmla->xpath("//item[@id='weather']");
|
|||
|
$path[0]->y = $y;
|
|||
|
|
|||
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
echo "ok";
|
|||
|
}
|
|||
|
|
|||
|
public function setVisibility($visibility){
|
|||
|
// Saving the position and z-index of the note:
|
|||
|
$xmla = simplexml_load_file('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
$path = $xmla->xpath("//item[@id='weather']");
|
|||
|
$path[0]->visibility = $visibility;
|
|||
|
|
|||
|
$xmla->asXML('../'.AccueilModules::CONFIG_FILE);
|
|||
|
|
|||
|
echo "ok";
|
|||
|
}
|
|||
|
|
|||
|
public static function updateConfig($updated){
|
|||
|
foreach ($updated as $what=>$withWhat){
|
|||
|
if(in_array($what, self::$paramsList)){
|
|||
|
call_user_func(array(get_class(), "set".ucfirst($what)), $withWhat);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|