Name = 'RSS'; $this->Version = '1.0'; $this->Creator = 'Chronos'; $this->License = 'GNU/GPL'; $this->Description = 'Web site RSS channel management'; $this->Dependencies = array(); $this->RSSChannels = array(); } function Start(): void { $this->System->RegisterPage(array('rss'), 'PageRSS'); Core::Cast($this->System)->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader')); } function RegisterRSS(array $Channel, ?int $Pos = NULL, $Callback = NULL): void { $this->RSSChannels[$Channel['Channel']] = $Channel; if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel']; else { array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']); } } function UnregisterRSS(string $ChannelName): void { unset($this->RSSChannels[$ChannelName]); // TODO: Remove channel from pos list } function ShowRSSHeader(): string { $Output = ''; foreach ($this->RSSChannels as $Channel) { //if ($this->System->User->Licence($Channel['Permission'])) $Output .= ' '; } return $Output; } } class PageRSS extends Page { function Show(): string { $this->RawPage = true; if (array_key_exists('channel', $_GET)) $ChannelName = $_GET['channel']; else $ChannelName = ''; if (array_key_exists('token', $_GET)) $Token = $_GET['token']; else $Token = ''; if (array_key_exists($ChannelName, $this->System->ModuleManager->Modules['RSS']->RSSChannels)) { $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName]; if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or $this->System->User->CheckToken($Channel['Permission']['Module'], $Channel['Permission']['Operation'], $Token)) { if (is_string($Channel['Callback'][0])) { $Class = new $Channel['Callback'][0]($this->System); $Method = $Channel['Callback'][1]; $Output = $Class->$Method(); } else $Output = call_user_func($Channel['Callback']); } else $Output = 'Nemáte oprávnění'; } else $Output = 'Kanál nenalezen'; return $Output; } }