Ignore:
Timestamp:
Nov 20, 2020, 12:08:12 AM (4 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/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');
Note: See TracChangeset for help on using the changeset viewer.