index.php 771 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Zend\Feed\Reader\Reader;
  4. use Zend\Feed\Reader\Feed\FeedInterface;
  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. $channel = Reader::import($url);
  15. if (!empty($channel)) {
  16. /** @var FeedInterface $item */
  17. foreach ($channel as $item) {
  18. $title = $item->getTitle();
  19. $link = $item->getLink();
  20. if (!empty($link)) {
  21. $title = Display::url($title, $link, ['target' => '_blank']);
  22. }
  23. echo Display::panel($item->getDescription(), $title);
  24. }
  25. }