Fix indentation and remove unnecessary lines
This commit is contained in:
parent
5fb27b2aa6
commit
cb7d477310
1 changed files with 32 additions and 36 deletions
|
@ -1,58 +1,54 @@
|
||||||
<?php
|
<?php
|
||||||
class CommonDreamsBridge extends BridgeAbstract{
|
class CommonDreamsBridge extends BridgeAbstract{
|
||||||
|
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
|
$this->maintainer = "nyutag";
|
||||||
|
$this->name = "CommonDreams Bridge";
|
||||||
|
$this->uri = "http://www.commondreams.org/";
|
||||||
|
$this->description = "Returns the newest articles.";
|
||||||
|
$this->update = "2016-08-02";
|
||||||
|
}
|
||||||
|
|
||||||
$this->maintainer = "nyutag";
|
function CommonDreamsExtractContent($url) {
|
||||||
$this->name = "CommonDreams Bridge";
|
|
||||||
$this->uri = "http://www.commondreams.org/";
|
|
||||||
$this->description = "Returns the newest articles.";
|
|
||||||
$this->update = "2016-08-02";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function CommonDreamsExtractContent($url) {
|
|
||||||
$html3 = $this->file_get_html($url);
|
$html3 = $this->file_get_html($url);
|
||||||
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
|
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
|
||||||
$html3->clear();
|
$html3->clear();
|
||||||
unset ($html3);
|
unset ($html3);
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectData(array $param){
|
public function collectData(array $param){
|
||||||
|
|
||||||
function CommonDreamsUrl($string) {
|
function CommonDreamsUrl($string) {
|
||||||
$html2 = explode(" ", $string);
|
$html2 = explode(" ", $string);
|
||||||
$string = $html2[2] . "/node/" . $html2[0];
|
$string = $html2[2] . "/node/" . $html2[0];
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = $this->file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404);
|
$html = $this->file_get_html('http://www.commondreams.org/rss.xml') or $this->returnError('Could not request CommonDreams.', 404);
|
||||||
$limit = 0;
|
$limit = 0;
|
||||||
foreach($html->find('item') as $element) {
|
foreach($html->find('item') as $element) {
|
||||||
if($limit < 4) {
|
if($limit < 4) {
|
||||||
$item = new \Item();
|
$item = new \Item();
|
||||||
$item->title = $element->find('title', 0)->innertext;
|
$item->title = $element->find('title', 0)->innertext;
|
||||||
$item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext);
|
$item->uri = CommonDreamsUrl($element->find('guid', 0)->innertext);
|
||||||
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
||||||
$item->content = $this->CommonDreamsExtractContent($item->uri);
|
$item->content = $this->CommonDreamsExtractContent($item->uri);
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
$limit++;
|
$limit++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
public function getName(){
|
||||||
|
return 'CommonDreams Bridge';
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getURI(){
|
||||||
return 'CommonDreams Bridge';
|
return 'http://www.commondreams.org/';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getURI(){
|
public function getCacheDuration(){
|
||||||
return 'http://www.commondreams.org/';
|
return 3600; // 1 hours
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDuration(){
|
|
||||||
return 3600; // 1 hours
|
|
||||||
// return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue