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/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();
Note: See TracChangeset for help on using the changeset viewer.