rss.phtml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php /** @var FreshRSS_View $this */ ?>
  2. <?= '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
  3. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"
  4. <?= $this->rss_base == '' ? '' : ' xml:base="' . $this->rss_base . '"' ?>
  5. >
  6. <channel>
  7. <title><?= $this->rss_title ?></title>
  8. <link><?= $this->internal_rendering ? $this->rss_url : Minz_Url::display('', 'html', true) ?></link>
  9. <description><?= _t('index.feed.rss_of', $this->rss_title) ?></description>
  10. <pubDate><?= date('D, d M Y H:i:s O') ?></pubDate>
  11. <lastBuildDate><?= gmdate('D, d M Y H:i:s') ?> GMT</lastBuildDate>
  12. <atom:link href="<?= $this->internal_rendering ? $this->rss_url :
  13. Minz_Url::display($this->rss_url, 'html', true) ?>" rel="self" type="application/rss+xml" />
  14. <?php
  15. /** @var FreshRSS_Entry */
  16. foreach ($this->entries as $item) {
  17. if (!$this->internal_rendering) {
  18. /** @var FreshRSS_Entry */
  19. $item = Minz_ExtensionManager::callHook('entry_before_display', $item);
  20. if ($item == null) {
  21. continue;
  22. }
  23. }
  24. ?>
  25. <item>
  26. <title><?= $item->title() ?></title>
  27. <link><?= $item->link() ?></link>
  28. <?php
  29. $authors = $item->authors();
  30. if (is_array($authors)) {
  31. foreach ($authors as $author) {
  32. echo "\t\t\t", '<dc:creator>', $author, '</dc:creator>', "\n";
  33. }
  34. }
  35. $categories = $item->tags();
  36. if (is_array($categories)) {
  37. foreach ($categories as $category) {
  38. echo "\t\t\t", '<category>', $category, '</category>', "\n";
  39. }
  40. }
  41. $thumbnail = $item->thumbnail(false);
  42. if (!empty($thumbnail['url'])) {
  43. // https://www.rssboard.org/media-rss#media-thumbnails
  44. echo "\t\t\t", '<media:thumbnail url="' . $thumbnail['url']
  45. . (empty($thumbnail['width']) ? '' : '" width="' . $thumbnail['width'])
  46. . (empty($thumbnail['height']) ? '' : '" height="' . $thumbnail['height'])
  47. . (empty($thumbnail['time']) ? '' : '" time="' . $thumbnail['time'])
  48. . '" />', "\n";
  49. }
  50. $enclosures = $item->enclosures(false);
  51. if (is_array($enclosures)) {
  52. foreach ($enclosures as $enclosure) {
  53. // https://www.rssboard.org/media-rss
  54. echo "\t\t\t", '<media:content url="' . $enclosure['url']
  55. . (empty($enclosure['medium']) ? '' : '" medium="' . $enclosure['medium'])
  56. . (empty($enclosure['type']) ? '' : '" type="' . $enclosure['type'])
  57. . (empty($enclosure['length']) ? '' : '" length="' . $enclosure['length'])
  58. . '">'
  59. . (empty($enclosure['title']) ? '' : '<media:title type="html">' . $enclosure['title'] . '</media:title>')
  60. . (empty($enclosure['credit']) ? '' : '<media:credit>' . $enclosure['credit'] . '</media:credit>')
  61. . '</media:content>', "\n";
  62. }
  63. }
  64. ?>
  65. <description><![CDATA[<?php
  66. echo $item->content(false);
  67. ?>]]></description>
  68. <pubDate><?= date('D, d M Y H:i:s O', $item->date(true)) ?></pubDate>
  69. <guid isPermaLink="false"><?= $item->id() > 0 ? $item->id() : $item->guid() ?></guid>
  70. </item>
  71. <?php } ?>
  72. </channel>
  73. </rss>