2014-05-26 02:30:46 +04:00
|
|
|
<?php
|
|
|
|
class TuxboardBridge extends BridgeAbstract{
|
|
|
|
|
2015-11-05 14:20:11 +03:00
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = "superbaillot.net";
|
|
|
|
$this->name = "Tuxboard";
|
|
|
|
$this->uri = "http://www.tuxboard.com/";
|
|
|
|
$this->description = "Tuxboard";
|
|
|
|
$this->update = "2014-07-08";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-05-26 02:30:46 +04:00
|
|
|
public function collectData(array $param){
|
|
|
|
|
2014-07-08 19:06:49 +04:00
|
|
|
function StripCDATA($string) {
|
|
|
|
$string = str_replace('<![CDATA[', '', $string);
|
|
|
|
$string = str_replace(']]>', '', $string);
|
|
|
|
return $string;
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2014-07-08 19:06:49 +04:00
|
|
|
function ExtractContent($url) {
|
2016-06-26 00:17:42 +03:00
|
|
|
$html2 = $this->file_get_html($url);
|
2014-07-08 19:06:49 +04:00
|
|
|
$text = $html2->find('article#page', 0)->innertext;
|
|
|
|
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
|
|
|
return $text;
|
|
|
|
}
|
2014-05-26 02:30:46 +04:00
|
|
|
|
2016-06-26 00:17:42 +03:00
|
|
|
$html = $this->file_get_html('http://www.tuxboard.com/feed/atom/') or $this->returnError('Could not request Tuxboard.', 404);
|
2014-07-08 19:06:49 +04:00
|
|
|
$limit = 0;
|
|
|
|
|
|
|
|
foreach($html->find('entry') as $element) {
|
|
|
|
if($limit < 10) {
|
|
|
|
$item = new \Item();
|
|
|
|
$item->title = StripCDATA($element->find('title', 0)->innertext);
|
|
|
|
$item->uri = $element->find('link', 0)->href;
|
|
|
|
$item->timestamp = strtotime($element->find('published', 0)->plaintext);
|
|
|
|
$item->content = ExtractContent($item->uri);
|
|
|
|
$this->items[] = $item;
|
|
|
|
$limit++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(){
|
|
|
|
return 'Tuxboard';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI(){
|
|
|
|
return 'http://www.tuxboard.com';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription(){
|
|
|
|
return 'Tuxboard via rss-bridge';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
2014-07-08 19:06:49 +04:00
|
|
|
return 3600; // 1 hour
|
2014-05-26 02:30:46 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|