Last change
on this file was 14, checked in by chronos, 4 years ago |
- Modified: Updated files to newer version.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[4] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | class RSS
|
---|
| 4 | {
|
---|
[14] | 5 | public string $Charset;
|
---|
| 6 | public string $Title;
|
---|
| 7 | public string $Link;
|
---|
| 8 | public string $Description;
|
---|
| 9 | public string $WebmasterEmail;
|
---|
| 10 | public array $Items;
|
---|
[4] | 11 |
|
---|
| 12 | function __construct()
|
---|
| 13 | {
|
---|
[14] | 14 | $this->Charset = 'utf8';
|
---|
| 15 | $this->Title = '';
|
---|
| 16 | $this->Link = '';
|
---|
| 17 | $this->Description = '';
|
---|
| 18 | $this->WebmasterEmail = '';
|
---|
[4] | 19 | $this->Items = array();
|
---|
| 20 | }
|
---|
| 21 |
|
---|
[14] | 22 | function Generate(): string
|
---|
[4] | 23 | {
|
---|
| 24 | $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<?
|
---|
[14] | 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";
|
---|
[10] | 34 | foreach ($this->Items as $Item)
|
---|
[4] | 35 | {
|
---|
| 36 | $Result .= " <item>\n".
|
---|
| 37 | ' <title>'.htmlspecialchars($Item['Title'])."</title>\n".
|
---|
| 38 | ' <description>'.htmlspecialchars($Item['Description'])."</description>\n".
|
---|
[14] | 39 | ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n".
|
---|
| 40 | ' <link>'.$Item['Link']."</link>\n".
|
---|
[4] | 41 | " </item>\n";
|
---|
| 42 | }
|
---|
| 43 | $Result .= " </channel>\n".
|
---|
| 44 | "</rss>";
|
---|
[10] | 45 | return $Result;
|
---|
[4] | 46 | }
|
---|
| 47 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.