index.php 964 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Zend\Feed\Reader\Feed\FeedInterface;
  4. use Zend\Feed\Reader\Reader;
  5. $plugin = RssPlugin::create();
  6. $url = $plugin->get_rss();
  7. $title = $plugin->get_block_title();
  8. $title = $title ? "<h4>$title</h4>" : '';
  9. $css = $plugin->get_css();
  10. if (empty($url)) {
  11. echo Display::return_message(get_lang('NoRSSItem'), 'warning');
  12. return;
  13. }
  14. try {
  15. $channel = Reader::import($url);
  16. if (!empty($channel)) {
  17. /** @var FeedInterface $item */
  18. foreach ($channel as $item) {
  19. $title = $item->getTitle();
  20. $link = $item->getLink();
  21. if (!empty($link)) {
  22. $title = Display::url($title, $link, ['target' => '_blank']);
  23. }
  24. echo Display::panel($item->getDescription(), $title);
  25. }
  26. }
  27. } catch (Exception $e) {
  28. echo Display::return_message($plugin->get_lang('no_valid_rss'), 'warning');
  29. error_log($e->getMessage());
  30. }