Last change
on this file was 8, checked in by chronos, 19 months ago |
- Modified: Updated Common package.
- Modified: Form types made as separate FormManager package.
- Fixed: PHP 8.1 support.
|
File size:
1.3 KB
|
Line | |
---|
1 | <?php
|
---|
2 |
|
---|
3 | class RSS
|
---|
4 | {
|
---|
5 | public string $Charset;
|
---|
6 | public string $Title;
|
---|
7 | public string $Link;
|
---|
8 | public string $Description;
|
---|
9 | public string $WebmasterEmail;
|
---|
10 | public array $Items;
|
---|
11 |
|
---|
12 | function __construct()
|
---|
13 | {
|
---|
14 | $this->Charset = 'utf8';
|
---|
15 | $this->Title = '';
|
---|
16 | $this->Link = '';
|
---|
17 | $this->Description = '';
|
---|
18 | $this->WebmasterEmail = '';
|
---|
19 | $this->Items = array();
|
---|
20 | }
|
---|
21 |
|
---|
22 | function Generate(): string
|
---|
23 | {
|
---|
24 | $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<?
|
---|
25 | '<rss version="2.0">'."\n".
|
---|
26 | " <channel>\n".
|
---|
27 | " <title>".$this->Title."</title>\n".
|
---|
28 | " <link>".$this->Link."</link>\n".
|
---|
29 | " <description>".$this->Description."</description>\n".
|
---|
30 | " <language>cs</language>\n".
|
---|
31 | " <webMaster>".$this->WebmasterEmail."</webMaster>\n".
|
---|
32 | " <pubDate>".date('r')."</pubDate>\n".
|
---|
33 | " <ttl>20</ttl>\n";
|
---|
34 | foreach ($this->Items as $Item)
|
---|
35 | {
|
---|
36 | $Result .= " <item>\n".
|
---|
37 | ' <title>'.htmlspecialchars($Item['Title'])."</title>\n".
|
---|
38 | ' <description>'.htmlspecialchars($Item['Description'])."</description>\n".
|
---|
39 | ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n".
|
---|
40 | ' <link>'.$Item['Link']."</link>\n".
|
---|
41 | " </item>\n";
|
---|
42 | }
|
---|
43 | $Result .= " </channel>\n".
|
---|
44 | "</rss>";
|
---|
45 | return $Result;
|
---|
46 | }
|
---|
47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.