FreenewsBridge.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. define("FREENEWS_RSS", 'http://feeds.feedburner.com/Freenews-Freebox?format=xml');
  3. class FreenewsBridge extends RssExpander {
  4. public function loadMetadatas() {
  5. $this->maintainer = "mitsukarenai";
  6. $this->name = "Freenews";
  7. $this->uri = "http://freenews.fr";
  8. $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.";
  9. $this->parameters[] = array(
  10. 'id'=>array('name'=>'Id de la rubrique (sans le \'-\')')
  11. );
  12. }
  13. public function collectData(array $param){
  14. parent::collectExpandableDatas($param, FREENEWS_RSS);
  15. }
  16. protected function parseRSSItem($newsItem) {
  17. $item = array();
  18. $item['title'] = trim($newsItem->title);
  19. $this->debugMessage("item has for title \"".$item['title']."\"");
  20. if(empty($newsItem->guid)) {
  21. $item['uri'] = (string) $newsItem->link;
  22. } else {
  23. $item['uri'] = (string) $newsItem->guid;
  24. }
  25. // now load that uri from cache
  26. $this->debugMessage("now loading page ".$item['uri']);
  27. $articlePage = str_get_html($this->get_cached($item['uri']));
  28. $content = $articlePage->find('.post-container', 0);
  29. $item['content'] = $content->innertext;
  30. $item['author'] = $articlePage->find('a[rel=author]', 0)->innertext;
  31. // format should parse 2014-03-25T16:21:20Z. But, according to http://stackoverflow.com/a/10478469, it is not that simple
  32. $item['timestamp'] = $this->RSS_2_0_time_to_timestamp($newsItem);
  33. return $item;
  34. }
  35. }