Changeset 887 for trunk/Common/VCL


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.
Location:
trunk/Common/VCL
Files:
2 edited

Legend:

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