2014-03-26 11:22:53 +01:00
< ? php
2015-11-05 21:26:48 +01:00
define ( " FREENEWS_RSS " , 'http://feeds.feedburner.com/Freenews-Freebox?format=xml' );
2016-08-24 19:06:07 +02:00
class FreenewsBridge extends RssExpander {
2015-11-05 16:50:18 +01: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. " ;
}
2016-08-25 01:24:53 +02:00
public function collectData (){
2016-08-25 17:11:49 +02:00
parent :: collectExpandableDatas ( FREENEWS_RSS );
2014-03-26 11:22:53 +01:00
}
2016-08-22 01:25:56 +02:00
2015-03-18 17:42:55 +01:00
protected function parseRSSItem ( $newsItem ) {
2016-08-22 18:55:59 +02:00
$item = array ();
$item [ 'title' ] = trim ( $newsItem -> title );
2016-08-24 20:19:30 +02:00
$this -> debugMessage ( " item has for title \" " . $item [ 'title' ] . " \" " );
2015-03-18 17:42:55 +01:00
if ( empty ( $newsItem -> guid )) {
2016-08-22 18:55:59 +02:00
$item [ 'uri' ] = ( string ) $newsItem -> link ;
2015-03-18 17:42:55 +01:00
} else {
2016-08-22 18:55:59 +02:00
$item [ 'uri' ] = ( string ) $newsItem -> guid ;
2015-03-18 17:42:55 +01:00
}
// now load that uri from cache
2016-08-24 20:19:30 +02:00
$this -> debugMessage ( " now loading page " . $item [ 'uri' ]);
2016-08-28 19:38:34 +02:00
$articlePage = $this -> get_cached ( $item [ 'uri' ]);
2014-03-26 11:22:53 +01:00
2015-03-18 17:42:55 +01:00
$content = $articlePage -> find ( '.post-container' , 0 );
2016-08-22 18:55:59 +02:00
$item [ 'content' ] = $content -> innertext ;
$item [ 'author' ] = $articlePage -> find ( 'a[rel=author]' , 0 ) -> innertext ;
2015-03-18 17:42:55 +01:00
// format should parse 2014-03-25T16:21:20Z. But, according to http://stackoverflow.com/a/10478469, it is not that simple
2016-08-22 18:55:59 +02:00
$item [ 'timestamp' ] = $this -> RSS_2_0_time_to_timestamp ( $newsItem );
2015-03-18 17:42:55 +01:00
return $item ;
2014-03-26 11:22:53 +01:00
}
}