Changeset 887


Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (3 years ago)
Author:
chronos
Message:
  • Added: Static types added to almost all classes, methods and function. Supported by PHP 7.4.
  • Fixed: Various found code issues.
Location:
trunk
Files:
145 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r886 r887  
    1414class Core extends Application
    1515{
    16   /** @var Type */
    17   var $Type;
    18   var $Pages;
    19   var $Bars;
    20   /** @var FormManager */
    21   var $FormManager;
    22   /** @var Config */
    23   var $ConfigManager;
    24   var $PathItems;
    25   var $RootURLFolder;
    26   var $ShowPage;
    27   var $Setup;
    28   var $CommandLine;
    29   var $PageHeaders;
    30   var $BaseView;
     16  public Type $Type;
     17  public array $Bars;
     18  public FormManager $FormManager;
     19  public array $Config;
     20  public Config $ConfigManager;
     21  public array $PathItems;
     22  public string $RootURLFolder;
     23  public bool $ShowPage;
     24  public Setup $Setup;
     25  public array $PageHeaders;
     26  public BaseView $BaseView;
     27  public LocaleManager $LocaleManager;
     28  public array $LinkLocaleExceptions;
    3129
    3230  function __construct()
    3331  {
    3432    parent::__construct();
    35     $this->Modules = array();
    36     $this->Pages = array();
     33    $this->Config = array();
    3734    $this->ModuleManager->FileName = dirname(__FILE__).'/../Config/ModulesConfig.php';
    3835    $this->FormManager = new FormManager($this->Database);
     
    4239    if (substr($this->RootURLFolder, -10, 10) == '/index.php')
    4340      $this->RootURLFolder = substr($this->RootURLFolder, 0, -10);
    44     $this->CommandLine = array();
    4541    $this->PageHeaders = array();
    46   }
    47 
    48   function RegisterPage($Path, $Handler)
    49   {
    50     if (is_array($Path))
    51     {
    52       $Page = &$this->Pages;
    53       $LastKey = array_pop($Path);
    54       foreach ($Path as $PathItem)
    55       {
    56         $Page = &$Page[$PathItem];
    57       }
    58       if (!is_array($Page)) $Page = array('' => $Page);
    59       $Page[$LastKey] = $Handler;
    60     } else $this->Pages[$Path] = $Handler;
    61   }
    62 
    63   function UnregisterPage($Path)
    64   {
    65     unset($this->Pages[$Path]);
    66   }
    67 
    68   function SearchPage($PathItems, $Pages)
     42    $this->LinkLocaleExceptions = array();
     43  }
     44
     45  function SearchPage(array $PathItems, array $Pages): ?string
    6946  {
    7047    if (count($PathItems) > 0) $PathItem = $PathItems[0];
     
    8057  }
    8158
    82   function PageNotFound()
    83   {
    84     return 'Page '.implode('/', $this->PathItems).' not found.';
    85   }
    86 
    87   function ShowPage()
     59  function ShowPage(): void
    8860  {
    8961    $this->BaseView = new BaseView($this);
     
    9466    {
    9567      $Page = new $ClassName($this);
    96     } else {
     68    } else
     69    {
    9770      $Page = new PageMissing($this);
    9871    }
     
    10073  }
    10174
    102   function ModulePresent($Name)
    103   {
    104     return array_key_exists($Name, $this->Modules);
    105   }
    106 
    107   function AddModule($Module)
    108   {
    109     $this->Modules[get_class($Module)] = $Module;
    110   }
    111 
    112   function HumanDate($Time)
     75  function ModulePresent(string $Name): bool
     76  {
     77    return array_key_exists($Name, $this->ModuleManager->Modules);
     78  }
     79
     80  function AddModule($Module): void
     81  {
     82    $this->ModuleManager->Modules[get_class($Module)] = $Module;
     83  }
     84
     85  function HumanDate(int $Time): string
    11386  {
    11487    return date('j.n.Y', $Time);
    11588  }
    11689
    117   function Link($Target)
     90  function Link(string $Target): string
    11891  {
    11992    return $this->RootURLFolder.$Target;
    12093  }
    12194
    122   function ShowAction($Id)
     95  function ShowAction(string $Id): string
    12396  {
    12497    $Output = '';
     
    131104      if ($Action['Icon'] == '') $Action['Icon'] = 'clear.png';
    132105      if (substr($Action['URL'], 0, 4) != 'http') $Action['URL'] = $this->Link($Action['URL']);
    133       if (!defined('NEW_PERMISSION') or $this->User->CheckPermission('System', 'Read', 'Item', $Id))
     106      if (!defined('NEW_PERMISSION') or ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('System', 'Read', 'Item', $Id))
    134107        $Output .= '<img alt="'.$Action['Title'].'" src="'.$this->Link('/images/favicons/'.$Action['Icon']).
    135108        '" width="16" height="16" /> <a href="'.$Action['URL'].'">'.$Action['Title'].'</a>';
     
    138111  }
    139112
    140   function RunCommon()
    141   {
    142     global $Database, $ScriptTimeStart, $ConfigFileName, $Mail, $Type,
    143       $DatabaseRevision, $Config, $GlobalLocaleManager;
     113  function RunCommon(): void
     114  {
     115    global $Database, $ScriptTimeStart, $ConfigFileName, $Config, $GlobalLocaleManager;
    144116
    145117    date_default_timezone_set('Europe/Prague');
     
    199171  }
    200172
    201   function Run()
     173  function Run(): void
    202174  {
    203175    $this->RunCommon();
     
    213185      {
    214186         $NewLangCode = $this->PathItems[0];
    215          if (array_key_exists($NewLangCode, $this->LocaleManager->Available)) 
     187         if (array_key_exists($NewLangCode, $this->LocaleManager->Available))
    216188         {
    217189           array_shift($this->PathItems);
     
    226198  }
    227199
    228   function RunCommandLine()
     200  function RunCommandLine(): void
    229201  {
    230202    global $argv;
     
    236208      {
    237209        $Command = $this->CommandLine[$argv[1]];
    238         $Output = call_user_func($Command['Callback'], $argv);
     210        $Output = call_user_func($Command->Callback, $argv);
    239211      } else $Output = 'Command "'.$argv[1].'" not supported.'."\n";
    240     } else $Output = 'No command was given as parameter'."\n";
     212    } else $Output = 'No command was given as parameter. Use "list" to show available commands.'."\n";
    241213    echo($Output);
    242214  }
    243215
    244   function RegisterCommandLine($Name, $Callback)
    245   {
    246     $this->CommandLine[$Name] = array('Name' => $Name, 'Callback' => $Callback);
    247   }
    248 
    249   function RegisterPageBar($Name)
     216  function RegisterPageBar(string $Name): void
    250217  {
    251218    $this->Bars[$Name] = array();
    252219  }
    253220
    254   function UnregisterPageBar($Name)
     221  function UnregisterPageBar(string $Name): void
    255222  {
    256223    unset($this->Bars[$Name]);
    257224  }
    258225
    259   function RegisterPageBarItem($BarName, $ItemName, $Callback)
     226  function RegisterPageBarItem(string $BarName, string $ItemName, callable $Callback): void
    260227  {
    261228    $this->Bars[$BarName][$ItemName] = $Callback;
    262229  }
    263230
    264   function RegisterPageHeader($Name, $Callback)
     231  function UnregisterPageBarItem(string $BarName, string $ItemName): void
     232  {
     233    unset($this->Bars[$BarName][$ItemName]);
     234  }
     235
     236  function RegisterPageHeader(string $Name, callable $Callback): void
    265237  {
    266238    $this->PageHeaders[$Name] = $Callback;
     239  }
     240
     241  function UnregisterPageHeader(string $Name): void
     242  {
     243    unset($this->PageHeaders[$Name]);
    267244  }
    268245}
     
    270247class PageMissing extends Page
    271248{
    272   var $FullTitle = 'Stránka nenalezena';
    273   var $ShortTitle = 'Stránka nenalezena';
    274 
    275   function __construct($System)
     249  function __construct(System $System)
    276250  {
    277251    parent::__construct($System);
     252    $this->FullTitle = 'Stránka nenalezena';
     253    $this->ShortTitle = 'Stránka nenalezena';
    278254    $this->ParentClass = 'PagePortal';
    279255  }
    280256
    281   function Show()
     257  function Show(): string
    282258  {
    283259    Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
  • trunk/Application/DefaultConfig.php

    r874 r887  
    33class DefaultConfig
    44{
    5   function Get()
     5  function Get(): array
    66  {
    77    $IsDeveloper = in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1'));
  • trunk/Application/FormClasses.php

    r844 r887  
    33// TODO: Split all form class definitions to modules
    44
    5 function RegisterFormClasses($FormManager)
     5function RegisterFormClasses(FormManager $FormManager): void
    66{
    77  $FormManager->Classes = array(
  • trunk/Application/FullInstall.php

    r782 r887  
    11<?php
    22
    3 function FullInstall($Manager)
     3function FullInstall(UpdateManager $Manager): void
    44{
    55  $Manager->Execute("
  • trunk/Application/UpdateTrace.php

    r885 r887  
    11<?php
    22
    3 function UpdateTo493($Manager)
     3function UpdateTo493(UpdateManager $Manager): void
    44{
    55  $Manager->Execute("ALTER TABLE `UserOnline` CHANGE `User` `User` INT( 11 ) NULL DEFAULT NULL COMMENT 'User.Id'");
    66}
    77
    8 function UpdateTo494($Manager)
     8function UpdateTo494(UpdateManager $Manager): void
    99{
    1010  $Manager->Execute("ALTER TABLE `FinanceOperation` DROP FOREIGN KEY `FinanceOperation_ibfk_2` ;\n".
     
    1313}
    1414
    15 function UpdateTo495($Manager)
     15function UpdateTo495(UpdateManager $Manager): void
    1616{
    1717  $Manager->Execute("INSERT INTO `MapPosition` (SELECT NULL AS `Id`, `Name`, `MapPositionX` AS `Latitude`, `MapPositionY` AS `Longitude` FROM `Subject`)");
     
    2424}
    2525
    26 function UpdateTo497($Manager)
     26function UpdateTo497(UpdateManager $Manager): void
    2727{
    2828  $Manager->Execute("ALTER TABLE `FinanceCharge` ADD `Id` INT NOT NULL AUTO_INCREMENT FIRST , ADD PRIMARY KEY ( `Id` ) ");
     
    5252}
    5353
    54 function UpdateTo498($Manager)
     54function UpdateTo498(UpdateManager $Manager): void
    5555{
    5656  $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
     
    7676}
    7777
    78 function UpdateTo499($Manager)
     78function UpdateTo499(UpdateManager $Manager): void
    7979{
    8080  $Manager->Execute("CREATE TABLE IF NOT EXISTS `Currency` (
     
    121121}
    122122
    123 function UpdateTo500($Manager)
     123function UpdateTo500(UpdateManager $Manager): void
    124124{
    125125  $Manager->Execute("CREATE TABLE IF NOT EXISTS `FinanceBank` (
     
    145145}
    146146
    147 function UpdateTo502($Manager)
     147function UpdateTo502(UpdateManager $Manager): void
    148148{
    149149  $Manager->Execute("ALTER TABLE `FinanceBankAccount` ADD `LoginName` VARCHAR( 255 ) NOT NULL ");
     
    159159}
    160160
    161 function UpdateTo505($Manager)
     161function UpdateTo505(UpdateManager $Manager): void
    162162{
    163163  $Manager->Execute("UPDATE `ISMenuItem` SET `Name` = 'Služby', `Table` = 'Service' WHERE `ISMenuItem`.`Name` ='Tarify';");
     
    186186}
    187187
    188 function UpdateTo507($Manager)
     188function UpdateTo507(UpdateManager $Manager): void
    189189{
    190190  $Manager->Execute("INSERT INTO `ISMenuItem` (`Id` ,`Name` ,`Parent` ,`Table` ,`IconName`) ".
     
    229229}
    230230
    231 function UpdateTo515($Manager)
     231function UpdateTo515(UpdateManager $Manager): void
    232232{
    233233  $Manager->Execute("ALTER TABLE `PermissionUserAssignment` CHANGE `User` `User` INT( 11 ) NULL");
    234234}
    235235
    236 function UpdateTo517($Manager)
     236function UpdateTo517(UpdateManager $Manager): void
    237237{
    238238  $Manager->Execute("ALTER TABLE `Log` ADD `IPAddress` VARCHAR( 16 ) NOT NULL");
    239239}
    240240
    241 function UpdateTo526($Manager)
     241function UpdateTo526(UpdateManager $Manager): void
    242242{
    243243  $Manager->Execute("ALTER TABLE `Hyperlink` CHANGE `Name` `Title` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_czech_ci NOT NULL");
     
    276276}
    277277
    278 function UpdateTo527($Manager)
     278function UpdateTo527(UpdateManager $Manager): void
    279279{
    280280  $Manager->Execute("RENAME TABLE `ISMenuItem` TO `MenuItem` ;");
     
    304304}
    305305
    306 function UpdateTo535($Manager)
     306function UpdateTo535(UpdateManager $Manager): void
    307307{
    308308  // Set all string collation to utf8 general
     
    314314}
    315315
    316 function UpdateTo549($Manager)
     316function UpdateTo549(UpdateManager $Manager): void
    317317{
    318318  $Manager->Execute("ALTER TABLE `FinanceOperation` ADD `Generate` INT NOT NULL DEFAULT '0',
     
    322322}
    323323
    324 function UpdateTo550($Manager)
     324function UpdateTo550(UpdateManager $Manager): void
    325325{
    326326  $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `LastImportId` VARCHAR( 255 ) NOT NULL ;');
     
    329329}
    330330
    331 function UpdateTo551($Manager)
     331function UpdateTo551(UpdateManager $Manager): void
    332332{
    333333  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `DocumentLine` INT NULL AFTER `Value` ,
     
    343343}
    344344
    345 function UpdateTo565($Manager)
     345function UpdateTo565(UpdateManager $Manager): void
    346346{
    347347  $Manager->Execute('CREATE TABLE IF NOT EXISTS `WikiPage` (
     
    369369}
    370370
    371 function UpdateTo571($Manager)
     371function UpdateTo571(UpdateManager $Manager): void
    372372{
    373373  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `LoginName` VARCHAR( 255 ) NOT NULL ,
     
    375375}
    376376
    377 function UpdateTo574($Manager)
     377function UpdateTo574(UpdateManager $Manager): void
    378378{
    379379  $Manager->Execute('ALTER TABLE `MapPosition` ADD `Pos` VARCHAR( 255 ) NOT NULL ;');
     
    383383}
    384384
    385 function UpdateTo584($Manager)
     385function UpdateTo584(UpdateManager $Manager): void
    386386{
    387387  $Manager->Execute("CREATE TABLE IF NOT EXISTS `Module` (
     
    441441}
    442442
    443 function UpdateTo591($Manager)
     443function UpdateTo591(UpdateManager $Manager): void
    444444{
    445445  $Manager->Execute('ALTER TABLE `StockItem` ADD `Esemble` INT NULL ,
     
    449449}
    450450
    451 function UpdateTo597($Manager)
     451function UpdateTo597(UpdateManager $Manager): void
    452452{
    453453  $Manager->Execute('CREATE TABLE IF NOT EXISTS `Model` (
     
    463463}
    464464
    465 function UpdateTo601($Manager)
     465function UpdateTo601(UpdateManager $Manager): void
    466466{
    467467  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceWireless` (
     
    489489}
    490490
    491 function UpdateTo615($Manager)
     491function UpdateTo615(UpdateManager $Manager): void
    492492{
    493493  $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `AntennaPolarity` INT NOT NULL ,
     
    523523}
    524524
    525 function UpdateTo619($Manager)
     525function UpdateTo619(UpdateManager $Manager): void
    526526{
    527527  $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLogged` INT NOT NULL ;');
    528528}
    529529
    530 function UpdateTo620($Manager)
     530function UpdateTo620(UpdateManager $Manager): void
    531531{
    532532  $Manager->Execute('ALTER TABLE `NetworkInterfaceWireless` ADD `ChannelWidthLower` INT NOT NULL ,
     
    536536}
    537537
    538 function UpdateTo627($Manager)
     538function UpdateTo627(UpdateManager $Manager): void
    539539{
    540540  $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `TimeCreation` `Time` DATETIME NOT NULL DEFAULT "0000-00-00 00:00:00";');
     
    542542}
    543543
    544 function UpdateTo632($Manager)
     544function UpdateTo632(UpdateManager $Manager): void
    545545{
    546546  $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceOperationRel` (
     
    557557}
    558558
    559 function UpdateTo633($Manager)
     559function UpdateTo633(UpdateManager $Manager): void
    560560{
    561561  $Manager->Execute('ALTER TABLE `UserOnline` ADD `StayLoggedHash` VARCHAR( 40 ) NOT NULL ;');
    562562}
    563563
    564 function UpdateTo645($Manager)
     564function UpdateTo645(UpdateManager $Manager): void
    565565{
    566566  $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceVATType` (
     
    576576}
    577577
    578 function UpdateTo646($Manager)
     578function UpdateTo646(UpdateManager $Manager): void
    579579{
    580580  $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contract` (
     
    612612}
    613613
    614 function UpdateTo647($Manager)
     614function UpdateTo647(UpdateManager $Manager): void
    615615{
    616616  $Manager->Execute('ALTER TABLE `EmployeeSalary` ADD FOREIGN KEY ( `Employee` ) REFERENCES `Employee` (
     
    647647}
    648648
    649 function UpdateTo656($Manager)
     649function UpdateTo656(UpdateManager $Manager): void
    650650{
    651651  $Manager->Execute('CREATE TABLE IF NOT EXISTS `Measure` (
     
    706706}
    707707
    708 function UpdateTo657($Manager)
     708function UpdateTo657(UpdateManager $Manager): void
    709709{
    710710  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceUpDown` (
     
    727727}
    728728
    729 function UpdateTo661($Manager)
     729function UpdateTo661(UpdateManager $Manager): void
    730730{
    731731  $Manager->Execute('CREATE TABLE IF NOT EXISTS `Contact` (
     
    773773}
    774774
    775 function UpdateTo662($Manager)
     775function UpdateTo662(UpdateManager $Manager): void
    776776{
    777777  $Manager->Execute('INSERT INTO `Contact` (SELECT NULL AS `Id`, 2 AS `Category`, `ICQ` AS `Value`, NULL AS `Subject`, `Id` AS `User` FROM `User`
     
    783783}
    784784
    785 function UpdateTo668($Manager)
     785function UpdateTo668(UpdateManager $Manager): void
    786786{
    787787  $Manager->Execute('CREATE TABLE IF NOT EXISTS `APIToken` (
     
    799799}
    800800
    801 function UpdateTo671($Manager)
     801function UpdateTo671(UpdateManager $Manager): void
    802802{
    803803  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSignal` (
     
    834834}
    835835
    836 function UpdateTo674($Manager)
     836function UpdateTo674(UpdateManager $Manager): void
    837837{
    838838  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `RateRx` INT NOT NULL ;');
     
    840840}
    841841
    842 function UpdateTo676($Manager)
     842function UpdateTo676(UpdateManager $Manager): void
    843843{
    844844  $Manager->Execute('ALTER TABLE `NetworkSignal` ADD `Device` INT NULL ,
     
    848848}
    849849
    850 function UpdateTo678($Manager)
     850function UpdateTo678(UpdateManager $Manager): void
    851851{
    852852  $Manager->Execute('ALTER TABLE `Contact` ADD `Description` VARCHAR( 255 ) NOT NULL ;');
     
    879879}
    880880
    881 function UpdateTo679($Manager)
     881function UpdateTo679(UpdateManager $Manager): void
    882882{
    883883  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `Product` INT NOT NULL AFTER `Id` ,
     
    885885}
    886886
    887 function UpdateTo688($Manager)
     887function UpdateTo688(UpdateManager $Manager): void
    888888{
    889889  // Convert monthly plus payment for consumption to regular service
     
    899899}
    900900
    901 function UpdateTo692($Manager)
     901function UpdateTo692(UpdateManager $Manager): void
    902902{
    903903  // Convert user emails to contacts
     
    912912}
    913913
    914 function UpdateTo696($Manager)
     914function UpdateTo696(UpdateManager $Manager): void
    915915{
    916916  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Duration` INT NOT NULL ;');
     
    920920}
    921921
    922 function UpdateTo697($Manager)
     922function UpdateTo697(UpdateManager $Manager): void
    923923{
    924924  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` CHANGE `Duration` `Duration` INT( 11 ) NULL ;');
     
    929929}
    930930
    931 function UpdateTo707($Manager)
     931function UpdateTo707(UpdateManager $Manager): void
    932932{
    933933  $Manager->Execute('ALTER TABLE `NetworkDevice` CHANGE `Product` `Product` INT(11) NULL;');
    934934}
    935935
    936 function UpdateTo710($Manager)
     936function UpdateTo710(UpdateManager $Manager): void
    937937{
    938938  $Manager->Execute('RENAME TABLE `StockItem` TO `StockSerialNumber`;');
     
    995995}
    996996
    997 function UpdateTo715($Manager)
     997function UpdateTo715(UpdateManager $Manager): void
    998998{
    999999  $Manager->Execute('ALTER TABLE `StockSerialNumber` DROP FOREIGN KEY `StockSerialNumber_ibfk_6`;');
     
    10051005}
    10061006
    1007 function UpdateTo718($Manager)
     1007function UpdateTo718(UpdateManager $Manager): void
    10081008{
    10091009  $Manager->Execute('CREATE TABLE IF NOT EXISTS `Company` (
     
    10331033}
    10341034
    1035 function UpdateTo719($Manager)
     1035function UpdateTo719(UpdateManager $Manager): void
    10361036{
    10371037  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `Direction` INT NOT NULL AFTER `Cash`;');
     
    10771077}
    10781078
    1079 function UpdateTo720($Manager)
     1079function UpdateTo720(UpdateManager $Manager): void
    10801080{
    10811081  $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `Direction` INT NOT NULL AFTER `TimePayment`;');
     
    11081108}
    11091109
    1110 function UpdateTo722($Manager)
     1110function UpdateTo722(UpdateManager $Manager): void
    11111111{
    11121112  $Manager->Execute('ALTER TABLE `Service` DROP `CustomerCount`;');
    11131113}
    11141114
    1115 function UpdateTo725($Manager)
     1115function UpdateTo725(UpdateManager $Manager): void
    11161116{
    11171117  // Text column of invoices is not used. Text from invoice items is taken instead.
     
    11491149}
    11501150
    1151 function UpdateTo726($Manager)
     1151function UpdateTo726(UpdateManager $Manager): void
    11521152{
    11531153  $Manager->Execute('ALTER TABLE `ServiceCustomerRel` CHANGE `Action` `ChangeAction` ENUM("add","modify","remove") CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL;');
     
    11721172}
    11731173
    1174 function UpdateTo729($Manager)
     1174function UpdateTo729(UpdateManager $Manager): void
    11751175{
    11761176 $Manager->Execute('ALTER TABLE `FinanceBankAccount` ADD `AutoImport` INT NOT NULL ;');
     
    12091209}
    12101210
    1211 function UpdateTo730($Manager)
     1211function UpdateTo730(UpdateManager $Manager): void
    12121212{
    12131213  $Manager->Execute('CREATE TABLE IF NOT EXISTS `SchedulerAction` (
     
    12241224}
    12251225
    1226 function UpdateTo731($Manager)
     1226function UpdateTo731(UpdateManager $Manager): void
    12271227{
    12281228  // NetworkDomain
     
    13081308}
    13091309
    1310 function UpdateTo735($Manager)
     1310function UpdateTo735(UpdateManager $Manager): void
    13111311{
    13121312  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkFreeAccess` (
     
    13321332}
    13331333
    1334 function UpdateTo736($Manager)
     1334function UpdateTo736(UpdateManager $Manager): void
    13351335{
    13361336  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkLinkType` (
     
    13451345}
    13461346
    1347 function UpdateTo739($Manager)
     1347function UpdateTo739(UpdateManager $Manager): void
    13481348{
    13491349  $Manager->Execute('ALTER TABLE `NetworkDomain` ADD KEY (`Parent`);');
     
    13641364}
    13651365
    1366 function UpdateTo740($Manager)
     1366function UpdateTo740(UpdateManager $Manager): void
    13671367{
    13681368  $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceInvoiceGroup` (
     
    14231423}
    14241424
    1425 function UpdateTo741($Manager)
     1425function UpdateTo741(UpdateManager $Manager): void
    14261426{
    14271427        // Add Direction column
     
    14361436}
    14371437
    1438 function UpdateTo742($Manager)
     1438function UpdateTo742(UpdateManager $Manager): void
    14391439{
    14401440  $Manager->Execute('CREATE TABLE IF NOT EXISTS `DocumentLineCode` (
     
    14861486}
    14871487
    1488 function UpdateTo747($Manager)
     1488function UpdateTo747(UpdateManager $Manager): void
    14891489{
    14901490  $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `ValueUser` FLOAT NOT NULL AFTER `Value`;');
     
    15091509}
    15101510
    1511 function UpdateTo748($Manager)
     1511function UpdateTo748(UpdateManager $Manager): void
    15121512{
    15131513  $DbResult = $Manager->Database->query('SELECT * FROM (SELECT `FinanceInvoice`.`Id`, ((SELECT SUM(`Price` * `Quantity`) FROM `FinanceInvoiceItem` WHERE `FinanceInvoiceItem`.`FinanceInvoice`=`FinanceInvoice`.`Id`) * `FinanceInvoiceGroup`.`ValueSign`) AS `Sum`,`FinanceInvoice`.`Value` FROM `FinanceInvoice` LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id`=`FinanceInvoice`.`Group`) AS `T` WHERE `Sum` != `Value`');
     
    15181518}
    15191519
    1520 function UpdateTo752($Manager)
     1520function UpdateTo752(UpdateManager $Manager): void
    15211521{
    15221522  $Manager->Database->query('INSERT INTO `SchedulerAction` (`Id`, `Name`, `Class`) '.
     
    15541554}
    15551555
    1556 function UpdateTo755($Manager)
     1556function UpdateTo755(UpdateManager $Manager): void
    15571557{
    15581558  $Manager->Execute("INSERT INTO `FinanceInvoiceGroup` (`Id`, `Name`, `DocumentLine`, `ValueSign`, `Direction`) ".
     
    15761576}
    15771577
    1578 function UpdateTo759($Manager)
     1578function UpdateTo759(UpdateManager $Manager): void
    15791579{
    15801580  $Manager->Execute('ALTER TABLE `Scheduler` ADD `Duration` INT NOT NULL AFTER `Period`;');
     
    15821582
    15831583/*
    1584 function UpdateTo761($Manager)
     1584function UpdateTo761(UpdateManager $Manager): void
    15851585{
    15861586  $Manager->Execute('INSERT INTO `MACAddress` (SELECT "" AS `Id`,`MAC` AS `Value` FROM `NetworkSignal` GROUP BY `MAC`)');
     
    15901590*/
    15911591
    1592 function UpdateTo762($Manager)
     1592function UpdateTo762(UpdateManager $Manager): void
    15931593{
    15941594  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `OnlineNotify` INT NOT NULL AFTER `API`;');
    15951595}
    15961596
    1597 function UpdateTo763($Manager)
     1597function UpdateTo763(UpdateManager $Manager): void
    15981598{
    15991599  $Manager->Execute('ALTER TABLE `NetworkInterface` ADD `OnlineNotify` INT NOT NULL AFTER `LastOnline`;');
     
    16011601}
    16021602
    1603 function UpdateTo765($Manager)
     1603function UpdateTo765(UpdateManager $Manager): void
    16041604{
    16051605  $Manager->Execute('CREATE TABLE IF NOT EXISTS `SupportActivity` (
     
    16321632}
    16331633
    1634 function UpdateTo768($Manager)
     1634function UpdateTo768(UpdateManager $Manager): void
    16351635{
    16361636  $Manager->Execute('ALTER TABLE `NetworkDomainAlias` ADD `Domain` INT NOT NULL AFTER `Comment`;');
     
    16721672}
    16731673
    1674 function UpdateTo770($Manager)
     1674function UpdateTo770(UpdateManager $Manager): void
    16751675{
    16761676  $Manager->Execute("CREATE TABLE IF NOT EXISTS `OS` (
     
    17871787}
    17881788
    1789 function UpdateTo785($Manager)
     1789function UpdateTo785(UpdateManager $Manager): void
    17901790{
    17911791  $Manager->Execute('DROP TABLE `NetworkInterfaceStat`');
    17921792}
    17931793
    1794 function UpdateTo786($Manager)
     1794function UpdateTo786(UpdateManager $Manager): void
    17951795{
    17961796  $Manager->Execute('ALTER TABLE `Member` DROP FOREIGN KEY Member_ibfk_28;');
     
    18031803}
    18041804
    1805 function UpdateTo792($Manager)
     1805function UpdateTo792(UpdateManager $Manager): void
    18061806{
    18071807  // Transform contracts
     
    18231823}
    18241824
    1825 function UpdateTo800($Manager)
     1825function UpdateTo800(UpdateManager $Manager): void
    18261826{
    18271827  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockItemHistory` (
     
    18401840}
    18411841
    1842 function UpdateTo802($Manager)
     1842function UpdateTo802(UpdateManager $Manager): void
    18431843{
    18441844  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveGroup` (
     
    18891889}
    18901890
    1891 function UpdateTo803($Manager)
     1891function UpdateTo803(UpdateManager $Manager): void
    18921892{
    18931893  $Manager->Execute('CREATE TABLE IF NOT EXISTS `StockMoveItemSerialRel` (
     
    19051905}
    19061906
    1907 function UpdateTo807($Manager)
     1907function UpdateTo807(UpdateManager $Manager): void
    19081908{
    19091909  $Manager->Execute('ALTER TABLE `Product` ADD `StockMinCount` INT NOT NULL AFTER `UnitOfMeasure`;');
    19101910}
    19111911
    1912 function UpdateTo808($Manager)
     1912function UpdateTo808(UpdateManager $Manager): void
    19131913{
    19141914  $Manager->Execute('CREATE TABLE IF NOT EXISTS `FinanceTreasuryCheck` (
     
    19481948}
    19491949
    1950 function UpdateTo814($Manager)
     1950function UpdateTo814(UpdateManager $Manager): void
    19511951{
    19521952  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkPort` (
     
    19721972}
    19731973
    1974 function UpdateTo817($Manager)
     1974function UpdateTo817(UpdateManager $Manager): void
    19751975{
    19761976  $Manager->Execute('ALTER TABLE `NetworkConfiguration` ADD `SysName` VARCHAR(255) NOT NULL FIRST;');
     
    19901990}
    19911991
    1992 function UpdateTo818($Manager)
     1992function UpdateTo818(UpdateManager $Manager): void
    19931993{
    19941994  $Manager->Execute('ALTER TABLE `NetworkPort` ADD `Protocol` INT NOT NULL AFTER `Enabled`;');
     
    20072007}
    20082008
    2009 function UpdateTo824($Manager)
     2009function UpdateTo824(UpdateManager $Manager): void
    20102010{
    20112011  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkInterfaceLatency` (
     
    20212021}
    20222022
    2023 function UpdateTo831($Manager)
     2023function UpdateTo831(UpdateManager $Manager): void
    20242024{
    20252025  $Manager->Execute('ALTER TABLE `NetworkLinkType` '.
     
    20332033}
    20342034
    2035 function UpdateTo838($Manager)
     2035function UpdateTo838(UpdateManager $Manager): void
    20362036{
    20372037  $Manager->Execute('ALTER TABLE `News` CHANGE `Date` `Date` DATETIME NULL, CHANGE `TargetDate` `TargetDate` DATETIME NULL;');
    20382038}
    20392039
    2040 function UpdateTo844($Manager)
     2040function UpdateTo844(UpdateManager $Manager): void
    20412041{
    20422042  $Manager->Execute('ALTER TABLE `DocumentLine` ADD `Yearly` BOOLEAN NOT NULL DEFAULT FALSE AFTER `Shortcut`;');
    20432043}
    20442044
    2045 function UpdateTo855($Manager)
     2045function UpdateTo855(UpdateManager $Manager): void
    20462046{
    20472047  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkDeviceLog` (
     
    20582058}
    20592059
    2060 function UpdateTo862($Manager)
     2060function UpdateTo862(UpdateManager $Manager): void
    20612061{
    20622062  $Manager->Execute('ALTER TABLE `NetworkInterfaceUpDown` ADD `Previous` INT NULL AFTER `Duration`');
     
    20652065}
    20662066
    2067 function UpdateTo867($Manager)
     2067function UpdateTo867(UpdateManager $Manager): void
    20682068{
    20692069  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NotifyLog` (
     
    20772077}
    20782078
    2079 function UpdateTo869($Manager)
     2079function UpdateTo869(UpdateManager $Manager): void
    20802080{
    20812081  $Manager->Execute('CREATE TABLE IF NOT EXISTS `NetworkSpeedLimit` (
     
    21042104}
    21052105
    2106 function UpdateTo870($Manager)
     2106function UpdateTo870(UpdateManager $Manager): void
    21072107{
    21082108  $Manager->Execute('ALTER TABLE `NetworkSubnet`ADD COLUMN `MaskIPv6` INT(11) NOT NULL AFTER `AddressRangeIPv6`;');
     
    21112111}
    21122112
    2113 function UpdateTo878($Manager)
     2113function UpdateTo878(UpdateManager $Manager): void
    21142114{
    21152115  $Manager->Execute('ALTER TABLE `NewsImport` ADD `Method` VARCHAR(255) NOT NULL AFTER `Category`;');
     
    21182118}
    21192119
    2120 function UpdateTo880($Manager)
     2120function UpdateTo880(UpdateManager $Manager): void
    21212121{
    21222122  $Manager->Execute('ALTER TABLE `UserOnline` CHANGE `IpAddress` `IpAddress` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT "";');
     
    21252125}
    21262126
    2127 function UpdateTo882($Manager)
     2127function UpdateTo882(UpdateManager $Manager): void
    21282128{
    21292129  $Manager->Execute('ALTER TABLE `FinanceMonthlyOverall` CHANGE `Investment` `Investment` INT(11) NOT NULL DEFAULT "0";');
    21302130}
    21312131
    2132 function UpdateTo885($Manager)
     2132function UpdateTo885(UpdateManager $Manager): void
    21332133{
    21342134  $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `Value` `Value` FLOAT NOT NULL DEFAULT "0";');
     
    21372137class Updates
    21382138{
    2139   function Get()
     2139  function Get(): array
    21402140  {
    21412141    return array(
  • trunk/Application/View.php

    r874 r887  
    66{
    77  var $TimeStart;
    8   var $FormatHTML = false;
    9   var $ShowRuntimeInfo = false;
    10   var $ClearPage = false;
    11   var $BasicHTML = false;
    12   var $ParentClass = '';
    13   var $ShortTitle;
    14   var $FullTitle;
    15   var $Encoding;
    16   var $Style;
     8  public bool $FormatHTML = false;
     9  public bool $ShowRuntimeInfo = false;
     10  public bool $ClearPage = false;
     11  public bool $BasicHTML = false;
     12  public string $ParentClass = '';
     13  public string $ShortTitle;
     14  public string $FullTitle;
     15  public string $Encoding;
     16  public string $Style;
    1717
    18   function __construct($System)
     18  function __construct(System $System)
    1919  {
    2020    parent::__construct($System);
     
    3636  }
    3737
    38   function SystemMessage($Title, $Text)
     38  function SystemMessage(string $Title, string $Text): string
    3939  {
    4040    return '<table align="center"><tr><td><div class="SystemMessage"><h3>'.$Title.'</h3><div>'.$Text.'</div></div></td></tr></table>';
     
    4343  }
    4444
    45   function ShowNavigation($Page)
     45  function ShowNavigation(Page $Page): string
    4646  {
    4747    if (array_key_exists('REQUEST_URI', $_SERVER))
     
    7171  }
    7272
    73   function ShowHeader($Page)
     73  function ShowHeader(Page $Page): string
    7474  {
    7575    $Title = $Page->FullTitle;
     
    109109  }
    110110
    111   function ShowFooter()
     111  function ShowFooter(): string
    112112  {
    113113    global $ScriptTimeStart, $Revision, $ReleaseTime;
     
    128128  }
    129129
    130   function GetOutput($Page)
     130  function GetOutput(Page $Page): string
    131131  {
    132132    $Page->OnSystemMessage = array($this->System->BaseView, 'SystemMessage');
     
    141141  }
    142142
    143   function NewPage($ClassName)
     143  function NewPage(string $ClassName): Page
    144144  {
    145145    $Page = new $ClassName();
     
    151151
    152152  // XML formating function
    153   function FormatOutput($s)
     153  function FormatOutput(string $s): string
    154154  {
    155155    $out = '';
  • trunk/Common/Form/Form.php

    r874 r887  
    2222class Form
    2323{
    24   var $FormManager;
    25   var $Definition;
    26   var $Values;
    27   var $ValuesValidate;
    28   var $ValuesFilter;
    29   var $OnSubmit;
    30   var $Database;
    31 
    32   function __construct($FormManager)
     24  public FormManager $FormManager;
     25  public Database $Database;
     26  public array $Definition;
     27  public array $Values;
     28  public array $ValuesValidate;
     29  public array $ValuesFilter;
     30  public string $OnSubmit;
     31
     32  function __construct(FormManager $FormManager)
    3333  {
    3434    $this->FormManager = &$FormManager;
     
    4141  }
    4242
    43   function LoadDefaults()
     43  function LoadDefaults(): void
    4444  {
    4545    foreach ($this->Definition['Items'] as $Index => $Item)
     
    5858  }
    5959
    60   function SetClass($Name)
     60  function SetClass(string $Name): void
    6161  {
    6262    $this->Definition = &$this->FormManager->Classes[$Name];
     
    6464  }
    6565
    66   function GetValue($Index, $Event = 'OnView')
     66  function GetValue(string $Index, string $Event = 'OnView'): string
    6767  {
    6868    $Item = $this->Definition['Items'][$Index];
     
    8282  }
    8383
    84   function ShowViewForm()
     84  function ShowViewForm(): string
    8585  {
    8686    $Table = array(
     
    116116  }
    117117
    118   function ShowEditForm()
     118  function ShowEditForm(): string
    119119  {
    120120    if (!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit';
     
    125125  }
    126126
    127   function ShowEditBlock($Context = '')
     127  function ShowEditBlock(string $Context = ''): string
    128128  {
    129129    $Hidden = '';
     
    182182  }
    183183
    184   function LoadValuesFromDatabase($Id)
     184  function LoadValuesFromDatabase(string $Id): void
    185185  {
    186186    foreach ($this->Definition['Items'] as $Index => $Item)
     
    232232  }
    233233
    234   function SaveValuesToDatabase($Id)
     234  function SaveValuesToDatabase(string $Id)
    235235  {
    236236    $Values = array();
     
    269269  }
    270270
    271   function LoadValuesFromForm()
     271  function LoadValuesFromForm(): void
    272272  {
    273273    $this->Values = $this->LoadValuesFromFormBlock();
    274274  }
    275275
    276   function LoadValuesFromFormBlock($Context = '')
     276  function LoadValuesFromFormBlock(string $Context = ''): array
    277277  {
    278278    if ($Context != '') $Context = $Context.'-';
     
    319319  }
    320320
    321   function Validate()
     321  function Validate(): bool
    322322  {
    323323    $Valid = true;
     
    358358
    359359
    360 function MakeLink($Target, $Title)
     360function MakeLink(string $Target, string $Title): string
    361361{
    362362  return '<a href="'.$Target.'">'.$Title.'</a>';
    363363}
    364364
    365 function Table($Table)
     365function Table(array $Table): string
    366366{
    367367  $Result = '<table class="BasicTable">';
     
    389389class FormManager
    390390{
    391   var $Classes;
    392   var $FormTypes;
    393   var $Database;
    394   var $Type;
    395   var $RootURL;
    396   var $ShowRelation;
    397 
    398   function __construct($Database)
     391  public array $Classes;
     392  public array $FormTypes;
     393  public Database $Database;
     394  public Type $Type;
     395  public string $RootURL;
     396  public bool $ShowRelation;
     397
     398  function __construct(Database $Database)
    399399  {
    400400    $this->Database = &$Database;
     
    405405  }
    406406
    407   function RegisterClass($Name, $Class)
     407  function RegisterClass(string $Name, array $Class): void
    408408  {
    409409    $this->Classes[$Name] = $Class;
    410410  }
    411411
    412   function UnregisterClass($Name)
     412  function UnregisterClass(string $Name): void
    413413  {
    414414    unset($this->Classes[$Name]);
    415415  }
    416416
    417   function RegisterFormType($Name, $Class)
     417  function RegisterFormType(string $Name, array $Class): void
    418418  {
    419419    $this->FormTypes[$Name] = $Class;
    420420  }
    421421
    422   function UnregisterFormType($Name)
     422  function UnregisterFormType(string $Name): void
    423423  {
    424424    unset($this->FormTypes[$Name]);
    425425  }
    426426
    427   function UpdateSQLMeta()
     427  function UpdateSQLMeta(): void
    428428  {
    429429    $this->Database->query('DELETE FROM ModelField');
  • trunk/Common/Form/Types/Base.php

    r874 r887  
    33class TypeBase
    44{
    5   var $FormManager;
    6   var $Database;
    7   var $DatabaseCompareOperators = array();
    8   var $Hidden;
     5  public FormManager $FormManager;
     6  public Database $Database;
     7  public array $DatabaseCompareOperators = array();
     8  public bool $Hidden;
    99
    10   function __construct($FormManager)
     10  function __construct(FormManager $FormManager)
    1111  {
    1212    $this->FormManager = &$FormManager;
     
    1515  }
    1616
    17   function OnView($Item)
     17  function OnView(array $Item): ?string
    1818  {
    1919    return '';
    2020  }
    2121
    22   function OnEdit($Item)
     22  function OnEdit(array $Item): string
    2323  {
    2424    return '';
    2525  }
    2626
    27   function OnLoad($Item)
     27  function OnLoad(array $Item): ?string
    2828  {
    2929    return '';
    3030  }
    3131
    32   function OnLoadDb($Item)
     32  function OnLoadDb(array $Item): ?string
    3333  {
    3434    return $Item['Value'];
    3535  }
    3636
    37   function OnSaveDb($Item)
     37  function OnSaveDb(array $Item): ?string
    3838  {
    3939    return $Item['Value'];
    4040  }
    4141
    42   function DatabaseEscape($Value)
     42  function DatabaseEscape(string $Value): string
    4343  {
    4444    return addslashes($Value);
    4545  }
    4646
    47   function OnFilterName($Item)
     47  function OnFilterName(array $Item): string
    4848  {
    4949    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     
    5353  }
    5454
    55   function OnFilterNameQuery($Item)
     55  function OnFilterNameQuery(array $Item): string
    5656  {
    5757    if (array_key_exists('SQL', $Item) and ($Item['SQL'] != ''))
     
    6161  }
    6262
    63   function Validate($Item)
     63  function Validate(array $Item): bool
    6464  {
    6565    return true;
    6666  }
    6767
    68   function GetValidationFormat()
     68  function GetValidationFormat(): string
    6969  {
    7070    return '';
  • trunk/Common/Form/Types/Boolean.php

    r874 r887  
    55class TypeBoolean extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    if ($Item['Value'] == 1) $Checked = ' checked="1"'; else $Checked = '';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    if (array_key_exists($Item['Name'], $_POST)) return 1;
  • trunk/Common/Form/Types/Color.php

    r874 r887  
    55class TypeColor extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = '<span style="background-color: #'.$Item['Value'].'">&nbsp;&nbsp;&nbsp;&nbsp;</span>';
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/Date.php

    r874 r887  
    55class TypeDate extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    11     global $MonthNames;
    12 
    1315    if ($Item['Value'] == null) return '';
    1416    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     
    1921  }
    2022
    21   function OnEdit($Item)
     23  function OnEdit(array $Item): string
    2224  {
    2325    global $MonthNames;
     
    7476  }
    7577
    76   function OnLoad($Item)
     78  function OnLoad(array $Item): ?string
    7779  {
    7880    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     
    8082  }
    8183
    82   function OnLoadDb($Item)
     84  function OnLoadDb(array $Item): ?string
    8385  {
    8486    return MysqlDateToTime($Item['Value']);
    8587  }
    8688
    87   function OnSaveDb($Item)
     89  function OnSaveDb(array $Item): ?string
    8890  {
    8991    if ($Item['Value'] == null) return null;
     
    9193  }
    9294
    93   function DatabaseEscape($Value)
     95  function DatabaseEscape(string $Value): string
    9496  {
    9597    return '"'.addslashes($Value).'"';
  • trunk/Common/Form/Types/DateTime.php

    r871 r887  
    55class TypeDateTime extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    11     global $MonthNames;
    12 
    1315    if ($Item['Value'] == 0) return '';
    1416    if ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == '')) $Item['Value'] = time();
     
    1921  }
    2022
    21   function OnEdit($Item)
     23  function OnEdit(array $Item): string
    2224  {
    2325    global $MonthNames;
     
    99101  }
    100102
    101   function OnLoad($Item)
     103  function OnLoad(array $Item): ?string
    102104  {
    103105    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     
    106108  }
    107109
    108   function OnLoadDb($Item)
     110  function OnLoadDb(array $Item): ?string
    109111  {
    110112    return MysqlDateTimeToTime($Item['Value']);
    111113  }
    112114
    113   function OnSaveDb($Item)
     115  function OnSaveDb(array $Item): ?string
    114116  {
    115117    if ($Item['Value'] == null) return null;
     
    117119  }
    118120
    119   function DatabaseEscape($Value)
     121  function DatabaseEscape(string $Value): string
    120122  {
    121123    return '"'.addslashes($Value).'"';
  • trunk/Common/Form/Types/Enumeration.php

    r874 r887  
    55class TypeEnumeration extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView($Item): ?string
    88  {
    99    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
     
    1414  }
    1515
    16   function OnEdit($Item)
     16  function OnEdit(array $Item): string
    1717  {
    1818    $Type = $this->FormManager->Type->GetTypeDefinition($Item['Type']);
     
    3232  }
    3333
    34   function OnLoad($Item)
     34  function OnLoad(array $Item): ?string
    3535  {
    3636    if ($_POST[$Item['Name']] == '') return NULL;
     
    3838  }
    3939
    40   function OnLoadDb($Item)
     40  function OnLoadDb(array $Item): ?string
    4141  {
    4242    if ($Item['Value'] == '') return NULL;
  • trunk/Common/Form/Types/File.php

    r874 r887  
    33class DbFile
    44{
    5   var $Id;
    6   var $FileName;
    7   var $Size;
    8   var $Directory;
    9   var $DirectoryId;
    10   var $TempName;
     5  public string $Id;
     6  public string $FileName;
     7  public int $Size;
     8  public string $Directory;
     9  public string $DirectoryId;
     10  public string $TempName;
    1111
    12   function DetectMimeType()
     12  function DetectMimeType(): string
    1313  {
    1414    // For proper mime-type detection php-pecl-Fileinfo package should be installed on *nix systems
     
    1919  }
    2020
    21   function GetSize($Item)
     21  function GetSize($Item): int
    2222  {
    2323    $FileName = $this->GetFullName($Item);
     
    2727  }
    2828
    29   function GetFullName()
     29  function GetFullName(): string
    3030  {
     31    $Path = '';
    3132    $ParentId = $this->Directory;
    3233    while ($ParentId != null)
     
    3738      $ParentId = $DbRow['Parent'];
    3839    }
    39     $Result = $this->UploadFileFolder.'/'.$Path.$File->Name;
     40    $Result = $this->UploadFileFolder.'/'.$Path.$this->FileName;
    4041    return $Result;
    4142  }
    4243
    43   function GetExt()
     44  function GetExt(): string
    4445  {
    4546    return substr($this->Name, 0, strpos($this->Name, '.') - 1);
    4647  }
    4748
    48   function Delete()
     49  function Delete(): void
    4950  {
    5051    if (file_exists($this->GetFullName())) unlink($this->GetFullName());
    5152  }
    5253
    53   function GetContent()
     54  function GetContent(): string
    5455  {
    5556    if ($this->TempName != '') $Content = file_get_contents($this->TempName);
     
    6162class TypeFile extends TypeBase
    6263{
    63   var $UploadFileFolder;
    64   var $FileDownloadURL;
    65   var $DirectoryId;
     64  public string $UploadFileFolder;
     65  public string $FileDownloadURL;
     66  public string $DirectoryId;
    6667
    67   function __construct($FormManager)
     68  function __construct(FormManager $FormManager)
    6869  {
    6970    parent::__construct($FormManager);
     
    7273  }
    7374
    74   function OnView($Item)
     75  function OnView(array $Item): ?string
    7576  {
    7677    $File = &$Item['Value'];
     
    7980  }
    8081
    81   function OnEdit($Item)
     82  function OnEdit(array $Item): string
    8283  {
    8384    // Check max value of upload_max_filesize
     
    8990  }
    9091
    91   function OnLoad($Item)
     92  function OnLoad(array $Item): ?string
    9293  {
    9394    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     
    106107  }
    107108
    108   function OnLoadDb($Item)
     109  function OnLoadDb(array $Item): ?string
    109110  {
    110111    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
    111112    $File = &$Item['Value'];
    112113    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    113     if ($DbResult->num_rows() > 0)
     114    if ($DbResult->num_rows > 0)
    114115    {
    115116      $DbRow = $DbResult->fetch_assoc();
     
    121122  }
    122123
    123   function OnSaveDb($Item)
     124  function OnSaveDb(array $Item): ?string
    124125  {
    125126    if (!is_object($Item['Value'])) $Item['Value'] = new DbFile();
     
    128129      'Size' => $File->GetSize(), 'Directory' => $File->Directory);
    129130    $DbResult = $this->Database->select('File', '*', 'Id='.$File->Id);
    130     if ($DbResult->num_rows() > 0)
     131    if ($DbResult->num_rows > 0)
    131132    {
    132133      $DbRow = $DbResult->fetch_assoc();
     
    143144    }
    144145    if (!move_uploaded_file($File->TempName, $FileName))
    145       SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
     146      $this->System->SystemMessage('Nahrání souboru', 'Cílová složka není dostupná!');
     147    return '';
    146148  }
    147149
  • trunk/Common/Form/Types/Float.php

    r874 r887  
    55class TypeFloat extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = $Item['Value'];
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/GPS.php

    r874 r887  
    55class TypeGPS extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    9     global $Database;
    10 
    11     $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
     9    $DbResult = $this->Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    1210    if ($DbResult->num_rows > 0)
    1311    {
     
    2018  }
    2119
    22   function OnEdit($Item)
     20  function OnEdit(array $Item): string
    2321  {
    24     global $Database;
    25 
    2622    if ($Item['Value'] != '')
    2723    {
    28       $DbResult = $Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
     24      $DbResult = $this->Database->query('SELECT * FROM `SystemGPS` WHERE `Id`='.$Item['Value']);
    2925      if ($DbResult->num_rows > 0)
    3026      {
     
    4339  }
    4440
    45   function OnLoad($Item)
     41  function OnLoad(array $Item): ?string
    4642  {
    47     global $Database;
    48 
    4943    $Latitude = $this->Implode($_POST[$Item['Name'].'-lat-deg'], $_POST[$Item['Name'].'-lat-min'], $_POST[$Item['Name'].'-lat-sec']);
    5044    $Longitude = $this->Implode($_POST[$Item['Name'].'-lon-deg'], $_POST[$Item['Name'].'-lon-min'], $_POST[$Item['Name'].'-lon-sec']);
    51     $Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');
    52     return $Database->insert_id;
     45    $this->Database->query('INSERT INTO SystemGPS (`Latitude`, `Longitude`) VALUES ("'.$Latitude.'", "'.$Longitude.'")');
     46    return $this->Database->insert_id;
    5347  }
    5448
    55   function Explode($Float)
     49  function Explode(float $Float): array
    5650  {
    5751    $Degrees = intval($Float);
     
    6458  }
    6559
    66   function Implode($Degrees, $Minutes, $Seconds)
     60  function Implode($Degrees, $Minutes, $Seconds): float
    6761  {
    6862    if ($Degrees < 0) return -(abs($Degrees) + ($Minutes + $Seconds / 60) / 60);
  • trunk/Common/Form/Types/Hidden.php

    r874 r887  
    1111  }
    1212
    13   function OnView($Item)
     13  function OnView(array $Item): ?string
    1414  {
    1515    $Output = $Item['Value'];
     
    1717  }
    1818
    19   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    2020  {
    2121    $Output = '<input type="hidden" name="'.$Item['Name'].'" value="'.$Item['Value'].'" />';
     
    2323  }
    2424
    25   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2626  {
    2727    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/Hyperlink.php

    r874 r887  
    55class TypeHyperlink extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    99    $Output = '<a href="'.$Item['Value'].'">'.$Item['Value'].'</a>';
     
    1111  }
    1212
    13   function OnEdit($Item)
     13  function OnEdit(array $Item): string
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1717  }
    1818
    19   function OnLoad($Item)
     19  function OnLoad(array $Item): ?string
    2020  {
    2121    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/IPv4Address.php

    r874 r887  
    55class TypeIPv4Address extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    99    $Output = $Item['Value'];
     
    1111  }
    1212
    13   function OnEdit($Item)
     13  function OnEdit(array $Item): string
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1717  }
    1818
    19   function OnLoad($Item)
     19  function OnLoad(array $Item): ?string
    2020  {
    2121    return $_POST[$Item['Name']];
    2222  }
    2323
    24   function Validate($Item)
     24  function Validate(array $Item): bool
    2525  {
    2626    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     
    2828  }
    2929
    30   function GetValidationFormat()
     30  function GetValidationFormat(): string
    3131  {
    3232    return 'x.x.x.x kde x je hodnota 0..255';
  • trunk/Common/Form/Types/IPv6Address.php

    r874 r887  
    55class TypeIPv6Address extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    99    $Output = $Item['Value'];
     
    1111  }
    1212
    13   function OnEdit($Item)
     13  function OnEdit(array $Item): string
    1414  {
    1515    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1717  }
    1818
    19   function OnLoad($Item)
     19  function OnLoad(array $Item): ?string
    2020  {
    2121    return $_POST[$Item['Name']];
    2222  }
    2323
    24   function Validate($Item)
     24  function Validate(array $Item): bool
    2525  {
    2626    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     
    2828  }
    2929
    30   function GetValidationFormat()
     30  function GetValidationFormat(): string
    3131  {
    3232    return 'xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx kde x je hexa hodnota 0..f';
  • trunk/Common/Form/Types/Image.php

    r874 r887  
    33class TypeImage extends TypeString
    44{
    5   function OnView($Item)
     5  function OnView(array $Item): ?string
    66  {
    77    global $System;
  • trunk/Common/Form/Types/Integer.php

    r874 r887  
    55class TypeInteger extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = $Item['Value'];
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<input type="text" name="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    return $_POST[$Item['Name']];
    2428  }
    2529
    26   function Validate($Item)
     30  function Validate(array $Item): bool
    2731  {
    2832    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     
    3034  }
    3135
    32   function GetValidationFormat()
     36  function GetValidationFormat(): string
    3337  {
    3438    return 'číselná hodnota';
  • trunk/Common/Form/Types/MacAddress.php

    r874 r887  
    55class TypeMacAddress extends TypeString
    66{
    7   var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = $Item['Value'];
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
     
    2529  }
    2630
    27   function DatabaseEscape($Value)
     31  function DatabaseEscape(string $Value): string
    2832  {
    2933    return '"'.addslashes($Value).'"';
    3034  }
    3135
    32   function Validate($Item)
     36  function Validate(array $Item): bool
    3337  {
    3438    if ($Item['Null'] and ($Item['Value'] == '')) return true;
     
    3640  }
    3741
    38   function GetValidationFormat()
     42  function GetValidationFormat(): string
    3943  {
    4044    return 'XX:XX:XX:XX:XX:XX kde X je hexa hodnota 0..F';
  • trunk/Common/Form/Types/OneToMany.php

    r874 r887  
    55class TypeOneToMany extends TypeBase
    66{
    7   var $EditActions;
     7  public array $EditActions;
    88
    9   function OnView($Item)
     9  function OnView(array $Item): ?string
    1010  {
    1111    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
     
    1818  }
    1919
    20   function OnEdit($Item)
     20  function OnEdit(array $Item): string
    2121  {
    2222    $Output = '<select name="'.$Item['Name'].'" id="'.$Item['Name'].'">';
     
    5454  }
    5555
    56   function OnLoad($Item)
     56  function OnLoad(array $Item): ?string
    5757  {
    5858    if ($_POST[$Item['Name']] == '') return NULL;
     
    6060  }
    6161
    62   function OnLoadDb($Item)
     62  function OnLoadDb(array $Item): ?string
    6363  {
    6464    if ($Item['Value'] == '') return NULL;
     
    6666  }
    6767
    68   function OnFilterName($Item)
     68  function OnFilterName(array $Item): string
    6969  {
    7070    return '`'.$Item['Name'].'_Filter`';
    7171  }
    7272
    73   function OnFilterNameQuery($Item)
     73  function OnFilterNameQuery(array $Item): string
    7474  {
    7575    $Type = $this->FormManager->Type->TypeDefinitionList[$Item['Type']];
  • trunk/Common/Form/Types/OneToMany2.php

    r874 r887  
    55class TypeOneToMany2 extends TypeBase
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    99    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
     
    1111  }
    1212
    13   function OnEdit($Item)
     13  function OnEdit(array $Item): string
    1414  {
    1515    $Output = '<a href="?Action=ShowList&amp;TableId='.$Item['TypeDefinition'].'&amp;ParentTable='.$Item['SourceTable'].'&amp;ParentColumn='.$Item['SourceItemId'].'">Seznam</a>';
     
    1717  }
    1818
    19   function OnLoad($Item)
     19  function OnLoad(array $Item): ?string
    2020  {
    2121    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/Password.php

    r874 r887  
    77class TypePassword extends TypeBase
    88{
    9   function OnView($Item)
     9  function OnView(array $Item): ?string
    1010  {
    1111    $Output = '';
     
    1515  }
    1616
    17   function OnEdit($Item)
     17  function OnEdit(array $Item): string
    1818  {
    1919    $Output = '<input type="password" name="'.$Item['Name'].'" value=""/>';
     
    2121  }
    2222
    23   function OnLoad($Item)
     23  function OnLoad(array $Item): ?string
    2424  {
    2525    global $Database;
     
    4242  }
    4343
    44   function OnSaveDb($Item)
     44  function OnSaveDb(array $Item): string
    4545  {
    4646    if ($Item['Value'] == '') return '';
     
    5151  }
    5252
    53   function OnLoadDb($Item)
     53  function OnLoadDb(array $Item): ?string
    5454  {
    5555    return '';
  • trunk/Common/Form/Types/RandomHash.php

    r874 r887  
    1111  }
    1212
    13   function OnView($Item)
     13  function OnView(array $Item): ?string
    1414  {
    1515    $Output = $Item['Value'];
     
    1717  }
    1818
    19   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    2020  {
    2121    if ($Item['Value'] == '')
     
    2929  }
    3030
    31   function OnLoad($Item)
     31  function OnLoad(array $Item): ?string
    3232  {
    3333    return $_POST[$Item['Name']];
  • trunk/Common/Form/Types/String.php

    r874 r887  
    55class TypeString extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = $Item['Value'];
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<input type="text" name="'.$Item['Name'].'" id="'.$Item['Name'].'" value="'.$Item['Value'].'"/>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    //echo($Item['Name'].'='.$_POST[$Item['Name']].','.is_null(NULL).'<br>');
     
    2529  }
    2630
    27   function DatabaseEscape($Value)
     31  function DatabaseEscape(string $Value): string
    2832  {
    2933    return '"'.addslashes($Value).'"';
  • trunk/Common/Form/Types/Text.php

    r874 r887  
    55class TypeText extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Jako' => 'LIKE', 'Rovno' => '=', 'Nerovno' => '!=');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    $Output = str_replace("\n", '<br/>', strip_tags($Item['Value']));
     
    1317  }
    1418
    15   function OnEdit($Item)
     19  function OnEdit(array $Item): string
    1620  {
    1721    $Output = '<textarea name="'.$Item['Name'].'">'.$Item['Value'].'</textarea>';
     
    1923  }
    2024
    21   function OnLoad($Item)
     25  function OnLoad(array $Item): ?string
    2226  {
    2327    return $_POST[$Item['Name']];
    2428  }
    2529
    26   function DatabaseEscape($Value)
     30  function DatabaseEscape(string $Value): string
    2731  {
    2832    return '"'.addslashes($Value).'"';
  • trunk/Common/Form/Types/Time.php

    r874 r887  
    55class TypeTime extends TypeBase
    66{
    7   var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     7  function __construct(FormManager $FormManager)
     8  {
     9    parent::__construct($FormManager);
     10    $this->DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
     11  }
    812
    9   function OnView($Item)
     13  function OnView(array $Item): ?string
    1014  {
    1115    if ($Item['Value'] == 0) return '';
     
    1721  }
    1822
    19   function OnEdit($Item)
     23  function OnEdit(array $Item): string
    2024  {
    2125    if (($Item['Value'] == null) or (($Item['Value'] !== null) and ((strtolower($Item['Value']) == 'now') or (strtolower($Item['Value']) == ''))))
     
    2428      $IsNull = true;
    2529    } else $IsNull = false;
    26     $Parts = getdate($Item['Value']);
     30    $TimeParts = getdate($Item['Value']);
    2731
    2832    $Output = '';
     
    7074  }
    7175
    72   function OnLoad($Item)
     76  function OnLoad(array $Item): ?string
    7377  {
    7478    if (!array_key_exists($Item['Name'].'-null', $_POST) and array_key_exists('Null', $Item) and ($Item['Null'] == true)) return null;
     
    7680  }
    7781
    78   function OnLoadDb($Item)
     82  function OnLoadDb(array $Item): ?string
    7983  {
    8084    return MysqlTimeToTime($Item['Value']);
    8185  }
    8286
    83   function OnSaveDb($Item)
     87  function OnSaveDb(array $Item): ?string
    8488  {
    8589    if ($Item['Value'] == null) return null;
     
    8791  }
    8892
    89   function DatabaseEscape($Value)
     93  function DatabaseEscape(string $Value): string
    9094  {
    9195    return '"'.addslashes($Value).'"';
  • trunk/Common/Form/Types/TimeDiff.php

    r874 r887  
    55class TypeTimeDiff extends TypeInteger
    66{
    7   function OnView($Item)
     7  function OnView(array $Item): ?string
    88  {
    99    if ($Item['Value'] == null) $Output = '';
  • trunk/Common/Form/Types/Type.php

    r874 r887  
    2828class Type
    2929{
    30   var $FormManager;
    31   var $TypeDefinitionList;
    32   var $Values;
     30  public FormManager $FormManager;
     31  public array $TypeDefinitionList;
     32  public array $Values;
    3333
    34   function __construct($FormManager)
     34  function __construct(FormManager $FormManager)
    3535  {
    3636    $this->FormManager = &$FormManager;
     
    6565  }
    6666
    67   function ExecuteTypeEvent($TypeName, $Event, $Parameters = array())
     67  function ExecuteTypeEvent(string $TypeName, string $Event, array $Parameters = array()): ?string
    6868  {
    6969    if (array_key_exists($TypeName, $this->TypeDefinitionList))
     
    7777  }
    7878
    79   function IsHidden($TypeName)
     79  function IsHidden(string $TypeName): bool
    8080  {
    8181    if (array_key_exists($TypeName, $this->TypeDefinitionList))
     
    8888  }
    8989
    90   function RegisterType($Name, $ParentType, $Parameters)
     90  function RegisterType(string $Name, string $ParentType, array $Parameters): void
    9191  {
    9292    if ($ParentType != '')
     
    103103  }
    104104
    105   function UnregisterType($Name)
     105  function UnregisterType(string $Name): void
    106106  {
    107107    unset($this->TypeDefinitionList[$Name]);
     
    109109  }
    110110
    111   function GetTypeDefinition($TypeName)
     111  function GetTypeDefinition(string $TypeName): array
    112112  {
    113113    return $this->TypeDefinitionList[$TypeName];
  • trunk/Common/Global.php

    r874 r887  
    2020$YesNo = array(false => 'Ne', true => 'Ano');
    2121
    22 function HumanSize($Value)
     22function HumanSize(int $Value): string
    2323{
    2424  global $UnitNames;
     
    3333}
    3434
    35 function GetMicrotime()
     35function GetMicrotime(): float
    3636{
    3737  list($Usec, $Sec) = explode(' ', microtime());
     
    3939}
    4040
    41 function ShowArray($Pole)
     41function ShowArray(array $Array): void
    4242{
    4343  echo('<pre style="font-size: 8pt;">');
    44   print_r($Pole);
     44  print_r($Array);
    4545  echo('</pre>');
    4646}
    4747
    48 function HumanDate($Time)
     48function HumanDate(?string $Time): string
    4949{
    5050  if ($Time != '')
     
    5858
    5959// Show page listing numbers
    60 function PagesList($URL, $Page, $TotalCount, $CountPerPage)
     60function PagesList(string $URL, int $Page, int $TotalCount, int $CountPerPage): string
    6161{
    6262  $Count = ceil($TotalCount / $CountPerPage);
     
    9494}
    9595
    96 function ExtractTime($Time)
     96function ExtractTime($Time): array
    9797{
    9898  return array(
     
    106106}
    107107
    108 function GetQueryStringArray($QueryString)
     108function GetQueryStringArray(string $QueryString): array
    109109{
    110110  $Result = array();
     
    122122}
    123123
    124 function SetQueryStringArray($QueryStringArray)
     124function SetQueryStringArray(array $QueryStringArray): string
    125125{
    126126  $Parts = array();
     
    132132}
    133133
    134 function GetPageList($ObjectName, $TotalCount)
     134function GetPageList(string $ObjectName, int $TotalCount): array
    135135{
    136136  global $System;
     
    209209$OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
    210210
    211 function GetOrderTableHeader($ObjectName, $Columns, $DefaultColumn, $DefaultOrder = 0)
     211function GetOrderTableHeader(string $ObjectName, array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array
    212212{
    213213  global $OrderDirSQL, $OrderArrowImage, $Config, $System;
     
    262262}
    263263
    264 function GetRemoteAddress()
     264function GetRemoteAddress(): string
    265265{
    266266  if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IP = $_SERVER['REMOTE_ADDR'];
     
    269269}
    270270
    271 function IsInternetAddr()
     271function IsInternetAddr(): bool
    272272{
    273273  global $Config;
     
    286286}
    287287
    288 function GetMemberByIP($IP)
    289 {
    290   global $Database;
    291 
     288function GetMemberByIP(Database $Database, string $IP): string
     289{
    292290  $DbResult = $Database->query('SELECT `Id` FROM `Member` WHERE '.
    293291  '(SELECT `Member` FROM `NetworkDevice` WHERE (SELECT `Device` FROM `NetworkInterface` '.
     
    300298}
    301299
    302 function CommandExist($Command)
     300function CommandExist(string $Command): bool
    303301{
    304302  $Result = shell_exec('which '.$Command);
     
    306304}
    307305
    308 function RemoveDiacritic($Text)
     306function RemoveDiacritic(string $Text): string
    309307{
    310308  return str_replace(
     
    316314}
    317315
    318 function RouterOSIdent($Name)
     316function RouterOSIdent(string $Name): string
    319317{
    320318  return strtr(strtolower(trim($Name)), array(' ' => '-', '.' => '', '(' => '-', ')' => '-', ',' => '-',
     
    328326}
    329327
    330 function NotBlank($Text)
     328function NotBlank(string $Text): string
    331329{
    332330  if ($Text == '') return '&nbsp';
     
    334332}
    335333
    336 function strip_cdata($string)
     334function strip_cdata(string $string): string
    337335{
    338336  preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $string, $matches);
     
    351349}
    352350
    353 function ProcessURL()
     351function ProcessURL(): array
    354352{
    355353  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     
    365363}
    366364
    367 function RepeatFunction($Period, $Callback)
     365function RepeatFunction(int $Period, callable $Callback): void
    368366{
    369367  while (1)
     
    384382  return call_user_func_array('pack', array_merge(array($v), (array)$a));
    385383}
    386 
  • trunk/Common/VCL/Database.php

    r874 r887  
    1919  }
    2020
    21   function Show()
     21  function Show(): string
    2222  {
    2323    // Get total item count in database
  • trunk/Common/VCL/General.php

    r874 r887  
    11<?php
    22
    3 
    4 //print_r($_SESSION);
    5 
    6 function ReadSessionVar($Name, $Persistent = true)
     3function ReadSessionVar(string $Name, bool $Persistent = true): string
    74{
    85  //echo($Name.',');
     
    2017class Element
    2118{
    22   var $Id;
    23   var $Enabled;
    24   var $Visible;
     19  public string $Id;
     20  public bool $Enabled;
     21  public bool $Visible;
    2522
    2623  function __construct()
     
    3027  }
    3128
    32   function Show()
     29  function Show(): string
    3330  {
    3431    $Output = '';
     
    3734  }
    3835
    39   function Prepare()
     36  function Prepare(): void
    4037  {
    4138  }
     
    4441class Layout extends Element
    4542{
    46   var $Items;
    47 
    48   function Show()
     43  public array $Items;
     44
     45  function Show(): string
    4946  {
    5047    if ($this->Visible)
     
    5754  }
    5855
    59   function Prepare()
     56  function Prepare(): void
    6057  {
    6158    foreach ($this->Items as $Item)
     
    6663class Button extends Element
    6764{
    68   var $Caption;
    69 
    70   function Show()
     65  public string $Caption;
     66
     67  function Show(): string
    7168  {
    7269    if ($this->Visible)
     
    7976class Edit extends Element
    8077{
    81   var $Text;
    82 
    83   function Show()
     78  public string $Text;
     79
     80  function Show(): string
    8481  {
    8582    return parent::Show().'<input type="text" name="'.$this->Id.'" value="'.$this->Text.'"/>';
    8683  }
    8784
    88   function Prepare()
     85  function Prepare(): void
    8986  {
    9087    $this->Text = ReadSessionVar($this->Id.'_Text');
     
    9491class PageSelect extends Element
    9592{
    96   var $Count;
    97   var $Position;
    98   var $PageSize;
     93  public int $Count;
     94  public int $Position;
     95  public int $PageSize;
    9996
    10097  function __construct()
     
    106103  }
    107104
    108   function Show()
     105  function Show(): string
    109106  {
    110107    if (array_key_exists($this->Id.'_Page', $_GET))
     
    122119  }
    123120
    124   function Prepare()
     121  function Prepare(): void
    125122  {
    126123    $this->Position = ReadSessionVar($this->Id.'_Page');
     
    130127class ListViewColumn extends Element
    131128{
    132   var $Name;
    133 
    134   function Show()
     129  public string $Name;
     130
     131  function Show(): string
    135132  {
    136133    return $this->Name;
     
    140137class ListView extends Element
    141138{
    142   var $Columns;
    143   var $Rows;
    144   var $OnColumnClick;
    145   var $OnColumnDraw;
     139  public array $Columns;
     140  public array $Rows;
     141  public $OnColumnClick;
     142  public $OnColumnDraw;
    146143
    147144  function __construct()
     
    152149  }
    153150
    154   function Show()
     151  function Show(): string
    155152  {
    156153    $Output = '<table class="WideTable" style="font-size: small;><tr>';
     
    176173class PageListView extends ListView
    177174{
    178   var $PageSelect;
    179   var $SortOrder;
    180   var $SortColumn;
    181   var $OrderArrowImage;
     175  public PageSelect $PageSelect;
     176  public int $SortOrder;
     177  public string $SortColumn;
     178  public array $OrderArrowImage;
    182179
    183180  function __construct()
     
    190187  }
    191188
    192   function ColumnClick($Column)
     189  function ColumnClick(ListViewColumn $Column): string
    193190  {
    194191    return '?'.$this->Id.'_SortColumn='.$Column->Id.'&amp;'.$this->Id.'_SortOrder='.(1 - $this->SortOrder);
    195192  }
    196193
    197   function ColumnDraw($Column)
     194  function ColumnDraw(ListViewColumn $Column): string
    198195  {
    199196    global $System;
     
    211208  }
    212209
    213   function Show()
     210  function Show(): string
    214211  {
    215212    $this->PageSelect->Count = count($this->Rows);
     
    222219  }
    223220
    224   function Prepare()
     221  function Prepare(): void
    225222  {
    226223    $this->PageSelect->Id = $this->Id.'PageSelect';
     
    233230class TableLayout extends Element
    234231{
    235   var $Rows;
    236   var $Span;
    237 
    238   function Show()
    239   {
    240     $Output .= '<table>';
     232  public array $Rows;
     233  public string $Span;
     234
     235  function Show(): string
     236  {
     237    $Output = '<table>';
    241238    foreach ($this->Rows as $RowNum => $Row)
    242239    {
     
    254251  }
    255252
    256   function Prepare()
     253  function Prepare(): void
    257254  {
    258255    foreach ($this->Rows as $RowNum => $Row)
     
    268265class Label extends Element
    269266{
    270   var $Caption;
    271   var $OnExecute;
    272 
    273   function Show()
     267  public string $Caption;
     268  public $OnExecute;
     269
     270  function Show(): string
    274271  {
    275272    $Output = $this->Caption;
     
    282279  }
    283280
    284   function Prepare()
     281  function Prepare(): void
    285282  {
    286283    $Object = ReadSessionVar('O', false);
     
    293290class Page2
    294291{
    295   var $Items;
    296 
    297   function Show()
     292  public array $Items;
     293
     294  function Show(): string
    298295  {
    299296    $Output = '<!DOCTYPE html><html><head></head><body>';
     
    304301  }
    305302
    306   function Prepare()
     303  function Prepare(): void
    307304  {
    308305    foreach ($this->Items as $Item)
  • trunk/Install/deb/debian/conf/Config.php

    r877 r887  
    33$IsDeveloper = array_key_exists('REMOTE_ADDR', $_SERVER) and in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1'));
    44
    5 $Config['SystemPassword'] = sha1(random(23232));
     5$Config['SystemPassword'] = sha1(rand(23232));
    66$Config['Database']['Host'] = 'localhost';
    77$Config['Database']['User'] = 'isp-central';
  • trunk/Install/deb/debian/conf/Modules.php

    r842 r887  
    1 <?php 
     1<?php
    22
    3 $ConfigModules = array (
     3$ConfigModules = array(
    44);
  • trunk/Modules/API/API.php

    r874 r887  
    1717class ModuleAPI extends AppModule
    1818{
    19   function __construct($System)
     19  function __construct(System $System)
    2020  {
    2121    parent::__construct($System);
     
    2828  }
    2929
    30   function DoStart()
     30  function DoStart(): void
    3131  {
    32     $this->System->RegisterPage(array('api'), 'PageAPI');
     32    $this->System->RegisterPage(['api'], 'PageAPI');
    3333  }
    3434}
     
    3636class PageAPI extends Page
    3737{
    38   var $DataFormat;
    39  
    40   function __construct($System)
     38  public string $DataFormat;
     39
     40  function __construct(System $System)
    4141  {
    4242    parent::__construct($System);
    4343    $this->ClearPage = true;
     44    $this->DataFormat = '';
    4445  }
    4546
    46   function Show()
     47  function Show(): string
    4748  {
    4849    // p - token
     
    5051      $Token = $_GET['p'];
    5152      $DbResult = $this->Database->query('SELECT `User` FROM `APIToken` WHERE `Token`="'.$Token.'"');
    52       if ($DbResult->num_rows > 0) 
     53      if ($DbResult->num_rows > 0)
    5354      {
    5455        $DbRow = $DbResult->fetch_assoc();
     
    7576  }
    7677
    77   function ShowList($Table, $ItemId)
     78  function ShowList(string $Table, $ItemId): string
    7879  {
    7980    if (($Table != '') and (array_key_exists($Table, $this->System->FormManager->Classes)))
     
    8485      $SourceTable = '('.$FormClass['SQL'].') AS `TX`';
    8586      else $SourceTable = '`'.$FormClass['Table'].'` AS `TX`';
    86      
     87
    8788    $Filter = '';
    8889    if ($ItemId != 0)
     
    112113    $dom->appendChild($root);
    113114
    114     $array2xml = function ($node, $array) use ($dom, &$array2xml) 
     115    $array2xml = function ($node, $array) use ($dom, &$array2xml)
    115116    {
    116117      foreach ($array as $key => $value)
    117118      {
    118         if ( is_array($value) ) 
     119        if ( is_array($value) )
    119120        {
    120121          if (is_numeric($key)) $key = 'N'.$key; //die('XML tag name "'.$key.'" can\'t be numeric');
  • trunk/Modules/Chat/Chat.php

    r874 r887  
    33class PageChatHistory extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1717  }
    1818
    19   function Show()
     19  function Show(): string
    2020  {
    2121    global $MonthNames;
    2222
    23     if (!$this->System->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění';
     23    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění';
    2424
    2525    if (array_key_exists('date', $_GET)) $Date = $_GET['date'];
     
    8787class ModuleChat extends AppModule
    8888{
    89   function __construct($System)
     89  function __construct(System $System)
    9090  {
    9191    parent::__construct($System);
     
    9898  }
    9999
    100   function DoStart()
     100  function DoStart(): void
    101101  {
    102102    $this->System->Pages['chat'] = 'PageChatHistory';
  • trunk/Modules/Chat/irc_bot.php

    r873 r887  
    3939  }
    4040
    41   function Run()
     41  function Run(): void
    4242  {
    4343    global $Database;
     
    195195    echo("-Connection lost.\n");
    196196  }
    197 
    198197}
    199198
  • trunk/Modules/Customer/Customer.php

    r874 r887  
    33class ModuleCustomer extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Member', array(
     
    187187    ));
    188188
    189     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Customer',
    190       array('ModuleCustomer', 'ShowDashboardItem'));
     189    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Customer',
     190      array($this, 'ShowDashboardItem'));
    191191  }
    192192
    193   function ShowDashboardItem()
     193  function ShowDashboardItem(): string
    194194  {
    195195    $DbResult = $this->Database->select('Member', 'COUNT(*)', '1');
  • trunk/Modules/EmailQueue/EmailQueue.php

    r882 r887  
    33class PageEmailQueueProcess extends Page
    44{
    5   var $FullTitle = 'Odeslání pošty z fronty';
    6   var $ShortTitle = 'Fronta pošty';
    7   var $ParentClass = 'PagePortal';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Odeslání pošty z fronty';
     9    $this->ShortTitle = 'Fronta pošty';
     10    $this->ParentClass = 'PagePortal';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     $Output = $this->System->ModuleManager->Modules['EmailQueue']->Process();
     15    $Output = ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->Process();
    1216    $Output = $this->SystemMessage('Zpracování fronty emailů', 'Nové emaily byly odeslány').$Output;
    1317    return $Output;
     
    1721class ModuleEmailQueue extends AppModule
    1822{
    19   function __construct($System)
     23  function __construct(System $System)
    2024  {
    2125    parent::__construct($System);
     
    2832  }
    2933
    30   function DoInstall()
     34  function DoInstall(): void
    3135  {
    3236  }
    3337
    34   function DoUninstall()
     38  function DoUninstall(): void
    3539  {
    3640  }
    3741
    38   function DoStart()
     42  function DoStart(): void
    3943  {
    40     $this->System->RegisterPage('fronta-posty', 'PageEmailQueueProcess');
     44    $this->System->RegisterPage(['fronta-posty'], 'PageEmailQueueProcess');
    4145    $this->System->FormManager->RegisterClass('Email', array(
    4246        'Title' => 'Nový email',
     
    7074  }
    7175
    72   function DoStop()
     76  function DoStop(): void
    7377  {
    7478  }
     
    8387  }
    8488
    85   function Process()
     89  function Process(): string
    8690  {
    8791    $Output = '';
     
    103107      $Mail->Send();
    104108      $this->Database->update('EmailQueue', 'Id='.$DbRow['Id'], array('Archive' => 1));
    105       $this->System->ModuleManager->Modules['Log']->NewRecord('System', 'SendEmail', $DbRow['Id']);
     109      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('System', 'SendEmail', $DbRow['Id']);
    106110      $Output .= 'To: '.$DbRow['To'].'  Subject: '.$DbRow['Subject'].'<br />';
    107111    }
    108112    return $Output;
    109113  }
     114
     115  static function Cast(AppModule $AppModule): ModuleEmailQueue
     116  {
     117    if ($AppModule instanceof ModuleEmailQueue)
     118    {
     119      return $AppModule;
     120    }
     121    throw new Exception('Expected ModuleEmailQueue type but '.gettype($AppModule));
     122  }
    110123}
    111 
  • trunk/Modules/Employee/Employee.php

    r738 r887  
    33class ModuleEmployee extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Employee', array(
  • trunk/Modules/Error/Error.php

    r873 r887  
    33class ModuleError extends AppModule
    44{
    5   var $Encoding;
    6   var $ShowError;
    7   var $UserErrors;
    8   var $ErrorHandler;
     5  public string $Encoding;
     6  public ErrorHandler $ErrorHandler;
    97
    10   function __construct($System)
     8  function __construct(System $System)
    119  {
    1210    parent::__construct($System);
     
    1917
    2018    $this->ErrorHandler = new ErrorHandler();
     19    $this->Encoding = 'utf-8';
    2120  }
    2221
    23   function DoInstall()
     22  function DoInstall(): void
    2423  {
    2524  }
    2625
    27   function DoUnInstall()
     26  function DoUnInstall(): void
    2827  {
    2928  }
    3029
    31   function DoStart()
     30  function DoStart(): void
    3231  {
    3332    $this->ErrorHandler->ShowError = $this->System->Config['Web']['ShowPHPError'];
     
    3635  }
    3736
    38   function DoStop()
     37  function DoStop(): void
    3938  {
    4039    $this->ErrorHandler->Stop();
    4140  }
    4241
    43   function DoOnError($Error)
     42  function DoOnError(string $Error): void
    4443  {
    45     $this->System->ModuleManager->Modules['Log']->NewRecord('Error', 'Log', $Error);
     44    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Error', 'Log', $Error);
    4645
    4746    //if ($Config['Web']['ErrorLogFile'] != '')
  • trunk/Modules/File/File.php

    r885 r887  
    55class File extends Model
    66{
    7   var $FilesDir;
    8 
    9   function __construct($System)
     7  public string $FilesDir;
     8
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1313  }
    1414
    15   function Delete($Id)
     15  function Delete($Id): void
    1616  {
    1717    $DbResult = $this->Database->select('File', 'Name', 'Id='.$Id);
     
    2424  }
    2525
    26   function CreateFromUpload($Name)
     26  function CreateFromUpload(string $Name): string
    2727  {
    2828    // Submited form with file input have to be enctype="multipart/form-data"
     
    4141  }
    4242
    43   function DetectMimeType($FileName)
     43  function DetectMimeType(string $FileName): string
    4444  {
    4545    $MimeTypes = GetMimeTypes();
     
    4949  }
    5050
    51   function Download($Id)
     51  function Download(string $Id): void
    5252  {
    5353    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
     
    6767  }
    6868
    69   function GetDir($Id)
     69  function GetDir(string $Id): string
    7070  {
    7171    $DbResult = $this->Database->select('FileDirectory', '*', 'Id='.$Id);
     
    7777  }
    7878
    79   function GetFullPath($Id)
     79  function GetFullPath(string $Id): string
    8080  {
    8181    $DbResult = $this->Database->select('File', '*', 'Id='.addslashes($Id));
     
    9393class PageFile extends Page
    9494{
    95   function Show()
     95  function Show(): string
    9696  {
    9797    if (array_key_exists('id', $_GET)) $Id = $_GET['id'];
     
    9999    else return $this->SystemMessage('Chyba', 'Nezadáno id souboru');
    100100    $this->ClearPage = true;
    101     $Output = $this->System->Modules['File']->Download($Id);
     101    $Output = ModuleFile::Cast($this->System->GetModule('File'))->File->Download($Id);
    102102    return $Output;
    103103  }
     
    106106class PageFileCheck extends Page
    107107{
    108   function __construct($System)
     108  function __construct(System $System)
    109109  {
    110110    parent::__construct($System);
     
    114114  }
    115115
    116   function GetAbsolutePath($Path)
     116  function GetAbsolutePath(string $Path): string
    117117  {
    118118    $Path = trim($Path);
     
    137137  }
    138138
    139   function Show()
     139  function Show(): string
    140140  {
    141141    $Output = '<strong>Missing files:</strong><br>';
    142     if (!$this->System->User->CheckPermission('File', 'Check'))
     142    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('File', 'Check'))
    143143      return 'Nemáte oprávnění';
    144144    $DbResult = $this->Database->select('File', 'Id');
     
    146146    {
    147147      $Id = $DbRow['Id'];
    148       $FileName = $this->GetAbsolutePath($this->System->Modules['File']->GetFullPath($Id));
     148      $FileName = $this->GetAbsolutePath(ModuleFile::Cast($this->System->GetModule('File'))->File->GetFullPath($Id));
    149149      if (!file_exists($FileName))
    150150        $Output .= '<a href="'.$this->System->Link('/is/?a=view&amp;t=File&amp;i='.$Id).'">'.$FileName.'</a><br>';
     
    156156class ModuleFile extends AppModule
    157157{
    158   function __construct($System)
     158  public File $File;
     159
     160  function __construct(System $System)
    159161  {
    160162    parent::__construct($System);
     
    164166    $this->License = 'GNU/GPLv3';
    165167    $this->Description = 'Base module for file management';
    166     $this->Dependencies = array();
    167   }
    168 
    169   function DoInstall()
    170   {
    171   }
    172 
    173   function DoUninstall()
    174   {
    175   }
    176 
    177   function DoStart()
     168    $this->Dependencies = array('User');
     169
     170    $this->File = new File($this->System);
     171  }
     172
     173  function DoInstall(): void
     174  {
     175  }
     176
     177  function DoUninstall(): void
     178  {
     179  }
     180
     181  function DoStart(): void
    178182  {
    179183    global $Config;
    180184
    181     $this->System->RegisterPage('file', 'PageFile');
    182     $this->System->RegisterPage('file-check', 'PageFileCheck');
    183     $this->System->AddModule(new File($this->System));
    184     $this->System->Modules['File']->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'];
     185    $this->System->RegisterPage(['file'], 'PageFile');
     186    $this->System->RegisterPage(['file-check'], 'PageFileCheck');
     187    $this->File->FilesDir = dirname(__FILE__).'/../../'.$Config['Web']['UploadFileFolder'];
    185188    $this->System->FormManager->RegisterClass('File', array(
    186189      'Title' => 'Soubor',
     
    271274  }
    272275
    273   function DoStop()
    274   {
    275   }
    276 }
     276  static function Cast(AppModule $AppModule): ModuleFile
     277  {
     278    if ($AppModule instanceof ModuleFile)
     279    {
     280      return $AppModule;
     281    }
     282    throw new Exception('Expected ModuleFile type but got '.gettype($AppModule));
     283  }
     284}
  • trunk/Modules/File/MimeTypes.php

    r885 r887  
    11<?php
    22
    3 function GetMimeTypes()
     3function GetMimeTypes(): array
    44{
    55  return array(
  • trunk/Modules/Finance/Bill.php

    r874 r887  
    33class Bill extends Model
    44{
    5   var $SpecificSymbol = 1; // počítačová sít
    6   var $Checked;
     5  public int $SpecificSymbol = 1; // computer network number
     6  public bool $Checked = false;
    77
    88  function GenerateHTML()
     
    1111  }
    1212
    13   function SaveToFile($FileName)
    14   {
    15     global $Database;
    16 
     13  function SaveToFile(string $FileName)
     14  {
    1715    $PdfData = $this->HtmlToPdf($this->GenerateHTML());
    1816    file_put_contents($FileName, $PdfData);
    1917  }
    2018
    21   function HtmlToPdf($HtmlCode)
     19  function HtmlToPdf(string $HtmlCode): string
    2220  {
    2321    $Encoding = new Encoding();
     
    3533class BillInvoice extends Bill
    3634{
    37   var $InvoiceId;
    38 
    39   function ShowSubjectInfo($Subject)
     35  public string $InvoiceId;
     36
     37  function ShowSubjectInfo(array $Subject): string
    4038  {
    4139    $BooleanText = array('Ne', 'Ano');
     
    5048  }
    5149
    52   function GenerateHTML()
    53   {
    54     $Finance = &$this->System->Modules['Finance'];
     50  function GenerateHTML(): string
     51  {
     52    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    5553    $Finance->LoadMonthParameters(0);
    5654
     
    152150class BillOperation extends Bill
    153151{
    154   var $OperationId;
    155 
    156   function GenerateHTML()
     152  public string $OperationId;
     153
     154  function GenerateHTML(): string
    157155  {
    158156    $DbResult = $this->Database->query('SELECT `FinanceOperation`.*, `FinanceOperationGroup`.`Direction`, `DocumentLineCode`.`Name` AS `BillName` FROM `FinanceOperation` '.
  • trunk/Modules/Finance/Finance.php

    r877 r887  
    4141  var $Rounding;
    4242
    43   function LoadMonthParameters($Period = 1) // 0 - now, 1 - next month
     43  function LoadMonthParameters(int $Period = 1) // 0 - now, 1 - next month
    4444  {
    4545    $DbResult = $this->Database->query('SELECT * FROM `FinanceBillingPeriod`');
     
    7878  }
    7979
    80   function W2Kc($Spotreba)
     80  function W2Kc($Spotreba): string
    8181  {
    8282    return round($Spotreba * 0.72 * $this->kWh);
     
    8888    $EndTime = mktime(0, 0, 0, 12, 31, $Year);
    8989    $this->Database->insert('FinanceYear', array('Year' => $Year,
    90           'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));
    91         $YearId = $this->Database->insert_id;
     90            'DateStart' => TimeToMysqlDate($StartTime), 'DateEnd' => TimeToMysqlDate($EndTime), 'Closed' => 0));
     91          $YearId = $this->Database->insert_id;
    9292
    9393    // Create DocumentLineSequence from previous
     
    9595    while ($DbRow = $DbResult->fetch_assoc())
    9696    {
    97           $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,
    98             'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));
    99         }
    100   }
    101 
    102   function GetFinanceYear($Year)
     97            $this->Database->insert('DocumentLineSequence', array('FinanceYear' => $YearId,
     98              'NextNumber' => 1, 'YearPrefix' => 1, 'DocumentLine' => $DbRow['Id']));
     99          }
     100  }
     101
     102  function GetFinanceYear(int $Year)
    103103  {
    104104    if ($Year == 0)
     
    107107      $DbResult = $this->Database->select('FinanceYear', '*', '1 ORDER BY `Year` DESC LIMIT 1');
    108108    } else $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    109     if ($DbResult->num_rows == 0) {
    110           if ($Year == date('Y'))
    111           {
    112                 $this->CreateFinanceYear($Year);
     109    if ($DbResult->num_rows == 0)
     110    {
     111            if ($Year == date('Y'))
     112            {
     113                    $this->CreateFinanceYear($Year);
    113114        $DbResult = $this->Database->select('FinanceYear', '*', '`Year`='.$Year);
    114           } else throw new Exception('Rok '.$Year.' nenalezen');
    115         }
     115            } else throw new Exception('Rok '.$Year.' nenalezen');
     116          }
    116117    $FinanceYear = $DbResult->fetch_assoc();
    117118    if ($FinanceYear['Closed'] == 1)
     
    120121  }
    121122
    122   function GetNextDocumentLineNumber($Id, $FinanceYear = 0)
    123   {
    124         $FinanceYear = $this->GetFinanceYear($FinanceYear);
     123  function GetNextDocumentLineNumber(string $Id, int $FinanceYear = 0)
     124  {
     125          $FinanceYear = $this->GetFinanceYear($FinanceYear);
    125126
    126127    $DbResult = $this->Database->query('SELECT `Shortcut`, `Id` FROM `DocumentLine` WHERE `Id`='.$Id);
     
    141142  }
    142143
    143   function GetNextDocumentLineNumberId($Id, $FinanceYear = 0)
     144  function GetNextDocumentLineNumberId(string $Id, int $FinanceYear = 0): int
    144145  {
    145146    $Code = $this->GetNextDocumentLineNumber($Id, $FinanceYear);
     
    148149  }
    149150
    150   function GetFinanceGroupById($Id, $Table)
     151  function GetFinanceGroupById(string $Id, string $Table): ?array
    151152  {
    152153    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `Id`= '.$Id);
     
    154155      $Group = $DbResult->fetch_assoc();
    155156      return $Group;
    156     } else die('Finance group id '.$Id.' not found in table '.$Table);
    157   }
    158 
    159   function RecalculateMemberPayment()
     157    }
     158    echo('Finance group id '.$Id.' not found in table '.$Table);
     159    return null;
     160  }
     161
     162  function RecalculateMemberPayment(): string
    160163  {
    161164    $Output = 'Aktualizuji finance členů...<br />';
     
    199202      $Consumption = 0;
    200203      $this->Database->insert('MemberPayment', array('Member' => $Member['Id'],
    201           'MonthlyInternet' => $MonthlyInet,
    202           'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
    203           'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
     204        'MonthlyInternet' => $MonthlyInet,
     205        'MonthlyTotal' => $Monthly, 'MonthlyConsumption' => $this->W2Kc($Consumption),
     206        'Cash' => $Cash, 'MonthlyPlus' => $this->W2Kc($ConsumptionPlus)));
    204207    }
    205     $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'RecalculateMemberPayment');
     208    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'RecalculateMemberPayment');
    206209    return $Output;
    207210  }
    208211
    209   function GetVATByType($TypeId)
     212  function GetVATByType(string $TypeId): string
    210213  {
    211214    $Time = time();
     
    220223class ModuleFinance extends AppModule
    221224{
    222   function __construct($System)
     225  public Finance $Finance;
     226  public Bill $Bill;
     227
     228  function __construct(System $System)
    223229  {
    224230    parent::__construct($System);
     
    229235    $this->Description = 'Base module for finance management';
    230236    $this->Dependencies = array('File', 'EmailQueue');
    231   }
    232 
    233   function DoInstall()
    234   {
    235   }
    236 
    237   function DoUninstall()
    238   {
    239   }
    240 
    241   function DoStart()
     237
     238    $this->Bill = new Bill($this->System);
     239    $this->Finance = new Finance($this->System);
     240  }
     241
     242  function DoInstall(): void
     243  {
     244  }
     245
     246  function DoUninstall(): void
     247  {
     248  }
     249
     250  function DoStart(): void
    242251  {
    243252    global $Config;
    244253
    245     $this->System->RegisterPage(array('finance', 'sprava'), 'PageFinanceManage');
    246     $this->System->RegisterPage(array('finance', 'platby'), 'PageFinanceUserState');
    247     $this->System->RegisterPage(array('finance', 'import'), 'PageFinanceImportPayment');
    248     $this->System->RegisterPage(array('finance', 'zivnost'), 'PageFinanceTaxFiling');
     254    $this->System->RegisterPage(['finance', 'sprava'], 'PageFinanceManage');
     255    $this->System->RegisterPage(['finance', 'platby'], 'PageFinanceUserState');
     256    $this->System->RegisterPage(['finance', 'import'], 'PageFinanceImportPayment');
     257    $this->System->RegisterPage(['finance', 'zivnost'], 'PageFinanceTaxFiling');
    249258
    250259    $this->System->FormManager->RegisterClass('FinanceOperation', array(
     
    644653    ));
    645654
    646 
    647     $this->System->AddModule(new Bill($this->System));
    648     $this->System->AddModule(new Finance($this->System));
    649     $this->System->Modules['Finance']->MainSubject = $Config['Finance']['MainSubjectId'];
    650     $this->System->Modules['Finance']->DirectoryId = $Config['Finance']['DirectoryId'];
    651 
    652     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Finance',
    653       array('ModuleFinance', 'ShowDashboardItem'));
    654   }
    655 
    656   function ShowDashboardItem()
     655    $this->Finance->MainSubject = $Config['Finance']['MainSubjectId'];
     656    $this->Finance->DirectoryId = $Config['Finance']['DirectoryId'];
     657
     658    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Finance', array($this, 'ShowDashboardItem'));
     659  }
     660
     661  function ShowDashboardItem(): string
    657662  {
    658663    $DbResult = $this->Database->select('FinanceOperation', 'ROUND(SUM(`Value`))', '1');
     
    662667  }
    663668
    664   function DoStop()
    665   {
    666   }
    667 
    668   function BeforeInsertFinanceOperation($Form)
     669  function DoStop(): void
     670  {
     671  }
     672
     673  function BeforeInsertFinanceOperation(Form $Form): array
    669674  {
    670675    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    671676      else $Year = date("Y", $Form->Values['ValidFrom']);
    672     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
    673     $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    674     return $Form->Values;
    675   }
    676 
    677   function AfterInsertFinanceOperation($Form, $Id)
    678   {
    679     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
     677    $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
     678    $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
     679    return $Form->Values;
     680  }
     681
     682  function AfterInsertFinanceOperation(Form $Form, string $Id): array
     683  {
     684    $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
    680685    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    681686      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    683688  }
    684689
    685   function BeforeModifyFinanceOperation($Form, $Id)
    686   {
    687     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
     690  function BeforeModifyFinanceOperation(Form $Form, string $Id): array
     691  {
     692    $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceOperationGroup');
    688693    $this->Database->query('UPDATE `'.$Form->Definition['Table'].'` SET `Value`= '.
    689694      ($Form->Values['ValueUser'] * $FinanceGroup['ValueSign']).' WHERE `Id`='.$Id);
     
    691696  }
    692697
    693   function BeforeInsertFinanceInvoice($Form)
     698  function BeforeInsertFinanceInvoice(Form $Form): array
    694699  {
    695700    // Get new DocumentLineCode by selected invoice Group
    696701    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    697702      else $Year = date("Y", $Form->Values['ValidFrom']);
    698     $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
    699     $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    700     return $Form->Values;
    701   }
    702 
    703   function AfterInsertFinanceInvoice($Form, $Id)
    704   {
    705     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
     703    $Group = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
     704    $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     705    return $Form->Values;
     706  }
     707
     708  function AfterInsertFinanceInvoice(Form $Form, string $Id): array
     709  {
     710    $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
    706711    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    707712    $DbRow = $DbResult->fetch_row();
     
    713718  }
    714719
    715   function BeforeModifyFinanceInvoice($Form, $Id)
    716   {
    717     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
     720  function BeforeModifyFinanceInvoice(Form $Form, string $Id): array
     721  {
     722    $FinanceGroup = $this->Finance->GetFinanceGroupById($Form->Values['Group'], 'FinanceInvoiceGroup');
    718723    $DbResult = $this->Database->query(str_replace('#Id', $Id, $Form->Definition['Items']['ValueUser']['SQL']));
    719724    $DbRow = $DbResult->fetch_row();
     
    724729  }
    725730
    726   function AfterInsertFinanceInvoiceItem($Form, $Id)
     731  function AfterInsertFinanceInvoiceItem(Form $Form, string $Id): array
    727732  {
    728733    $ParentForm = new Form($this->System->FormManager);
     
    733738  }
    734739
    735   function AfterModifyFinanceInvoiceItem($Form, $Id)
     740  function AfterModifyFinanceInvoiceItem(Form $Form, string $Id): array
    736741  {
    737742    $ParentForm = new Form($this->System->FormManager);
     
    742747  }
    743748
    744   function BeforeInsertContract($Form)
     749  function BeforeInsertContract(Form $Form): array
    745750  {
    746751    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    747752      else $Year = date("Y", $Form->Values['ValidFrom']);
    748     $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year);
    749     return $Form->Values;
     753    $Form->Values['BillCode'] = $this->Finance->GetNextDocumentLineNumberId($Form->Values['DocumentLine'], $Year);
     754    return $Form->Values;
     755  }
     756
     757  static function Cast(AppModule $AppModule): ModuleFinance
     758  {
     759    if ($AppModule instanceof ModuleFinance)
     760    {
     761      return $AppModule;
     762    }
     763    throw new Exception('Expected ModuleFinance type but '.gettype($AppModule));
    750764  }
    751765}
  • trunk/Modules/Finance/Import.php

    r874 r887  
    33class PageFinanceImportPayment extends Page
    44{
    5   var $FullTitle = 'Import plateb';
    6   var $ShortTitle = 'Import plateb';
    7   var $ParentClass = 'PageFinance';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Import plateb';
     9    $this->ShortTitle = 'Import plateb';
     10    $this->ParentClass = 'PageFinance';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
     15    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
    1216    if (array_key_exists('Operation', $_GET))
    1317    {
     
    2630  }
    2731
    28   function Prepare()
     32  function Prepare(): string
    2933  {
    30     $Finance = $this->System->Modules['Finance'];
     34    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    3135    $Finance->LoadMonthParameters(0);
    3236    $Data = explode("\n", $_POST['Source']);
     
    124128  }
    125129
    126   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group)
     130  function InsertMoney(string $Subject, string $Value, string $Cash, string $Taxable, string $Time, string $Text, array $Group)
    127131  {
    128132    $Year = date('Y', $Time);
    129     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     133    $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    130134    // TODO: Fixed BankAccount=1, allow to select bank account for import
    131135    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    136140  }
    137141
    138   function Insert()
     142  function Insert(): string
    139143  {
    140     $Finance = $this->System->Modules['Finance'];
     144    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    141145    $Finance->LoadMonthParameters(0);
    142146    $Output = '';
     
    144148    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    145149    {
    146       if ($_POST['Money'.$I] < 0) {
    147         $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    148       } else {
    149         $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
     150      if ($_POST['Money'.$I] < 0)
     151      {
     152        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
     153      } else
     154      {
     155        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    150156      }
    151157      $Date = explode('-', $_POST['Date'.$I]);
     
    154160        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    155161      $Output .= $I.', ';
    156       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     162      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    157163    }
    158164    return $Output;
  • trunk/Modules/Finance/Manage.php

    r886 r887  
    33class PageFinanceManage extends Page
    44{
    5   var $FullTitle = 'Správa financí';
    6   var $ShortTitle = 'Správa financí';
    7   var $ParentClass = 'PageFinance';
    8 
    9   function Show()
    10   {
    11     $Output = '';
    12     if (!$this->System->User->CheckPermission('Finance', 'Manage'))
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Správa financí';
     9    $this->ShortTitle = 'Správa financí';
     10    $this->ParentClass = 'PageFinance';
     11  }
     12
     13  function Show(): string
     14  {
     15    $Output = '';
     16    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage'))
    1317      return 'Nemáte oprávnění';
    1418
     
    1822    {
    1923      case 'Recalculate':
    20         $Output .= $this->System->Modules['Finance']->RecalculateMemberPayment();
     24        $Output .= ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->RecalculateMemberPayment();
    2125        break;
    2226      case 'ShowMonthlyPayment':
     
    5155    $Year = date('Y', $Time);
    5256
    53     $MonthCount = $this->System->Modules['Finance']->BillingPeriods[$Period]['MonthCount'];
     57    $MonthCount = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Period]['MonthCount'];
    5458    if ($MonthCount <= 0) return array('From' => NULL, 'To' => NULL, 'MonthCount' => 0);
    5559    $MonthCurrent = date('n', $Time);
     
    7276  function ShowMonthlyPayment()
    7377  {
    74     if (!$this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
     78    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
    7579    $SQL = 'SELECT `Member`.*, `MemberPayment`.`MonthlyTotal` AS `Monthly`, '.
    7680      '`MemberPayment`.`Cash` AS `Cash`, '.
     
    128132    global $LastInsertTime;
    129133
     134    $Finance = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     135
    130136    $Year = date('Y', $TimeCreation);
    131     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     137    $BillCode = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    132138    $SumValue = 0;
    133139    foreach ($Items as $Item) {
    134140      $SumValue = $SumValue + $Item['Price'] * $Item['Quantity'];
    135141    }
    136     $Finance = &$this->System->Modules['Finance'];
    137142    $SumValue = round($SumValue, $Finance->Rounding);
    138143    $this->Database->insert('FinanceInvoice', array(
     
    181186        {
    182187          $InvoiceItems[] = array('Description' => $Service['Name'], 'Price' => $Service['Price'],
    183             'Quantity' => $Period['MonthCount'], 'VAT' => $this->System->Modules['Finance']->GetVATByType($Service['VAT']));
     188            'Quantity' => $Period['MonthCount'], 'VAT' => ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetVATByType($Service['VAT']));
    184189          $MonthlyTotal += $Service['Price'];
    185190        }
     
    196201
    197202        // Load invoice group
    198         $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
     203        $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($InvoiceGroupId, 'FinanceInvoiceGroup');
    199204        foreach ($InvoiceItems as $Index => $Item)
    200205        {
     
    275280  function ProcessMonthlyPayment()
    276281  {
    277     if (!$this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
     282    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
    278283    $Output = '';
    279284
    280285    $Output .= $this->ProcessTableUpdates();
    281286
    282     $Finance = &$this->System->Modules['Finance'];
     287    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    283288    $Finance->LoadMonthParameters(0);
    284289
     
    334339      //flush();
    335340      //$this->GenerateBills();
    336       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
     341      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'ProcessMonthlyPayment', $Output);
    337342    }
    338343    $Output = str_replace("\n", '<br/>', $Output);
     
    379384      $Service = $DbResult->fetch_assoc();
    380385      $Content .= '<strong>'.$Service['Name'].'</strong><br />'."\n".
    381         'Vaše platební období: <strong>'.$this->System->Modules['Finance']->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".
     386        'Vaše platební období: <strong>'.ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->BillingPeriods[$Member['BillingPeriod']]['Name'].'</strong><br />'."\n".
    382387        'Pravidelná platba za období: <strong>'.($MemberPayment['MonthlyTotal'] * $Period['MonthCount']).' Kč</strong><br />'."\n".
    383388        'Bankovní účet: <strong>'.$MainSubjectAccount['NumberFull'].'</strong><br/>'."\n".
     
    407412
    408413      $Content .= '<br />Tento email je generován automaticky. V případě zjištění nesrovnalostí napište zpět.';
    409       $this->System->ModuleManager->Modules['EmailQueue']->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,
     414      ModuleEmailQueue::Cast($this->System->GetModule('EmailQueue'))->AddItem($User['Name'].' <'.$User['Email'].'>', $Title, $Content,
    410415         $Config['Web']['Admin'].' <'.$Config['Web']['AdminEmail'].'>');
    411416      $Output = '';
     
    416421  function GenerateInvoice($Where)
    417422  {
     423    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    418424    $Output = '';
    419425    $DbResult = $this->Database->query('SELECT * FROM `FinanceInvoice` WHERE (`BillCode` <> "") '.
     
    423429      if ($Row['File'] == null)
    424430      {
    425         $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0,
    426           'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));
     431        $this->Database->insert('File', array('Name' => '', 'Size' => 0, 'Directory' => $DirectoryId, 'Time' => 'NOW()'));
    427432        $FileId = $this->Database->insert_id;
    428433      } else $FileId = $Row['File'];
     
    432437      $Bill->System = &$this->System;
    433438      $Bill->InvoiceId = $Row['Id'];
    434       $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;
     439      $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName;
    435440      $Bill->SaveToFile($FullFileName);
    436441      if (file_exists($FullFileName))
     
    446451  function GenerateOperation($Where)
    447452  {
     453    $DirectoryId = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->DirectoryId;
    448454    $Output = '';
    449455    $DbResult = $this->Database->query('SELECT * FROM `FinanceOperation` WHERE (`BillCode` <> "") '.
     
    454460      {
    455461        $DbResult2 = $this->Database->insert('File', array('Name' => '', 'Size' => 0,
    456           'Directory' => $this->System->Modules['Finance']->DirectoryId, 'Time' => 'NOW()'));
     462          'Directory' => $DirectoryId, 'Time' => 'NOW()'));
    457463        $FileId = $this->Database->insert_id;
    458464      } else $FileId = $Row['File'];
     
    462468      $Bill->System = &$this->System;
    463469      $Bill->OperationId = $Row['Id'];
    464       $FullFileName = $this->System->Modules['File']->GetDir($this->System->Modules['Finance']->DirectoryId).$FileName;
     470      $FullFileName = ModuleFile::Cast($this->System->GetModule('File'))->File->GetDir($DirectoryId).$FileName;
    465471      $Bill->SaveToFile($FullFileName);
    466472      if (file_exists($FullFileName))
  • trunk/Modules/Finance/Trade.php

    r874 r887  
    33class PageFinanceTaxFiling extends Page
    44{
    5   var $FullTitle = 'Daňová evidence';
    6   var $ShortTitle = 'Daňová evidence';
    7   var $ParentClass = 'PageFinance';
    85  var $StartEvidence = 0;
     6
     7  function __construct(System $System)
     8  {
     9    parent::__construct($System);
     10    $this->FullTitle = 'Daňová evidence';
     11    $this->ShortTitle = 'Daňová evidence';
     12    $this->ParentClass = 'PageFinance';
     13  }
    914
    1015  function GetTimePeriodBalance($StartTime, $EndTime)
     
    340345  function ShowSubjectAccount()
    341346  {
     347    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
     348
    342349    $Output = '<table style="width: 100%"><tr><td style="vertical-align: top;">';
    343350    $Output .= '<strong>Výpis příjmů/výdajů</strong>';
     
    424431  }
    425432
    426   function Show()
    427   {
    428     if (!$this->System->User->CheckPermission('Finance', 'TradingStatus'))
     433  function Show(): string
     434  {
     435    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'TradingStatus'))
    429436      return 'Nemáte oprávnění';
    430 
    431     $Finance = &$this->System->Modules['Finance'];
    432437
    433438    $Output = '';
  • trunk/Modules/Finance/UserState.php

    r874 r887  
    33class PageFinanceUserState extends Page
    44{
    5   var $FullTitle = 'Stav financí účastníka';
    6   var $ShortTitle = 'Stav financí';
    7   var $ParentClass = 'PageUser';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Stav financí účastníka';
     9    $this->ShortTitle = 'Stav financí';
     10    $this->ParentClass = 'PageUser';
     11  }
    812
    913  function ShowFinanceOperation($Subject)
     
    6973  }
    7074
    71   function Show()
     75  function Show(): string
    7276  {
    73     $Finance = &$this->System->Modules['Finance'];
     77    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    7478    $Finance->LoadMonthParameters(0);
    7579
     
    7781    if (array_key_exists('i', $_GET))
    7882    {
    79       if (!$this->System->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
     83      if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'Manage')) return 'Nemáte oprávnění';
    8084      $CustomerId = $_GET['i'];
    8185    } else
    8286    {
    83       if (!$this->System->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění';
    84       $UserId = $this->System->User->User['Id'];
     87      if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState')) return 'Nemáte oprávnění';
     88      $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'];
    8589      $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` WHERE `User`='.$UserId.' LIMIT 1');
    8690      if ($DbResult->num_rows > 0)
  • trunk/Modules/FinanceBankAPI/FileImport.php

    r884 r887  
    55class BankImport
    66{
    7   var $System;
    8   var $Database;
    9   var $BankAccount;
    10 
    11   function __construct($System)
     7  public System $System;
     8  public Database $Database;
     9  public int $BankAccount;
     10
     11  function __construct(System $System)
    1212  {
    1313    $this->Database = &$System->Database;
     
    1515  }
    1616
    17   function Import()
    18   {
     17  function Import(): string
     18  {
     19    return '';
    1920  }
    2021
     
    2324  }
    2425
    25   function PairOperations()
    26   {
     26  function PairOperations(): void
     27  {
     28    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    2729    $DbResult = $this->Database->select('FinanceBankImport', '*', 'FinanceOperation IS NULL');
    2830    while ($DbRow = $DbResult->fetch_assoc())
     
    3436        {
    3537          $DbRow2 = $DbResult2->fetch_assoc();
    36           if ($DbRow['Value'] >= 0) {
    37             $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
    38           } else {
    39             $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
     38          if ($DbRow['Value'] >= 0)
     39          {
     40            $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN, 'FinanceOperationGroup');
     41          } else
     42          {
     43            $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT, 'FinanceOperationGroup');
    4044          }
    4145          $Year = date('Y', MysqlDateToTime($DbRow['Time']));
    42           $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
    43           $DbResult3 = $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
     46          $BillCode = $Finance->GetNextDocumentLineNumberId($FinanceGroup['DocumentLine'], $Year);
     47          $this->Database->insert('FinanceOperation', array('Subject' => $DbRow2['Id'], 'Cash' => 0,
    4448            'ValueUser' => Abs($DbRow['Value']), 'Value' => 0, 'Taxable' => 1, 'BankAccount' => $DbRow['BankAccount'], 'Network' => 1,
    4549            'Time' => $DbRow['Time'], 'Text' => $DbRow['Description'], 'BillCode' => $BillCode, 'Group' => $FinanceGroup['Id']));
     
    6569class PageImportAPI extends Page
    6670{
    67   var $FullTitle = 'Import plateb přes API';
    68   var $ShortTitle = 'Import plateb přes API';
    69   var $ParentClass = 'PageFinance';
    70 
    71   function Import($Id)
     71  function __construct(System $System)
     72  {
     73    parent::__construct($System);
     74    $this->FullTitle = 'Import plateb přes API';
     75    $this->ShortTitle = 'Import plateb přes API';
     76    $this->ParentClass = 'PageFinance';
     77  }
     78
     79  function Import(int $Id): string
    7280  {
    7381    $Output = '';
     
    92100  }
    93101
    94   function Show()
    95   {
    96     if (!$this->System->User->CheckPermission('Finance', 'SubjectList'))
     102  function Show(): string
     103  {
     104    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList'))
    97105      return 'Nemáte oprávnění';
    98106
     
    104112class PageImportFile extends Page
    105113{
    106   var $FullTitle = 'Import plateb ze souboru';
    107   var $ShortTitle = 'Import plateb ze souboru';
    108   var $ParentClass = 'PageFinance';
    109 
    110   function Show()
     114  function __construct(System $System)
     115  {
     116    parent::__construct($System);
     117    $this->FullTitle = 'Import plateb ze souboru';
     118    $this->ShortTitle = 'Import plateb ze souboru';
     119    $this->ParentClass = 'PageFinance';
     120  }
     121
     122  function Show(): string
    111123  {
    112124    $Output = '';
    113     if (!$this->System->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
     125    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'SubjectList')) return 'Nemáte oprávnění';
    114126    if (array_key_exists('Operation', $_GET))
    115127    {
     
    121133  }
    122134
    123   function ShowForm()
     135  function ShowForm(): string
    124136  {
    125137    $Form = new Form($this->System->FormManager);
     
    156168  }
    157169
    158   function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group)
     170  function InsertMoney($Subject, $Value, $Cash, $Taxable, $Time, $Text, $Group): void
    159171  {
    160172    $Year = date('Y', $Time);
    161     $BillCode = $this->System->Modules['Finance']->GetNextDocumentLineNumberId(
     173    $BillCode = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetNextDocumentLineNumberId(
    162174      $Group['DocumentLine'], $Year);
    163175    $this->Database->insert('FinanceOperation', array('Text' => $Text,
     
    166178  }
    167179
    168   function Insert()
    169   {
    170     $Finance = $this->System->Modules['Finance'];
     180  function Insert(): string
     181  {
     182    $Finance = $ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    171183    $Output = '';
    172184
    173185    for ($I = $_POST['ItemCount'] - 1; $I >= 0 ; $I--)
    174186    {
    175       if ($_POST['Money'.$I] >= 0) {
     187      if ($_POST['Money'.$I] >= 0)
     188      {
    176189        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_IN,
    177190          'FinanceOperationGroup');
    178       } else {
     191      } else
     192      {
    179193        $FinanceGroup = $Finance->GetFinanceGroupById(OPERATION_GROUP_ACCOUNT_OUT,
    180194          'FinanceOperationGroup');
     
    185199        0, $_POST['Taxable'.$I], $Date, $_POST['Text'.$I], $FinanceGroup);
    186200      $Output .= $I.', ';
    187       $this->System->ModuleManager->Modules['Log']->NewRecord('Finance', 'NewPaymentInserted');
     201      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Finance', 'NewPaymentInserted');
    188202    }
    189203    return $Output;
  • trunk/Modules/FinanceBankAPI/FinanceBankAPI.php

    r874 r887  
    88class ModuleFinanceBankAPI extends AppModule
    99{
    10   function __construct($System)
     10  function __construct(System $System)
    1111  {
    1212    parent::__construct($System);
     
    1616    $this->License = 'GNU/GPLv3';
    1717    $this->Description = 'Communication through API to various banks, manual file import';
    18     $this->Dependencies = array('Finance', 'Scheduler');
     18    $this->Dependencies = array('Finance', 'Scheduler', 'IS');
    1919  }
    2020
    21   function DoInstall()
     21  function DoInstall(): void
    2222  {
    2323  }
    2424
    25   function DoUninstall()
     25  function DoUninstall(): void
    2626  {
    2727  }
    2828
    29   function DoStart()
     29  function DoStart(): void
    3030  {
    3131    $this->System->FormManager->RegisterClass('ImportBankFile', array(
     
    6060    ));
    6161
    62     $this->System->RegisterPage(array('finance', 'import-api'), 'PageImportAPI');
    63     $this->System->RegisterPage(array('finance', 'import-soubor'), 'PageImportFile');
     62    $this->System->RegisterPage(['finance', 'import-api'], 'PageImportAPI');
     63    $this->System->RegisterPage(['finance', 'import-soubor'], 'PageImportFile');
    6464
    65     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('FinanceBankAPI',
    66       array('ModuleFinanceBankAPI', 'ShowDashboardItem'));
     65    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('FinanceBankAPI',
     66      array($this, 'ShowDashboardItem'));
    6767  }
    6868
    69   function DoStop()
     69  function DoStop(): void
    7070  {
    7171  }
    7272
    73   function ShowDashboardItem()
     73  function ShowDashboardItem(): string
    7474  {
    7575    $DbResult = $this->Database->select('FinanceBankImport', 'COUNT(*)', '`FinanceOperation` IS NULL');
     
    7979  }
    8080
    81   function PresetItem($Item)
     81  function PresetItem(array $Item): array
    8282  {
    8383    $Preset = array();
    8484    if ($Item['Value'] < 0) $OperationGroupId = OPERATION_GROUP_ACCOUNT_OUT;
    8585       else $OperationGroupId = OPERATION_GROUP_ACCOUNT_IN;
    86     $FinanceGroup = $this->System->Modules['Finance']->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');
     86    $FinanceGroup = ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance->GetFinanceGroupById($OperationGroupId, 'FinanceOperationGroup');
    8787
    8888    $Preset = array(
     
    100100class ScheduleBankImport extends SchedulerTask
    101101{
    102   function Execute()
     102  function Execute(): string
    103103  {
    104104    $Output = '';
  • trunk/Modules/FinanceBankAPI/Fio.php

    r874 r887  
    55class Fio
    66{
    7   var $UserName;
    8   var $Password;
    9   var $Account;
     7  public string $UserName;
     8  public string $Password;
     9  public int $Account;
    1010
    11   function Import($TimeFrom, $TimeTo)
     11  function Import(int $TimeFrom, int $TimeTo): array
    1212  {
    1313    if ($this->UserName == '') throw new Exception('Missing value for UserName property.');
     
    5959  }
    6060
    61   function NoValidDataError($Response)
     61  function NoValidDataError(array $Response): void
    6262  {
    6363    // Try to get error message
    64     // If something go wrong fio show HTML login page and display error message
    65   $Response = implode('', $Response);
     64    // If something go wrong fio shows HTML login page and display error message
     65    $Response = implode('', $Response);
    6666    $ErrorMessageStart = '<div id="oldform_warning">';
    6767    if (strpos($Response, $ErrorMessageStart) !== false)
    68   {
    69     $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
    70     $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));
    71   } else $ErrorMessage = '';
    72   throw new Exception('No valid GPC data: '.$ErrorMessage);
     68    {
     69      $Response = substr($Response, strpos($Response, $ErrorMessageStart) + strlen($ErrorMessageStart));
     70      $ErrorMessage = trim(substr($Response, 0, strpos($Response, '</div>')));
     71    } else $ErrorMessage = '';
     72    throw new Exception('No valid GPC data: '.$ErrorMessage);
    7373  }
    7474}
  • trunk/Modules/FinanceBankAPI/FioAPI.php

    r874 r887  
    2323  }
    2424
    25   function Import($TimeFrom, $TimeTo)
     25  function Import(int $TimeFrom, int $TimeTo): array
    2626  {
    2727    if ($this->Token == '') throw new Exception('Missing value for Token property.');
     
    101101  }
    102102
    103   function NoValidDataError($Response)
     103  function NoValidDataError(array $Response): void
    104104  {
    105105    // Try to get error message
  • trunk/Modules/FinanceBankAPI/GPC.php

    r874 r887  
    66class GPC
    77{
    8   function ParseLine($Line)
     8  function ParseLine(string $Line): array
    99  {
    1010    $Line = ' '.$Line;
  • trunk/Modules/FinanceBankAPI/ImportFio.php

    r884 r887  
    55class ImportFio extends BankImport
    66{
    7   function Import()
     7  function Import(): string
    88  {
    99    $Fio = new FioAPI();
  • trunk/Modules/FinanceBankAPI/ImportPS.php

    r873 r887  
    1111  function ImportTxt($Content)
    1212  {
    13     $Finance = &$this->System->Modules['Finance'];
    14     $Data = explode("\n", $Content);
    1513  }
    1614
    1715  function ImportCVS($Content)
    1816  {
    19     $Finance = &$this->System->Modules['Finance'];
    20 
    2117    $Data = explode("\n", $Content);
    2218    foreach ($Data as $Key => $Value)
  • trunk/Modules/IS/IS.php

    r873 r887  
    55class PageIS extends Page
    66{
    7   var $FullTitle = 'Správa dat';
    8   var $ShortTitle = 'Správa dat';
    9   var $ParentClass = 'PagePortal';
    10   var $MenuItems;
    11   var $HideMenu;
    12   var $ShowActionName;
     7  public array $MenuItems;
     8  public bool $HideMenu;
     9  public bool $ShowActionName;
    1310
    1411  function __construct($System)
    1512  {
    1613    parent::__construct($System);
     14    $this->FullTitle = 'Správa dat';
     15    $this->ShortTitle = 'Správa dat';
     16    $this->ParentClass = 'PagePortal';
     17
    1718    $this->MenuItems = array();
    1819    $this->HideMenu = false;
     
    2021  }
    2122
    22   function Show()
    23   {
    24     if (!$this->System->User->CheckPermission('IS', 'Manage'))
     23  function Show(): string
     24  {
     25    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('IS', 'Manage'))
    2526      return 'Nemáte oprávnění';
    2627    $this->System->FormManager->ShowRelation = true;
     
    7879  }
    7980
    80   function Dashboard()
     81  function Dashboard(): string
    8182  {
    8283    $Output = '<strong>Nástěnka:</strong><br/>';
    83     foreach ($this->System->ModuleManager->Modules['IS']->DashboardItems as $Item)
     84    foreach (ModuleIS::Cast($this->System->GetModule('IS'))->DashboardItems as $Item)
    8485    {
    8586      if (is_string($Item['Callback'][0]))
     
    9394  }
    9495
    95   function ShowFavoriteAdd($Table, $ItemId)
    96   {
    97     $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     96  function ShowFavoriteAdd(string $Table, string $ItemId): string
     97  {
     98    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')');
    9899    if ($DbResult->num_rows > 0)
    99100    {
     
    101102    } else
    102103    {
    103       $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id']));
     104      $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']));
    104105      $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených');
    105106    }
     
    108109  }
    109110
    110   function ShowFavoriteDel($Table, $ItemId)
    111   {
    112     $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     111  function ShowFavoriteDel(string $Table, string $ItemId): string
     112  {
     113    $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')');
    113114    if ($DbResult->num_rows > 0)
    114115    {
     
    124125  }
    125126
    126   function LogChange($Form, $Action, $NewId, $OldId)
     127  function LogChange(Form $Form, string $Action, string $NewId, string $OldId): void
    127128  {
    128129    $Values = $Form->Definition['Table'].' (Id: '.$OldId.' => '.$NewId.'):'."\n";
     
    152153      }
    153154    }
    154     $this->System->ModuleManager->Modules['Log']->NewRecord('IS', $Action, $Values);
    155   }
    156 
    157   function ShowEdit($Table, $Id)
     155    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('IS', $Action, $Values);
     156  }
     157
     158  function ShowEdit(string $Table, string $Id): string
    158159  {
    159160    $Output = '';
    160161    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    161162      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    162     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     163    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
    163164      return $this->SystemMessage('Oprávnění', 'Nemáte oprávnění');
    164165    if (array_key_exists('o', $_GET))
     
    226227  }
    227228
    228   function ShowDelete($Table, $Id)
     229  function ShowDelete(string $Table, string $Id): string
    229230  {
    230231    $Output = '';
     
    232233      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    233234    $FormClass = $this->System->FormManager->Classes[$Table];
    234     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     235    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
    235236      return 'Nemáte oprávnění';
    236237    $DbResult = $this->Database->select($Table, '*', '`Id`='.$Id);
     
    266267  }
    267268
    268   function ShowAdd($Table, $Actions = array())
     269  function ShowAdd(string $Table, array $Actions = array()): string
    269270  {
    270271    $Output = '';
    271272    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    272273      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    273     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     274    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
    274275      return 'Nemáte oprávnění';
    275276    if (array_key_exists('o', $_GET))
     
    315316
    316317        //$this->Database->update($Table, 'Id='.$Id,
    317         //  array('UserCreate' => $this->System->User->User['Id'],
     318        //  array('UserCreate' => ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'],
    318319        //  'TimeCreate' => 'NOW()'));
    319320        } catch (Exception $E)
     
    357358  }
    358359
    359   function ShowAddSub($Table, $Filter = '', $Title = '')
    360   {
    361     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     360  function ShowAddSub(string $Table, string $Filter = '', string $Title = ''): string
     361  {
     362    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
    362363      return 'Nemáte oprávnění';
    363364    $this->BasicHTML = true;
     
    367368  }
    368369
    369   function ShowTabs($Tabs, $QueryParamName, $TabContent)
     370  function ShowTabs(array $Tabs, string $QueryParamName, string $TabContent): string
    370371  {
    371372    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     
    388389  }
    389390
    390   function ShowView($Table, $Id, $WithoutActions = false)
     391  function ShowView(string $Table, string $Id, bool $WithoutActions = false): string
    391392  {
    392393    if (!array_key_exists($Table, $this->System->FormManager->Classes))
    393394      return $this->SystemMessage('Chyba', 'Tabulka '.$Table.' nenalezena');
    394395    $FormClass = $this->System->FormManager->Classes[$Table];
    395     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     396    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read'))
    396397      return 'Nemáte oprávnění';
    397398
     
    473474  }
    474475
    475   function ShowTable($Table, $Filter = '', $Title = '', $RowActions = array(), $ExcludeColumn = '')
     476  function ShowTable(string $Table, string $Filter = '', string $Title = '', string $RowActions = '', string $ExcludeColumn = ''): string
    476477  {
    477478    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     
    673674  }
    674675
    675   function ShowSelect($Table, $Filter = '', $Title = '')
    676   {
    677     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     676  function ShowSelect(string $Table, string $Filter = '', string $Title = ''): string
     677  {
     678    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read'))
    678679      return 'Nemáte oprávnění';
    679680    $this->BasicHTML = true;
     
    686687  }
    687688
    688   function ShowMapSelect($Table, $Filter = '', $Title = '')
    689   {
    690     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write'))
     689  function ShowMapSelect(string $Table, string $Filter = '', string $Title = ''): string
     690  {
     691    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write'))
    691692      return 'Nemáte oprávnění';
    692693    $Map = new MapOpenStreetMaps($this->System);
     
    701702  }
    702703
    703   function ShowList($Table, $Filter = '', $Title = '', $ExcludeColumn = '', $ExcludeValue = '')
     704  function ShowList(string $Table, string $Filter = '', string $Title = '', string $ExcludeColumn = '', string $ExcludeValue = ''): string
    704705  {
    705706    $Output = '';
    706     if (defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Read'))
     707    if (defined('NEW_PERMISSION') and !ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Read'))
    707708      return 'Nemáte oprávnění';
    708709    if (!array_key_exists($Table, $this->System->FormManager->Classes))
     
    738739    if (array_key_exists('mi', $_GET))
    739740    {
    740       $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.$this->System->User->User['Id'].')');
     741      $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')');
    741742      if ($DbResult->num_rows > 0)
    742743      {
     
    761762  }
    762763
    763   function ShowFavorites()
     764  function ShowFavorites(): string
    764765  {
    765766    $this->MenuItems = array();
     
    768769      'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '.
    769770      'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '.
    770       'WHERE `MenuItemFavorite`.`User`='.$this->System->User->User['Id'].' '.
     771      'WHERE `MenuItemFavorite`.`User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].' '.
    771772      'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`');
    772773    while ($DbRow = $DbResult->fetch_assoc())
     
    778779  }
    779780
    780   function ShowMenu()
     781  function ShowMenu(): string
    781782  {
    782783    $this->MenuItems = array();
     
    794795  }
    795796
    796   function ShowMenuItem($Parent, $All = false)
     797  function ShowMenuItem(string $Parent, bool $All = false): string
    797798  {
    798799    $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">';
     
    810811        if ($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/>&nbsp;';
    811812          else $Image = '<img src="'.$this->System->Link('/images/favicons/'.$Icon).'"/>&nbsp;';
    812         //if ($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
     813        //if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION'))
    813814          $Output .= '<li>'.$Image.$LinkTitle.'</li>';
    814815        if ($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']);
     
    819820  }
    820821
    821   function TableToModule($Table)
     822  function TableToModule(string $Table): string
    822823  {
    823824    $DbResult = $this->Database->query('SELECT (SELECT `Name` FROM `Module` '.
     
    830831  }
    831832
    832   function ShowAction($Name, $Target, $Icon, $Confirm = '')
     833  function ShowAction(string $Name, string $Target, string $Icon, string $Confirm = ''): string
    833834  {
    834835    $Output = '<img alt="'.$Name.'" title="'.$Name.'" src="'.
     
    846847  var $DashboardItems;
    847848
    848   function __construct($System)
     849  function __construct(System $System)
    849850  {
    850851    parent::__construct($System);
     
    855856    $this->License = 'GNU/GPLv3';
    856857    $this->Description = 'User interface for generic information system';
    857     $this->Dependencies = array();
     858    $this->Dependencies = array('User');
    858859
    859860    $this->DashboardItems = array();
    860861  }
    861862
    862   function DoInstall()
    863   {
    864   }
    865 
    866   function DoUninstall()
    867   {
    868   }
    869 
    870   function DoStart()
    871   {
    872     $this->System->RegisterPage('is', 'PageIS');
     863  function DoInstall(): void
     864  {
     865  }
     866
     867  function DoUninstall(): void
     868  {
     869  }
     870
     871  function DoStart(): void
     872  {
     873    $this->System->RegisterPage(['is'], 'PageIS');
    873874    $this->System->FormManager->RegisterClass('MenuItem', array(
    874875      'Title' => 'Položky nabídky',
     
    914915  }
    915916
    916   function DoStop()
    917   {
    918   }
    919 
    920   function RegisterDashboardItem($Name, $Callback)
     917  function DoStop(): void
     918  {
     919  }
     920
     921  function RegisterDashboardItem(string $Name, callable $Callback): void
    921922  {
    922923    $this->DashboardItems[$Name] = array('Callback' => $Callback);
    923924  }
    924925
    925   function UnregisterDashboardItem($Name)
     926  function UnregisterDashboardItem(string $Name): void
    926927  {
    927928    unset($this->DashboardItems[$Name]);
    928929  }
     930
     931  static function Cast(AppModule $AppModule): ModuleIS
     932  {
     933    if ($AppModule instanceof ModuleIS)
     934    {
     935      return $AppModule;
     936    }
     937    throw new Exception('Expected ModuleIS type but '.gettype($AppModule));
     938  }
    929939}
  • trunk/Modules/Log/Log.php

    r874 r887  
    33class ModuleLog extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoInstall()
     16  function DoInstall(): void
    1717  {
    1818  }
    1919
    20   function DoUnInstall()
     20  function DoUnInstall(): void
    2121  {
    2222  }
    2323
    24   function DoStart()
     24  function DoStart(): void
    2525  {
    2626    $this->System->FormManager->RegisterClass('Log', array(
     
    3838      ),
    3939    ));
    40     $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Logs',
    41       'Channel' => 'log', 'Callback' => array('ModuleLog', 'ShowRSS'),
     40    ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Logs',
     41      'Channel' => 'log', 'Callback' => array($this, 'ShowRSS'),
    4242      'Permission' => array('Module' => 'Log', 'Operation' => 'RSS')));
    4343  }
    4444
    45   function DoStop()
     45  function DoStop(): void
    4646  {
    4747  }
    4848
    49   function NewRecord($Module, $Operation, $Value = '')
     49  function NewRecord(string $Module, string $Operation, string $Value = ''): void
    5050  {
    51     if (array_key_exists('User', $this->System->ModuleManager->Modules) and
    52       array_key_exists('Id', $this->System->User->User))
    53       $UserId = $this->System->User->User['Id'];
     51    if ($this->System->ModuleManager->ModulePresent('User') and
     52      array_key_exists('Id', ModuleUser::Cast($this->System->GetModule('User'))->User->User))
     53      $UserId = ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'];
    5454      else $UserId = NULL;
    5555    if (array_key_exists('REMOTE_ADDR', $_SERVER)) $IPAddress = $_SERVER['REMOTE_ADDR'];
     
    6060  }
    6161
    62   function ShowRSS()
     62  function ShowRSS(): string
    6363  {
    6464    $this->ClearPage = true;
     
    9898    return $RSS->Generate();
    9999  }
     100
     101  static function Cast(AppModule $AppModule): ModuleLog
     102  {
     103    if ($AppModule instanceof ModuleLog)
     104    {
     105      return $AppModule;
     106    }
     107    throw new Exception('Expected ModuleLog type but got '.gettype($AppModule));
     108  }
    100109}
  • trunk/Modules/Map/Map.php

    r874 r887  
    55class PageNetworkMap extends Page
    66{
    7   var $FullTitle = 'Mapa sítě';
    8   var $ShortTitle = 'Mapa sítě';
    9   var $ParentClass = 'PagePortal';
     7  function __construct(System $System)
     8  {
     9    parent::__construct($System);
     10    $this->FullTitle = 'Mapa sítě';
     11    $this->ShortTitle = 'Mapa sítě';
     12    $this->ParentClass = 'PagePortal';
     13  }
    1014  //var $Load = 'initialize()';
    1115  //var $Unload = 'GUnload()';
    1216
    13   function Show()
    14   {
    15     if (!$this->System->User->CheckPermission('Map', 'Show'))
     17  function Show(): string
     18  {
     19    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Map', 'Show'))
    1620      return 'Nemáte oprávnění';
    1721
     
    2327  }
    2428
    25   function ShowPosition()
     29  function ShowPosition(): string
    2630  {
    2731    $DbResult = $this->Database->select('MapPosition', '*', '`Id`='.$_GET['i']);
     
    4448  }
    4549
    46   function ShowMain()
     50  function ShowMain(): string
    4751  {
    4852    $Map = new MapOpenStreetMaps($this->System);
     
    242246class TypeMapPosition extends TypeString
    243247{
    244   function OnEdit($Item)
     248  function OnEdit(array $Item): string
    245249  {
    246250    $Output = parent::OnEdit($Item);
     
    255259class ModuleMap extends AppModule
    256260{
    257   function __construct($System)
     261  function __construct(System $System)
    258262  {
    259263    parent::__construct($System);
     
    263267    $this->License = 'GNU/GPL';
    264268    $this->Description = 'Show objects on Google maps';
    265     $this->Dependencies = array('Network');
     269    $this->Dependencies = array('Network', 'User');
    266270    $this->SupportedModels = array();
    267271  }
    268272
    269   function DoStart()
     273  function DoStart(): void
    270274  {
    271275    $this->System->Pages['map'] = 'PageNetworkMap';
     
    310314  }
    311315
    312   function DoInstall()
     316  function DoInstall(): void
    313317  {
    314318    $this->System->Database->query("CREATE TABLE IF NOT EXISTS `MapPosition` (
     
    320324  }
    321325
    322   function DoUninstall()
     326  function DoUninstall(): void
    323327  {
    324328    $this->Database->query('DROP TABLE `MapPosition`');
  • trunk/Modules/Map/MapAPI.php

    r874 r887  
    33class MapMarker
    44{
    5   var $Position;
    6   var $Text;
     5  public array $Position;
     6  public string $Text;
    77}
    88
    99class MapPolyLine
    1010{
    11   var $Points = array();
    12   var $Color = 'black';
     11  public array $Points = array();
     12  public string $Color = 'black';
    1313}
    1414
    1515class Map extends Model
    1616{
    17   var $Position;
    18   var $Zoom;
    19   var $Key;
     17  public array $Position;
     18  public int $Zoom;
     19  public string $Key;
    2020  var $OnClickObject;
    21   var $MarkerText;
    22   var $Markers;
    23   var $PolyLines;
     21  public string $MarkerText;
     22  public array $Markers;
     23  public array $PolyLines;
    2424
    25   function __construct($System)
     25  function __construct(System $System)
    2626  {
    2727    parent::__construct($System);
     
    3535  }
    3636
    37   function Show()
     37  function Show(): string
    3838  {
    3939    return '';
     
    4343class MapGoogle extends Map
    4444{
    45   function ShowPage($Page)
     45  function ShowPage(Page $Page): string
    4646  {
    4747    $Page->Load = 'initialize()';
     
    113113class MapOpenStreetMaps extends Map
    114114{
    115   function GetPageHeader()
     115  function GetPageHeader(): string
    116116  {
    117117    $Output = '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css"
     
    124124  }
    125125
    126   function ShowPage($Page)
     126  function ShowPage(Page $Page): string
    127127  {
    128128    $this->System->PageHeaders[] = array($this, 'GetPageHeader');
  • trunk/Modules/Meals/Meals.php

    r874 r887  
    33class PageEatingPlace extends Page
    44{
    5   var $FullTitle = 'Jídleníček jídelny Na kopečku';
    6   var $ShortTitle = 'Jídelníček';
    7   var $ParentClass = 'PagePortal';
    85  var $DayNames = array('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota');
    96  var $DayNamesShort = array('NE', 'PO', 'ÚT', 'ST', 'ČT', 'PÁ', 'SO');
     
    118  var $DayCount = 20;    // počet dopředu zobrazených dnů
    129
    13   function Show()
     10  function __construct(System $System)
     11  {
     12    parent::__construct($System);
     13    $this->FullTitle = 'Jídleníček jídelny Na kopečku';
     14    $this->ShortTitle = 'Jídelníček';
     15    $this->ParentClass = 'PagePortal';
     16  }
     17
     18  function Show(): string
    1419  {
    1520    if (count($this->System->PathItems) > 1)
     
    2126  }
    2227
    23   function ShowMenu()
     28  function ShowMenu(): string
    2429  {
    2530    //echo('Dnes je '.HumanDate(date('Y-m-d')).'<br>');
     
    4348  }
    4449
    45   function ShowPrint()
     50  function ShowPrint(): string
    4651  {
    4752    $this->ClearPage = true;
     
    9499  }
    95100
    96   function PrintTableRow($Row)
     101  function PrintTableRow(array $Row): string
    97102  {
    98103    global $LastWeekOfYear;
     
    120125  }
    121126
    122   function ShowEdit()
     127  function ShowEdit(): string
    123128  {
    124129    Header('Cache-Control: no-cache');
     
    136141        }
    137142        $Output .= '<div style="color: red; font-size: larger;">Menu uloženo!</div>';
    138         $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'MenuSave');
     143        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'MenuSave');
    139144      }
    140145      if ($_GET['action'] == 'saveinfo')
     
    143148        $this->Database->insert('MealsInfo', array('Info' => $_POST['info'], 'Price' => $_POST['price']));
    144149        $Output .= '<div style="color: red; font-size: larger;">Informační údaje uloženy!</div>';
    145         $this->System->ModuleManager->Modules['Log']->NewRecord('EatingPlace', 'InfoSave');
     150        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('EatingPlace', 'InfoSave');
    146151      }
    147152    }
     
    179184class ModuleMeals extends AppModule
    180185{
    181   function __construct($System)
     186  function __construct(System $System)
    182187  {
    183188    parent::__construct($System);
     
    191196  }
    192197
    193   function DoInstall()
    194   {
    195   }
    196 
    197   function DoUnInstall()
    198   {
    199   }
    200 
    201   function DoStart()
    202   {
    203     $this->System->RegisterPage('jidelna', 'PageEatingPlace');
     198  function DoInstall(): void
     199  {
     200  }
     201
     202  function DoUnInstall(): void
     203  {
     204  }
     205
     206  function DoStart(): void
     207  {
     208    $this->System->RegisterPage(['jidelna'], 'PageEatingPlace');
    204209  }
    205210}
  • trunk/Modules/Meteostation/Meteostation.php

    r874 r887  
    33class PageMeteo extends Page
    44{
    5   var $FullTitle = 'Stav meteostanice';
    6   var $ShortTitle = 'Meteostanice';
    7   var $ParentClass = 'PagePortal';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Stav meteostanice';
     9    $this->ShortTitle = 'Meteostanice';
     10    $this->ParentClass = 'PagePortal';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    1115    $Output = 'Stav meteostanice:<br/>';
     
    2226  var $URL;
    2327
    24   function DownloadData()
     28  function DownloadData(): void
    2529  {
    2630    $XmlData = simplexml_load_file($this->URL);
     
    5054  }
    5155
    52   function CreateImage($FileName)
     56  function CreateImage($FileName): void
    5357  {
    5458    $Image = new Image();
     
    6367  }
    6468
    65   function LoadFromDb()
     69  function LoadFromDb(): void
    6670  {
    6771    $DbResult = $this->Database->select('Meteostation', '*', 'Id = '.$this->Id);
     
    7781  var $Data;
    7882
    79   function __construct($System)
     83  function __construct(System $System)
    8084  {
    8185    parent::__construct($System);
     
    8892  }
    8993
    90   function DownloadAll()
     94  function DownloadAll(): void
    9195  {
    9296    $DbResult = $this->Database->select('MeteoStation', '*');
    9397    while ($DbRow = $DbResult->fetch_assoc())
    9498    {
    95       $MeteoStation = new MeteoStation();
     99      $MeteoStation = new MeteoStation($this->System);
    96100      $MeteoStation->Id = $DbRow['Id'];
    97101      $MeteoStation->LoadFromDb();
     
    102106
    103107
    104   function DoInstall()
     108  function DoInstall(): void
    105109  {
    106110  }
    107111
    108   function DoUninstall()
     112  function DoUninstall(): void
    109113  {
    110114  }
    111115
    112   function DoStart()
     116  function DoStart(): void
    113117  {
    114     $this->System->RegisterPage('meteo', 'PageMeteo');
     118    $this->System->RegisterPage(['meteo'], 'PageMeteo');
    115119  }
    116120
    117   function DoStop()
     121  function DoStop(): void
    118122  {
    119123  }
  • trunk/Modules/Network/HostList.php

    r874 r887  
    55class PageHostList extends Page
    66{
    7   var $FullTitle = 'Seznam registrovaných počítačů';
    8   var $ShortTitle = 'Seznam počítačů';
    9   var $ParentClass = 'PageNetwork';
     7  function __construct(System $System)
     8  {
     9    parent::__construct($System);
     10    $this->FullTitle = 'Seznam registrovaných počítačů';
     11    $this->ShortTitle = 'Seznam počítačů';
     12    $this->ParentClass = 'PageNetwork';
     13  }
    1014
    11   function Show()
     15  function Show(): string
    1216  {
    13     if (!$this->System->User->CheckPermission('Network', 'ShowHostList'))
     17    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowHostList'))
    1418      return 'Nemáte oprávnění';
    1519
  • trunk/Modules/Network/Hosting.php

    r874 r887  
    33class PageHosting extends Page
    44{
    5   var $FullTitle = 'Hostované projekty';
    6   var $ShortTitle = 'Hostované projekty';
    7   var $ParentClass = 'PageNetwork';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Hostované projekty';
     9    $this->ShortTitle = 'Hostované projekty';
     10    $this->ParentClass = 'PageNetwork';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    1115    $Output = '<br /><table class="WideTable"><tr><th>Název projektu</th><th>Založeno</th><th>Umístění na serveru</th><th>Zodpovědná osoba</th></tr>';
  • trunk/Modules/Network/Network.php

    r879 r887  
    88class PageFrequencyPlan extends Page
    99{
    10   var $FullTitle = 'Výpis obsazení frekvenčních kanálů';
    11   var $ShortTitle = 'Frekvenční plán';
    12   var $ParentClass = 'PageNetwork';
    13 
    14   function Show()
     10  function __construct(System $System)
     11  {
     12    parent::__construct($System);
     13    $this->FullTitle = 'Výpis obsazení frekvenčních kanálů';
     14    $this->ShortTitle = 'Frekvenční plán';
     15    $this->ParentClass = 'PageNetwork';
     16  }
     17
     18  function Show(): string
    1519  {
    1620    // http://en.wikipedia.org/wiki/List_of_WLAN_channels
     
    7579class PageNetwork extends Page
    7680{
    77   var $FullTitle = 'Technické informace o síti';
    78   var $ShortTitle = 'Síť';
    79   var $ParentClass = 'PagePortal';
    80 
    81   function Show()
    82   {
    83     if (count($this->System->PathItems) > 1)
    84     {
    85       $Output = $this->PageNotFound();
    86     } else $Output = $this->ShowInformation();
    87     return $Output;
    88   }
    89 
    90   function ShowInformation()
    91   {
    92     if (!$this->System->User->CheckPermission('Network', 'ShowInfo'))
     81  function __construct(System $System)
     82  {
     83    parent::__construct($System);
     84    $this->FullTitle = 'Technické informace o síti';
     85    $this->ShortTitle = 'Síť';
     86    $this->ParentClass = 'PagePortal';
     87  }
     88
     89  function Show(): string
     90  {
     91    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Network', 'ShowInfo'))
    9392      return 'Nemáte oprávnění';
    9493
     
    102101class ModuleNetwork extends AppModule
    103102{
    104   var $MinNotifyTime;
    105 
    106   function __construct($System)
     103  public int $MinNotifyTime;
     104
     105  function __construct(System $System)
    107106  {
    108107    parent::__construct($System);
     
    112111    $this->License = 'GNU/GPLv3';
    113112    $this->Description = 'Networking related tools';
    114     $this->Dependencies = array('Notify');
     113    $this->Dependencies = array('Notify', 'IS');
    115114
    116115    // TODO: Make notify time configurable
     
    118117  }
    119118
    120   function DoInstall()
    121   {
    122   }
    123 
    124   function DoUninstall()
    125   {
    126   }
    127 
    128   function DoStart()
    129   {
    130     $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkReachability',
     119  function DoInstall(): void
     120  {
     121  }
     122
     123  function DoUninstall(): void
     124  {
     125  }
     126
     127  function DoStart(): void
     128  {
     129    ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkReachability',
    131130      array($this, 'ReachabilityCheck'));
    132     $this->System->ModuleManager->Modules['Notify']->RegisterCheck('NetworkPort',
     131    ModuleNotify::Cast($this->System->GetModule('Notify'))->RegisterCheck('NetworkPort',
    133132      array($this, 'PortCheck'));
    134133
    135     $this->System->RegisterPage('network', 'PageNetwork');
    136     $this->System->RegisterPage(array('network', 'administration'), 'PageNetworkAdministration');
    137     $this->System->RegisterPage(array('network', 'subnet'), 'PageSubnet');
    138     $this->System->RegisterPage(array('network', 'user-hosts'), 'PageNetworkHostList');
    139     $this->System->RegisterPage(array('network', 'hosting'),'PageHosting');
    140     $this->System->RegisterPage(array('network', 'hosts'), 'PageHostList');
    141     $this->System->RegisterPage(array('network', 'frequency-plan'), 'PageFrequencyPlan');
    142 
    143     $this->System->RegisterCommandLine('networklog_import', array($this, 'ImportNetworkLog'));
     134    $this->System->RegisterPage(['network'], 'PageNetwork');
     135    $this->System->RegisterPage(['network', 'administration'], 'PageNetworkAdministration');
     136    $this->System->RegisterPage(['network', 'subnet'], 'PageSubnet');
     137    $this->System->RegisterPage(['network', 'user-hosts'], 'PageNetworkHostList');
     138    $this->System->RegisterPage(['network', 'hosting'],'PageHosting');
     139    $this->System->RegisterPage(['network', 'hosts'], 'PageHostList');
     140    $this->System->RegisterPage(['network', 'frequency-plan'], 'PageFrequencyPlan');
     141
     142    $this->System->RegisterCommandLine('networklog_import', 'Imports network logs from remote server', array($this, 'ImportNetworkLog'));
    144143
    145144    $this->System->FormManager->RegisterClass('NetworkDomainAlias', array(
     
    750749    ));
    751750
    752     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Network',
    753       array('ModuleNetwork', 'ShowDashboardItem'));
     751    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Network',
     752      array($this, 'ShowDashboardItem'));
    754753
    755754    $this->System->RegisterModel('NetworkDevice', array(
     
    761760  }
    762761
    763   function AfterInsertNetworkDevice($Form)
     762  function AfterInsertNetworkDevice(Form $Form): void
    764763  {
    765764    $this->System->Models['NetworkDevice']->DoOnChange();
    766765  }
    767766
    768   function AfterModifyNetworkDevice($Form, $Id)
     767  function AfterModifyNetworkDevice(Form $Form, string $Id): void
    769768  {
    770769    $this->System->Models['NetworkDevice']->DoOnChange();
    771770  }
    772771
    773   function AfterInsertNetworkInterface($Form)
     772  function AfterInsertNetworkInterface(Form $Form): void
    774773  {
    775774    $this->System->Models['NetworkInterface']->DoOnChange();
    776775  }
    777776
    778   function AfterModifyNetworkInterface($Form, $Id)
     777  function AfterModifyNetworkInterface(Form $Form, string $Id): void
    779778  {
    780779    $this->System->Models['NetworkInterface']->DoOnChange();
    781780  }
    782781
    783   function BeforeDeleteNetworkInterface($Form, $Id)
     782  function BeforeDeleteNetworkInterface(Form $Form, string $Id): void
    784783  {
    785784    $this->Database->query('DELETE FROM `NetworkInterfaceUpDown` WHERE `Interface`='.$Id);
     
    791790  }
    792791
    793   function ImportNetworkLog($Parameters)
     792  function ImportNetworkLog(array $Parameters): void
    794793  {
    795794    global $Config;
     
    813812      {
    814813        $DbRow2 = $DbResult2->fetch_assoc();
    815         $DeviceID = $DbRow2['Device'];
     814        $DeviceId = $DbRow2['Device'];
    816815        $this->System->Database->insert('NetworkDeviceLog', array('Time' => $DbRow['ReceivedAt'],
    817816          'Device' => $DeviceId, 'Message' => $DbRow['Message'], 'Tags' => $DbRow['SysLogTag']));
     
    820819  }
    821820
    822   function ShowDashboardItem()
     821  function ShowDashboardItem(): string
    823822  {
    824823    $Output = '';
     
    841840  }
    842841
    843   function DoStop()
    844   {
    845   }
    846 
    847   function OnlineList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
     842  function DoStop(): void
     843  {
     844  }
     845
     846  function OnlineList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array
    848847  {
    849848    $Time = time();
     
    886885  }
    887886
    888   function ReachabilityCheck()
     887  function ReachabilityCheck(): array
    889888  {
    890889    $NewOnline = $this->OnlineList('Nově online', 1, 0, 0);
     
    898897  }
    899898
    900   function PortCheckList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
     899  function PortCheckList(string $Title, string $OnlineNow, string $OnlinePrevious, int $MinDuration): array
    901900  {
    902901    $Time = time();
     
    937936  }
    938937
    939   function PortCheck()
     938  function PortCheck(): array
    940939  {
    941940    $Output = '';
  • trunk/Modules/Network/Subnet.php

    r874 r887  
    33class PageSubnet extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `NetworkSubnet`');
  • trunk/Modules/Network/UserHosts.php

    r874 r887  
    33class PageNetworkHostList extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    global $Config;
    1616
    17     if ($this->System->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');
     17    if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == '') return $this->SystemMessage('Nepovolený přístup', 'Nemáte oprávnění pro tuto operaci');
    1818    $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
    1919    $Output .= '<tr><th>Jméno počítače</th><th>Místní adresa</th><th>Veřejná adresa</th><th>Fyzická adresa</th><th>Typ</th><th>Naposledy online</th></tr>';
    2020    $DbResult = $this->Database->query('SELECT NetworkDevice.*, NetworkDeviceType.Name AS HostType FROM NetworkDevice '.
    2121      'LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type '.
    22       'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.$this->System->User->User['Id'].') ORDER BY NetworkDevice.Name');
     22      'WHERE NetworkDevice.Used = 1 AND NetworkDevice.Member = (SELECT Customer FROM UserCustomerRel WHERE User='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].') ORDER BY NetworkDevice.Name');
    2323    while ($Device = $DbResult->fetch_assoc())
    2424    {
  • trunk/Modules/NetworkConfig/Generate.php

    r873 r887  
    22
    33if (isset($_SERVER['REMOTE_ADDR'])) die();
    4 include_once(dirname(__FILE__).'/../../Application/System.php');
     4include_once(dirname(__FILE__).'/../../Application/Core.php');
    55$System = new Core();
    66$System->ShowPage = false;
  • trunk/Modules/NetworkConfig/NetworkConfig.php

    r874 r887  
    55  var $ConfigItems;
    66
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1717  }
    1818
    19   function DoInstall()
     19  function DoInstall(): void
    2020  {
    2121  }
    2222
    23   function DoUnInstall()
     23  function DoUnInstall(): void
    2424  {
    2525  }
    2626
    27   function DoStart()
     27  function DoStart(): void
    2828  {
    2929    $this->System->FormManager->RegisterClass('NetworkConfiguration', array(
     
    5555      'States' => array('Neplánováno', 'V plánu', 'Provádí se'),
    5656    ));
    57    
    58     $this->System->RegisterCommandLine('config', array($this, 'Config'));
     57
     58    $this->System->RegisterCommandLine('config', 'Configures network services.', array($this, 'Config'));
    5959    $this->System->Models['NetworkDevice']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6060    $this->System->Models['NetworkInterface']->RegisterOnChange('NetworkConfig', array($this, 'DoNetworkChange'));
    6161  }
    62  
    63   function DoNetworkChange()
     62
     63  function DoNetworkChange(): void
    6464  {
    6565    $this->Database->query('UPDATE `NetworkConfiguration` SET `Changed`=1 WHERE '.
     
    6767  }
    6868
    69   function RegisterConfigItem($Name, $ClassName)
     69  function RegisterConfigItem(string $Name, string $ClassName): void
    7070  {
    7171    $this->ConfigItems[$Name] = $ClassName;
    7272  }
    7373
    74   function UnregisterConfigItem($Name)
     74  function UnregisterConfigItem(string $Name): void
    7575  {
    7676    unset($this->ConfigItems[$Name]);
    7777  }
    7878
    79   function Config($Parameters)
     79  function Config(array $Parameters): void
    8080  {
    8181    $Output = '';
     
    9090      } else $Output = 'Config item '.$ConfigItemName.' not found';
    9191    } else $Output = 'Not enough parameters';
    92     return $Output;
     92    echo($Output);
     93  }
     94
     95  static function Cast(AppModule $AppModule): ModuleNetworkConfig
     96  {
     97    if ($AppModule instanceof ModuleNetworkConfig)
     98    {
     99      return $AppModule;
     100    }
     101    throw new Exception('Expected ModuleNetworkConfig type but got '.gettype($AppModule));
    93102  }
    94103}
     
    96105class NetworkConfigItem extends Model
    97106{
    98   function Run()
     107  function Run(): void
    99108  {
    100 
    101109  }
    102110}
  • trunk/Modules/NetworkConfigAirOS/Generators/Signal.php

    r873 r887  
    55class ConfigAirOSSignal extends NetworkConfigItem
    66{
    7   function ReadWirelessRegistration()
     7  function ReadWirelessRegistration(): void
    88  {
    99    $Time = time();
     
    1919      //$SSHClient->Debug = true;
    2020      $Result = $SSHClient->Execute('wstalist');
    21       if (count($Result) > 0) 
    22       {     
     21      if (count($Result) > 0)
     22      {
    2323      //print_r($Result);
    2424      $Array = json_decode(implode("\n", $Result), true);
     
    4444      echo("\n");
    4545      } else echo("Empty response\n");
    46      
    4746    }
    4847  }
    4948
    50   function Run()
     49  function Run(): void
    5150  {
    5251    RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
  • trunk/Modules/NetworkConfigAirOS/NetworkConfigAirOS.php

    r781 r887  
    55class ModuleNetworkConfigAirOS extends AppModule
    66{
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1616  }
    1717
    18   function DoInstall()
     18  function DoInstall(): void
    1919  {
    2020  }
    2121
    22   function DoUnInstall()
     22  function DoUnInstall(): void
    2323  {
    2424  }
    2525
    26   function DoStart()
     26  function DoStart(): void
    2727  {
    28     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');
     28    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('airos-signal', 'ConfigAirOSSignal');
    2929  }
    3030}
  • trunk/Modules/NetworkConfigLinux/Generators/CheckPorts.php

    r874 r887  
    33class ConfigCheckPorts extends NetworkConfigItem
    44{
    5   function CheckPortStatus($IP, $Port, $Protocol = 'tcp')
     5  function CheckPortStatus($IP, $Port, $Protocol = 'tcp'): int
    66  {
    77    $Timeout = 1;
     
    1717    return $State;
    1818  }
    19  
    20   function CheckPorts()
     19
     20  function CheckPorts(): void
    2121  {
    2222    $StartTime = time();
     
    7777  }
    7878
    79   function Run()
     79  function Run(): void
    8080  {
    8181    RepeatFunction(60, array($this, 'CheckPorts'));
  • trunk/Modules/NetworkConfigLinux/Generators/DNS.php

    r873 r887  
    77class ConfigDNS extends NetworkConfigItem
    88{
    9   function GenerateDNS($DNS)
     9  function GenerateDNS(array $DNS): void
    1010  {
    1111    $Output = '$ORIGIN '.$DNS['Domain'].'.'."\n".
     
    147147  }
    148148
    149   function Run()
     149  function Run(): void
    150150  {
    151151    $BaseDomain = 'zdechov.net';
  • trunk/Modules/NetworkConfigLinux/Generators/Latency.php

    r873 r887  
    33class ConfigLatency extends NetworkConfigItem
    44{
    5   function PingHosts()
     5  function PingHosts(): void
    66  {
    77    $Timeout = 2000; // ms
     
    2323
    2424    $Queries = array();
    25     foreach ($Output as $Index => $Line) 
     25    foreach ($Output as $Index => $Line)
    2626    {
    2727      $IP = substr($Line, 0, strPos($Line, ' '));
     
    3535  }
    3636
    37   function Run()
     37  function Run(): void
    3838  {
    3939    RepeatFunction(10 * 60, array($this, 'PingHosts'));
  • trunk/Modules/NetworkConfigLinux/NetworkConfigLinux.php

    r824 r887  
    77class ModuleNetworkConfigLinux extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    30     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-dns', 'ConfigDNS');
    31     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts');
    32     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('linux-latency', 'ConfigLatency');
     30    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-dns', 'ConfigDNS');
     31    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-checkports', 'ConfigCheckPorts');
     32    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('linux-latency', 'ConfigLatency');
    3333  }
    3434}
  • trunk/Modules/NetworkConfigRouterOS/Generators/DHCP.php

    r873 r887  
    44class ConfigRouterOSDHCP extends NetworkConfigItem
    55{
    6   function Run()
     6  function Run(): void
    77  {
    88    $Path = array('ip', 'dhcp-server', 'lease');
  • trunk/Modules/NetworkConfigRouterOS/Generators/DNS.php

    r873 r887  
    33class ConfigRouterOSDNS extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'dns', 'static');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallFilter.php

    r873 r887  
    33class ConfigRouterOSFirewallFilter extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'firewall', 'filter');
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallMangle.php

    r873 r887  
    33class ConfigRouterOSFirewallMangle extends NetworkConfigItem
    44{
    5   function ProcessNode($Node)
     5  function ProcessNode($Node): void
    66  {
    77    global $InetInterface, $ItemsFirewall;
    88
    9     foreach ($Node['Items'] as $Index => $Item)
     9    foreach ($Node['Items'] as $Item)
    1010    {
    1111      if (count($Item['Items']) == 0)
     
    4747  }
    4848
    49   function Run()
     49  function Run(): void
    5050  {
    5151    $this->RunIPv4();
     
    5353  }
    5454
    55   function RunIPv4()
     55  function RunIPv4(): void
    5656  {
    5757    global $ItemsFirewall;
     
    149149  }
    150150
    151   function RunIPv6()
     151  function RunIPv6(): void
    152152  {
    153153    global $ItemsFirewall;
  • trunk/Modules/NetworkConfigRouterOS/Generators/FirewallNAT.php

    r873 r887  
    33class ConfigRouterOSFirewallNAT extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('ip', 'firewall', 'nat');
  • trunk/Modules/NetworkConfigRouterOS/Generators/Netwatch.php

    r873 r887  
    33class ConfigRouterOSNetwatch extends NetworkConfigItem
    44{
    5   function Run()
     5  function Run(): void
    66  {
    77    $Path = array('tool', 'netwatch');
  • trunk/Modules/NetworkConfigRouterOS/Generators/NetwatchImport.php

    r873 r887  
    33class ConfigRouterOSNetwatchImport extends NetworkConfigItem
    44{
    5   function NetwatchImport()
     5  function NetwatchImport(): void
    66  {
    77    $StartTime = time();
     
    4444    $Queries = array();
    4545    $QueriesInsert = array();
    46     foreach ($Interfaces as $Index => $Interface)
     46    foreach ($Interfaces as $Interface)
    4747    {
    4848      // Update last online time if still online
     
    103103  }
    104104
    105   function Run()
     105  function Run(): void
    106106  {
    107107    RepeatFunction(10, array($this, 'NetwatchImport'));
  • trunk/Modules/NetworkConfigRouterOS/Generators/Queue.php

    r873 r887  
    1414  }
    1515
    16   function Print()
     16  function Print(): string
    1717  {
    1818    $Output = '(Min: '.$this->Min.' Max: '.$this->Max;
     
    4646  }
    4747
    48   function CheckName($Name, &$UsedNames)
     48  function CheckName($Name, &$UsedNames): void
    4949  {
    5050    if (in_array($Name, $UsedNames)) die("\n".'Duplicate name: '.$Name);
     
    5252  }
    5353
    54   function GetCommands(&$UsedNames = null)
     54  function GetCommands(&$UsedNames = null): array
    5555  {
    5656    if ($UsedNames == null) $UsedNames = array();
     
    7272  }
    7373
    74   function GetParentName(string $Suffix)
     74  function GetParentName(string $Suffix): string
    7575  {
    7676    if ($this->Parent != null) return $this->Parent->Name.$Suffix;
     
    7878  }
    7979
    80   function UpdateMinSpeeds()
     80  function UpdateMinSpeeds(): void
    8181  {
    8282    if (($this->LimitIn->Min == 0) or ($this->LimitOut->Min == 0))
     
    100100class SpeedLimitItems extends GenericList
    101101{
    102   function AddNew(string $Name, SpeedLimitItem $Parent = null)
     102  function AddNew(string $Name, SpeedLimitItem $Parent = null): SpeedLimitItem
    103103  {
    104104    $Item = new SpeedLimitItem($Name, $Parent);
    105     $Item->LimitIn = new SpeedLimit();
    106     $Item->LimitOut = new SpeedLimit();
     105    $Item->LimitIn = new SpeedLimit(0, 0);
     106    $Item->LimitOut = new SpeedLimit(0, 0);
    107107    $this->Items[] = $Item;
    108108    return $Item;
     
    119119  }
    120120
    121   function GetCommands(&$UsedNames)
     121  function GetCommands(&$UsedNames): array
    122122  {
    123123    $Output = array();
     
    137137  var $SpeedLimits;
    138138
    139   function Run()
     139  function Run(): void
    140140  {
    141141    $PathQueue = array('queue', 'tree');
     
    149149    $this->UsedNames = array();
    150150
    151     $Finance = &$this->System->Modules['Finance'];
     151    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    152152    $Finance->LoadMonthParameters(0);
    153153
     
    280280  }
    281281
    282   function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem)
     282  function BuildSpeedLimit(&$SpeedLimit, $TopSpeedLimitItem): void
    283283  {
    284284    $SpeedLimitName = $SpeedLimit['Name'].'-grp';
     
    297297  }
    298298
    299   function LoadSpeedLimits($SpeedLimitItem)
     299  function LoadSpeedLimits($SpeedLimitItem): void
    300300  {
    301301    echo('Limit groups: ');
     
    326326  }
    327327
    328   function UpdateMinSpeed($DeviceId)
     328  function UpdateMinSpeed($DeviceId): void
    329329  {
    330330    $MinSpeed = 0;
     
    340340
    341341  // Calculate maximum real speed available for each network device Start with main router and continue with adjecement nodes.
    342   function BuildTree($RootDeviceId, $BaseSpeed)
     342  function BuildTree($RootDeviceId, $BaseSpeed): void
    343343  {
    344344    // Load network devices
     
    438438  }
    439439
    440   function BuildQueueItems($DeviceId, $SpeedLimitParent)
     440  function BuildQueueItems($DeviceId, $SpeedLimitParent): void
    441441  {
    442442    $Device = $this->Devices[$DeviceId];
     
    475475  }
    476476
    477   function RunTopology()
     477  function RunTopology(): void
    478478  {
    479479    $PathQueue = array('queue', 'tree');
     
    487487    $this->UsedNames = array();
    488488
    489     $Finance = &$this->System->Modules['Finance'];
     489    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    490490    $Finance->LoadMonthParameters(0);
    491491
  • trunk/Modules/NetworkConfigRouterOS/Generators/Signal.php

    r874 r887  
    33class ConfigRouterOSSignal extends NetworkConfigItem
    44{
    5   function ReadWirelessRegistration()
     5  function ReadWirelessRegistration(): void
    66  {
    77    $Time = time();
     
    6666    $this->Database->Transaction($Queries);
    6767  }
    68  
    69   function StripUnits($Value)
     68
     69  function StripUnits($Value): string
    7070  {
    7171    if (strpos($Value, '-') !== false) $Value = substr($Value, 0, strpos($Value, '-') - 1); // without channel info
    7272    if (substr($Value, -3, 3) == "MHz") $Value = substr($Value, 0, -3); // without MHz unit
    73     if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit   
    74     if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit   
     73    if (substr($Value, -4, 4) == "Mbps") $Value = substr($Value, 0, -4); // without Mbps unit
     74    if (substr($Value, -3, 3) == "Mbp") $Value = substr($Value, 0, -3); // without Mbp unit
    7575    if (substr($Value, -1, 1) == "M") $Value = substr($Value, 0, -1); // without M unit
    7676    return $Value;
    7777  }
    7878
    79   function Run()
     79  function Run(): void
    8080  {
    8181    RepeatFunction(60 * 60, array($this, 'ReadWirelessRegistration'));
  • trunk/Modules/NetworkConfigRouterOS/NetworkConfigRouterOS.php

    r874 r887  
    1818class ModuleNetworkConfigRouterOS extends AppModule
    1919{
    20   function __construct($System)
     20  function __construct(System $System)
    2121  {
    2222    parent::__construct($System);
     
    2929  }
    3030
    31   function DoInstall()
     31  function DoInstall(): void
    3232  {
    3333  }
    3434
    35   function DoUnInstall()
     35  function DoUnInstall(): void
    3636  {
    3737  }
    3838
    39   function DoStart()
     39  function DoStart(): void
    4040  {
    4141    $this->System->Pages['zdarma'] = 'PageFreeAccess';
    42     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS');
    43     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');
    44     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal');
    45     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch');
    46     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport');
    47     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter');
    48     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT');
    49     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle');
    50     $this->System->ModuleManager->Modules['NetworkConfig']->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue');
     42    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dns', 'ConfigRouterOSDNS');
     43    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-dhcp', 'ConfigRouterOSDHCP');
     44    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-signal', 'ConfigRouterOSSignal');
     45    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch', 'ConfigRouterOSNetwatch');
     46    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-netwatch-import', 'ConfigRouterOSNetwatchImport');
     47    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-filter', 'ConfigRouterOSFirewallFilter');
     48    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-nat', 'ConfigRouterOSFirewallNAT');
     49    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-firewall-mangle', 'ConfigRouterOSFirewallMangle');
     50    ModuleNetworkConfig::Cast($this->System->GetModule('NetworkConfig'))->RegisterConfigItem('routeros-queue', 'ConfigRouterOSQueue');
    5151  }
    5252}
     
    5454class PageFreeAccess extends Page
    5555{
    56   var $FullTitle = 'Přístup zdarma k Internetu';
    57   var $ShortTitle = 'Internet zdarma';
    58   var $ParentClass = 'PagePortal';
    59   var $AddressList = 'free-access';
    60   var $Timeout;
     56  public string $AddressList = 'free-access';
     57  public int $Timeout;
    6158
    62   function __construct($System)
     59  function __construct(System $System)
    6360  {
    6461    parent::__construct($System);
     62    $this->FullTitle = 'Přístup zdarma k Internetu';
     63    $this->ShortTitle = 'Internet zdarma';
     64    $this->ParentClass = 'PagePortal';
     65
    6566    $this->Timeout = 24 * 60 * 60;
    6667  }
    6768
    68   function Show()
     69  function Show(): string
    6970  {
    7071    $IPAddress = GetRemoteAddress();
    7172    $Output = 'Vaše IP adresa je: '.$IPAddress.'<br/>';
    72     if (IsInternetAddr($IPAddress)) {
     73    if (IsInternetAddr($IPAddress))
     74    {
    7375      $Output .= '<p>Internet zdarma je dostupný pouze z vnitřní sítě.</p>';
    7476      return $Output;
     
    117119class ScheduleConfigureFreeAccess extends SchedulerTask
    118120{
    119   function Execute()
     121  function Execute(): string
    120122  {
    121123    $Output = '';
  • trunk/Modules/NetworkConfigRouterOS/Routerboard.php

    r874 r887  
    1919  }
    2020
    21   function Execute($Commands)
     21  function Execute(array $Commands): array
    2222  {
    2323    $Output = array();
     
    4444  }
    4545
    46   function ExecuteBatch($Commands)
     46  function ExecuteBatch(string $Commands): string
    4747  {
    4848    $Commands = trim($Commands);
     
    6565  }
    6666
    67   function ItemGet($Path)
     67  function ItemGet(array $Path): array
    6868  {
    6969    $Result = $this->Execute(implode(' ', $Path).' print');
     
    8282  }
    8383
    84   function ListGet($Path, $Properties, $Conditions = array())
     84  function ListGet(array $Path, array $Properties, array $Conditions = array()): array
    8585  {
    8686    $PropertyList = '"';
     
    116116  }
    117117
    118   function ListGetPrint($Path, $Properties, $Conditions = array())
     118  function ListGetPrint($Path, $Properties, $Conditions = array()): array
    119119  {
    120120    $ConditionList = '';
     
    151151  }
    152152
    153   function ListEraseAll($Path)
     153  function ListEraseAll(array $Path): void
    154154  {
    155155    $this->Execute(implode(' ', $Path).' { remove [find] }');
    156156  }
    157157
    158   function ListUpdate($Path, $Properties, $Values, $Condition = array(), $UsePrint = false)
     158  function ListUpdate(array $Path, array $Properties, array $Values, array $Condition = array(), bool $UsePrint = false): array
    159159  {
    160160    // Get current list from routerboard
  • trunk/Modules/NetworkConfigRouterOS/Routerboard2.php

    r874 r887  
    1111  );
    1212
    13   function Execute($Commands)
     13  function Execute($Commands): array
    1414  {
    1515    if (is_array($Commands)) $Commands = implode(';', $Commands);
     
    1717  }
    1818
    19   function GetItem($Command)
     19  function GetItem($Command): array
    2020  {
    2121    $Result = $this->Execute($Command);
     
    2525    {
    2626      $ResultLineParts = explode(' ', trim($ResultLine));
    27       if ($ResultLineParts[1]{0} == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
     27      if ($ResultLineParts[1][0] == '"') $ResultLineParts[1] = substr($ResultLineParts[1], 1, -1); // Remove quotes
    2828      $List[substr($ResultLineParts[0], 0, -1)] = $ResultLineParts[1];
    2929    }
     
    3131  }
    3232
    33   function GetList($Command, $Properties)
     33  function GetList($Command, $Properties): array
    3434  {
    3535    $PropertyList = '"';
     
    5555  }
    5656
    57   function GetSystemResource()
     57  function GetSystemResource(): array
    5858  {
    5959    return $this->GetItem('/system resource print');
    6060  }
    6161
    62   function GetFirewallFilterList()
     62  function GetFirewallFilterList(): array
    6363  {
    6464    return $this->GetList('/ip firewall nat', array('src-address', 'dst-address', 'bytes'));
    6565  }
    6666
    67   function GetDHCPServerLeasesList()
     67  function GetDHCPServerLeasesList(): array
    6868  {
    6969    return $this->GetList('/ip dhcp-server lease', array('address', 'active-address', 'comment', 'lease-time', 'status', 'host-name'));
  • trunk/Modules/NetworkConfigRouterOS/RouterboardAPI.php

    r874 r887  
    2525  }
    2626
    27   function EncodeLength($Length)
    28   {
    29     if ($Length < 0x80) {
     27  function EncodeLength(int $Length): int
     28  {
     29    if ($Length < 0x80)
     30    {
    3031      $Length = chr($Length);
    31     } else if ($Length < 0x4000) {
     32    } else if ($Length < 0x4000)
     33    {
    3234      $Length |= 0x8000;
    3335      $Length = chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    34     } else if ($Length < 0x200000) {
     36    } else if ($Length < 0x200000)
     37    {
    3538      $Length |= 0xC00000;
    3639      $Length = chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
    37     } else if ($Length < 0x10000000) {
     40    } else if ($Length < 0x10000000)
     41    {
    3842      $Length |= 0xE0000000;
    3943      $Length = chr(($Length >> 24) & 0xFF).chr(($Length >> 16) & 0xFF).chr(($Length >> 8) & 0xFF).chr($Length & 0xFF);
     
    4347  }
    4448
    45   function ConnectOnce($IP, $Login, $Password)
     49  function ConnectOnce(string $IP, string $Login, string $Password): void
    4650  {
    4751    if ($this->Connected) $this->Disconnect();
     
    6367  }
    6468
    65   function Connect($IP, $Login, $Password)
     69  function Connect(string $IP, string $Login, string $Password): bool
    6670  {
    6771    for ($Attempt = 1; $Attempt <= $this->Attempts; $Attempt++)
     
    7478  }
    7579
    76   function Disconnect()
     80  function Disconnect(): void
    7781  {
    7882    if ($this->Connected)
     
    8387  }
    8488
    85   function ParseResponse($Response)
    86   {
    87     if (is_array($Response)) {
     89  function ParseResponse(array $Response): array
     90  {
     91    if (is_array($Response))
     92    {
    8893      $Parsed      = array();
    8994      $Current     = null;
    9095      $SingleValue = null;
    9196      $count       = 0;
    92       foreach ($Response as $x) {
     97      foreach ($Response as $x)
     98      {
    9399        if (in_array($x, array(
    94100            '!fatal',
    95101            '!re',
    96102            '!trap'
    97         ))) {
    98           if ($x == '!re') {
     103        )))
     104        {
     105          if ($x == '!re')
     106          {
    99107            $Current =& $Parsed[];
    100108          } else
    101109            $Current =& $Parsed[$x][];
    102         } else if ($x != '!done') {
    103           if (preg_match_all('/[^=]+/i', $x, $Matches)) {
     110        } else if ($x != '!done')
     111        {
     112          if (preg_match_all('/[^=]+/i', $x, $Matches))
     113          {
    104114            if ($Matches[0][0] == 'ret') {
    105115              $SingleValue = $Matches[0][1];
     
    109119        }
    110120      }
    111       if (empty($Parsed) && !is_null($SingleValue)) {
     121      if (empty($Parsed) && !is_null($SingleValue))
     122      {
    112123        $Parsed = $SingleValue;
    113124      }
     
    117128  }
    118129
    119   function ArrayChangeKeyName(&$array)
    120   {
    121     if (is_array($array)) {
    122       foreach ($array as $k => $v) {
     130  function ArrayChangeKeyName(array &$array): array
     131  {
     132    if (is_array($array))
     133    {
     134      foreach ($array as $k => $v)
     135      {
    123136        $tmp = str_replace("-", "_", $k);
    124137        $tmp = str_replace("/", "_", $tmp);
    125         if ($tmp) {
     138        if ($tmp)
     139        {
    126140          $array_new[$tmp] = $v;
    127         } else {
     141        } else
     142        {
    128143          $array_new[$k] = $v;
    129144        }
    130145      }
    131146      return $array_new;
    132     } else {
     147    } else
     148    {
    133149      return $array;
    134150    }
    135151  }
    136152
    137   function Read($Parse = true)
     153  function Read(bool $Parse = true): array
    138154  {
    139155    $Line = '';
    140156    $Response = array();
    141     while (true) {
     157    while (true)
     158    {
    142159      // Read the first byte of input which gives us some or all of the length
    143160      // of the remaining reply.
     
    149166      // If the fourth bit is set, we need to remove anything left in the first byte
    150167      // and then read in yet another byte.
    151       if ($Byte & 0x80) {
    152         if (($Byte & 0xc0) == 0x80) {
     168      if ($Byte & 0x80)
     169      {
     170        if (($Byte & 0xc0) == 0x80)
     171        {
    153172          $Length = (($Byte & 63) << 8) + ord(fread($this->Socket, 1));
    154         } else {
    155           if (($Byte & 0xe0) == 0xc0) {
     173        } else
     174        {
     175          if (($Byte & 0xe0) == 0xc0)
     176          {
    156177            $Length = (($Byte & 31) << 8) + ord(fread($this->Socket, 1));
    157178            $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    158           } else {
    159             if (($Byte & 0xf0) == 0xe0) {
     179          } else
     180          {
     181            if (($Byte & 0xf0) == 0xe0)
     182            {
    160183              $Length = (($Byte & 15) << 8) + ord(fread($this->Socket, 1));
    161184              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    162185              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
    163             } else {
     186            } else
     187            {
    164188              $Length = ord(fread($this->Socket, 1));
    165189              $Length = ($Length << 8) + ord(fread($this->Socket, 1));
     
    169193          }
    170194        }
    171       } else {
     195      } else
     196      {
    172197        $Length = $Byte;
    173198      }
    174199      // If we have got more characters to read, read them in.
    175       if ($Length > 0) {
     200      if ($Length > 0)
     201      {
    176202        $Line = '';
    177203        $RetLen = 0;
    178         while ($RetLen < $Length) {
     204        while ($RetLen < $Length)
     205        {
    179206          $ToRead = $Length - $RetLen;
    180207          $Line .= fread($this->Socket, $ToRead);
     
    196223  }
    197224
    198   function Write($Command, $Param2 = true)
     225  function Write(string $Command, bool $Param2 = true): bool
    199226  {
    200227    if ($Command)
    201228    {
    202229      $Data = explode("\n", $Command);
    203       foreach ($Data as $Com) {
     230      foreach ($Data as $Com)
     231      {
    204232        $Com = trim($Com);
    205233        fwrite($this->Socket, $this->EncodeLength(strlen($Com)).$Com);
    206234      }
    207       if (gettype($Param2) == 'integer') {
     235      if (gettype($Param2) == 'integer')
     236      {
    208237        fwrite($this->Socket, $this->EncodeLength(strlen('.tag='.$Param2)).'.tag='.$Param2.chr(0));
    209238      } else if (gettype($Param2) == 'boolean')
     
    214243  }
    215244
    216   function Comm($Com, $Arr = array())
     245  function Comm(string $Com, array $Arr = array()): array
    217246  {
    218247    $Count = count($Arr);
    219248    $this->write($Com, !$Arr);
    220249    $i = 0;
    221     foreach ($Arr as $k => $v) {
    222       switch ($k[0]) {
     250    foreach ($Arr as $k => $v)
     251    {
     252      switch ($k[0])
     253      {
    223254        case "?":
    224255          $el = "$k=$v";
  • trunk/Modules/NetworkShare/NetworkShare.php

    r738 r887  
    77class ModuleNetworkShare extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    30     $this->System->RegisterPage('share', 'SharePage');
     30    $this->System->RegisterPage(['share'], 'SharePage');
    3131  }
    3232}
  • trunk/Modules/NetworkShare/SharePage.php

    r874 r887  
    33class SharePage extends Page
    44{
    5   var $FullTitle = 'Prohledávání sdílených souborů';
    6   var $ShortTitle = 'Sdílené soubory';
    7   var $ParentClass = 'PagePortal';
    85  var $Dependencies = array('Log');
    96  var $MaxNesting = 20; // Maximální vnoření
     
    2017  );
    2118
     19  function __construct(System $System)
     20  {
     21    parent::__construct($System);
     22    $this->FullTitle = 'Prohledávání sdílených souborů';
     23    $this->ShortTitle = 'Sdílené soubory';
     24    $this->ParentClass = 'PagePortal';
     25  }
     26
    2227  function ShowTime()
    2328  {
     
    6671  }
    6772
    68   function Show()
    69   {
    70     if (!$this->System->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění';
     73  function Show(): string
     74  {
     75    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('NetworkShare', 'Display')) return 'Nemáte oprávnění';
    7176
    7277    // If not only online checkbox checked
     
    102107    // Log search
    103108    if (array_key_exists('keyword', $_POST) or array_key_exists('keyword', $_GET))
    104       $this->System->ModuleManager->Modules['Log']->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);
     109      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Share', 'Hledaný výraz', $_SESSION['keyword']);
    105110
    106111    // Zobrazení formuláře
  • trunk/Modules/NetworkTopology/NetworkTopology.php

    r874 r887  
    33class PageNetworkTopology extends Page
    44{
    5   var $FullTitle = 'Grafické zobrazení topologie sítě';
    6   var $ShortTitle = 'Topologie sítě';
    7   var $ParentClass = 'PagePortal';
    85  var $TopHostName = 'NIX-ROUTER';
    96
    10   function Show()
     7  function __construct(System $System)
     8  {
     9    parent::__construct($System);
     10    $this->FullTitle = 'Grafické zobrazení topologie sítě';
     11    $this->ShortTitle = 'Topologie sítě';
     12    $this->ParentClass = 'PagePortal';
     13  }
     14
     15  function Show(): string
    1116  {
    1217    if (count($this->System->PathItems) > 1)
     
    132137class ModuleNetworkTopology extends AppModule
    133138{
    134   function __construct($System)
     139  function __construct(System $System)
    135140  {
    136141    parent::__construct($System);
     
    143148  }
    144149
    145   function DoInstall()
     150  function DoInstall(): void
    146151  {
    147152  }
    148153
    149   function DoUnInstall()
     154  function DoUnInstall(): void
    150155  {
    151156  }
    152157
    153   function DoStart()
     158  function DoStart(): void
    154159  {
    155     $this->System->RegisterPage('topologie', 'PageNetworkTopology');
     160    $this->System->RegisterPage(['topologie'], 'PageNetworkTopology');
    156161  }
    157162}
  • trunk/Modules/News/Import/Vismo.php

    r878 r887  
    33class NewsSourceVismo extends NewsSource
    44{
    5   function Import()
     5  function Import(): string
    66  {
    77    $Output = parent::Import();
  • trunk/Modules/News/ImportKinoVatra.php

    r873 r887  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../../Application/System.php');
    4 $System = new System();
     3include_once(dirname(__FILE__).'/../../Application/Core.php');
     4$System = new Core();
    55$System->ShowPage = false;
    66$System->Run();
  • trunk/Modules/News/ImportTvBeskyd.php

    r873 r887  
    11<?php
    22
    3 include_once(dirname(__FILE__).'/../../Application/System.php');
     3include_once(dirname(__FILE__).'/../../Application/Core.php');
    44$System = new Core();
    55$System->ShowPage = false;
  • trunk/Modules/News/News.php

    r878 r887  
    1313class ModuleNews extends AppModule
    1414{
    15   var $NewsCountPerCategory = 3;
    16   var $UploadedFilesFolder = 'files/news/';
    17 
    18   function __construct($System)
     15  public int $NewsCountPerCategory = 3;
     16  public string $UploadedFilesFolder = 'files/news/';
     17
     18  function __construct(System $System)
    1919  {
    2020    parent::__construct($System);
     
    2828  }
    2929
    30   function DoInstall()
    31   {
    32   }
    33 
    34   function DoUnInstall()
    35   {
    36   }
    37 
    38   function DoStart()
    39   {
    40     $this->System->RegisterPage('aktuality', 'PageNews');
    41     $this->System->RegisterPage(array('aktuality', 'aktualizace'), 'PageNewsUpdate');
     30  function DoInstall(): void
     31  {
     32  }
     33
     34  function DoUnInstall(): void
     35  {
     36  }
     37
     38  function DoStart(): void
     39  {
     40    $this->System->RegisterPage(['aktuality'], 'PageNews');
     41    $this->System->RegisterPage(['aktuality', 'subscription'], 'PageNewsSubscription');
     42    $this->System->RegisterPage(['aktuality', 'rss'], 'PageNewsRss');
     43    $this->System->RegisterPage(['aktuality', 'aktualizace'], 'PageNewsUpdate');
    4244    $this->System->FormManager->RegisterClass('News', array(
    4345      'Title' => 'Aktualita',
     
    8688    if ($this->System->ModuleManager->ModulePresent('Search'))
    8789    {
    88       $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));
    89     }
    90   }
    91 
    92   function ShowNews($Category, $ItemCount, $DaysAgo)
     90      ModuleSearch::Cast($this->System->GetModule('Search'))->RegisterSearch('Novinky', 'News', array('Title', 'Content'));
     91    }
     92  }
     93
     94  function ShowNews(string $Category, int $ItemCount, int $DaysAgo): string
    9395  {
    9496    $ItemCount = abs($ItemCount);
     
    98100    $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption'];
    99101    $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>';
    100     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))
     102    if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category))
    101103      $Output .= ' <a href="aktuality/?action=add&amp;category='.$Category.'">Přidat</a>';
    102104    $Output .= '</div></div><div class="Content">';
     
    139141  }
    140142
    141   function LoadSettingsFromCookies()
     143  function LoadSettingsFromCookies(): void
    142144  {
    143145    // Initialize default news setting
     
    163165  }
    164166
    165   function Show()
     167  function Show(): string
    166168  {
    167169    $Output = '';
     
    197199  }
    198200
    199   function ShowCustomizeMenu()
     201  function ShowCustomizeMenu(): string
    200202  {
    201203    $Output = '<form action="?Action=CustomizeNewsSave" method="post">';
     
    220222  }
    221223
    222   function CustomizeSave()
     224  function CustomizeSave(): void
    223225  {
    224226    $Checkbox = array('' => 0, 'on' => 1);
     
    245247  }
    246248
    247   function ModifyContent($Content)
     249  function ModifyContent(string $Content): string
    248250  {
    249251    $Result = '';
     
    254256    {
    255257      $I = strpos($Content, 'http://');
    256       if (($I > 0) and ($Content{$I - 1} != '"'))
     258      if (($I > 0) and ($Content[$I - 1] != '"'))
    257259      {
    258260        $Result .= substr($Content, 0, $I);
     
    272274    return $Result;
    273275  }
     276
     277  static function Cast(AppModule $AppModule): ModuleNews
     278  {
     279    if ($AppModule instanceof ModuleNews)
     280    {
     281      return $AppModule;
     282    }
     283    throw new Exception('Expected ModuleNews type but got '.gettype($AppModule));
     284  }
    274285}
  • trunk/Modules/News/NewsPage.php

    r878 r887  
    33class PageNews extends Page
    44{
    5   var $FullTitle = 'Aktualní informace';
    6   var $ShortTitle = 'Aktuality';
    7   var $ParentClass = 'PagePortal';
    8   var $UploadedFilesFolder;
    9 
    10   function Show()
    11   {
    12     $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder;
    13     if (count($this->System->PathItems) > 1)
    14     {
    15       if ($this->System->PathItems[1] == 'subscription') return $this->ShowSubscription();
    16         else if ($this->System->PathItems[1] == 'rss') return $this->ShowRSS();
    17         else return PAGE_NOT_FOUND;
    18     } else return $this->ShowMain();
    19   }
    20 
    21   function ShowView()
    22   {
    23     $Output = '';
    24     if (!$this->System->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Aktualní informace';
     9    $this->ShortTitle = 'Aktuality';
     10    $this->ParentClass = 'PagePortal';
     11  }
     12
     13  function ShowView(): string
     14  {
     15    $Output = '';
     16    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Display', 'Item')) $Output .= 'Nemáte oprávnění';
    2517    else
    2618    {
     
    3527          else $Author = $Row['Name'];
    3628        $Output .= '<div class="Panel"><div class="Title">'.$Row['Title'].' ('.HumanDate($Row['Date']).', '.$Author.')';
    37         if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     29        if ((ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] == $Row['User']) and
     30          (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    3831        {
    3932          $Output .= '<div class="Action">';
     
    4235          $Output .= '</div>';
    4336        }
    44         $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
     37        $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />';
    4538        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    4639        if ($Row['Enclosure'] != '')
     
    5043          foreach ($Enclosures as $Enclosure)
    5144          {
    52             if (file_exists($this->UploadedFilesFolder.$Enclosure))
    53               $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
     45            if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure))
     46              $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    5447          }
    5548        }
     
    6053  }
    6154
    62   function ShowAdd()
    63   {
    64     $Output = '';
    65     $Category = $this->GetCategory();
    66     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     55  function ShowAdd(): string
     56  {
     57    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
     58    $Output = '';
     59    $Category = $this->GetCategory();
     60    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    6761    {
    6862      $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    7569      while ($DbRow = $DbResult->fetch_array())
    7670      {
    77         if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
     71        if ($User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    7872        {
    7973          if ($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
     
    9690  }
    9791
    98   function ShowAdd2()
    99   {
     92  function ShowAdd2(): string
     93  {
     94    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    10095    $Output = '';
    10196    $RemoteAddr = GetRemoteAddress();
    10297    $Category = $this->GetCategory();
    103     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     98    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    10499    {
    105100      // Process uploaded file
     
    110105        if (array_key_exists($EnclosureName, $_FILES) and ($_FILES[$EnclosureName]['name'] != ''))
    111106        {
    112           $UploadedFilePath = $this->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
     107          $UploadedFilePath = ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.basename($_FILES[$EnclosureName]['name']);
    113108          if (move_uploaded_file($_FILES[$EnclosureName]['tmp_name'], $UploadedFilePath))
    114109          {
     
    124119        $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
    125120          'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
    126           'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'],
    127           'User' => $this->System->User->User['Id'], 'Link' => $_POST['link']));
     121          'Enclosure' => $Enclosures, 'Author' => $User->User['Name'],
     122          'User' => $User->User['Id'], 'Link' => $_POST['link']));
    128123        $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
    129124        $Output .= '<a href="?category='.$_POST['category'].'">Zpět na seznam aktualit</a>';
    130         $this->System->ModuleManager->Modules['Log']->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
     125        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('News', 'Aktualita přidána', $this->Database->insert_id);
    131126    } else $Output .= 'Do této kategorie nemůžete vkládat aktuality!';
    132127    return $Output;
    133128  }
    134129
    135   function GetPageHeader()
     130  function GetPageHeader(): string
    136131  {
    137132    return '<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
     
    152147  }
    153148
    154   function ShowEdit()
    155   {
    156     $Output = '';
    157     $Category = $this->GetCategory();
    158     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     149  function ShowEdit(): string
     150  {
     151    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
     152    $Output = '';
     153    $Category = $this->GetCategory();
     154    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    159155    {
    160156      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    161157      $Row = $DbResult->fetch_array();
    162       if (($this->System->User->User['Id'] == $Row['User']))
     158      if (($User->User['Id'] == $Row['User']))
    163159      {
    164160        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
     
    177173  }
    178174
    179   function ShowUpdate()
    180   {
     175  function ShowUpdate(): string
     176  {
     177    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    181178    $Output = '';
    182179    $RemoteAddr = GetRemoteAddress();
    183180    $Category = $this->GetCategory();
    184     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     181    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    185182    {
    186183      $_POST['id'] = $_POST['id'] * 1;
     
    189186      {
    190187        $Row = $DbResult->fetch_array();
    191         if ($this->System->User->User['Id'] == $Row['User'])
     188        if ($User->User['Id'] == $Row['User'])
    192189        {
    193190          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
     
    201198  }
    202199
    203   function ShowDelete()
    204   {
    205     $Output = '';
    206     $Category = $this->GetCategory();
    207     if ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     200  function ShowDelete(): string
     201  {
     202    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
     203    $Output = '';
     204    $Category = $this->GetCategory();
     205    if ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    208206    {
    209207      $DbResult = $this->Database->query('SELECT * FROM `News` WHERE `Id`='.$_GET['id']);
    210208      $Row = $DbResult->fetch_array();
    211       if ($this->System->User->User['Id'] == $Row['User'])
     209      if ($User->User['Id'] == $Row['User'])
    212210      {
    213211        // TODO: Make upload using general File class
     
    218216          foreach ($Enclosures as $Enclosure)
    219217          {
    220             if (file_exists($this->UploadedFilesFolder.$Enclosure)) unlink($this->UploadedFilesFolder.$Enclosure);
     218            if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure)) unlink(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure);
    221219          }
    222220        }
     
    228226  }
    229227
    230   function ShowList()
    231   {
    232     $Output = '';
    233     $Category = $this->GetCategory();
    234     if ($this->System->User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
     228  function ShowList(): string
     229  {
     230    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
     231    $Output = '';
     232    $Category = $this->GetCategory();
     233    if ($User->CheckPermission('News', 'Display', 'Group', $Category['Id']))
    235234    {
    236235      $PerPage = 20;
     
    250249          else $Author = $Row['Name'];
    251250        $Output .= '<div class="Panel"><div class="Title"><a href="?action=view&amp;id='.$Row['Id'].'">'.$Row['Title'].'</a> ('.HumanDate($Row['Date']).', '.$Author.')';
    252         if (($this->System->User->User['Id'] == $Row['User']) and ($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
     251        if (($User->User['Id'] == $Row['User']) and ($User->CheckPermission('News', 'Insert', 'Group', $Category['Id'])))
    253252        {
    254253          $Output .= '<div class="Action">';
     
    257256          $Output .= '</div>';
    258257        }
    259         $Output .= '</div><div class="Content">'.$this->System->ModuleManager->Modules['News']->ModifyContent($Row['Content']).'<br />';
     258        $Output .= '</div><div class="Content">'.ModuleNews::Cast($this->System->GetModule('News'))->ModifyContent($Row['Content']).'<br />';
    260259        if ($Row['Link'] != '') $Output .= '<br/><a href="'.$Row['Link'].'">Odkaz</a>';
    261260        if ($Row['Enclosure'] != '')
     
    265264          foreach ($Enclosures as $Enclosure)
    266265          {
    267             if (file_exists($this->UploadedFilesFolder.$Enclosure))
    268               $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
     266            if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure))
     267              $Output .= ' <a href="'.$this->System->Link('/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    269268          }
    270269        }
     
    277276  }
    278277
    279   function GetCategory()
     278  function GetCategory(): array
    280279  {
    281280    $Category = array('Id' => 1); // Default category
     
    292291  }
    293292
    294   function ShowMain()
     293  function Show(): string
    295294  {
    296295    $Output = '';
     
    306305    return $Output;
    307306  }
    308 
    309   function ShowSubscription()
     307}
     308
     309class PageNewsUpdate extends Page
     310{
     311  function __construct(System $System)
     312  {
     313    parent::__construct($System);
     314    $this->FullTitle = 'Aktualizace aktualit';
     315    $this->ShortTitle = 'Aktualizace aktualit';
     316    $this->ParentClass = 'PageNews';
     317  }
     318
     319  function Show(): string
     320  {
     321    $NewsSources = new NewsSources();
     322    $NewsSources->Database = $this->Database;
     323    if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']);
     324      else $Output = $NewsSources->Parse();
     325    return $Output;
     326  }
     327}
     328
     329class PageNewsSubscription extends Page
     330{
     331  function __construct(System $System)
     332  {
     333    parent::__construct($System);
     334    $this->FullTitle = 'Odběry aktualit';
     335    $this->ShortTitle = 'Odběry aktualit';
     336    $this->ParentClass = 'PageNews';
     337  }
     338
     339  function Show(): string
    310340  {
    311341    if (array_key_exists('build', $_GET))
     
    333363    return $Output;
    334364  }
    335 
    336   function ShowRSS()
     365}
     366
     367class PageNewsRss extends Page
     368{
     369  function __construct(System $System)
     370  {
     371    parent::__construct($System);
     372    $this->FullTitle = 'RSS kanál aktualit';
     373    $this->ShortTitle = 'Aktuality RSS';
     374    $this->ParentClass = 'PageNews';
     375  }
     376
     377  function Show(): string
    337378  {
    338379    $this->ClearPage = true;
     
    409450        foreach ($Enclosures as $Enclosure)
    410451        {
    411           if (file_exists($this->UploadedFilesFolder.$Enclosure))
    412             $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
     452          if (file_exists(ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure))
     453            $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.ModuleNews::Cast($this->System->GetModule('News'))->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    413454        }
    414455      }
     
    432473  }
    433474}
    434 
    435 class PageNewsUpdate extends Page
    436 {
    437   function __construct($System)
    438   {
    439     parent::__construct($System);
    440     $this->FullTitle = 'Aktualizace aktualit';
    441     $this->ShortTitle = 'Aktualizace aktualit';
    442     $this->ParentClass = 'PageNews';
    443   }
    444 
    445   function Show()
    446   {
    447     $NewsSources = new NewsSources();
    448     $NewsSources->Database = $this->Database;
    449     if (array_key_exists('i', $_GET)) $Output = $NewsSources->Parse($_GET['i']);
    450       else $Output = $NewsSources->Parse();
    451     return $Output;
    452   }
    453 }
    454 
  • trunk/Modules/News/NewsSource.php

    r878 r887  
    11<?php
    22
    3 function GetTextBetween(&$Text, $Start, $End)
     3function GetTextBetween(string &$Text, string $Start, string $End): string
    44{
    55  $Result = '';
     
    3434}
    3535
    36 function HumanDateTimeToTime($DateTime)
     36function HumanDateTimeToTime(string $DateTime): int
    3737{
    3838  if ($DateTime == '') return NULL;
     
    4949}
    5050
    51 function HumanDateToTime($Date)
     51function HumanDateToTime(string $Date): int
    5252{
    5353  if ($Date == '') return NULL;
     
    5555}
    5656
    57 function GetUrlBase($Url)
     57function GetUrlBase(string $Url): string
    5858{
    5959  $Result = parse_url($Url);
     
    6363class NewsSources
    6464{
    65   public $Database;
     65  public Database $Database;
    6666
    6767  function Parse($Id = null)
     
    9494class NewsSource
    9595{
    96   public $Name;
    97   public $URL;
     96  public string $Name;
     97  public string $URL;
    9898  public $Method;
    99   public $Id;
    100   public $Database;
    101   public $NewsItems;
    102   public $AddedCount;
     99  public int $Id;
     100  public Database $Database;
     101  public array $NewsItems;
     102  public int $AddedCount;
    103103  public $Category;
    104104
     
    109109  }
    110110
    111   function Import()
     111  function Import(): string
    112112  {
    113113    return '';
    114114  }
    115115
    116   function DoImport()
     116  function DoImport(): string
    117117  {
    118118    $this->NewsItems = array();
     
    133133class NewsItem
    134134{
    135   var $Database;
    136   var $Title = '';
    137   var $Content = '';
    138   var $Date = '';
    139   var $Link = '';
    140   var $Category = '';
    141   var $Author = '';
    142   var $IP = '';
    143   var $Enclosure = '';
     135  public Database $Database;
     136  public string $Title = '';
     137  public string $Content = '';
     138  public int $Date = 0;
     139  public string $Link = '';
     140  public string $Category = '';
     141  public string $Author = '';
     142  public string $IP = '';
     143  public string $Enclosure = '';
    144144
    145   function AddIfNotExist()
     145  function AddIfNotExist(): int
    146146  {
    147147    $Where = '(`Title` = "'.$this->Database->real_escape_string($this->Title).'") AND '.
  • trunk/Modules/Notify/Notify.php

    r874 r887  
    55class ModuleNotify extends AppModule
    66{
    7   var $Checks;
    8 
    9   function __construct($System)
     7  public array $Checks;
     8
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1919  }
    2020
    21   function DoStart()
     21  function DoStart(): void
    2222  {
    2323    $this->System->FormManager->RegisterClass('NotifyUser', array(
     
    3838      ),
    3939    ));
    40     $this->System->RegisterCommandLine('notify', array($this, 'RunCheck'));
    41     $this->System->ModuleManager->Modules['RSS']->RegisterRSS(array('Title' => 'Notify log',
    42     'Channel' => 'notifylog', 'Callback' => array('ModuleNotify', 'ShowLogRSS'),
     40    $this->System->RegisterCommandLine('notify', 'Perform notifications processing.', array($this, 'RunCheck'));
     41    ModuleRSS::Cast($this->System->GetModule('RSS'))->RegisterRSS(array('Title' => 'Notify log',
     42    'Channel' => 'notifylog', 'Callback' => array($this, 'ShowLogRSS'),
    4343    'Permission' => array('Module' => 'Notify', 'Operation' => 'RSS')));
    4444  }
    4545
    46   function RegisterCheck($Name, $Callback)
     46  function RegisterCheck(string $Name, callable $Callback): void
    4747  {
    4848    if (array_key_exists($Name, $this->Checks))
     
    5151  }
    5252
    53   function UnregisterCheck($Name)
     53  function UnregisterCheck(string $Name): void
    5454  {
    5555    if (!array_key_exists($Name, $this->Checks))
     
    5858  }
    5959
    60   function Check()
     60  function Check(): string
    6161  {
    6262    $Output = '';
     
    123123  }
    124124
    125   function RunCheck($Parameters)
     125  function RunCheck(array $Parameters): void
    126126  {
    127127    RepeatFunction(30, array($this, 'Check'));
    128128  }
    129129
    130   function DoInstall()
     130  function DoInstall(): void
    131131  {
    132132    $this->Database->query('CREATE TABLE IF NOT EXISTS `NotifyCategory` (
     
    160160  }
    161161
    162   function DoUninstall()
     162  function DoUninstall(): void
    163163  {
    164164    $this->Database->query('DROP TABLE `NotifyUser`');
     
    166166  }
    167167
    168   function ShowLogRSS()
     168  function ShowLogRSS(): string
    169169  {
    170170    $this->ClearPage = true;
     
    197197    return $RSS->Generate();
    198198  }
     199
     200  static function Cast(AppModule $AppModule): ModuleNotify
     201  {
     202    if ($AppModule instanceof ModuleNotify)
     203    {
     204      return $AppModule;
     205    }
     206    throw new Exception('Expected ModuleNotify type but got '.gettype($AppModule));
     207  }
    199208}
  • trunk/Modules/OpeningHours/OpeningHours.php

    r874 r887  
    55class PageSubjectOpenTime extends Page
    66{
    7   var $FullTitle = 'Otvírací doby místních subjektů';
    8   var $ShortTitle = 'Otvírací doby';
    9   var $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle');
    10   var $EventType = array('Žádný', 'Otevřeno', 'Zavřeno');
    11   var $ParentClass = 'PagePortal';
    12 
    13   function ToHumanTime($Time)
     7  public array $DaysOfWeek = array('Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota', 'Neděle');
     8  public array $EventType = array('Žádný', 'Otevřeno', 'Zavřeno');
     9
     10  function __construct(System $System)
     11  {
     12    parent::__construct($System);
     13    $this->FullTitle = 'Otvírací doby místních subjektů';
     14    $this->ShortTitle = 'Otvírací doby';
     15    $this->ParentClass = 'PagePortal';
     16  }
     17
     18  function ToHumanTime(float $Time): string
    1419  {
    1520    $Hours = floor($Time / 60);
     
    2025  }
    2126
    22   function ToHumanTime2($Time)
     27  function ToHumanTime2(float $Time): string
    2328  {
    2429    $Days = floor($Time / 24 / 60);
     
    3439  }
    3540
    36   function EditSubject($Id)
    37   {
    38     if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))
     41  function EditSubject(int $Id): string
     42  {
     43    if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit'))
    3944    {
    4045      $Output = '<div class="Centred">';
     
    7378  }
    7479
    75   function SaveSubject($Id)
    76   {
    77     global $Config;
    78 
     80  function SaveSubject(int $Id): string
     81  {
    7982    $Output = '';
    80     if ($this->System->User->CheckPermission('OpeningHours', 'Edit'))
     83    if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('OpeningHours', 'Edit'))
    8184    {
    8285      $this->Database->delete('SubjectOpenTimeDay', 'Subject='.$Id);
     
    100103      $Output .= 'Uloženo';
    101104
    102       $File = new File($this->Database);
     105      $File = new File($this->System);
    103106
    104107      // Delete old file
     
    114117  }
    115118
    116   function ShowAll()
     119  function ShowAll(): string
    117120  {
    118121    $Output = '<div class="Centred">';
     
    138141        }
    139142      }
    140       //print_r($Events);
    141143
    142144      // Calculate time to next event
     
    190192      if ($Subject['Photo'] != 0) $Output .= '<a href="file?id='.$Subject['Photo'].'">Fotka</a> ';
    191193
    192       if ($this->System->User->CheckPermission('SubjectOpenTime', 'Edit'))
     194      if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('SubjectOpenTime', 'Edit'))
    193195        $Output .= '<a href="edit?Subject='.$Subject['Id'].'">Editovat</a><br />';
    194196      $Output .= '<br />';
     
    198200  }
    199201
    200   function Show()
     202  function Show(): string
    201203  {
    202204    if (count($this->System->PathItems) > 1)
     
    215217class ModuleOpeningHours extends AppModule
    216218{
    217   function __construct($System)
     219  function __construct(System $System)
    218220  {
    219221    parent::__construct($System);
     
    226228  }
    227229
    228   function DoStart()
    229   {
    230     $this->System->Pages['otviraci-doby'] = 'PageSubjectOpenTime';
    231   }
    232 
    233   function DoInstall()
    234   {
    235   }
    236 
    237   function DoUnInstall()
     230  function DoStart(): void
     231  {
     232    $this->System->RegisterPage(['otviraci-doby'], 'PageSubjectOpenTime');
     233  }
     234
     235  function DoStop(): void
     236  {
     237    $this->System->UnregisterPage(['otviraci-doby']);
     238  }
     239
     240  function DoInstall(): void
     241  {
     242  }
     243
     244  function DoUnInstall(): void
    238245  {
    239246  }
  • trunk/Modules/Portal/Portal.php

    r874 r887  
    55class ModulePortal extends AppModule
    66{
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1616  }
    1717
    18   function DoInstall()
    19   {
    20   }
    21 
    22   function DoUninstall()
    23   {
    24   }
    25 
    26   function DoStart()
    27   {
    28     $this->System->RegisterPage('', 'PagePortal');
     18  function DoInstall(): void
     19  {
     20  }
     21
     22  function DoUninstall(): void
     23  {
     24  }
     25
     26  function DoStart(): void
     27  {
     28    $this->System->RegisterPage([''], 'PagePortal');
    2929    $this->System->FormManager->RegisterClass('MemberOptions', array(
    3030      'Title' => 'Nastavení zákazníka',
     
    4242      ),
    4343    ));
    44     $this->System->ModuleManager->Modules['User']->UserPanel[] = array('PagePortal', 'UserPanel');
    45   }
    46 
    47   function DoStop()
     44    ModuleUser::Cast($this->System->GetModule('User'))->UserPanel[] = array('PagePortal', 'UserPanel');
     45  }
     46
     47  function DoStop(): void
    4848  {
    4949  }
     
    5252class PagePortal extends Page
    5353{
    54   var $FullTitle = 'Zděchovský rozcestník';
    55   var $ShortTitle = 'Rozcestník';
    56 
    57   function ShowActions($ActionGroup)
     54  function __construct(System $System)
     55  {
     56    parent::__construct($System);
     57    $this->FullTitle = 'Zděchovský rozcestník';
     58    $this->ShortTitle = 'Rozcestník';
     59  }
     60
     61  function ShowActions(array $ActionGroup): string
    5862  {
    5963    $Output = '';
     
    6771  }
    6872
    69   function InfoBar()
     73  function InfoBar(): string
    7074  {
    7175    $Output2 = '';
     
    98102    //$Output .= 'Server běží: '.$this->GetServerUptime().' &nbsp;  &nbsp; ';
    99103
    100     if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
    101     {
    102       $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.$this->System->User->User['Id'].')');
     104    if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Finance', 'DisplaySubjectState'))
     105    {
     106      $DbResult = $this->Database->select('MemberPayment', 'Cash', 'Member=(SELECT Customer FROM UserCustomerRel WHERE Id='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'].')');
    103107      if ($DbResult->num_rows > 0)
    104108      {
     
    112116  }
    113117
    114   function UserPanel()
    115   {
     118  function UserPanel(): string
     119  {
     120    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    116121    $Output = '<a href="'.$this->System->Link('/user/?Action=UserOptions').'">Profil</a><br />';
    117     if ($this->System->User->CheckPermission('Finance', 'MemberOptions'))
     122    if ($User->CheckPermission('Finance', 'MemberOptions'))
    118123      $Output .= '<a href="'.$this->System->Link('/?Action=MemberOptions').'">Fakturační adresa</a><br />';
    119     if ($this->System->User->CheckPermission('Finance', 'DisplaySubjectState'))
     124    if ($User->CheckPermission('Finance', 'DisplaySubjectState'))
    120125      $Output .= '<a href="'.$this->System->Link('/finance/platby/').'">Finance</a><br />';
    121     if ($this->System->User->CheckPermission('Network', 'RegistredHostList'))
     126    if ($User->CheckPermission('Network', 'RegistredHostList'))
    122127      $Output .= '<a href="'.$this->System->Link('/network/user-hosts/').'">Počítače</a><br />';
    123     if ($this->System->User->CheckPermission('News', 'Insert'))
     128    if ($User->CheckPermission('News', 'Insert'))
    124129      $Output .= '<a href="'.$this->System->Link('/aktuality/?action=add').'">Vložení aktuality</a><br />';
    125     if ($this->System->User->CheckPermission('EatingPlace', 'Edit'))
     130    if ($User->CheckPermission('EatingPlace', 'Edit'))
    126131      $Output .= '<a href="'.$this->System->Link('/jidelna/menuedit.php').'">Úprava jídelníčků</a><br />';
    127     if ($this->System->User->CheckPermission('Finance', 'Manage'))
     132    if ($User->CheckPermission('Finance', 'Manage'))
    128133      $Output .= '<a href="'.$this->System->Link('/finance/sprava/').'">Správa financí</a><br />';
    129     if ($this->System->User->CheckPermission('IS', 'Manage'))
     134    if ($User->CheckPermission('IS', 'Manage'))
    130135      $Output .= '<a href="'.$this->System->Link('/is/').'">Správa dat</a><br />';
    131136    return $Output;
    132137  }
    133138
    134   function WebcamPanel()
    135   {
    136     $Output = $this->System->ModuleManager->Modules['WebCam']->ShowImage();
    137     return $Output;
    138   }
    139 
    140   function MeteoPanel()
     139  function WebcamPanel(): string
     140  {
     141    $Output = ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ShowImage();
     142    return $Output;
     143  }
     144
     145  function MeteoPanel(): string
    141146  {
    142147    $Output = '<a href="https://stat.zdechov.net/meteo/?Measure=28" title="Klikněte pro detailní informace a předpověď"><img src="https://www.zdechov.net/meteo/koliba.png" border="0" alt="Počasí - Meteostanice Zděchov" width="150" height="150" /></a>';
     
    144149  }
    145150
    146   function OnlineHostList()
     151  function OnlineHostList(): string
    147152  {
    148153    $Output = '<span style="font-size: smaller;">';
     
    158163  }
    159164
    160   function ShowBadPayerList()
    161   {
    162     $Output .= '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';
    163     $DbResult = $Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');
     165  function ShowBadPayerList(): string
     166  {
     167    $Output = '<div class="PanelTitle">Dlužníci:</div><span style="font-size: smaller;">';
     168    $DbResult = $this->Database->select('Subject', 'Name', 'Money < 0 ORDER BY Money');
    164169    while ($Row = $DbResult->fetch_array())
    165170    {
     
    170175  }
    171176
    172   function Panel($Title, $Content, $Menu = array())
     177  function Panel(string $Title, string $Content, array $Menu = array()): string
    173178  {
    174179    if (count($Menu) > 0)
     180    {
    175181      foreach ($Menu as $Item)
     182      {
    176183        $Title .= '<div class="Action">'.$Item.'</div>';
     184      }
     185    }
    177186    return '<div class="Panel"><div class="Title">'.$Title.'</div><div class="Content">'.$Content.'</div></div>';
    178187  }
    179188
    180   function Show()
     189  function Show(): string
    181190  {
    182191    $Output = '';
     
    186195      if ($Action == 'CustomizeNewsSave')
    187196      {
    188         $Output .= $this->System->ModuleManager->Modules['News']->CustomizeSave();
     197        $Output .= ModuleNews::Cast($this->System->GetModule('News'))->CustomizeSave();
    189198      } else
    190199      if ($Action == 'MemberOptions')
    191200      {
    192201        $DbResult = $this->Database->query('SELECT `Customer` FROM `UserCustomerRel` '.
    193           'WHERE `User`='.$this->System->User->User['Id']);
     202          'WHERE `User`='.ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id']);
    194203        while ($CustomerUserRel = $DbResult->fetch_assoc())
    195204        {
     
    218227          $Form->Values['FamilyMemberCount'] = 0;
    219228
    220         $DbResult = $this->Database->update('Member', 'Id='.$this->System->User->User['Member'],
     229        $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
     230        $DbResult = $this->Database->update('Member', 'Id='.$User->User['Member'],
    221231           array('FamilyMemberCount' => $Form->Values['FamilyMemberCount']));
    222         $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$this->System->User->User['Member']);
     232        $DbResult = $this->Database->query('SELECT Subject FROM Member WHERE Id='.$User->User['Member']);
    223233        $Member = $DbResult->fetch_assoc();
    224234        $DbResult = $this->Database->update('Subject', 'Id='.$Member['Subject'],
     
    228238          'DIC' => $Form->Values['DIC']));
    229239        $Output .= $this->SystemMessage('Nastavení', 'Nastavení zákazníka uloženo.');
    230         $this->System->ModuleManager->Modules['Log']->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',
     240        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('Member+Subject', 'Nastavení zákazníka/subjektu změněno',
    231241          $Form->Values['Name']);
    232242        $DbResult = $this->Database->query('SELECT Member.Id, Member.FamilyMemberCount, '.
    233243          'Subject.Name, Subject.AddressStreet, Subject.AddressTown, Subject.AddressPSC, '.
    234244          'Subject.AddressCountry, Subject.IC, Subject.DIC FROM Member JOIN Subject '.
    235           'ON Subject.Id = Member.Subject WHERE Member.Id='.$this->System->User->User['Member']);
     245          'ON Subject.Id = Member.Subject WHERE Member.Id='.$User->User['Member']);
    236246        $DbRow = $DbResult->fetch_array();
    237247        foreach ($Form->Definition['Items'] as $Index => $Item)
     
    246256  }
    247257
    248   function ShowMain()
     258  function ShowMain(): string
    249259  {
    250260    $Output = '';
     
    270280        else if ($Panel['Module'] == 'UserOptions')
    271281        {
    272           //if ($this->System->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
     282          //if (ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'] != null) $Output .= $this->Panel('Přihlášený uživatel', $this->UserPanel());
    273283        } else
    274284        if ($Panel['Module'] == 'Webcam') $Output .= $this->Panel('Kamery', $this->WebcamPanel());
    275285        if ($Panel['Module'] == 'Meteo') $Output .= $this->Panel('Meteostanice', $this->MeteoPanel());
    276286        else if ($Panel['Module'] == 'NewsGroupList')
    277           $Output .= $this->Panel('Aktuality', $this->System->ModuleManager->Modules['News']->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
     287          $Output .= $this->Panel('Aktuality', ModuleNews::Cast($this->System->GetModule('News'))->Show(), array('<a href="?Action=CustomizeNews">Upravit</a>'));
    278288      }
    279289      $Output .= '</td>';
  • trunk/Modules/RSS/RSS.php

    r874 r887  
    33class ModuleRSS extends AppModule
    44{
    5   var $RSSChannels;
     5  public array $RSSChannels;
    66
    7   function __construct($System)
     7  function __construct(System $System)
    88  {
    99    parent::__construct($System);
     
    1717  }
    1818
    19   function Start()
     19  function DoStart(): void
    2020  {
    21     $this->System->RegisterPage('rss', 'PageRSS');
     21    $this->System->RegisterPage(['rss'], 'PageRSS');
    2222    $this->System->RegisterPageHeader('RSS', array($this, 'ShowRSSHeader'));
    2323  }
    2424
    25   function RegisterRSS($Channel, $Pos = NULL, $Callback = NULL)
     25  function RegisterRSS(array $Channel, $Pos = NULL, $Callback = NULL): void
    2626  {
    2727    $this->RSSChannels[$Channel['Channel']] = $Channel;
    2828
    2929    if (is_null($Pos)) $this->RSSChannelsPos[] = $Channel['Channel'];
    30     else {
     30    else
     31    {
    3132      array_splice($this->RSSChannelsPos, $Pos, 0, $Channel['Channel']);
    3233    }
    3334  }
    3435
    35   function UnregisterRSS($ChannelName)
     36  function UnregisterRSS($ChannelName): void
    3637  {
    3738    unset($this->RSSChannels[$ChannelName]);
     
    3940  }
    4041
    41   function ShowRSSHeader()
     42  function ShowRSSHeader(): string
    4243  {
    4344    $Output = '';
    4445    foreach ($this->RSSChannels as $Channel)
    4546    {
    46       //if ($this->System->User->Licence($Channel['Permission']))
     47      //if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence($Channel['Permission']))
    4748        $Output .= ' <link rel="alternate" title="'.$Channel['Title'].'" href="'.
    4849          $this->System->Link('/rss/?channel='.$Channel['Channel']).'" type="application/rss+xml" />';
     
    5051    return $Output;
    5152  }
     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  }
    5262}
    5363
    5464class PageRSS extends Page
    5565{
    56   function Show()
     66  function Show(): string
    5767  {
    5868    $this->ClearPage = true;
     
    6272    if (array_key_exists('token', $_GET)) $Token = $_GET['token'];
    6373      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))
    6575    {
    66       $Channel = $this->System->ModuleManager->Modules['RSS']->RSSChannels[$ChannelName];
    67       if ($this->System->User->CheckPermission($Channel['Permission']['Module'], $Channel['Permission']['Operation']) or
    68       $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))
    6979      {
    7080        if (is_string($Channel['Callback'][0]))
  • trunk/Modules/Scheduler/Scheduler.php

    r874 r887  
    33class ModuleScheduler extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Scheduler', array(
     
    4848      'Filter' => '1',
    4949    ));
    50     $this->System->RegisterCommandLine('run-scheduler', array($this->System->ModuleManager->Modules['Scheduler'], 'Run'));
     50    $this->System->RegisterCommandLine('run-scheduler', 'Runs scheduled tasks',
     51      array(ModuleScheduler::Cast($this->System->GetModule('Scheduler')), 'Run'));
    5152  }
    5253
    53   function DoInstall()
     54  function DoInstall(): void
    5455  {
    5556  }
    5657
    57   function DoUnInstall()
     58  function DoUnInstall(): void
    5859  {
    5960  }
    6061
    61   function Run($Parameters)
     62  function Run(array $Parameters): void
    6263  {
    6364    while (true)
     
    100101    }
    101102  }
     103
     104  static function Cast(AppModule $AppModule): ModuleScheduler
     105  {
     106    if ($AppModule instanceof ModuleScheduler)
     107    {
     108      return $AppModule;
     109    }
     110    throw new Exception('Expected ModuleScheduler type but got '.gettype($AppModule));
     111  }
    102112}
    103113
    104114class SchedulerTask extends Model
    105115{
    106   function Execute()
     116  function Execute(): string
    107117  {
     118    return '';
    108119  }
    109120}
    110121
    111 
    112122class ScheduleTaskTest extends SchedulerTask
    113123{
    114   function Execute()
     124  function Execute(): string
    115125  {
    116126    $Output = '#';
  • trunk/Modules/Search/Search.php

    r874 r887  
    33class PageSearch extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function Show()
     13  function Show(): string
    1414  {
    1515    $Output = '';
     
    2121    '</form>';
    2222    if ($Text != '')
    23     foreach ($this->System->ModuleManager->Modules['Search']->Items as $Item)
     23    foreach (ModuleSearch::Cast($this->System->GetModule('Search'))->Items as $Item)
    2424    {
    2525      $Columns = '';
     
    3333      $Condition = substr($Condition, 3);
    3434      $DbResult = $this->Database->Select($Item['Table'], $Columns, $Condition.' LIMIT '.
    35         $this->System->ModuleManager->Modules['Search']->MaxItemCount);
     35        ModuleSearch::Cast($this->System->GetModule('Search'))->MaxItemCount);
    3636      if ($DbResult->num_rows > 0) $Output .= '<strong>'.$Item['Name'].'</strong><br/>';
    3737      while ($Row = $DbResult->fetch_assoc())
     
    4949class ModuleSearch extends AppModule
    5050{
    51   var $Items;
    52   var $MaxItemCount;
     51  public array $Items;
     52  public int $MaxItemCount;
    5353
    54   function __construct($System)
     54  function __construct(System $System)
    5555  {
    5656    parent::__construct($System);
     
    6565  }
    6666
    67   function DoStart()
     67  function DoStart(): void
    6868  {
    6969    $this->System->Pages['search'] = 'PageSearch';
    7070  }
    7171
    72   function DoInstall()
     72  function DoInstall(): void
    7373  {
    7474  }
    7575
    76   function DoUnInstall()
     76  function DoUnInstall(): void
    7777  {
    7878  }
    7979
    80   function RegisterSearch($Title, $TableName, $Columns)
     80  function RegisterSearch(string $Title, string $TableName, array $Columns): void
    8181  {
    8282    $this->Items[] = array('Name' => $Title, 'Table' => $TableName, 'Columns' => $Columns);
    8383  }
     84
     85  static function Cast(AppModule $AppModule): ModuleSearch
     86  {
     87    if ($AppModule instanceof ModuleSearch)
     88    {
     89      return $AppModule;
     90    }
     91    throw new Exception('Expected ModuleSearch type but got '.gettype($AppModule));
     92  }
    8493}
  • trunk/Modules/SpeedTest/SpeedTest.php

    r874 r887  
    1414class ModuleSpeedTest extends AppModule
    1515{
    16   function __construct($System)
     16  function __construct(System $System)
    1717  {
    1818    parent::__construct($System);
     
    2525  }
    2626
    27   function DoStart()
     27  function DoStart(): void
    2828  {
    2929    $this->System->Pages['speedtest'] = 'PageSpeedTest';
     
    3333class PageSpeedTest extends Page
    3434{
    35   var $FullTitle = 'Test rychlosti připojení';
    36   var $ShortTitle = 'Test rychlosti';
    37   var $ParentClass = 'PagePortal';
     35  function __construct(System $System)
     36  {
     37    parent::__construct($System);
     38    $this->FullTitle = 'Test rychlosti připojení';
     39    $this->ShortTitle = 'Test rychlosti';
     40    $this->ParentClass = 'PagePortal';
     41  }
    3842
    39   function Show()
     43  function Show(): string
    4044  {
    4145    if (count($this->System->PathItems) > 1)
     
    4751  }
    4852
    49   function ShowDownload()
     53  function ShowDownload(): void
    5054  {
    5155    global $config;
     
    5458  }
    5559
    56   function ShowMain()
     60  function ShowMain(): string
    5761  {
    5862    global $config;
  • trunk/Modules/Stock/Stock.php

    r874 r887  
    33class ModuleStock extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    global $Config;
     
    246246  }
    247247
    248   function BeforeInsertStockMove($Form)
     248  function BeforeInsertStockMove(Form $Form): array
    249249  {
     250    $Finance = &ModuleFinance::Cast($this->System->GetModule('Finance'))->Finance;
    250251    if (array_key_exists('Time', $Form->Values)) $Year = date("Y", $Form->Values['Time']);
    251252      else $Year = date("Y", $Form->Values['ValidFrom']);
    252     $Group = $this->System->Modules['Finance']->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup');
    253     $Form->Values['BillCode'] = $this->System->Modules['Finance']->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
     253    $Group = $Finance->GetFinanceGroupById($Form->Values['Group'], 'StockMoveGroup');
     254    $Form->Values['BillCode'] = $Finance->GetNextDocumentLineNumberId($Group['DocumentLine'], $Year);
    254255    return $Form->Values;
    255256  }
  • trunk/Modules/Subject/Subject.php

    r886 r887  
    33class ModuleSubject extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Subject', array(
     
    127127      'Filter' => '1',
    128128    ));
    129     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Subject',
    130       array('ModuleSubject', 'ShowDashboardItem'));
     129    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Subject',
     130      array($this, 'ShowDashboardItem'));
    131131  }
    132132
    133   function DoInstall()
     133  function DoInstall(): void
    134134  {
    135135    $this->Database->query("CREATE TABLE IF NOT EXISTS `Subject` (
     
    173173  }
    174174
    175   function DoUninstall()
     175  function DoUninstall(): void
    176176  {
    177177    $this->Database->query('DROP TABLE `Contact`');
     
    180180  }
    181181
    182   function ShowDashboardItem()
     182  function ShowDashboardItem(): string
    183183  {
    184184    $DbResult = $this->Database->select('Subject', 'COUNT(*)', '1');
  • trunk/Modules/System/System.php

    r874 r887  
    33class PageModules extends Page
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1111  }
    1212
    13   function ShowList()
     13  function ShowList(): string
    1414  {
    1515    $Output = '';
     
    6262  }
    6363
    64   function Show()
     64  function Show(): string
    6565  {
    6666    $Output = '';
     
    6969      if ($_GET['A'] == 'SaveToDb')
    7070      {
    71         $Output .= $this->System->ModuleManager->Modules['System']->SaveToDatabase();
     71        $Output .= ModuleSystem::Cast($this->System->GetModule('System'))->SaveToDatabase();
    7272        $Output .= $this->SystemMessage('Načtení modulů', 'Seznam modulů v databázi zaktualizován');
    7373      } else
     
    7878        if ($ModuleName != '')
    7979        {
    80           $this->System->Modules[$ModuleName]->Install();
    81           $this->System->ModuleManager->Init();
     80          $this->System->ModuleManager->GetModule($ModuleName)->Install();
    8281        } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen';
    8382
     
    8887        if ($ModuleName != '')
    8988        {
    90           $this->System->ModuleManager->Modules[$ModuleName]->UnInstall();
    91           $this->System->ModuleManager->Init();
     89          $this->System->ModuleManager->GetModule($ModuleName)->UnInstall();
    9290        } else $Output .= 'Modul id '.$_GET['Id'].' nenalezen';
    9391      } else $Output .= 'Neplatná akce';
     
    10098class ModuleSystem extends AppModule
    10199{
    102   var $InstalledChecked;
    103 
    104   function __construct($System)
     100  public bool $InstalledChecked;
     101
     102  function __construct(System $System)
    105103  {
    106104    parent::__construct($System);
     
    113111  }
    114112
    115   function DoInstall()
     113  function DoInstall(): void
    116114  {
    117115    $this->Database->query('CREATE TABLE IF NOT EXISTS `SystemVersion` (
     
    164162  }
    165163
    166   function DoUnInstall()
     164  function DoUnInstall(): void
    167165  {
    168166    // Delete tables with reverse order
     
    178176  }
    179177
    180   function DoStart()
    181   {
    182     $this->System->RegisterPage('module', 'PageModules');
     178  function DoStart(): void
     179  {
     180    $this->System->RegisterPage(['module'], 'PageModules');
    183181    $this->System->FormManager->RegisterClass('Action', array(
    184182      'Title' => 'Akce',
     
    402400  }
    403401
    404   function DoStop()
    405   {
    406   }
    407 
    408   function IsInstalled()
     402  function DoStop(): void
     403  {
     404  }
     405
     406  function IsInstalled(): bool
    409407  {
    410408    if ($this->InstalledChecked == false)
     
    419417  }
    420418
    421   function ModuleChange($Module)
     419  function ModuleChange($Module): void
    422420  {
    423421    //if ($this->IsInstalled())
     
    430428  }
    431429
    432   function LoadFromDatabase()
     430  function LoadFromDatabase(): void
    433431  {
    434432    //DebugLog('Loading modules...');
     
    448446  }
    449447
    450   function SaveToDatabase()
     448  function SaveToDatabase(): string
    451449  {
    452450    $Output = '';
     
    457455      $Modules[$DbRow['Name']] = $DbRow;
    458456      if ($this->System->ModuleManager->ModulePresent($DbRow['Name']))
    459         $this->System->ModuleManager->Modules[$DbRow['Name']]->Id = $DbRow['Id'];
     457        $this->System->ModuleManager->GetModule($DbRow['Name'])->Id = $DbRow['Id'];
    460458    }
    461459
     
    470468          'Description' => $Module->Description, 'License' => $Module->License,
    471469          'Installed' => $Module->Installed));
    472         $this->System->ModuleManager->Modules[$Module->Name]->Id = $this->Database->insert_id;
     470        $this->System->ModuleManager->GetModule($Module->Name)->Id = $this->Database->insert_id;
    473471      }
    474472      else $this->Database->update('Module', 'Name = "'.$Module->Name.'"', array(
     
    512510      {
    513511        if (!array_key_exists($Module->Id, $DbDependency) or
    514         !in_array($this->System->ModuleManager->Modules[$Dependency]->Id, $DbDependency[$Module->Id]))
     512        !in_array($this->System->ModuleManager->GetModule($Dependency)->Id, $DbDependency[$Module->Id]))
    515513        {
    516           if (array_key_exists($Dependency, $this->System->ModuleManager->Modules))
    517             $DependencyId = $this->System->ModuleManager->Modules[$Dependency]->Id;
     514          if ($this->System->ModuleManager->ModulePresent($Dependency))
     515            $DependencyId = $this->System->ModuleManager->GetModule($Dependency)->Id;
    518516            else throw new Exception('Dependent module '.$Dependency.' not found');
    519517          $this->Database->insert('ModuleLink', array('Module' => $Module->Id,
     
    534532    return $Output;
    535533  }
     534
     535  static function Cast(AppModule $AppModule): ModuleSystem
     536  {
     537    if ($AppModule instanceof ModuleSystem)
     538    {
     539      return $AppModule;
     540    }
     541    throw new Exception('Expected ModuleSystem type but got '.gettype($AppModule));
     542  }
    536543}
  • trunk/Modules/TV/TV.php

    r874 r887  
    55class PageIPTV extends Page
    66{
    7   var $FullTitle = 'Síťová televize';
    8   var $ShortTitle = 'IPTV';
    9   var $ParentClass = 'PagePortal';
    10 
    11   function Show()
     7  function __construct(System $System)
    128  {
    13     if (count($this->System->PathItems) > 1)
    14     {
    15       if ($this->System->PathItems[1] == 'playlist.m3u') return $this->ShowPlayList();
    16         else return PAGE_NOT_FOUND;
    17     } else return $this->ShowChannelList();
     9    parent::__construct($System);
     10    $this->FullTitle = 'Síťová televize';
     11    $this->ShortTitle = 'IPTV';
     12    $this->ParentClass = 'PagePortal';
    1813  }
    1914
    20   function ShowChannelList()
     15  function Show(): string
    2116  {
    22     global $Channels;
    23 
    24     $Output = 'Stažení přehrávače: <a href="http://www.videolan.org/vlc/">VLC Media Player</a><br/>'.
     17    $Output = 'Stažení přehrávače: <a href="https://www.videolan.org/vlc/">VLC Media Player</a><br/>'.
    2518    'Seznam všech kanálů do přehrávače: <a href="playlist.m3u">Playlist</a><br/>'.
    2619    'Zobrazení playlistu ve VLC lze provést pomocí menu <strong>View - Playlist</strong> nebo klávesové zkratky CTRL+L<br/>'.
     
    2821    '<div align="center"><strong>Výpis kanálů:</strong><br>';
    2922
    30     $Where =
    3123    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `TV` LEFT JOIN `TVGroup` ON `TVGroup`.`Id` = `TV`.`Category` '.
    3224      ' LEFT JOIN `Language` ON `Language`.`Id` = `TV`.`Language` WHERE (`TV`.`Stream` <> "") OR (`TV`.`StreamWeb` <> "")');
     
    6961    $Output .= '</div><br/>';
    7062
    71     $Output .= 'Další online TV na webu: <a href="http://spustit.cz">Spustit.cz</a><br/>';
    72     $Output .= 'Další online TV na webu: <a href="http://www.tvinfo.cz/live/televize/evropa/cz">TV info</a><br/>';
     63    $Output .= 'Další online TV na webu: <a href="https://spustit.cz/">Spustit.cz</a><br/>';
    7364
    7465    return $Output;
    7566  }
     67}
    7668
    77   function ShowPlayList()
     69class PagePlaylist extends Page
     70{
     71  function Show(): string
    7872  {
    7973    $this->ClearPage = true;
     
    8276    Header("Content-Disposition: attachment; filename=playlist.m3u");
    8377
    84     echo('#EXTM3U'."\n");
     78    $Output = '#EXTM3U'."\n";
    8579    if (array_key_exists('id', $_GET))
    8680    {
     
    8983      {
    9084        $Channel = $DbResult->fetch_array();
    91         echo('#EXTINF:0,'.$Channel['Name']."\n");
    92         echo($Channel['Stream']."\n");
     85        $Output .= '#EXTINF:0,'.$Channel['Name']."\n";
     86        $Output .= $Channel['Stream']."\n";
    9387      }
    9488    } else
     
    9791      while ($Channel = $DbResult->fetch_array())
    9892      {
    99         echo('#EXTINF:0,'.$Channel['Name']."\n");
    100         echo($Channel['Stream']."\n");
     93        $Output .= '#EXTINF:0,'.$Channel['Name']."\n";
     94        $Output .= $Channel['Stream']."\n";
    10195      }
    10296    }
     97    return $Output;
    10398  }
    10499}
     
    106101class ModuleTV extends AppModule
    107102{
    108   function __construct($System)
     103  function __construct(System $System)
    109104  {
    110105    parent::__construct($System);
     
    117112  }
    118113
    119   function DoInstall()
     114  function DoInstall(): void
    120115  {
    121116  }
    122117
    123   function DoUninstall()
     118  function DoUninstall(): void
    124119  {
    125120  }
    126121
    127   function DoStart()
     122  function DoStart(): void
    128123  {
    129     $this->System->RegisterPage('tv', 'PageIPTV');
     124    $this->System->RegisterPage(['tv'], 'PageIPTV');
     125    $this->System->RegisterPage(['tv', 'playlist.m3u'], 'PagePlaylist');
    130126    $this->System->FormManager->RegisterClass('TV', array(
    131127      'Title' => 'TV kanály',
     
    170166  }
    171167
    172   function DoStop()
     168  function DoStop(): void
    173169  {
    174170  }
  • trunk/Modules/TV/tkr.php

    r874 r887  
    33class CableTVChennelListPage extends Page
    44{
    5   var $FullTitle = 'Seznam televizních kanálů místní kabelové televize';
    6   var $ShortTitle = 'Kanály kabelové televize';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Seznam televizních kanálů místní kabelové televize';
     9    $this->ShortTitle = 'Kanály kabelové televize';
     10  }
    711
    8   function Show()
     12  function Show(): string
    913  {
    1014    $Output = '<div align="center"><strong>Výpis kanálů:</strong><br>'.
     
    2125}
    2226
    23 $System->AddModule(new CableTVChennelListPage($System));
    24 $System->Modules['CableTVChennelListPage']->GetOutput();
     27$Page = new CableTVChennelListPage($System);
     28$Page->GetOutput();
  • trunk/Modules/Task/Task.php

    r760 r887  
    33class ModuleTask extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->System->FormManager->RegisterClass('Task', array(
     
    8989    ));
    9090
    91     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('Task',
    92       array('ModuleTask', 'ShowDashboardItem'));
     91    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('Task',
     92      array($this, 'ShowDashboardItem'));
    9393  }
    9494
    95   function DoInstall()
     95  function DoInstall(): void
    9696  {
    97 
    9897  }
    9998
    100   function ShowDashboardItem()
     99  function ShowDashboardItem(): string
    101100  {
    102101    $DbResult = $this->Database->select('Task', 'COUNT(*)', '`Progress` < 100');
  • trunk/Modules/TimeMeasure/Graph.php

    r874 r887  
    99  var $DefaultHeight;
    1010
    11   function __construct($System)
     11  function __construct(System $System)
    1212  {
    1313    parent::__construct($System);
     
    1717  }
    1818
    19   function Show()
     19  function Show(): string
    2020  {
    2121    $this->ClearPage = true;
    22     return $this->Render();
     22    $this->Render();
     23    return '';
    2324  }
    2425
    25   function Render()
     26  function Render(): void
    2627  {
    2728    $PrefixMultiplier = new PrefixMultiplier();
  • trunk/Modules/TimeMeasure/Main.php

    r874 r887  
    33class PageMeasure extends Page
    44{
    5   var $GraphTimeRanges;
    6   var $DefaultVariables;
    7   var $ImageHeight;
    8   var $ImageWidth;
    9 
    10   function __construct($System)
     5  public array $GraphTimeRanges;
     6  public array $DefaultVariables;
     7  public int $ImageHeight;
     8  public int $ImageWidth;
     9
     10  function __construct(System $System)
    1111  {
    1212    parent::__construct($System);
     
    2323    );
    2424    $this->GraphTimeRanges = array
    25   (
    26     'hour' => array(
    27       'caption' => 'Hodina',
    28       'period' => 3600,
    29     ),
    30     'day' => array(
    31       'caption' => 'Den',
    32       'period' => 86400, // 3600 * 24,
    33     ),
    34     'week' => array(
    35       'caption' => 'Týden',
    36       'period' => 604800, // 3600 * 24 * 7,
    37     ),
    38     'month' => array(
    39       'caption' => 'Měsíc',
    40       'period' => 2592000, // 3600 * 24 * 30,
    41     ),
    42     'year' => array(
    43       'caption' => 'Rok',
    44       'period' => 31536000, // 3600 * 24 * 365,
    45     ),
    46     'years' => array(
    47       'caption' => 'Desetiletí',
    48       'period' => 315360000, // 3600 * 24 * 365 * 10,
    49     ),
    50   );
     25    (
     26      'hour' => array(
     27        'caption' => 'Hodina',
     28        'period' => 3600,
     29      ),
     30      'day' => array(
     31        'caption' => 'Den',
     32        'period' => 86400, // 3600 * 24,
     33      ),
     34      'week' => array(
     35        'caption' => 'Týden',
     36        'period' => 604800, // 3600 * 24 * 7,
     37      ),
     38      'month' => array(
     39        'caption' => 'Měsíc',
     40        'period' => 2592000, // 3600 * 24 * 30,
     41      ),
     42      'year' => array(
     43        'caption' => 'Rok',
     44        'period' => 31536000, // 3600 * 24 * 365,
     45      ),
     46      'years' => array(
     47        'caption' => 'Desetiletí',
     48        'period' => 315360000, // 3600 * 24 * 365 * 10,
     49      ),
     50    );
    5151  }
    5252
     
    114114  }
    115115
    116   function Show()
     116  function Show(): string
    117117  {
    118118    $Debug = 0;
     
    182182  }
    183183
    184   function Graph()
     184  function Graph(): string
    185185  {
    186186    $Output = '<strong>Graf:</strong><br/>';
     
    194194  }
    195195
    196   function MeasureTable()
     196  function MeasureTable(): string
    197197  {
    198198    $PrefixMultiplier = new PrefixMultiplier();
     
    266266class PageMeasureAddValue extends Page
    267267{
    268   function Show()
     268  function Show(): string
    269269  {
    270270    $this->ClearPage = true;
  • trunk/Modules/TimeMeasure/TimeMeasure.php

    r738 r887  
    77class ModuleTimeMeasure extends AppModule
    88{
    9   function __construct($System)
     9  function __construct(System $System)
    1010  {
    1111    parent::__construct($System);
     
    1818  }
    1919
    20   function DoInstall()
     20  function DoInstall(): void
    2121  {
    2222  }
    2323
    24   function DoUnInstall()
     24  function DoUnInstall(): void
    2525  {
    2626  }
    2727
    28   function DoStart()
     28  function DoStart(): void
    2929  {
    30     $this->System->RegisterPage('grafy', 'PageMeasure');
    31     $this->System->RegisterPage(array('grafy', 'graf.png'), 'PageGraph');
    32     $this->System->RegisterPage(array('grafy', 'add.php'), 'PageMeasureAddValue');
     30    $this->System->RegisterPage(['grafy'], 'PageMeasure');
     31    $this->System->RegisterPage(['grafy', 'graf.png'], 'PageGraph');
     32    $this->System->RegisterPage(['grafy', 'add.php'], 'PageMeasureAddValue');
    3333    $this->System->FormManager->RegisterClass('Measure', array(
    3434      'Title' => 'Měření',
     
    5050  }
    5151
    52   function DoStop()
     52  function DoStop(): void
    5353  {
    5454  }
  • trunk/Modules/User/User.php

    r874 r887  
    77class ModuleUser extends AppModule
    88{
    9   var $UserPanel;
    10 
    11   function __construct($System)
     9  public array $UserPanel;
     10  public User $User;
     11
     12  function __construct(System $System)
    1213  {
    1314    parent::__construct($System);
     
    1920    $this->Dependencies = array();
    2021    $this->UserPanel = array();
    21   }
    22 
    23   function DoInstall()
     22    $this->User = new User($System);
     23  }
     24
     25  function DoInstall(): void
    2426  {
    2527    $this->Database->query("CREATE TABLE IF NOT EXISTS `User` (
     
    108110  }
    109111
    110   function DoUninstall()
     112  function DoUninstall(): void
    111113  {
    112114    $this->Database->query('DROP TABLE `PermissionUserAssignment`');
     
    118120  }
    119121
    120   function DoUpgrade()
     122  function DoUpgrade(): void
    121123  {
    122124    /*
     
    129131  }
    130132
    131   function DoStart()
    132   {
    133     $this->System->User = new User($this->System);
    134     if (isset($_SERVER['REMOTE_ADDR'])) $this->System->User->Check();
    135     $this->System->RegisterPage('userlist', 'PageUserList');
    136     $this->System->RegisterPage('user', 'PageUser');
     133  function DoStart(): void
     134  {
     135    if (isset($_SERVER['REMOTE_ADDR'])) $this->User->Check();
     136    $this->System->RegisterPage(['userlist'], 'PageUserList');
     137    $this->System->RegisterPage(['user'], 'PageUser');
    137138    $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    138139    $this->System->FormManager->RegisterClass('UserLogin', array(
     
    272273      'Filter' => '1',
    273274    ));
    274     $this->System->ModuleManager->Modules['IS']->RegisterDashboardItem('User',
    275         array('ModuleUser', 'ShowDashboardItem'));
    276   }
    277 
    278   function ShowDashboardItem()
     275    ModuleIS::Cast($this->System->GetModule('IS'))->RegisterDashboardItem('User',
     276      array($this, 'ShowDashboardItem'));
     277  }
     278
     279  function ShowDashboardItem(): string
    279280  {
    280281    $DbResult = $this->Database->select('User', 'COUNT(*)', '1');
     
    284285  }
    285286
    286   function DoStop()
    287   {
    288   }
    289 
    290   function TopBarCallback()
    291   {
    292     if ($this->System->User->User['Id'] == null)
     287  function DoStop(): void
     288  {
     289  }
     290
     291  function TopBarCallback(): string
     292  {
     293    if ($this->User->User['Id'] == null)
    293294    {
    294295      $Output = '<a href="'.$this->System->Link('/user/?Action=LoginForm').'">Přihlášení</a> '.
     
    296297    } else
    297298    {
    298       $Output = $this->System->User->User['Name'].
     299      $Output = $this->User->User['Name'].
    299300        ' <a href="'.$this->System->Link('/user/?Action=UserMenu').'">Nabídka</a>'.
    300301        ' <a href="'.$this->System->Link('/user/?Action=Logout').'">Odhlásit</a>';
     
    303304    return $Output;
    304305  }
     306
     307  static function Cast(AppModule $AppModule): ModuleUser
     308  {
     309    if ($AppModule instanceof ModuleUser)
     310    {
     311      return $AppModule;
     312    }
     313    throw new Exception('Expected ModuleUser type but got '.gettype($AppModule));
     314  }
    305315}
  • trunk/Modules/User/UserList.php

    r874 r887  
    33class PageUserList extends Page
    44{
    5   var $FullTitle = 'Seznam registrovaných uživatelů';
    6   var $ShortTitle = 'Seznam uživatelů';
    7   var $ParentClass = 'PagePortal';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Seznam registrovaných uživatelů';
     9    $this->ShortTitle = 'Seznam uživatelů';
     10    $this->ParentClass = 'PagePortal';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     if (!$this->System->User->CheckPermission('User', 'ShowList'))
     15    if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('User', 'ShowList'))
    1216      return 'Nemáte oprávnění';
    1317
  • trunk/Modules/User/UserModel.php

    r878 r887  
    2828class PasswordHash
    2929{
    30   function Hash($Password, $Salt)
     30  function Hash(string $Password, string $Salt): string
    3131  {
    3232    return sha1(sha1($Password).$Salt);
    3333  }
    3434
    35   function Verify($Password, $Salt, $StoredHash)
     35  function Verify(string $Password, string $Salt, string $StoredHash): bool
    3636  {
    3737    return $this->Hash($Password, $Salt) == $StoredHash;
    3838  }
    3939
    40   function GetSalt()
     40  function GetSalt(): string
    4141  {
    4242    mt_srand(microtime(true) * 100000 + memory_get_usage(true));
     
    4949class User extends Model
    5050{
    51   var $Roles = array();
    52   var $User = array();
    53   var $OnlineStateTimeout;
    54   var $PermissionCache = array();
    55   var $PermissionGroupCache = array();
    56   var $PermissionGroupCacheOp = array();
    57   /** @var Password */
    58   var $PasswordHash;
    59 
    60   function __construct($System)
     51  public array $Roles = array();
     52  public array $User = array();
     53  public int $OnlineStateTimeout;
     54  public array $PermissionCache = array();
     55  public array $PermissionGroupCache = array();
     56  public array $PermissionGroupCacheOp = array();
     57  public PasswordHash $PasswordHash;
     58
     59  function __construct(System $System)
    6160  {
    6261    parent::__construct($System);
     
    6665  }
    6766
    68   function Check()
     67  function Check(): void
    6968  {
    7069    $SID = session_id();
     
    117116    {
    118117      $this->Database->delete('UserOnline', 'Id='.$DbRow['Id']);
    119       if ($DbRow['User'] != null) $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout');
     118      if ($DbRow['User'] != null) ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout');
    120119    }
    121120    //$this->LoadPermission($this->User['Role']);
     
    125124  }
    126125
    127   function Register($Login, $Password, $Password2, $Email, $Name)
     126  function Register(string $Login, string $Password, string $Password2, string $Email, string $Name): string
    128127  {
    129128    if (($Email == '') || ($Login == '') || ($Password == '') || ($Password2 == '')  || ($Name == '')) $Result = DATA_MISSING;
     
    172171
    173172            $Result = USER_REGISTRATED;
    174             $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'NewRegistration', $Login);
     173            ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'NewRegistration', $Login);
    175174          }
    176175        }
     
    180179  }
    181180
    182   function RegisterConfirm($Id, $Hash)
     181  function RegisterConfirm(string $Id, string $Hash): string
    183182  {
    184183    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
     
    191190        $this->Database->update('User', 'Id='.$Row['Id'], array('Locked' => 0));
    192191        $Output = USER_REGISTRATION_CONFIRMED;
    193         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'Login='.
     192        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'RegisterConfirm', 'Login='.
    194193          $Row['Login'].', Id='.$Row['Id']);
    195194      } else $Output = PASSWORDS_UNMATCHED;
     
    198197  }
    199198
    200   function Login($Login, $Password, $StayLogged = false)
     199  function Login(string $Login, string $Password, bool $StayLogged = false): string
    201200  {
    202201    if ($StayLogged) $StayLogged = 1; else $StayLogged = 0;
     
    228227        $Result = USER_LOGGED_IN;
    229228        $this->Check();
    230         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
     229        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Login', 'Login='.$Login.',Host='.gethostbyaddr(GetRemoteAddress()));
    231230      }
    232231    } else $Result = USER_NOT_REGISTRED;
     
    234233  }
    235234
    236   function Logout()
     235  function Logout(): string
    237236  {
    238237    $SID = session_id();
    239238    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => null));
    240     $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Logout', $this->User['Login']);
     239    ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Logout', $this->User['Login']);
    241240    $this->Check();
    242241    return USER_LOGGED_OUT;
     
    248247    $DbResult = $this->Database->select('UserRole', '*');
    249248    while ($DbRow = $DbResult->fetch_array())
     249    {
    250250      $this->Roles[] = $DbRow;
     251    }
    251252  }
    252253
     
    257258    if ($DbResult->num_rows > 0)
    258259    while ($DbRow = $DbResult->fetch_array())
     260    {
    259261      $this->User['Permission'][$DbRow['Operation']] = $DbRow;
    260   }
    261 
    262   function PermissionMatrix()
     262    }
     263  }
     264
     265  function PermissionMatrix(): array
    263266  {
    264267    $Result = array();
     
    274277  }
    275278
    276   function CheckGroupPermission($GroupId, $OperationId)
     279  function CheckGroupPermission(string $GroupId, string $OperationId): bool
    277280  {
    278281    $PermissionExists = false;
     
    322325  }
    323326
    324   function CheckPermission($Module, $Operation, $ItemType = '', $ItemIndex = 0)
     327  function CheckPermission(string $Module, string $Operation, string $ItemType = '', int $ItemIndex = 0): bool
    325328  {
    326329    // Get module id
     
    373376  }
    374377
    375   function PasswordRecoveryRequest($Login, $Email)
     378  function PasswordRecoveryRequest(string $Login, string $Email): string
    376379  {
    377380    $DbResult = $this->Database->select('User', 'Login, Name, Id, Email, Password', '`Login`="'.$Login.'" AND `Email`="'.$Email.'"');
     
    395398
    396399      $Output = USER_PASSWORD_RECOVERY_SUCCESS;
    397       $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
     400      ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryRequest', 'Login='.$Login.',Email='.$Email);
    398401    } else $Output = USER_PASSWORD_RECOVERY_FAIL;
    399402    return $Output;
    400403  }
    401404
    402   function PasswordRecoveryConfirm($Id, $Hash, $NewPassword)
     405  function PasswordRecoveryConfirm(string $Id, string $Hash, string $NewPassword): string
    403406  {
    404407    $DbResult = $this->Database->select('User', 'Id, Login, Password', 'Id = '.$Id);
     
    414417          'Salt' => $Salt, 'Locked' => 0));
    415418        $Output = USER_PASSWORD_RECOVERY_CONFIRMED;
    416         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
     419        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'PasswordRecoveryConfirm', 'Login='.$Row['Login']);
    417420      } else $Output = PASSWORDS_UNMATCHED;
    418421    } else $Output = USER_NOT_FOUND;
     
    420423  }
    421424
    422   function CheckToken($Module, $Operation, $Token)
     425  function CheckToken(string $Module, string $Operation, string $Token): bool
    423426  {
    424427    $DbResult = $this->Database->select('APIToken', 'User', '`Token`="'.$Token.'"');
  • trunk/Modules/User/UserPage.php

    r874 r887  
    33class PageUser extends Page
    44{
    5   var $FullTitle = 'Uživatel';
    6   var $ShortTitle = 'Uživatel';
    7   var $ParentClass = 'PagePortal';
    8 
    9   function Panel($Title, $Content, $Menu = array())
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Uživatel';
     9    $this->ShortTitle = 'Uživatel';
     10    $this->ParentClass = 'PagePortal';
     11  }
     12
     13  function Panel(string $Title, string $Content, array $Menu = array()): string
    1014  {
    1115    if (count($Menu) > 0)
     
    1519  }
    1620
    17   function ShowContacts()
     21  function ShowContacts(): string
    1822  {
    1923    $Query = 'SELECT `Contact`.`Value`, `Contact`.`Description`, (SELECT `Name` FROM `ContactCategory` WHERE `ContactCategory`.`Id` = `Contact`.`Category`) AS `Category` '.
    2024      'FROM `Contact` WHERE `User` = '.
    21       $this->System->User->User['Id'];
     25      ModuleUser::Cast($this->System->GetModule('User'))->User->User['Id'];
    2226    $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS T');
    2327    $DbRow = $DbResult->fetch_row();
     
    5357  }
    5458
    55   function ShowUserPanel()
    56   {
     59  function ShowUserPanel(): string
     60  {
     61    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    5762    $Output = '';
    58     if ($this->System->User->User['Id'] != null)
     63    if ($User->User['Id'] != null)
    5964    {
    6065      $Actions = '';
    61       foreach ($this->System->ModuleManager->Modules['User']->UserPanel as $Action)
     66      foreach (ModuleUser::Cast($this->System->GetModule('User'))->UserPanel as $Action)
    6267      {
    6368        if (is_string($Action[0]))
     
    7176      $Output .= $this->Panel('Nabídka uživatele', $Actions);
    7277      $Output .= '</td><td style="vertical-align:top;">';
    73       if ($this->System->User->User['Id'] != null)
     78      if ($User->User['Id'] != null)
    7479        {
    7580          $Form = new Form($this->System->FormManager);
    7681          $Form->SetClass('UserOptions');
    77           $Form->LoadValuesFromDatabase($this->System->User->User['Id']);
     82          $Form->LoadValuesFromDatabase($User->User['Id']);
    7883          $Form->OnSubmit = '?Action=UserOptionsSave';
    7984          $Output .= $Form->ShowViewForm();
     
    8893  }
    8994
    90   function Show()
    91   {
     95  function Show(): string
     96  {
     97    $User = &ModuleUser::Cast($this->System->GetModule('User'))->User;
    9298    $Output = '';
    9399    if (array_key_exists('Action', $_GET))
     
    112118          if (array_key_exists('StayLogged', $_POST) and ($_POST['StayLogged'] == 'on')) $StayLogged = true;
    113119            else $StayLogged = false;
    114           $Result = $this->System->User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
     120          $Result = $User->Login($_POST['Username'], $_POST['Password'], $StayLogged);
    115121          $Output .= $this->SystemMessage('Přihlášení', $Result);
    116122          if ($Result <> USER_LOGGED_IN)
     
    130136      if ($Action == 'Logout')
    131137      {
    132         if ($this->System->User->User['Id'] != null)
    133         {
    134           $Output .= $this->SystemMessage('Odhlášení', $this->System->User->Logout());
     138        if ($User->User['Id'] != null)
     139        {
     140          $Output .= $this->SystemMessage('Odhlášení', $User->Logout());
    135141        } else $Output .= $this->SystemMessage('Nastavení uživatele', 'Nejste přihlášen');
    136142      } else
    137143      if ($Action == 'UserOptions')
    138144      {
    139         if ($this->System->User->User['Id'] != null)
     145        if ($User->User['Id'] != null)
    140146        {
    141147          $Form = new Form($this->System->FormManager);
    142148          $Form->SetClass('UserOptions');
    143           $Form->LoadValuesFromDatabase($this->System->User->User['Id']);
     149          $Form->LoadValuesFromDatabase($User->User['Id']);
    144150          $Form->OnSubmit = '?Action=UserOptionsSave';
    145151          $Output .= $Form->ShowEditForm();
     
    151157        $Form->SetClass('UserOptions');
    152158        $Form->LoadValuesFromForm();
    153         $Form->SaveValuesToDatabase($this->System->User->User['Id']);
     159        $Form->SaveValuesToDatabase($User->User['Id']);
    154160        $Output .= $this->SystemMessage('Nastavení', 'Nastavení uloženo.');
    155         $this->System->ModuleManager->Modules['Log']->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']);
    156         $Form->LoadValuesFromDatabase($this->System->User->User['Id']);
     161        ModuleLog::Cast($this->System->GetModule('Log'))->NewRecord('User', 'Nastavení uživatele změněno', $Form->Values['Name']);
     162        $Form->LoadValuesFromDatabase($User->User['Id']);
    157163        $Form->OnSubmit = '?Action=UserOptionsSave';
    158164        $Output .= $Form->ShowEditForm();
     
    169175      {
    170176        $Output .= $this->SystemMessage('Potvrzení registrace',
    171           $this->System->User->RegisterConfirm($_GET['User'], $_GET['H']));
     177          $User->RegisterConfirm($_GET['User'], $_GET['H']));
    172178      } else
    173179      if ($Action == 'PasswordRecovery')
     
    183189        $Form->SetClass('PasswordRecovery');
    184190        $Form->LoadValuesFromForm();
    185         $Result = $this->System->User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
     191        $Result = $User->PasswordRecoveryRequest($Form->Values['Name'], $Form->Values['Email']);
    186192        $Output .= $this->SystemMessage('Obnova hesla', $Result);
    187193        if ($Result <> USER_PASSWORD_RECOVERY_SUCCESS)
     
    192198      if ($Action == 'PasswordRecoveryConfirm')
    193199      {
    194         $Output .= $this->SystemMessage('Obnova hesla', $this->System->User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
     200        $Output .= $this->SystemMessage('Obnova hesla', $User->PasswordRecoveryConfirm($_GET['User'], $_GET['H'], $_GET['P']));
    195201      } else
    196202      if ($Action == 'UserRegisterSave')
     
    199205        $Form->SetClass('UserRegister');
    200206        $Form->LoadValuesFromForm();
    201         $Result = $this->System->User->Register($Form->Values['Login'], $Form->Values['Password'],
     207        $Result = $User->Register($Form->Values['Login'], $Form->Values['Password'],
    202208          $Form->Values['Password2'], $Form->Values['Email'], $Form->Values['Name']);
    203209        $Output .= $this->SystemMessage('Registrace nového účtu', $Result);
     
    216222  }
    217223
    218   function ShowMain()
     224  function ShowMain(): string
    219225  {
    220226    $Output = 'Nebyla vybrána akce';
  • trunk/Modules/VPS/VPS.php

    r770 r887  
    33class ModuleVPS extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1616  }
    1717
    18   function DoStart()
     18  function DoStart(): void
    1919  {
    2020
    2121  }
    2222
    23   function DoInstall()
     23  function DoInstall(): void
    2424  {
    2525
  • trunk/Modules/WebCam/WebCam.php

    r874 r887  
    33class PageWebcam extends Page
    44{
    5   var $FullTitle = 'Webová kamera';
    6   var $ShortTitle = 'Kamera';
    7   var $ParentClass = 'PagePortal';
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->FullTitle = 'Webová kamera';
     9    $this->ShortTitle = 'Kamera';
     10    $this->ParentClass = 'PagePortal';
     11  }
    812
    9   function Show()
     13  function Show(): string
    1014  {
    11     if (file_exists($this->System->ModuleManager->Modules['WebCam']->ImageFileName))
     15    if (file_exists(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName))
    1216    {
    1317      $Output = '<script language="JavaScript">
    14       var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'.$this->System->Modules['Webcam']->ImageFileName.'";
     18      var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'.ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName.'";
    1519
    1620      // Force an immediate image load
     
    3236      </script>';
    3337
    34       $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '.date('j.n.Y G:i', filemtime($this->System->Modules['Webcam']->ImageFileName)).'<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />';
     38      $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '.
     39        date('j.n.Y G:i', filemtime(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)).
     40        '<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />';
    3541    } else $Output = '<br />Obrázek nenalezen.<br /><br />';
    3642
     
    4450class ModuleWebCam extends AppModule
    4551{
    46   var $ImageFileName = 'webcam.jpg';
     52  public string $ImageFileName = 'webcam.jpg';
    4753
    48   function __construct($System)
     54  function __construct(System $System)
    4955  {
    5056    parent::__construct($System);
     
    5864  }
    5965
    60   function DoStart()
     66  function DoStart(): void
    6167  {
    6268    $this->System->Pages['webcam'] = 'PageWebcam';
    6369  }
    6470
    65  function ShowImage()
     71 function ShowImage(): string
    6672  {
    6773    global $Config;
     
    7480    return $Output;
    7581  }
     82
     83  static function Cast(AppModule $AppModule): ModuleWebCam
     84  {
     85    if ($AppModule instanceof ModuleWebCam)
     86    {
     87      return $AppModule;
     88    }
     89    throw new Exception('Expected ModuleWebCam type but got '.gettype($AppModule));
     90  }
    7691}
  • trunk/Modules/Wiki/Wiki.php

    r874 r887  
    33class ModuleWiki extends AppModule
    44{
    5   function __construct($System)
     5  function __construct(System $System)
    66  {
    77    parent::__construct($System);
     
    1515  }
    1616
    17   function DoInstall()
     17  function DoInstall(): void
    1818  {
    1919    parent::Install();
     
    4242  }
    4343
    44   function DoUnInstall()
     44  function DoUnInstall(): void
    4545  {
    4646    $this->Database->query('DELETE TABLE `WikiPageContent`');
     
    4848  }
    4949
    50   function DoStart()
     50  function DoStart(): void
    5151  {
    5252    $this->LoadPages();
    5353  }
    5454
    55   function DoStop()
    56   {
    57   }
    58 
    59   function LoadPages()
     55  function DoStop(): void
     56  {
     57  }
     58
     59  function LoadPages(): void
    6060  {
    6161    $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1');
    6262    while ($DbRow = $DbResult->fetch_assoc())
    6363    {
    64       $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
     64      $this->System->RegisterPage([$DbRow['NormalizedName']], 'PageWiki');
    6565      $this->System->RegisterMenuItem(array(
    6666        'Title' => $DbRow['Name'],
     
    7676class PageWiki extends Page
    7777{
    78   var $FullTitle = 'Wiki stránky';
    79   var $ShortTitle = 'Wiki';
    80   var $ParentClass = 'PagePortal';
    81 
    82   function Show()
     78  function __construct(System $System)
     79  {
     80    parent::__construct($System);
     81    $this->FullTitle = 'Wiki stránky';
     82    $this->ShortTitle = 'Wiki';
     83    $this->ParentClass = 'PagePortal';
     84  }
     85
     86  function Show(): string
    8387  {
    8488    if (array_key_exists('Action', $_GET))
     
    9296  }
    9397
    94   function ShowContent()
     98  function ShowContent(): string
    9599  {
    96100    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    107111          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    108112          $Output .= $DbRow2['Content'];
    109           if ($this->System->User->Licence(LICENCE_MODERATOR))
     113          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    110114            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    111         } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     115        } else $Output = ShowmMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    112116      } else
    113117      {
     
    118122          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    119123          $Output .= $DbRow2['Content'];
    120           if ($this->System->User->Licence(LICENCE_MODERATOR))
     124          if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    121125            $Output .= '<div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    122126        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    126130  }
    127131
    128   function EditContent()
    129   {
    130     if ($this->System->User->Licence(LICENCE_MODERATOR))
     132  function EditContent(): string
     133  {
     134    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    131135    {
    132136    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    151155  }
    152156
    153   function SaveContent()
    154   {
    155     if ($this->System->User->Licence(LICENCE_MODERATOR))
     157  function SaveContent(): string
     158  {
     159    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    156160    {
    157161    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    162166      if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
    163167      {
    164         $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
    165           'User' => $this->System->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
     168        $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
     169          'User' => ModuleUser::Cast($this->System->GetModule('User'))->User->Id, 'Time' => 'NOW()', 'Page' => $DbRow['Id']));
    166170        $Output = ShowMessage('Wiki stránka uložena', MESSAGE_INFORMATION);
    167171      } else $Output = ShowMessage('Nezadána platná data', MESSAGE_CRITICAL);
     
    172176  }
    173177
    174   function ShowHistory()
    175   {
    176     if ($this->System->User->Licence(LICENCE_MODERATOR))
     178  function ShowHistory(): string
     179  {
     180    if (ModuleUser::Cast($this->System->GetModule('User'))->User->Licence(LICENCE_MODERATOR))
    177181    {
    178182      $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
     
    218222  }
    219223
    220   function ToHtml($text)
     224  function ToHtml(string $text): string
    221225  {
    222226    $text = preg_replace('/&lt;source lang=&quot;(.*?)&quot;&gt;(.*?)&lt;\/source&gt;/', '<pre lang="$1">$2</pre>', $text);
  • trunk/Packages/Common/AppModule.php

    r880 r887  
    3636class AppModule
    3737{
    38   var $Id;
    39   var $Name;
    40   var $Title;
    41   var $Version;
    42   var $License;
    43   var $Creator;
    44   var $HomePage;
    45   var $Description;
    46   var $Running;
    47   var $Enabled;
    48   var $Installed;
    49   var $InstalledVersion;
    50   /** @var ModuleType */
    51   var $Type;
    52   var $Dependencies;
    53   /** @var Database */
    54   var $Database;
    55   /** @var System */
    56   var $System;
    57   /** @var AppModuleManager */
    58   var $Manager;
    59   var $OnChange;
    60 
    61   function __construct(System $System)
     38  public int $Id;
     39  public string $Name;
     40  public string $Title;
     41  public string $Version;
     42  public string $License;
     43  public string $Creator;
     44  public string $HomePage;
     45  public string $Description;
     46  public bool $Running;
     47  public bool $Enabled;
     48  public bool $Installed;
     49  public string $InstalledVersion;
     50  public int $Type;
     51  public array $Dependencies;
     52  public Database $Database;
     53  public Application $System;
     54  public AppModuleManager $Manager;
     55  public $OnChange;
     56  public array $Models;
     57
     58  function __construct(Application $System)
    6259  {
    6360    $this->System = &$System;
     
    7370    $this->Dependencies = array();
    7471    $this->Type = ModuleType::Normal;
    75   }
    76 
    77   function Install()
     72    $this->Models = array();
     73  }
     74
     75  function Install(): void
    7876  {
    7977    if ($this->Installed) return;
     
    8785  }
    8886
    89   function Uninstall()
     87  function Uninstall(): void
    9088  {
    9189    if (!$this->Installed) return;
     
    9896  }
    9997
    100   function Upgrade()
     98  function Upgrade(): void
    10199  {
    102100    if (!$this->Installed) return;
     
    108106  }
    109107
    110   function Reinstall()
     108  function Reinstall(): void
    111109  {
    112110    $this->Uninstall();
     
    115113  }
    116114
    117   function Start()
     115  function Start(): void
    118116  {
    119117    if ($this->Running) return;
     
    126124  }
    127125
    128   function Stop()
     126  function Stop(): void
    129127  {
    130128    if (!$this->Running) return;
     
    136134  }
    137135
    138   function Restart()
     136  function Restart(): void
    139137  {
    140138    $this->Stop();
     
    142140  }
    143141
    144   function Enable()
     142  function Enable(): void
    145143  {
    146144    if ($this->Enabled) return;
     
    152150  }
    153151
    154   function Disable()
     152  function Disable(): void
    155153  {
    156154    if (!$this->Enabled) return;
     
    162160  }
    163161
    164   protected function DoStart()
    165   {
    166   }
    167 
    168   protected function DoStop()
    169   {
    170   }
    171 
    172   protected function DoInstall()
    173   {
    174   }
    175 
    176   protected function DoUninstall()
    177   {
    178   }
    179 
    180   protected function DoUpgrade()
    181   {
    182 
     162  protected function DoStart(): void
     163  {
     164  }
     165
     166  protected function DoStop(): void
     167  {
     168  }
     169
     170  protected function DoInstall(): void
     171  {
     172  }
     173
     174  protected function DoUninstall(): void
     175  {
     176  }
     177
     178  protected function DoUpgrade(): void
     179  {
     180  }
     181
     182  function AddModel(Model $Model): void
     183  {
     184    $this->Models[get_class($Model)] = $Model;
    183185  }
    184186}
     
    187189class AppModuleManager
    188190{
    189   var $Modules;
    190   var $System;
    191   var $FileName;
    192   var $ModulesDir;
    193   var $OnLoadModules;
     191  public array $Modules;
     192  public System $System;
     193  public string $FileName;
     194  public string $ModulesDir;
     195  public $OnLoadModules;
    194196
    195197  function __construct(System $System)
     
    201203  }
    202204
    203   function Perform($List, $Actions, $Conditions = array(ModuleCondition::All))
     205  function Perform(array $List, array $Actions, array $Conditions = array(ModuleCondition::All)): void
    204206  {
    205207    foreach ($List as $Index => $Module)
     
    227229  }
    228230
    229   function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
     231  function EnumDependenciesCascade(AppModule $Module, array &$List, array $Conditions = array(ModuleCondition::All))
    230232  {
    231233    foreach ($Module->Dependencies as $Dependency)
     
    248250  }
    249251
    250   function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
     252  function EnumSuperiorDependenciesCascade(AppModule $Module, array &$List, array $Conditions = array(ModuleCondition::All))
    251253  {
    252254    foreach ($this->Modules as $RefModule)
     
    267269  }
    268270
    269   function Start()
     271  function Start(): void
    270272  {
    271273    $this->LoadModules();
     
    274276  }
    275277
    276   function StartAll()
     278  function StartAll(): void
    277279  {
    278280    $this->Perform($this->Modules, array(ModuleAction::Start));
    279281  }
    280282
    281   function StartEnabled()
     283  function StartEnabled(): void
    282284  {
    283285    $this->Perform($this->Modules, array(ModuleAction::Start), array(ModuleCondition::Enabled));
    284286  }
    285287
    286   function StopAll()
     288  function StopAll(): void
    287289  {
    288290    $this->Perform($this->Modules, array(ModuleAction::Stop));
    289291  }
    290292
    291   function InstallAll()
     293  function InstallAll(): void
    292294  {
    293295    $this->Perform($this->Modules, array(ModuleAction::Install));
     
    295297  }
    296298
    297   function UninstallAll()
     299  function UninstallAll(): void
    298300  {
    299301    $this->Perform($this->Modules, array(ModuleAction::Uninstall));
     
    301303  }
    302304
    303   function EnableAll()
     305  function EnableAll(): void
    304306  {
    305307    $this->Perform($this->Modules, array(ModuleAction::Enable));
     
    307309  }
    308310
    309   function DisableAll()
     311  function DisableAll(): void
    310312  {
    311313    $this->Perform($this->Modules, array(ModuleAction::Disable));
     
    313315  }
    314316
    315   function ModulePresent($Name)
     317  function ModulePresent(string $Name): bool
    316318  {
    317319    return array_key_exists($Name, $this->Modules);
    318320  }
    319321
    320   function ModuleEnabled($Name)
     322  function ModuleEnabled(string $Name): bool
    321323  {
    322324    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled;
    323325  }
    324326
    325   function ModuleRunning($Name)
     327  function ModuleRunning(string $Name): bool
    326328  {
    327329    return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running;
    328330  }
    329331
    330   /* @return Module */
    331   function SearchModuleById($Id)
     332  function GetModule(string $Name): AppModule
     333  {
     334    return $this->Modules[$Name];
     335  }
     336
     337  function SearchModuleById(int $Id): string
    332338  {
    333339    foreach ($this->Modules as $Module)
     
    339345  }
    340346
    341   function LoadState()
     347  function LoadState(): void
    342348  {
    343349    $ConfigModules = array();
     
    355361  }
    356362
    357   function SaveState()
     363  function SaveState(): void
    358364  {
    359365    $Data = array();
     
    369375  }
    370376
    371   function RegisterModule(AppModule $Module)
     377  function RegisterModule(AppModule $Module): void
    372378  {
    373379    $this->Modules[$Module->Name] = &$Module;
     
    376382  }
    377383
    378   function UnregisterModule(AppModule $Module)
     384  function UnregisterModule(AppModule $Module): void
    379385  {
    380386    unset($this->Modules[array_search($Module, $this->Modules)]);
    381387  }
    382388
    383   function LoadModulesFromDir($Directory)
     389  function LoadModulesFromDir(string $Directory): void
    384390  {
    385391    $List = scandir($Directory);
     
    395401  }
    396402
    397   function LoadModules()
     403  function LoadModules(): void
    398404  {
    399405    if (is_array($this->OnLoadModules) and (count($this->OnLoadModules) == 2) and method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    400       $this->OnLoadModules();
     406      call_user_func($this->OnLoadModules);
    401407    else $this->LoadModulesFromDir($this->ModulesDir);
    402408  }
  • trunk/Packages/Common/Application.php

    r873 r887  
    33class ModelDef
    44{
    5   var $OnChange;
    6  
     5  public array $OnChange;
     6
    77  function __construct()
    88  {
    99    $this->OnChange = array();
    1010  }
    11  
    12   function DoOnChange()
     11
     12  function DoOnChange(): void
    1313  {
    1414    foreach ($this->OnChange as $Callback)
     
    1717    }
    1818  }
    19  
    20   function RegisterOnChange($SysName, $Callback)
     19
     20  function RegisterOnChange(string $SysName, callable $Callback): void
    2121  {
    2222    $this->OnChange[$SysName] = $Callback;
    2323  }
    24  
    25   function UnregisterOnChange($SysName)
     24
     25  function UnregisterOnChange(string $SysName): void
    2626  {
    2727    unset($this->OnChange[$SysName]);
     
    2929}
    3030
     31class Command
     32{
     33  public string $Name;
     34  public string $Description;
     35  public $Callback;
     36
     37  function __construct(string $Name, string $Description, callable $Callback)
     38  {
     39    $this->Name = $Name;
     40    $this->Description = $Description;
     41    $this->Callback = $Callback;
     42  }
     43}
     44
    3145class Application extends System
    3246{
    33   var $Name;
    34   /** @var AppModuleManager */
    35   var $ModuleManager;
    36   var $Modules;
    37   var $Models;
    38  
     47  public string $Name;
     48  public AppModuleManager $ModuleManager;
     49  public array $Models;
     50  public array $CommandLine;
     51  public array $Pages;
     52
    3953  function __construct()
    4054  {
     
    4256    $this->Name = 'Application';
    4357    $this->ModuleManager = new AppModuleManager($this);
    44     $this->Modules = array();
    4558    $this->Models = array();
     59    $this->CommandLine = array();
     60    $this->Pages = array();
     61
     62    $this->RegisterCommandLine('list', 'Prints available commands', array($this, 'ListCommands'));
    4663  }
    47  
    48   function RegisterModel($SysName, $Model)
     64
     65  function GetModule(string $Name): AppModule
     66  {
     67    return $this->ModuleManager->Modules[$Name];
     68  }
     69
     70  function RegisterModel(string $SysName, array $Model): void
    4971  {
    5072    $NewModelDef = new ModelDef();
     
    5375  }
    5476
    55   function UnregisterModel($SysName)
     77  function UnregisterModel(string $SysName): void
    5678  {
    5779    unset($this->Models[$SysName]);
    5880  }
    59  
    60   function Run()
     81
     82  function RegisterCommandLine(string $Name, string $Description, callable $Callback): void
    6183  {
     84    $this->CommandLine[$Name] = new Command($Name, $Description, $Callback);
     85  }
    6286
     87  function UnrgisterCommandLine(string $Name): void
     88  {
     89    unset($this->CommandLine[$Name]);
     90  }
     91
     92  function ListCommands(array $Parameters)
     93  {
     94    $Output = 'Available commands:'."\n";
     95    foreach ($this->CommandLine as $Command)
     96    {
     97      $Output .= ' '.$Command->Name.' - '.$Command->Description."\n";
     98    }
     99    echo($Output."\n");
     100  }
     101
     102  function RegisterPage(array $Path, string $Handler): void
     103  {
     104    $Page = &$this->Pages;
     105    $LastKey = array_pop($Path);
     106    foreach ($Path as $PathItem)
     107    {
     108      $Page = &$Page[$PathItem];
     109    }
     110    if (!is_array($Page)) $Page = array('' => $Page);
     111    $Page[$LastKey] = $Handler;
     112  }
     113
     114  function UnregisterPage(array $Path): void
     115  {
     116    $Page = &$this->Pages;
     117    $LastKey = array_pop($Path);
     118    foreach ($Path as $PathItem)
     119    {
     120      $Page = &$Page[$PathItem];
     121    }
     122    unset($Page[$LastKey]);
     123  }
     124
     125  function Run(): void
     126  {
     127  }
     128
     129  function Link(string $Target): string
     130  {
     131    return $Target;
    63132  }
    64133}
  • trunk/Packages/Common/Base.php

    r790 r887  
    33class System
    44{
    5   /* @var Database */
    6   var $Database;
     5  public Database $Database;
    76
    87  function __construct()
     
    1413class Base
    1514{
    16   /** @var Application */
    17   var $System;
    18   /* @var Database */
    19   var $Database;
     15  public Application $System;
     16  public Database $Database;
    2017
    21   function __construct(Application $System)
     18  function __construct(System $System)
    2219  {
    2320    $this->System = &$System;
  • trunk/Packages/Common/Common.php

    r874 r887  
    2626class PackageCommon
    2727{
    28   var $Name;
    29   var $Version;
    30   var $ReleaseDate;
    31   var $License;
    32   var $Creator;
    33   var $Homepage;
     28  public string $Name;
     29  public string $Version;
     30  public int $ReleaseDate;
     31  public string $License;
     32  public string $Creator;
     33  public string $Homepage;
    3434
    3535  function __construct()
     
    4646class Paging
    4747{
    48   var $TotalCount;
    49   var $ItemPerPage;
    50   var $Around;
    51   var $SQLLimit;
    52   var $Page;
     48  public int $TotalCount;
     49  public int $ItemPerPage;
     50  public int $Around;
     51  public string $SQLLimit;
     52  public int $Page;
    5353
    5454  function __construct()
     
    6060  }
    6161
    62   function Show()
     62  function Show(): string
    6363  {
    6464    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
  • trunk/Packages/Common/Database.php

    r874 r887  
    22
    33// Extended database class
    4 // Date: 2016-01-11
     4// Date: 2020-11-10
    55
    66function microtime_float()
     
    1313{
    1414  var $PDOStatement;
    15   var $num_rows = 0;
     15  public int $num_rows = 0;
    1616
    1717  function fetch_assoc()
     
    3333class Database
    3434{
    35   var $Prefix;
    36   var $Functions;
    37   var $Type;
    38   var $PDO;
    39   var $Error;
    40   var $insert_id;
    41   var $LastQuery;
    42   var $ShowSQLError;
    43   var $ShowSQLQuery;
    44   var $LogSQLQuery;
    45   var $LogFile;
     35  public string $Prefix;
     36  public array $Functions;
     37  public string $Type;
     38  public PDO $PDO;
     39  public string $Error;
     40  public string $insert_id;
     41  public string $LastQuery;
     42  public bool $ShowSQLError;
     43  public bool $ShowSQLQuery;
     44  public bool $LogSQLQuery;
     45  public string $LogFile;
    4646
    4747  function __construct()
     
    5757    $this->LogFile = dirname(__FILE__).'/../../Query.log';
    5858  }
    59  
    60 
    61   function Connect($Host, $User, $Password, $Database)
     59
     60  function Connect(string $Host, string $User, string $Password, string $Database)
    6261  {
    6362    if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
     
    7978  }
    8079
    81   function Connected()
     80  function Connected(): bool
    8281  {
    8382    return isset($this->PDO);
    8483  }
    8584
    86   function select_db($Database)
     85  function select_db(string $Database)
    8786  {
    8887    $this->query('USE `'.$Database.'`');
    8988  }
    9089
    91   function query($Query)
     90  function query($Query): DatabaseResult
    9291  {
    9392    if (!$this->Connected()) throw new Exception(T('Not connected to database'));
     
    9998      $Time = round(microtime_float() - $QueryStartTime, 4);
    10099      $Duration = ' ; '.$Time. ' s';
    101     } 
     100    }
    102101    if (($this->LogSQLQuery == true) and ($Time != 0))
    103102      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
     
    112111      $this->insert_id = $this->PDO->lastInsertId();
    113112    } else
    114     {     
    115       $this->Error = $this->PDO->errorInfo();
    116       $this->Error = $this->Error[2];
     113    {
     114      $Error = $this->PDO->errorInfo();
     115      $this->Error = $Error[2];
    117116      if (($this->Error != '') and ($this->ShowSQLError == true))
    118117        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     
    122121  }
    123122
    124   function select($Table, $What = '*', $Condition = 1)
     123  function select(string $Table, string $What = '*', string $Condition = '1'): DatabaseResult
    125124  {
    126125    return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    127126  }
    128127
    129   function delete($Table, $Condition)
     128  function delete(string $Table, string $Condition)
    130129  {
    131130    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    132131  }
    133132
    134   function insert($Table, $Data)
     133  function insert(string $Table, array $Data)
    135134  {
    136135    $this->query($this->GetInsert($Table, $Data));
    137136    $this->insert_id = $this->PDO->lastInsertId();
    138137  }
    139  
    140   function GetInsert($Table, $Data)
     138
     139  function GetInsert(string $Table, array $Data): string
    141140  {
    142141    $Name = '';
     
    157156  }
    158157
    159   function update($Table, $Condition, $Data)
     158  function update(string $Table, string $Condition, array $Data)
    160159  {
    161160    $this->query($this->GetUpdate($Table, $Condition, $Data));
    162161  }
    163  
    164   function GetUpdate($Table, $Condition, $Data)
     162
     163  function GetUpdate(string $Table, string $Condition, array $Data): string
    165164  {
    166165    $Values = '';
     
    178177  }
    179178
    180   function replace($Table, $Data)
     179  function replace(string $Table, array $Data)
    181180  {
    182181    $Name = '';
     
    199198  }
    200199
    201   function charset($Charset)
     200  function charset(string $Charset)
    202201  {
    203202    $this->query('SET NAMES "'.$Charset.'"');
    204203  }
    205204
    206   function real_escape_string($Text)
     205  function real_escape_string(string $Text): string
    207206  {
    208207    return addslashes($Text);
    209208  }
    210209
    211   function quote($Text)
     210  function quote(string $Text): string
    212211  {
    213212    return $this->PDO->quote($Text);
     
    222221  {
    223222  }
    224  
    225   public function Transaction($Queries)
     223
     224  public function Transaction(array $Queries)
    226225  {
    227226    //echo('|'."\n");
  • trunk/Packages/Common/Error.php

    r873 r887  
    33class ErrorHandler
    44{
    5   var $Encoding;
    6   var $ShowError;
    7   var $UserErrors;
    8   var $OnError;
     5  public string $Encoding;
     6  public bool $ShowError;
     7  public int $UserErrors;
     8  public $OnError;
    99
    1010  function __construct()
     
    7575  }
    7676
    77   function ShowDefaultError($Message)
     77  function ShowDefaultError(string $Message): void
    7878  {
    7979    $Output = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>'."\n".
  • trunk/Packages/Common/Generics.php

    r869 r887  
    55  var $Items = array();
    66
    7   function Add($Item)
     7  function Add($Item): void
    88  {
    99    $this->Items[] = $Item;
    1010  }
    1111
    12   function RemoveAt(int $Index)
     12  function RemoveAt(int $Index): void
    1313  {
    1414    unset($this->Items[$Index]);
  • trunk/Packages/Common/Image.php

    r874 r887  
    99class Font
    1010{
    11   var $Size;
    12   var $FileName;
    13   var $Color;
     11  public int $Size;
     12  public string $FileName;
     13  public int $Color;
    1414
    1515  function __construct()
     
    2323class Pen
    2424{
    25   var $Color;
    26   var $X;
    27   var $Y;
     25  public int $Color;
     26  public int $X;
     27  public int $Y;
    2828
    2929  function __construct()
     
    3838class Brush
    3939{
    40   var $Color;
     40  public int $Color;
    4141
    4242  function __construct()
     
    4949class Image
    5050{
    51   var $Image;
    52   var $Type;
    53   var $Font;
    54   var $Pen;
     51  public $Image;
     52  public int $Type;
     53  public Font $Font;
     54  public Pen $Pen;
     55  public Brush $Brush;
    5556
    5657  function __construct()
     
    6364  }
    6465
    65   function SaveToFile($FileName)
     66  function SaveToFile(string $FileName): void
    6667  {
    6768    if ($this->Type == IMAGETYPE_JPEG)
     
    7980  }
    8081
    81   function LoadFromFile($FileName)
     82  function LoadFromFile(string $FileName): void
    8283  {
    8384    $ImageInfo = getimagesize($FileName);
     
    9798  }
    9899
    99   function Output()
     100  function Output(): void
    100101  {
    101102    $this->SaveToFile(NULL);
    102103  }
    103104
    104   function SetSize($Width, $Height)
     105  function SetSize(int $Width, int $Height): void
    105106  {
    106107    $NewImage = imagecreatetruecolor($Width, $Height);
     
    110111  }
    111112
    112   function GetWidth()
     113  function GetWidth(): int
    113114  {
    114115    return imagesx($this->Image);
    115116  }
    116117
    117   function GetHeight()
     118  function GetHeight(): int
    118119  {
    119120    return imagesy($this->Image);
    120121  }
    121122
    122   function TextOut($X, $Y, $Text)
     123  function TextOut(int $X, int $Y, string $Text): void
    123124  {
    124125    imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text);
    125126  }
    126127
    127   function ConvertColor($Color)
     128  function ConvertColor(int $Color): int
    128129  {
    129130    return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff);
    130131  }
    131132
    132   function FillRect($X1, $Y1, $X2, $Y2)
     133  function FillRect(int $X1, int $Y1, int $X2, int $Y2): void
    133134  {
    134135    imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color));
    135136  }
    136137
    137   function Line($X1, $Y1, $X2, $Y2)
     138  function Line(int $X1, int $Y1, int $X2, int $Y2): void
    138139  {
    139140    imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color));
  • trunk/Packages/Common/Locale.php

    r874 r887  
    33class LocaleText
    44{
    5   var $Data;
    6   var $Code;
    7   var $Title;
     5  public array $Data;
     6  public string $Code;
     7  public string $Title;
    88
    99  function __construct()
     
    1414  }
    1515
    16   function Load()
    17   {
    18   }
    19 
    20   function Translate($Text, $Group = '')
     16  function Load(): void
     17  {
     18  }
     19
     20  function Translate(string $Text, string $Group = ''): string
    2121  {
    2222    if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
     
    2525  }
    2626
    27   function TranslateReverse($Text, $Group = '')
     27  function TranslateReverse(string $Text, string $Group = ''): string
    2828  {
    2929    $Key = array_search($Text, $this->Data[$Group]);
     
    3535class LocaleFile extends Model
    3636{
    37   var $Texts;
    38   var $Dir;
     37  public LocaleText $Texts;
     38  public string $Dir;
    3939
    4040  function __construct(System $System)
     
    4444  }
    4545
    46   function Load($Language)
     46  function Load(string $Language): void
    4747  {
    4848    $FileName = $this->Dir.'/'.$Language.'.php';
     
    5555  }
    5656
    57   function AnalyzeCode($Path)
     57  function AnalyzeCode(string $Path): void
    5858  {
    5959    // Search for php files
     
    9898  }
    9999
    100   function SaveToFile($FileName)
     100  function SaveToFile(string $FileName): void
    101101  {
    102102    $Content = '<?php'."\n".
     
    119119  }
    120120
    121   function LoadFromDatabase($Database, $LangCode)
     121  function LoadFromDatabase(Database $Database, string $LangCode): void
    122122  {
    123123    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
     
    132132  }
    133133
    134   function SaveToDatabase(Database $Database, $LangCode)
    135   {
    136     $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
     134  function SaveToDatabase(string $LangCode): void
     135  {
     136    $DbResult = $this->Database->select('Language', '*', 'Code='.$this->Database->quote($LangCode));
    137137    if ($DbResult->num_rows > 0)
    138138    {
    139139      $Language = $DbResult->fetch_assoc();
    140       $Database->delete('Locale', '`Language`='.$Language['Id']);
     140      $this->Database->delete('Locale', '`Language`='.$Language['Id']);
    141141      foreach ($this->Texts->Data as $Index => $Item)
    142         $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
    143         'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')');
    144     }
    145   }
    146 
    147   function UpdateToDatabase(Database $Database, $LangCode)
    148   {
    149     $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode));
     142        $this->Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
     143        'VALUES('.$Language['Id'].','.$this->Database->quote($Index).','.$this->Database->quote($Item).')');
     144    }
     145  }
     146
     147  function UpdateToDatabase(string $LangCode): void
     148  {
     149    $DbResult = $this->Database->select('Language', '*', '`Code`='.$this->Database->quote($LangCode));
    150150    if ($DbResult->num_rows > 0)
    151151    {
     
    153153      foreach ($this->Texts->Data as $Index => $Item)
    154154      {
    155         $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).
     155        $DbResult = $this->Database->select('Locale', '*', '(`Original` ='.$this->Database->quote($Index).
    156156          ') AND (`Language`='.($Language['Id']).')');
    157157        if ($DbResult->num_rows > 0)
    158         $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    159           '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
    160         else $Database->insert('Locale', array('Language' => $Language['Id'],
     158        $this->Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
     159          '(`Original` ='.$this->Database->quote($Index).')', array('Translated' => $Item));
     160        else $this->Database->insert('Locale', array('Language' => $Language['Id'],
    161161         'Original' => $Index, 'Translated' => $Item));
    162162      }
     
    167167class LocaleManager extends Model
    168168{
    169   var $CurrentLocale;
    170   var $Codes;
    171   var $Dir;
    172   var $LangCode;
    173   var $DefaultLangCode;
    174   var $Available;
     169  public LocaleFile $CurrentLocale;
     170  public array $Codes;
     171  public string $Dir;
     172  public string $LangCode;
     173  public string $DefaultLangCode;
     174  public array $Available;
    175175
    176176  function __construct(System $System)
     
    182182    $this->DefaultLangCode = 'en';
    183183    $this->Available = array();
    184   }
    185 
    186   function LoadAvailable()
     184    $this->Dir = '';
     185  }
     186
     187  function LoadAvailable(): void
    187188  {
    188189    $this->Available = array();
     
    201202  }
    202203
    203   function UpdateAll($Directory)
     204  function UpdateAll(string $Directory): void
    204205  {
    205206    $Locale = new LocaleFile($this->System);
     
    222223          if (!array_key_exists($Index, $Locale->Texts->Data))
    223224            unset($FileLocale->Texts->Data[$Index]);
    224         $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code);
     225        $FileLocale->UpdateToDatabase($FileLocale->Texts->Code);
    225226        $FileName = $this->Dir.'/'.$FileLocale->Texts->Code.'.php';
    226227        $FileLocale->SaveToFile($FileName);
     
    230231  }
    231232
    232   function LoadLocale($Code)
     233  function LoadLocale(string $Code): void
    233234  {
    234235    if (array_key_exists($Code, $this->Available))
     
    241242
    242243// Short named global translation function
    243 function T($Text, $Group = '')
     244function T(string $Text, string $Group = ''): string
    244245{
    245246  global $GlobalLocaleManager;
  • trunk/Packages/Common/Mail.php

    r874 r887  
    99class Mail
    1010{
    11   var $Priorities;
    12   var $Subject;
    13   var $From;
    14   var $Recipients;
    15   var $Bodies;
    16   var $Attachments;
    17   var $AgentIdent;
    18   var $Organization;
    19   var $ReplyTo;
    20   var $Headers;
     11  public string $Subject;
     12  public string $From;
     13  public array $Recipients;
     14  public array $Bodies;
     15  public array $Attachments;
     16  public string $AgentIdent;
     17  public string $Organization;
     18  public string $ReplyTo;
     19  public array $Headers;
     20  private array $Priorities;
     21  private string $Boundary;
    2122
    2223  function __construct()
     
    2829  }
    2930
    30   function Clear()
     31  function Clear(): void
    3132  {
    3233    $this->Bodies = array();
     
    4142  }
    4243
    43   function AddToCombined($Address)
     44  function AddToCombined(string $Address): void
    4445  {
    4546    $this->Recipients[] = array('Address' => $Address, 'Type' => 'SendCombined');
    4647  }
    4748
    48   function AddTo($Address, $Name)
     49  function AddTo(string $Address, string $Name): void
    4950  {
    5051    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Send');
    5152  }
    5253
    53   function AddCc($Address, $Name)
     54  function AddCc(string $Address, string $Name): void
    5455  {
    5556    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Copy');
    5657  }
    5758
    58   function AddBcc($Address, $Name)
     59  function AddBcc(string $Address, string $Name): void
    5960  {
    6061    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'HiddenCopy');
    6162  }
    6263
    63   function AddBody($Content, $MimeType = 'text/plain', $Charset = 'utf-8')
     64  function AddBody(string $Content, string $MimeType = 'text/plain', string $Charset = 'utf-8'): void
    6465  {
    6566    $this->Bodies[] = array('Content' => $Content, 'Type' => strtolower($MimeType),
     
    6768  }
    6869
    69   function Organization($org)
     70  function Organization(string $org): void
    7071  {
    7172    if (trim($org != '')) $this->xheaders['Organization'] = $org;
    7273  }
    7374
    74   function Priority($Priority)
     75  function Priority(int $Priority): bool
    7576  {
    7677    if (!intval($Priority)) return false;
    7778
    78     if (!isset($this->priorities[$Priority - 1])) return false;
    79 
    80     $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1];
     79    if (!isset($this->Priorities[$Priority - 1])) return false;
     80
     81    $this->xheaders['X-Priority'] = $this->Priorities[$Priority - 1];
    8182    return true;
    8283  }
    8384
    84   function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT)
     85  function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT): void
    8586  {
    8687    $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType,
     
    8889  }
    8990
    90   function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT)
     91  function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT): void
    9192  {
    9293    $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType,
     
    9495  }
    9596
    96   function Send()
     97  function Send(): bool
    9798  {
    9899    if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
     
    144145    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    145146
    146 
    147147    $res = mail($To, $this->Subject, $Body, $Headers);
    148148    return $res;
    149149  }
    150150
    151   function ValidEmail($Address)
    152   {
    153     if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
    154     if (ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
     151  function ValidEmail(string $Address): bool
     152  {
     153    if (preg_match(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
     154    if (preg_match("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
    155155      return true;
    156156      else return false;
    157157  }
    158158
    159   function CheckAdresses($Addresses)
     159  function CheckAdresses(array $Addresses): void
    160160  {
    161161    foreach ($Addresses as $Address)
    162162    {
    163163      if (!$this->ValidEmail($Address))
    164   throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
    165     }
    166   }
    167 
    168   private function ContentEncoding($Charset)
     164      {
     165        throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
     166      }
     167    }
     168  }
     169
     170  private function ContentEncoding($Charset): string
    169171  {
    170172    if ($Charset != CHARSET_ASCII) return '8bit';
     
    172174  }
    173175
    174   private function BuildAttachment($Body)
     176  private function BuildAttachment($Body): string
    175177  {
    176178    if (count($this->Attachments) > 0)
     
    206208  }
    207209
    208   private function BuildBody()
     210  private function BuildBody(): string
    209211  {
    210212    $Result = '';
     
    219221      $this->Headers['Content-Transfer-Encoding'] = $this->ContentEncoding($this->Bodies[0]['Charset']);
    220222    }
    221 
    222223
    223224    foreach ($this->Bodies as $Body)
  • trunk/Packages/Common/Page.php

    r874 r887  
    33class Page extends View
    44{
    5   var $FullTitle;
    6   var $ShortTitle;
    7   var $ParentClass;
    8   var $ClearPage;
     5  public string $FullTitle;
     6  public string $ShortTitle;
     7  public string $ParentClass;
     8  public bool $ClearPage;
    99  var $OnSystemMessage;
    10   var $Load;
    11   var $Unload;
     10  public string $Load;
     11  public string $Unload;
    1212
    13   function __construct($System)
     13  function __construct(System $System)
    1414  {
    1515    parent::__construct($System);
    1616    $this->ClearPage = false;
    1717    $this->OnSystemMessage = array();
     18    $this->FullTitle = "";
     19    $this->ShortTitle = "";
     20    $this->ParentClass = "";
    1821  }
    1922
    20   function Show()
     23  function Show(): string
    2124  {
    2225    return '';
    2326  }
    2427
    25   function GetOutput()
     28  function GetOutput(): string
    2629  {
    2730    $Output = $this->Show();
     
    2932  }
    3033
    31   function SystemMessage($Title, $Text)
     34  function SystemMessage(string $Title, string $Text): string
    3235  {
    3336    return call_user_func_array($this->OnSystemMessage, array($Title, $Text));
  • trunk/Packages/Common/RSS.php

    r874 r887  
    33class RSS
    44{
    5   var $Charset;
    6   var $Title;
    7   var $Link;
    8   var $Description;
    9   var $WebmasterEmail;
    10   var $Items;
     5  public string $Charset;
     6  public string $Title;
     7  public string $Link;
     8  public string $Description;
     9  public string $WebmasterEmail;
     10  public array $Items;
    1111
    1212  function __construct()
    1313  {
    1414    $this->Charset = 'utf8';
     15    $this->Title = '';
     16    $this->Link = '';
     17    $this->Description = '';
     18    $this->WebmasterEmail = '';
    1519    $this->Items = array();
    1620  }
    1721
    18   function Generate()
     22  function Generate(): string
    1923  {
    2024    $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<?
  • trunk/Packages/Common/Setup.php

    r874 r887  
    33class PageSetup extends Page
    44{
    5   var $UpdateManager;
    6   var $ConfigDefinition;
    7   var $Config;
    8   var $DatabaseRevision;
    9   var $Revision;
    10   var $Updates;
    11   var $ConfigDir;
    12 
    13   function __construct($System)
     5  public UpdateManager $UpdateManager;
     6  public array $ConfigDefinition;
     7  public array $Config;
     8  public int $DatabaseRevision;
     9  public int $Revision;
     10  public string $ConfigDir;
     11  public array $YesNo;
     12
     13  function __construct(System $System)
    1414  {
    1515    parent::__construct($System);
    16     $this->Title = T('Application setup');
     16    $this->FullTitle = T('Application setup');
     17    $this->ShortTitle = T('Application setup');
    1718    //$this->ParentClass = 'PagePortal';
    1819    $this->ConfigDir = dirname(dirname(dirname(__FILE__))).'/Config';
     
    2021  }
    2122
    22   function LoginPanel()
     23  function LoginPanel(): string
    2324  {
    2425    $Output = '<h3>Přihlášení k instalaci</h3>'.
     
    3233  }
    3334
    34   function ControlPanel()
     35  function ControlPanel(): string
    3536  {
    3637    $Output = '<h3>'.T('Instance management').'</h3>';
     
    6263  }
    6364
    64   function Show()
     65  function Show(): string
    6566  {
    6667    global $ConfigDefinition, $DatabaseRevision, $Config, $Updates;
     
    163164  }
    164165
    165   function ShowModules()
     166  function ShowModules(): string
    166167  {
    167168    $Output = '';
     
    170171    if ($Operation == 'install')
    171172    {
    172       $this->System->ModuleManager->Modules[$_GET['name']]->Install();
     173      $this->System->ModuleManager->GetModule($_GET['name'])->Install();
    173174      $this->System->ModuleManager->SaveState();
    174175      $Output .= 'Modul '.$_GET['name'].' instalován<br/>';
     
    176177    if ($Operation == 'uninstall')
    177178    {
    178       $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall();
     179      $this->System->ModuleManager->GetModule($_GET['name'])->Uninstall();
    179180      $this->System->ModuleManager->SaveState();
    180181      $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>';
     
    182183    if ($Operation == 'enable')
    183184    {
    184       $this->System->ModuleManager->Modules[$_GET['name']]->Enable();
     185      $this->System->ModuleManager->GetModule($_GET['name'])->Enable();
    185186      $this->System->ModuleManager->SaveState();
    186187      $Output .= 'Modul '.$_GET['name'].' povolen<br/>';
     
    188189    if ($Operation == 'disable')
    189190    {
    190       $this->System->ModuleManager->Modules[$_GET['name']]->Disable();
     191      $this->System->ModuleManager->GetModule($_GET['name'])->Disable();
    191192      $this->System->ModuleManager->SaveState();
    192193      $Output .= 'Modul '.$_GET['name'].' zakázán<br/>';
     
    194195    if ($Operation == 'upgrade')
    195196    {
    196       $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade();
     197      $this->System->ModuleManager->GetModule($_GET['name'])->Upgrade();
    197198      $this->System->ModuleManager->SaveState();
    198199      $Output .= 'Modul '.$_GET['name'].' povýšen<br/>';
     
    203204  }
    204205
    205   function ShowList()
     206  function ShowList(): string
    206207  {
    207208    $Output = '';
     
    247248  }
    248249
    249   function PrepareConfig($Config)
     250  function PrepareConfig($Config): string
    250251  {
    251252    $Output = '';
     
    322323  }
    323324
    324   function CreateConfig($Config)
     325  function CreateConfig($Config): string
    325326  {
    326327    $Output = "<?php\n\n".
     
    359360class PageSetupRedirect extends Page
    360361{
    361   function Show()
     362  function Show(): string
    362363  {
    363364    $Output = '';
     
    377378class Setup extends Model
    378379{
    379   var $UpdateManager;
     380  public UpdateManager $UpdateManager;
    380381
    381382  function Start()
     
    383384    global $DatabaseRevision;
    384385
    385     $this->System->RegisterPage('', 'PageSetupRedirect');
    386     $this->System->RegisterPage('setup', 'PageSetup');
     386    $this->System->RegisterPage([''], 'PageSetupRedirect');
     387    $this->System->RegisterPage(['setup'], 'PageSetup');
    387388
    388389    // Check database persistence structure
     
    396397  {
    397398    unset($this->UpdateManager);
    398     $this->System->UnregisterPage('');
    399     $this->System->UnregisterPage('setup');
    400   }
    401 
    402   function CheckState()
     399    $this->System->UnregisterPage(['']);
     400    $this->System->UnregisterPage(['setup']);
     401  }
     402
     403  function CheckState(): bool
    403404  {
    404405    return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     
    432433  }
    433434
    434   function IsInstalled()
     435  function IsInstalled(): bool
    435436  {
    436437    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"');
     
    438439  }
    439440
    440   function Upgrade()
     441  function Upgrade(): string
    441442  {
    442443    $Updates = new Updates();
  • trunk/Packages/Common/Table.php

    r874 r887  
    55  var $Name;
    66
    7   function Show()
     7  function Show(): string
    88  {
    99    return '';
     
    1313class Table
    1414{
    15   function GetCell($Y, $X)
     15  function GetCell($Y, $X): string
    1616  {
    1717    return '';
     
    2626  }
    2727
    28   function RowsCount()
     28  function RowsCount(): int
    2929  {
    3030    return 0;
     
    3434class TableMemory extends Table
    3535{
    36   var $Cells;
     36  public array $Cells;
    3737
    38   function GetCell($Y, $X)
     38  function GetCell($Y, $X): string
    3939  {
    4040    return $this->Cells[$Y][$X];
    4141  }
    4242
    43   function RowsCount()
     43  function RowsCount(): int
    4444  {
    4545    return count($this->Cells);
     
    4949class TableSQL extends Table
    5050{
    51   var $Query;
    52   var $Database;
    53   var $Cells;
     51  public string $Query;
     52  public Database $Database;
     53  public array $Cells;
    5454
    55   function GetCell($Y, $X)
     55  function GetCell($Y, $X): string
    5656  {
    5757    return $this->Cells[$Y][$X];
     
    7373  }
    7474
    75   function RowsCount()
     75  function RowsCount(): int
    7676  {
    7777    return count($this->Cells);
     
    8181class TableColumn
    8282{
    83   var $Name;
    84   var $Title;
     83  public string $Name;
     84  public string $Title;
    8585}
    8686
    8787class VisualTable extends Control
    8888{
    89   var $Cells;
    90   var $Columns;
    91   var $OrderSQL;
    92   var $OrderColumn;
    93   var $OrderDirection;
    94   var $OrderArrowImage;
    95   var $DefaultColumn;
    96   var $DefaultOrder;
    97   var $Table;
    98   var $Style;
     89  public array $Cells;
     90  public array $Columns;
     91  public string $OrderSQL;
     92  public string $OrderColumn;
     93  public int $OrderDirection;
     94  public array $OrderArrowImage;
     95  public string $DefaultColumn;
     96  public int $DefaultOrder;
     97  public TableMemory $Table;
     98  public string $Style;
    9999
    100100  function __construct()
     
    126126  }
    127127
    128   function Show()
     128  function Show(): string
    129129  {
    130130    $Output = '<table class="'.$this->Style.'">';
     
    148148  }
    149149
    150   function GetOrderHeader()
     150  function GetOrderHeader(): string
    151151  {
    152152    if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
  • trunk/Packages/Common/UTF8.php

    r874 r887  
    526526  }
    527527
    528   function ToUTF8($String, $Charset = 'iso2')
     528  function ToUTF8string ($String, string $Charset = 'iso2'): string
    529529  {
    530530    $Result = '';
     
    540540  }
    541541
    542   function FromUTF8($String, $Charset = 'iso2')
     542  function FromUTF8(string $String, string $Charset = 'iso2'): string
    543543  {
    544544    $Result = '';
     
    546546    for ($I = 0; $I < strlen($String); $I++)
    547547    {
    548       if (ord($String{$I}) & 0x80) // UTF control character
     548      if (ord($String[$I]) & 0x80) // UTF control character
    549549      {
    550         if (ord($String{$I}) & 0x40) // First
     550        if (ord($String[$I]) & 0x40) // First
    551551        {
    552552          if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    553           $UTFPrefix = $String{$I};
     553          $UTFPrefix = $String[$I];
    554554        }
    555         else $UTFPrefix .= $String{$I}; // Next
     555        else $UTFPrefix .= $String[$I]; // Next
    556556      } else
    557557      {
    558558        if ($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
    559559        $UTFPrefix = '';
    560         $Result .= $String{$I};
     560        $Result .= $String[$I];
    561561      }
    562562    }
  • trunk/Packages/Common/Update.php

    r874 r887  
    33class UpdateManager
    44{
    5   var $Revision;
    6   var $Trace;
    7   var $VersionTable;
    8   /* @var Database */
    9   var $Database;
    10   var $InstallMethod;
     5  public int $Revision;
     6  public array $Trace;
     7  public string $VersionTable;
     8  public Database $Database;
     9  public string $InstallMethod;
    1110
    1211  function __construct()
     
    6362    $InstallMethod = $this->InstallMethod;
    6463    $InstallMethod($this);
    65     $this->Update();
    6664  }
    6765
     
    7775  }
    7876
    79   function Execute($Query)
     77  function Execute(string $Query): DatabaseResult
    8078  {
    8179    echo($Query.';<br/>');
  • trunk/Packages/Package.php

    r746 r887  
    11<?php
    22
    3 class Package {
    4   var $Name;
    5   var $Version;
    6   var $License;
    7   var $Creator;
    8   var $Homepage;
     3class Package
     4{
     5  public string $Name;
     6  public string $Version;
     7  public string $License;
     8  public string $Creator;
     9  public string $Homepage;
    910}
  • trunk/Readme.txt

    r848 r887  
    1 Webový portál počítačové sítě ZděchovNET
    2 ========================================
     1Internet service portal and management system
     2=============================================
     3
     4* Required PHP 7.4 or higher
    35
    461) Instalace a nastavení systému
  • trunk/block/index.php

    r886 r887  
    11<?php
    22
    3 include_once('../Application/System.php');
     3include_once('../Application/Core.php');
    44
    55class BlockPage extends Page
    66{
    7   var $FullTitle = 'Blokování internetu';
    8   var $ShortTitle = 'Blokování internetu';
    9   var $Reasons = array(
     7  private array $Reasons = array(
    108    0 => 'Internet máte povolen, avšak došlo k chybě při kontrole přístupů k Internetu.',
    119    1 => 'Váš počítač má blokován přístup k internetu. Pravděpodobně je váš účet v mínusu. Přihlaste se do systému a zkontrolujte stav vašich plateb. ',
     
    1513  );
    1614
    17   function Show()
     15  function __construct(System $System)
     16  {
     17    parent::__construct($System);
     18    $this->FullTitle = 'Blokování internetu';
     19    $this->ShortTitle = 'Blokování internetu';
     20  }
     21
     22  function Show(): string
    1823  {
    1924    $Output = '<br/><div style="font-size: 20 pt;">Máte blokován přístup k Internetu.</div>
     
    4247}
    4348
    44 $System = new System();
     49$System = new Core();
    4550$System->ShowPage = false;
    4651$System->Run();
    47 $System->AddModule(new BlockPage($System));
    48 $System->Modules['BlockPage']->GetOutput();
     52$Page = new BlockPage($System);
     53echo($Page->GetOutput());
    4954
  • trunk/cmd.php

    r873 r887  
    11<?php
    22
    3 include_once('Application/System.php');
     3include_once('Application/Core.php');
    44
    55if (isset($_SERVER['REMOTE_ADDR'])) die();
  • trunk/index.php

    r790 r887  
    11<?php
    22
    3 include_once('Application/System.php');
     3include_once('Application/Core.php');
    44
    55$System = new Core();
  • trunk/locale/cs.php

    r883 r887  
    33class LocaleTextcs extends LocaleText
    44{
    5   function Load()
     5  function Load(): void
    66  {
    77    $this->Code = 'cs';
  • trunk/locale/en.php

    r883 r887  
    33class LocaleTexten extends LocaleText
    44{
    5   function Load()
     5  function Load(): void
    66  {
    77    $this->Code = 'en';
Note: See TracChangeset for help on using the changeset viewer.