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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.