RssBridge.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /* rss-bridge library.
  3. Foundation functions for rss-bridge project.
  4. See https://github.com/sebsauvage/rss-bridge
  5. Licence: Public domain.
  6. */
  7. define('PATH_VENDOR', '/../vendor');
  8. require __DIR__ . '/Exceptions.php';
  9. require __DIR__ . '/Format.php';
  10. require __DIR__ . '/FormatAbstract.php';
  11. require __DIR__ . '/Bridge.php';
  12. require __DIR__ . '/BridgeAbstract.php';
  13. require __DIR__ . '/FeedExpander.php';
  14. require __DIR__ . '/Cache.php';
  15. require __DIR__ . '/Authentication.php';
  16. require __DIR__ . '/Configuration.php';
  17. require __DIR__ . '/BridgeCard.php';
  18. require __DIR__ . '/BridgeList.php';
  19. require __DIR__ . '/validation.php';
  20. require __DIR__ . '/html.php';
  21. require __DIR__ . '/error.php';
  22. require __DIR__ . '/contents.php';
  23. $vendorLibSimpleHtmlDom = __DIR__ . PATH_VENDOR . '/simplehtmldom/simple_html_dom.php';
  24. if(!file_exists($vendorLibSimpleHtmlDom)) {
  25. throw new \HttpException('"PHP Simple HTML DOM Parser" library is missing.
  26. Get it from http://simplehtmldom.sourceforge.net and place the script "simple_html_dom.php" in '
  27. . substr(PATH_VENDOR, 4)
  28. . '/simplehtmldom/',
  29. 500);
  30. }
  31. require_once $vendorLibSimpleHtmlDom;
  32. $vendorLibPhpUrlJoin = __DIR__ . PATH_VENDOR . '/php-urljoin/src/urljoin.php';
  33. if(!file_exists($vendorLibPhpUrlJoin)) {
  34. throw new \HttpException('"php-urljoin" library is missing.
  35. Get it from https://github.com/fluffy-critter/php-urljoin and place the script "urljoin.php" in '
  36. . substr(PATH_VENDOR, 4)
  37. . '/php-urljoin/src/',
  38. 500);
  39. }
  40. require_once $vendorLibPhpUrlJoin;
  41. /* Example use
  42. require_once __DIR__ . '/lib/RssBridge.php';
  43. // Data retrieval
  44. Bridge::setDir(__DIR__ . '/bridges/');
  45. $bridge = Bridge::create('GoogleSearch');
  46. $bridge->collectData($_REQUEST);
  47. // Data transformation
  48. Format::setDir(__DIR__ . '/formats/');
  49. $format = Format::create('Atom');
  50. $format
  51. ->setItems($bridge->getItems())
  52. ->setExtraInfos(array(
  53. 'name' => $bridge->getName(),
  54. 'uri' => $bridge->getURI(),
  55. ))
  56. ->display();
  57. */