Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ajout de bridges #56

Merged
merged 3 commits into from
May 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions bridges/FSBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* RssBridgeFS
* Returns the 5 newest posts from http://www.futura-sciences.com (full text)
*
* @name Futurasciences
* @description Returns the 20 newest posts from FS (full text)
*@maintainer qwertygc
*/
class FSBridge extends BridgeAbstract{





public function collectData(array $param){

function FS_StripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
function FS_ExtractContent($url) {
$html2 = file_get_html($url);
$text = $html2->find('div.fiche-actualite', 0)->innertext;
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
return $text;
}
$html = file_get_html('http://www.futura-sciences.com/rss/actualites.xml') or $this->returnError('Could not request Futura Sciences.', 404);
$limit = 0;

foreach($html->find('item') as $element) {
if($limit < 20) {
$item = new \Item();
$item->title = FS_StripCDATA($element->find('title', 0)->innertext);
$item->uri = FS_StripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = FS_ExtractContent($item->uri);
$this->items[] = $item;
$limit++;
}
}

}

public function getName(){
return 'Futura Sciences';
}

public function getURI(){
return 'http://www.futura-sciences.com/';
}

public function getCacheDuration(){
return 3600; // 1 hour
// return 0; // 1 hour
}
}
56 changes: 56 additions & 0 deletions bridges/GuruMedBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* RssBridgeGuruMed
* Returns the 10 newest posts from http://www.gurumed.org (full text)
*
* @name GuruMed
* @description Returns the 20 newest posts from Gurumed (full text)
*@maintainer qwertygc
*/
class GuruMedBridge extends BridgeAbstract{





public function collectData(array $param){

function GurumedStripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
function GurumedExtractContent($url) {
$html2 = file_get_html($url);
$text = $html2->find('div.entry', 0)->innertext;
return $text;
}
$html = file_get_html('http://gurumed.org/feed') or $this->returnError('Could not request Gurumed.', 404);
$limit = 0;

foreach($html->find('item') as $element) {
if($limit < 10) {
$item = new \Item();
$item->title = GurumedStripCDATA($element->find('title', 0)->innertext);
$item->uri = GurumedStripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = GurumedExtractContent($item->uri);
$this->items[] = $item;
$limit++;
}
}

}

public function getName(){
return 'Gurumed';
}

public function getURI(){
return 'http://gurumed.org/';
}

public function getCacheDuration(){
return 3600; // 1 hour
}
}
58 changes: 58 additions & 0 deletions bridges/OpenTheoryBridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* RssBridgeOpenTheory
* Returns the 10 newest posts from http://open1theory.com (full text)
*
* @name Opentheory
* @description Returns the 20 newest posts from OpenTheory (full text)
*@maintainer qwertygc
*/
class OpenTheoryBridge extends BridgeAbstract{





public function collectData(array $param){

function StripCDATA($string) {
$string = str_replace('<![CDATA[', '', $string);
$string = str_replace(']]>', '', $string);
return $string;
}
function ExtractContent($url) {
$html2 = file_get_html($url);
$text = $html2->find('div.entry-content', 0)->innertext;
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
return $text;
}
$html = file_get_html('http://open1theory.com/feed') or $this->returnError('Could not request OpenTheory.', 404);
$limit = 0;

foreach($html->find('item') as $element) {
if($limit < 10) {
$item = new \Item();
$item->title = StripCDATA($element->find('title', 0)->innertext);
$item->uri = StripCDATA($element->find('guid', 0)->plaintext);
$item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
$item->content = ExtractContent($item->uri);
$this->items[] = $item;
$limit++;
}
}

}

public function getName(){
return 'OpenTheory';
}

public function getURI(){
return 'http://open1theory.com/feed';
}

public function getCacheDuration(){
return 3600; // 1 hour
// return 0; // 1 hour
}
}