2014-07-14 20:12:52 +02:00
|
|
|
<?php
|
2016-09-05 18:43:56 +02:00
|
|
|
class LeJournalDuGeekBridge extends FeedExpander {
|
2014-07-14 20:12:52 +02:00
|
|
|
|
2016-08-30 11:23:55 +02:00
|
|
|
const MAINTAINER = "polopollo";
|
|
|
|
const NAME = "journaldugeek.com (FR)";
|
|
|
|
const URI = "http://www.journaldugeek.com/";
|
|
|
|
const DESCRIPTION = "Returns the 5 newest posts from LeJournalDuGeek (full text).";
|
2015-11-03 23:28:44 +01:00
|
|
|
|
2016-09-05 18:43:56 +02:00
|
|
|
public function collectData(){
|
2016-09-05 20:26:45 +02:00
|
|
|
$this->collectExpandableDatas(self::URI . 'rss', 5);
|
2016-09-05 18:43:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function parseItem($newsItem){
|
|
|
|
$item = $this->parseRSS_2_0_Item($newsItem);
|
|
|
|
$item['content'] = $this->LeJournalDuGeekExtractContent($item['uri']);
|
|
|
|
return $item;
|
2015-11-03 23:28:44 +01:00
|
|
|
}
|
|
|
|
|
2016-08-06 16:00:56 +02:00
|
|
|
private function LeJournalDuGeekExtractContent($url) {
|
2016-09-05 18:43:56 +02:00
|
|
|
$articleHTMLContent = $this->get_cached($url);
|
2016-08-03 20:34:30 +02:00
|
|
|
$text = $articleHTMLContent->find('div.post-content', 0)->innertext;
|
2014-07-14 20:12:52 +02:00
|
|
|
|
2016-08-03 20:14:59 +02:00
|
|
|
foreach($articleHTMLContent->find('a.more') as $element) {
|
|
|
|
if ($element->innertext == "Source") {
|
|
|
|
$text = $text . '<p><a href="' . $element->href . '">Source : ' . $element->href . '</a></p>';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-07-14 20:12:52 +02:00
|
|
|
|
2016-08-03 20:14:59 +02:00
|
|
|
foreach($articleHTMLContent->find('iframe') as $element) {
|
|
|
|
if (preg_match("/youtube/i", $element->src)) {
|
|
|
|
$text = $text . '// An IFRAME to Youtube was included in the article: <a href="' . $element->src . '">' . $element->src . '</a><br>';
|
|
|
|
}
|
|
|
|
}
|
2016-08-03 20:11:25 +02:00
|
|
|
|
2016-08-03 20:32:26 +02:00
|
|
|
$text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $text);
|
2016-08-03 20:14:59 +02:00
|
|
|
$text = strip_tags($text, '<p><b><a><blockquote><img><em><br/><br><ul><li>');
|
|
|
|
return $text;
|
|
|
|
}
|
2014-07-14 20:12:52 +02:00
|
|
|
|
2016-08-03 20:14:59 +02:00
|
|
|
public function getCacheDuration(){
|
|
|
|
return 1800; // 30min
|
|
|
|
}
|
2014-07-14 20:12:52 +02:00
|
|
|
}
|