2014-03-26 14:22:53 +04:00
< ? php
2015-11-05 23:26:48 +03:00
define ( " FREENEWS_RSS " , 'http://feeds.feedburner.com/Freenews-Freebox?format=xml' );
2015-03-18 19:42:55 +03:00
class Freenews extends RssExpander {
2015-11-05 18:50:18 +03:00
public function loadMetadatas () {
$this -> maintainer = " mitsukarenai " ;
$this -> name = " Freenews " ;
$this -> uri = " http://freenews.fr " ;
$this -> description = " Un site d'actualité pour les freenautes (mais ne parlant pas que de la freebox). Ne rentrez pas d'id si vous voulez accéder aux actualités générales. " ;
$this -> update = " 26/03/2014 " ;
$this -> parameters [] =
' [
{
" name " : " Id de la rubrique (sans le \ '- \ ') " ,
" identifier " : " id "
}
] ' ;
}
2014-03-26 14:22:53 +04:00
public function collectData ( array $param ){
2015-11-05 23:26:48 +03:00
parent :: collectExpandableDatas ( $param , FREENEWS_RSS );
2014-03-26 14:22:53 +04:00
}
2015-03-18 19:42:55 +03:00
protected function parseRSSItem ( $newsItem ) {
$item = new Item ();
$item -> title = trim ( $newsItem -> title );
// $this->message("item has for title \"".$item->title."\"");
if ( empty ( $newsItem -> guid )) {
2016-03-28 21:10:18 +03:00
$item -> uri = ( string ) $newsItem -> link ;
2015-03-18 19:42:55 +03:00
} else {
2016-03-28 21:10:18 +03:00
$item -> uri = ( string ) $newsItem -> guid ;
2015-03-18 19:42:55 +03:00
}
// now load that uri from cache
// $this->message("now loading page ".$item->uri);
$articlePage = str_get_html ( $this -> get_cached ( $item -> uri ));
2014-03-26 14:22:53 +04:00
2015-03-18 19:42:55 +03:00
$content = $articlePage -> find ( '.post-container' , 0 );
$item -> content = $content -> innertext ;
$item -> name = $articlePage -> find ( 'a[rel=author]' , 0 ) -> innertext ;
// format should parse 2014-03-25T16:21:20Z. But, according to http://stackoverflow.com/a/10478469, it is not that simple
$item -> timestamp = $this -> RSS_2_0_time_to_timestamp ( $newsItem );
return $item ;
2014-03-26 14:22:53 +04:00
}
}