Changeset 887 for trunk/Modules/RSS/RSS.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/RSS/RSS.php
r874 r887 3 3 class ModuleRSS extends AppModule 4 4 { 5 var$RSSChannels;5 public array $RSSChannels; 6 6 7 function __construct( $System)7 function __construct(System $System) 8 8 { 9 9 parent::__construct($System); … … 17 17 } 18 18 19 function Start()19 function DoStart(): void 20 20 { 21 $this->System->RegisterPage( 'rss', 'PageRSS');21 $this->System->RegisterPage(['rss'], 'PageRSS'); 22 22 $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader')); 23 23 } 24 24 25 function RegisterRSS( $Channel, $Pos = NULL, $Callback = NULL)25 function RegisterRSS(array $Channel, $Pos = NULL, $Callback = NULL): void 26 26 { 27 27 $this->RSSChannels[$Channel['Channel']] = $Channel; 28 28 29 29 if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; 30 else { 30 else 31 { 31 32 array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); 32 33 } 33 34 } 34 35 35 function UnregisterRSS($ChannelName) 36 function UnregisterRSS($ChannelName): void 36 37 { 37 38 unset($this->RSSChannels[$ChannelName]); … … 39 40 } 40 41 41 function ShowRSSHeader() 42 function ShowRSSHeader(): string 42 43 { 43 44 $Output = ''; 44 45 foreach ($this->RSSChannels as $Channel) 45 46 { 46 //if ( $this->System->User->Licence($Channel['Permission']))47 //if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence($Channel['Permission'])) 47 48 $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'. 48 49 $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />'; … … 50 51 return $Output; 51 52 } 53 54 static function Cast(AppModule $AppModule): ModuleRSS 55 { 56 if ($AppModule instanceof ModuleRSS) 57 { 58 return $AppModule; 59 } 60 throw new Exception('Expected ModuleRSS type but got '.gettype($AppModule)); 61 } 52 62 } 53 63 54 64 class PageRSS extends Page 55 65 { 56 function Show() 66 function Show(): string 57 67 { 58 68 $this->ClearPage = true; … … 62 72 if (array_key_exists('token', $_GET)) $Token = $_GET['token']; 63 73 else $Token = ''; 64 if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels))74 if (array_key_exists($ChannelName, ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels)) 65 75 { 66 $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];67 if ( $this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or68 $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token))76 $Channel = ModuleRSS::Cast($this->System->GetModule('RSS'))->RSSChannels[$ChannelName]; 77 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or 78 ModuleUser::Cast($this->System->GetModule('User'))->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) 69 79 { 70 80 if (is_string($Channel['Callback'][0]))
Note:
See TracChangeset
for help on using the changeset viewer.