rss.phtml 3.1 KB

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