Changeset 473 for trunk


Ignore:
Timestamp:
Jan 1, 2013, 12:21:11 PM (12 years ago)
Author:
chronos
Message:
  • Upraveno: Otvírací doby přepracovány na aplikační modul.
  • Upraveno: Předávání zobrazení stránek nyní pracuje se stromem registrovaných stránek.
Location:
trunk
Files:
2 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Common/Global.php

    r471 r473  
    3232include_once(dirname(__FILE__).'/../Modules/Network/Network.php');
    3333include_once(dirname(__FILE__).'/../Modules/TV/TV.php');
    34 
     34include_once(dirname(__FILE__).'/../Modules/OpeningHours/OpeningHours.php');
    3535$PrefixMultipliers = array
    3636(
     
    110110  /** @var AppModuleManager */
    111111  var $ModuleManager;
     112  var $PathItems;
    112113
    113114  function __construct()
     
    125126  }
    126127 
    127   function ShowPage($Path)
     128  function SearchPage($PathItems, $Pages)
     129  {
     130    $PathItem = $PathItems[0];
     131    if(array_key_exists($PathItem, $Pages))
     132    {
     133      if(is_array($Pages[$PathItem]))
     134      {
     135        array_shift($PathItems);
     136        return(SearchPage($PathItems, $Path[$PathItem]));
     137      } else return($this->Pages[$PathItem]);
     138    } else return('');
     139  }
     140 
     141  function ShowPage()
    128142  {
    129143    /* @var $Page Page */
    130     if(array_key_exists($Path, $this->Pages))
    131     {
    132       $ClassName = $this->Pages[$Path];
     144    $ClassName = $this->SearchPage($this->PathItems, $this->Pages);   
     145    if($ClassName != '')
     146    {
    133147      $Page = new $ClassName();
    134148      $Page->System = &$this;
    135149      $Page->Database = &$this->Database;
    136150      $Page->GetOutput();
    137     } else echo('Page '.$Path.' not found.');
     151    } else echo('Page '.implode('/', $this->PathItems).' not found.');
    138152  }
    139153 
     
    283297  $System->ModuleManager->RegisterModule(new Network($System));
    284298  $System->ModuleManager->RegisterModule(new TV($System));
     299  $System->ModuleManager->RegisterModule(new ModuleOpeningHours($System));
    285300  $System->ModuleManager->StartAll();
    286301}
  • trunk/Common/Page.php

    r471 r473  
    11<?php
     2
     3define('PAGE_NOT_FOUND', 'Stránka nenalezena');
    24
    35class Page extends Module
  • trunk/Modules/TV/TV.php

    r471 r473  
    22
    33include_once('Common/Global.php');
    4 
    5 class PagePlayList extends Page
    6 {
    7   function Show()
    8   {
    9     $this->ClearPage = true;
    10        
    11     Header("Content-Type: audio/mpegurl");
    12     Header("Content-Disposition: attachment; filename=playlist.m3u");
    13 
    14     echo('#EXTM3U'."\n");
    15     if(array_key_exists('id', $_GET))
    16     {
    17       $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") ');
    18       if($DbResult->num_rows > 0)
    19       {
    20         $Channel = $DbResult->fetch_array();
    21         echo('#EXTINF:0,'.$Channel['Name']."\n");
    22         echo($Channel['Stream']."\n");
    23       }
    24     } else
    25     {
    26       $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');
    27       while($Channel = $DbResult->fetch_array())
    28       {
    29         echo('#EXTINF:0,'.$Channel['Name']."\n");
    30         echo($Channel['Stream']."\n");
    31       }
    32     }
    33   }
    34 }
    354
    365class PageIPTV extends Page
     
    409 
    4110  function Show()
     11  {   
     12    if(count($this->System->PathItems) > 1)
     13    {
     14      if($this->System->PathItems[1] == 'playlist.m3u') return($this->ShowPlayList());
     15        else return(PAGE_NOT_FOUND);
     16    } else return($this->ShowChannelList());
     17  }
     18 
     19  function ShowChannelList()
    4220  {
    4321    global $Channels;
     
    9674    return($Output);
    9775  }
     76
     77  function ShowPlayList()
     78  {
     79    $this->ClearPage = true;
     80       
     81    Header("Content-Type: audio/mpegurl");
     82    Header("Content-Disposition: attachment; filename=playlist.m3u");
     83
     84    echo('#EXTM3U'."\n");
     85    if(array_key_exists('id', $_GET))
     86    {
     87      $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") AND (`ShortName`="'.addslashes($_GET['id']).'") ');
     88      if($DbResult->num_rows > 0)
     89      {
     90        $Channel = $DbResult->fetch_array();
     91        echo('#EXTINF:0,'.$Channel['Name']."\n");
     92        echo($Channel['Stream']."\n");
     93      }
     94    } else
     95    {
     96      $DbResult = $this->Database->select('TV', '*', ' (`Stream` <> "") ORDER BY `Name` ');
     97      while($Channel = $DbResult->fetch_array())
     98      {
     99        echo('#EXTINF:0,'.$Channel['Name']."\n");
     100        echo($Channel['Stream']."\n");
     101      }
     102    }
     103  } 
    98104}
    99105
     
    123129    parent::Start();
    124130    $this->System->RegisterPage('tv', 'PageIPTV');
    125     $this->System->RegisterPage('tv/playlist.m3u', 'PagePlayList');   
    126131  } 
    127132 
  • trunk/index.php

    r470 r473  
    22
    33include_once('Common/Global.php');
    4 $Path = ProcessURL();
    5 $System->ShowPage(implode('/', $Path));
     4$System->PathItems = ProcessURL();
     5$System->ShowPage();
    66
    77?>
Note: See TracChangeset for help on using the changeset viewer.