2015-03-05 14:42:25 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2015-03-05 15:01:45 +01:00
|
|
|
* RssBridgeFrandroid
|
2015-03-05 18:25:40 +01:00
|
|
|
* Returns the RSS feed from Frandroid (full text articles)
|
2015-03-05 15:01:45 +01:00
|
|
|
*
|
|
|
|
* @name Frandroid
|
|
|
|
* @homepage http://www.frandroid.com/
|
2015-03-05 18:25:40 +01:00
|
|
|
* @description Returns the RSS feed from Frandroid (full text articles)
|
|
|
|
* @maintainer Daiyousei
|
2015-03-05 18:28:45 +01:00
|
|
|
* @update 2015-03-05
|
2015-03-05 15:01:45 +01:00
|
|
|
*/
|
|
|
|
class FrandroidBridge extends BridgeAbstract
|
|
|
|
{
|
2015-03-05 14:42:25 +01:00
|
|
|
|
2015-03-05 15:01:45 +01:00
|
|
|
public function collectData(array $param)
|
|
|
|
{
|
|
|
|
|
|
|
|
function FrandroidStripCDATA($string)
|
|
|
|
{
|
|
|
|
$string = str_replace('<![CDATA[', '', $string);
|
|
|
|
$string = str_replace(']]>', '', $string);
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
function FrandroidExtractContent($url)
|
|
|
|
{
|
|
|
|
$html2 = file_get_html($url);
|
|
|
|
$html3 = $html2->find('div.post-content', 0);
|
|
|
|
$html3->find('div.no-sidebar-ad-top', 0)->outertext = '';
|
|
|
|
$ret = $html3->find('div.shortcode-container');
|
|
|
|
foreach ($ret as $value) {
|
|
|
|
$value->outertext = '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html3->find('div#hrr-link', 0)->outertext = '';
|
|
|
|
$text = $html3->innertext;
|
|
|
|
$text = strip_tags($text, '<h1><span><h2><p><b><a><blockquote><img><em><ul><ol>');
|
|
|
|
return $text;
|
|
|
|
}
|
2015-03-05 14:42:25 +01:00
|
|
|
$html = file_get_html('http://feeds.feedburner.com/Frandroid?format=xml') or $this->returnError('Could not request Frandroid.', 404);
|
2015-03-05 15:01:45 +01:00
|
|
|
$limit = 0;
|
|
|
|
|
|
|
|
foreach ($html->find('item') as $element) {
|
|
|
|
if ($limit < 5) {
|
|
|
|
$item = new \Item();
|
|
|
|
$item->title = FrandroidStripCDATA($element->find('title', 0)->innertext);
|
|
|
|
$item->uri = FrandroidStripCDATA($element->find('guid', 0)->plaintext);
|
|
|
|
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
|
|
|
|
$item->content = FrandroidExtractContent($item->uri);
|
|
|
|
$this->items[] = $item;
|
|
|
|
$limit++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-05 14:42:25 +01:00
|
|
|
}
|
2015-03-05 15:01:45 +01:00
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
2015-03-05 14:42:25 +01:00
|
|
|
return 'Frandroid';
|
|
|
|
}
|
2015-03-05 15:01:45 +01:00
|
|
|
|
|
|
|
public function getURI()
|
|
|
|
{
|
2015-03-05 14:42:25 +01:00
|
|
|
return 'http://www.frandroid.com/';
|
|
|
|
}
|
2015-03-05 15:01:45 +01:00
|
|
|
|
|
|
|
public function getCacheDuration()
|
|
|
|
{
|
2015-03-05 14:42:25 +01:00
|
|
|
return 300; // 5min
|
|
|
|
}
|
|
|
|
}
|