Rss-Bridge/bridges/CommonDreamsBridge.php
Pierre Mazière f1fb95b257 [core] extract BridgeAbstract methods to make them functions
- returnError, returnServerError, returnClientError ,debugMessage are
  moved to lib/error.php

- getContents, getSimpleHTMLDOM, getSimpleHTMLDOMCached are moved to
  lib/contents.php

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
2016-09-25 23:22:33 +02:00

27 lines
739 B
PHP

<?php
class CommonDreamsBridge extends FeedExpander {
const MAINTAINER = "nyutag";
const NAME = "CommonDreams Bridge";
const URI = "http://www.commondreams.org/";
const DESCRIPTION = "Returns the newest articles.";
public function collectData(){
$this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10);
}
protected function parseItem($newsItem){
$item = parent::parseItem($newsItem);
$item['content'] = $this->CommonDreamsExtractContent($item['uri']);
return $item;
}
private function CommonDreamsExtractContent($url) {
$html3 = getSimpleHTMLDOMCached($url);
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
$html3->clear();
unset ($html3);
return $text;
}
}