source: trunk/Modules/News/RSS.php

Last change on this file was 893, checked in by chronos, 21 months ago
  • Fixed: Class types casting for better type checking.
  • Fixed: XML direct export.
  • Modified: User class instance moved from Core class to ModuleUser class.
File size: 2.0 KB
Line 
1<?php
2
3function GenerateRSS($Data)
4{
5 global $Config;
6
7 $Result = '<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'" ?>'."\n". //<?
8 '<rss version="2.0">'."\n".
9 " <channel>\n".
10 " <title>".$Data['Title']."</title>\n".
11 " <link>".$Data['Link']."</link>\n".
12 " <description>".$Data['Description']."</description>\n".
13 " <language>cs</language>\n".
14 " <webMaster>".$Data['WebmasterEmail']."</webMaster>\n".
15 " <pubDate>".date('r')."</pubDate>\n".
16 " <ttl>20</ttl>\n";
17 foreach ($Data['Items'] as $Item)
18 {
19 $Result .= " <item>\n".
20 ' <title>'.htmlspecialchars($Item['Title'])."</title>\n".
21 ' <description>'.htmlspecialchars($Item['Description'])."</description>\n".
22 ' <pubDate>'.date('r',$Item['Time'])."</pubDate>\n".
23 ' <link>'.$Item['Link']."</link>\n".
24 " </item>\n";
25 }
26 $Result .= " </channel>\n".
27 "</rss>";
28 return $Result;
29}
30
31class PageRSS extends Page
32{
33 function Show(): string
34 {
35 $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
36 $this->RawPage = true;
37
38 if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel'];
39 else $ChannelName = '';
40 if (array_key_exists('token', $_GET)) $Token = $_GET['token'];
41 else $Token = '';
42 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['News']->RSSChannels))
43 {
44 $Channel = $this->System->ModuleManager->Modules['News']->RSSChannels[$ChannelName];
45 if ($User->Licence($Channel['Permission']) or
46 $User->CheckToken($Channel['Permission'], $Token))
47 {
48 if (is_string($Channel['Callback'][0]))
49 {
50 $Class = new $Channel['Callback'][0]($this->System);
51 $Method = $Channel['Callback'][1];
52 $Output = $Class->$Method();
53 } else $Output = call_user_func($Channel['Callback']);
54 } else $Output = T('Access denied');
55 } else $Output = 'Nezadán žádný kanál';
56 return $Output;
57 }
58}
Note: See TracBrowser for help on using the repository browser.