TuxboardBridge.php 1.4 KB

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