From 3506a18a398814bd78eee23c467d4b0ff2a10583 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 26 Apr 2015 19:22:20 +0200 Subject: [PATCH] Add CommonDreamsBridge.php --- bridges/CommonDreamsBridge.php | 56 ++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 bridges/CommonDreamsBridge.php diff --git a/bridges/CommonDreamsBridge.php b/bridges/CommonDreamsBridge.php new file mode 100644 index 0000000..7dcf33d --- /dev/null +++ b/bridges/CommonDreamsBridge.php @@ -0,0 +1,56 @@ +find('div[class=field--type-text-with-summary]', 0)->innertext; + return $text; + } + + $html = file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404); + $limit = 0; + foreach($html->find('item') as $element) { + if($limit < 2) { + $item = new \Item(); + $item->title = $element->find('title', 0)->innertext; + $item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext); + $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext); + $item->content = CommonDreamsExtractContent($item->uri); + $this->items[] = $item; + $limit++; + } + } + + } + + public function getName(){ + return 'CommonDreams Bridge'; + } + + public function getURI(){ + return 'http://www.commondreams.org/'; + } + + public function getCacheDuration(){ +// return 3600*2; // 2 hours + return 0; + } +}