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' );
2016-08-24 20:06:07 +03:00
class FreenewsBridge extends RssExpander {
2015-11-05 18:50:18 +03:00
2016-08-30 12:23:55 +03:00
const MAINTAINER = " mitsukarenai " ;
const NAME = " Freenews " ;
const URI = " http://freenews.fr " ;
const 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. " ;
2015-11-05 18:50:18 +03:00
2016-08-25 02:24:53 +03:00
public function collectData (){
2016-08-25 18:11:49 +03:00
parent :: collectExpandableDatas ( FREENEWS_RSS );
2014-03-26 14:22:53 +04:00
}
2016-08-22 02:25:56 +03:00
2015-03-18 19:42:55 +03:00
protected function parseRSSItem ( $newsItem ) {
2016-08-22 19:55:59 +03:00
$item = array ();
$item [ 'title' ] = trim ( $newsItem -> title );
2016-08-24 21:19:30 +03:00
$this -> debugMessage ( " item has for title \" " . $item [ 'title' ] . " \" " );
2015-03-18 19:42:55 +03:00
if ( empty ( $newsItem -> guid )) {
2016-08-22 19:55:59 +03:00
$item [ 'uri' ] = ( string ) $newsItem -> link ;
2015-03-18 19:42:55 +03:00
} else {
2016-08-22 19:55:59 +03:00
$item [ 'uri' ] = ( string ) $newsItem -> guid ;
2015-03-18 19:42:55 +03:00
}
// now load that uri from cache
2016-08-24 21:19:30 +03:00
$this -> debugMessage ( " now loading page " . $item [ 'uri' ]);
2016-08-28 20:38:34 +03:00
$articlePage = $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 );
2016-08-22 19:55:59 +03:00
$item [ 'content' ] = $content -> innertext ;
$item [ 'author' ] = $articlePage -> find ( 'a[rel=author]' , 0 ) -> innertext ;
2015-03-18 19:42:55 +03: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 19:55:59 +03:00
$item [ 'timestamp' ] = $this -> RSS_2_0_time_to_timestamp ( $newsItem );
2015-03-18 19:42:55 +03:00
return $item ;
2014-03-26 14:22:53 +04:00
}
}