TuxboardBridge.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. class TuxboardBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "superbaillot.net";
  5. $this->name = "Tuxboard";
  6. $this->uri = "http://www.tuxboard.com/";
  7. $this->description = "Tuxboard";
  8. $this->update = "2014-07-08";
  9. }
  10. public function collectData(array $param){
  11. function StripCDATA($string) {
  12. $string = str_replace('<![CDATA[', '', $string);
  13. $string = str_replace(']]>', '', $string);
  14. return $string;
  15. }
  16. function ExtractContent($url) {
  17. $html2 = $this->file_get_html($url);
  18. $text = $html2->find('article#page', 0)->innertext;
  19. $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
  20. return $text;
  21. }
  22. $html = $this->file_get_html('http://www.tuxboard.com/feed/atom/') or $this->returnError('Could not request Tuxboard.', 404);
  23. $limit = 0;
  24. foreach($html->find('entry') as $element) {
  25. if($limit < 10) {
  26. $item = new \Item();
  27. $item->title = StripCDATA($element->find('title', 0)->innertext);
  28. $item->uri = $element->find('link', 0)->href;
  29. $item->timestamp = strtotime($element->find('published', 0)->plaintext);
  30. $item->content = ExtractContent($item->uri);
  31. $this->items[] = $item;
  32. $limit++;
  33. }
  34. }
  35. }
  36. public function getName(){
  37. return 'Tuxboard';
  38. }
  39. public function getURI(){
  40. return 'http://www.tuxboard.com';
  41. }
  42. public function getDescription(){
  43. return 'Tuxboard via rss-bridge';
  44. }
  45. public function getCacheDuration(){
  46. return 3600; // 1 hour
  47. }
  48. }
  49. ?>