Title = 'IPTV'; $this->Description = 'Síťová televize'; $this->ParentClass = 'PagePortal'; } function Show(): string { $Output = 'Stažení přehrávače: VLC Media Player
'. 'Seznam všech kanálů do přehrávače: Playlist
'. 'Zobrazení playlistu ve VLC lze provést pomocí menu View - Playlist nebo klávesové zkratky CTRL+L
'. '
'. '
Výpis kanálů:
'; $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '. ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")'); $DbRow = $DbResult->fetch_row(); $PageList = GetPageList('TVChannels', $DbRow[0]); $Output .= $PageList['Output']; $Output .= ''; $TableColumns = array( array('Name' => 'Name', 'Title' => 'Jméno stanice'), array('Name' => 'Language', 'Title' => 'Jazyk'), array('Name' => 'Category', 'Title' => 'Zaměření'), array('Name' => 'SourceType', 'Title' => 'Zdroj'), array('Name' => '', 'Title' => 'Ladění'), ); $Order = GetOrderTableHeader('TVChannels', $TableColumns, 'Name', 0); $Output .= $Order['Output']; $Query = 'SELECT `TV`.*, `TVGroup`.`Name` AS `Category`, `Language`.`Name` AS `Language` FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '. ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "") '.$Order['SQL'].$PageList['SQLLimit']; $DbResult = $this->Database->query($Query); while ($Line = $DbResult->fetch_assoc()) { if ($Line['Stream'] <> '') $Line['Show'] = 'Naladit'; else if ($Line['StreamWeb'] <> '') $Line['Show'] = 'Naladit'; else $Line['Show'] = ' '; $Output .= ''. ''. ''. ''. ''; } $Output .= '
'.$Line['Name'].''.$Line['Language'].''.$Line['Category'].''.$Line['SourceType'].''.$Line['Show'].'
'; $Output .= $PageList['Output']; $Output .= '

'; $Output .= 'Další online TV na webu: Spustit.cz
'; return $Output; } } class PagePlaylist extends Page { function Show(): string { $this->RawPage = true; Header("Content-Type: audio/mpegurl"); Header("Content-Disposition: attachment; filename=playlist.m3u"); $Output = '#EXTM3U'."\n"; if (array_key_exists('id', $_GET)) { $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") '); if ($DbResult->num_rows > 0) { $Channel = $DbResult->fetch_array(); $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; $Output .= $Channel['Stream']."\n"; } } else { $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` '); while ($Channel = $DbResult->fetch_array()) { $Output .= '#EXTINF:0,'.$Channel['Name']."\n"; $Output .= $Channel['Stream']."\n"; } } return $Output; } } class ModuleTV extends Module { function __construct(System $System) { parent::__construct($System); $this->Name = 'TV'; $this->Version = '1.0'; $this->Creator = 'Chronos'; $this->License = 'GNU/GPLv3'; $this->Description = 'Television channels management'; $this->Models = array(TVGroup::GetClassName(), TV::GetClassName()); } function DoStart(): void { $this->System->RegisterPage(['tv'], 'PageIPTV'); $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist'); $this->System->FormManager->RegisterClass('TV', array( 'Title' => 'TV kanály', 'Table' => 'TV', 'DefaultSortColumn' => 'Name', 'Items' => array( 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 'Frequency' => array('Type' => 'Integer', 'Caption' => 'Frekvence', 'Default' => '', 'Suffix' => 'Hz'), 'Norm' => array('Type' => 'String', 'Caption' => 'Video norma', 'Default' => ''), 'Homepage' => array('Type' => 'Hyperlink', 'Caption' => 'Web', 'Default' => ''), 'Language' => array('Type' => 'TLanguage', 'Caption' => 'Jazyk', 'Default' => '', 'Null' => true), 'ShortName' => array('Type' => 'String', 'Caption' => 'Zkratka', 'Default' => ''), 'Stream' => array('Type' => 'Hyperlink', 'Caption' => 'Proud', 'Default' => ''), 'StreamWeb' => array('Type' => 'Hyperlink', 'Caption' => 'Proud web', 'Default' => ''), 'SourceType' => array('Type' => 'String', 'Caption' => 'Typ zdroje', 'Default' => ''), 'Category' => array('Type' => 'TTVGroup', 'Caption' => 'Kategorie', 'Default' => '', 'Null' => true), ), )); $this->System->FormManager->RegisterClass('TVGroup', array( 'Title' => 'Skupiny TV kanálů', 'Table' => 'TVGroup', 'DefaultSortColumn' => 'Name', 'Items' => array( 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 'Channels' => array('Type' => 'TTVListCategory', 'Caption' => 'Kanály', 'Default' => ''), ), )); $this->System->FormManager->RegisterFormType('TTVGroup', array( 'Type' => 'Reference', 'Table' => 'TVGroup', 'Id' => 'Id', 'Name' => 'Name', 'Filter' => '1', )); $this->System->FormManager->RegisterFormType('TTVListCategory', array( 'Type' => 'ManyToOne', 'Table' => 'TV', 'Id' => 'Id', 'Ref' => 'Category', 'Filter' => '1', )); } } class TVGroup extends Model { static function GetModelDesc(): ModelDesc { $Desc = new ModelDesc(self::GetClassName()); $Desc->AddString('Name'); return $Desc; } } class TV extends Model { static function GetModelDesc(): ModelDesc { $Desc = new ModelDesc(self::GetClassName()); $Desc->AddString('Name'); $Desc->AddInteger('Frequency'); $Desc->AddString('Norm'); $Desc->AddString('Homepage'); $Desc->AddReference('Language', Language::GetClassName()); $Desc->AddString('ShortName'); $Desc->AddString('Stream'); $Desc->AddString('StreamWeb'); $Desc->AddString('SourceType'); $Desc->AddReference('Category', TVGroup::GetClassName()); return $Desc; } }