FrandroidBridge.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. class FrandroidBridge extends BridgeAbstract
  3. {
  4. public function loadMetadatas() {
  5. $this->maintainer = "Daiyousei";
  6. $this->name = "Frandroid";
  7. $this->uri = "http://www.frandroid.com/";
  8. $this->description = "Returns the RSS feed from Frandroid (full text articles)";
  9. $this->update = "2015-03-05";
  10. }
  11. public function collectData(array $param)
  12. {
  13. function FrandroidStripCDATA($string)
  14. {
  15. $string = str_replace('<![CDATA[', '', $string);
  16. $string = str_replace(']]>', '', $string);
  17. return $string;
  18. }
  19. function FrandroidExtractContent($url)
  20. {
  21. $html2 = $this->file_get_html($url);
  22. $html3 = $html2->find('div.post-content', 0);
  23. $html3->find('div.no-sidebar-ad-top', 0)->outertext = '';
  24. $ret = $html3->find('div.shortcode-container');
  25. foreach ($ret as $value) {
  26. $value->outertext = '';
  27. }
  28. $html3->find('div#hrr-link', 0)->outertext = '';
  29. $text = $html3->innertext;
  30. $text = strip_tags($text, '<h1><span><h2><p><b><a><blockquote><img><em><ul><ol>');
  31. return $text;
  32. }
  33. $html = $this->file_get_html('http://feeds.feedburner.com/Frandroid?format=xml') or $this->returnError('Could not request Frandroid.', 404);
  34. $limit = 0;
  35. foreach ($html->find('item') as $element) {
  36. if ($limit < 5) {
  37. $item = new \Item();
  38. $item->title = FrandroidStripCDATA($element->find('title', 0)->innertext);
  39. $item->uri = FrandroidStripCDATA($element->find('guid', 0)->plaintext);
  40. $item->timestamp = strtotime($element->find('pubDate', 0)->plaintext);
  41. $item->content = FrandroidExtractContent($item->uri);
  42. $this->items[] = $item;
  43. $limit++;
  44. }
  45. }
  46. }
  47. public function getName()
  48. {
  49. return 'Frandroid';
  50. }
  51. public function getURI()
  52. {
  53. return 'http://www.frandroid.com/';
  54. }
  55. public function getCacheDuration()
  56. {
  57. return 300; // 5min
  58. }
  59. }