1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<?php
declare(strict_types=1);
/** @var FreshRSS_View $this */
?>
<?= '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
<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/" <?=
$this->rss_base === '' ? '' : ' xml:base="' . $this->rss_base . '"' ?>>
<channel>
<title><?= $this->rss_title ?></title>
<link><?= $this->html_url ?></link>
<description><?= $this->description ?: _t('index.feed.rss_of', $this->rss_title) ?></description>
<pubDate><?= date('D, d M Y H:i:s O') ?></pubDate>
<lastBuildDate><?= gmdate('D, d M Y H:i:s') ?> GMT</lastBuildDate>
<atom:link href="<?= $this->rss_url ?>" rel="self" type="application/rss+xml" />
<?php if ($this->image_url !== ''): ?>
<image>
<url><?= $this->image_url ?></url>
<title><?= $this->rss_title ?></title>
<link><?= $this->html_url ?></link>
</image>
<?php endif; ?>
<?php
foreach ($this->entries as $item) {
if (!$this->internal_rendering) {
/** @var FreshRSS_Entry|null $item */
$item = Minz_ExtensionManager::callHook(Minz_HookType::EntryBeforeDisplay, $item);
if ($item === null) {
continue;
}
}
?>
<item>
<title><?= $item->title() ?></title>
<link><?= $item->link() ?></link>
<?php
$authors = $item->authors();
if (is_array($authors)) {
foreach ($authors as $author) {
echo "\t\t\t", '<dc:creator>', $author, '</dc:creator>', "\n";
}
}
if ($this->publishLabelsInsteadOfTags) {
$categories = $this->entryIdsTagNames['e_' . $item->id()] ?? [];
if (is_array($categories)) {
foreach ($categories as $category) {
echo "\t\t\t", '<category>', $category, '</category>', "\n";
}
}
} else {
$categories = $item->tags();
if (is_array($categories)) {
foreach ($categories as $category) {
echo "\t\t\t", '<category>', $category, '</category>', "\n";
}
}
}
$enclosures = iterator_to_array($item->enclosures(false), preserve_keys: false); // TODO: Optimise: avoid iterator_to_array if possible
$thumbnail = $item->thumbnail(false);
if (!empty($thumbnail['url'])) {
// https://www.rssboard.org/media-rss#media-thumbnails
echo "\t\t\t", '<media:thumbnail url="' . $thumbnail['url']
. (empty($thumbnail['width']) ? '' : '" width="' . $thumbnail['width'])
. (empty($thumbnail['height']) ? '' : '" height="' . $thumbnail['height'])
. (empty($thumbnail['time']) ? '' : '" time="' . $thumbnail['time'])
. '" />', "\n";
// Mostly for MailChimp + Feedbro which do not support <media:thumbnail> https://mailchimp.com/help/rss-merge-tags/
$thumbnail['medium'] ??= 'image';
array_unshift($enclosures, $thumbnail);
}
$urls = [];
foreach ($enclosures as $enclosure) {
if (empty($enclosure['url']) || isset($urls[$enclosure['url']])) {
continue;
}
$urls[$enclosure['url']] = true;
$credits = $enclosure['credit'] ?? [];
if (!is_array($credits)) { // For entries < FreshRSS 1.24
$credits = [$credits];
}
$mediaCredits = '';
foreach ($credits as $credit) {
$mediaCredits = '<media:credit>' . $credit . '</media:credit>';
}
// https://www.rssboard.org/media-rss
echo "\t\t\t", '<media:content url="' . $enclosure['url']
. (empty($enclosure['medium']) ? '' : '" medium="' . $enclosure['medium'])
. (empty($enclosure['type']) ? '' : '" type="' . $enclosure['type'])
. (empty($enclosure['length']) ? '' : '" length="' . $enclosure['length'])
. (empty($enclosure['height']) ? '' : '" height="' . $enclosure['height'])
. (empty($enclosure['width']) ? '' : '" width="' . $enclosure['width'])
. '">'
. (empty($enclosure['title']) ? '' : '<media:title type="html">' . $enclosure['title'] . '</media:title>')
. $mediaCredits
. '</media:content>', "\n";
}
?>
<description><![CDATA[<?php
echo $item->content(false);
?>]]></description>
<pubDate><?= date('D, d M Y H:i:s O', $item->date(true)) ?></pubDate>
<guid isPermaLink="false"><?= $item->id() > 0 ? $item->id() : $item->guid() ?></guid>
</item>
<?php } ?>
</channel>
</rss>
|