Ignore:
Timestamp:
Dec 6, 2021, 11:33:48 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Updated Common package.
  • Added: Explicit types for better type checking.
  • Fixed: Support for php 8.0.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/Table.php

    r94 r95  
    11<?php
    22
    3 class Control extends Base
     3class Control
    44{
    5   var $Name;
     5  public string $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
    100   function __construct(Application $System)
     100  function __construct()
    101101  {
    102     parent::__construct($System);
     102    global $System;
    103103
    104104    $this->Columns = array();
    105105    $this->Table = new TableMemory();
    106106    $this->OrderDirSQL = array('ASC', 'DESC');
    107     $this->OrderArrowImage = array($this->System->Link('/images/sort_asc.png'),
    108       $this->System->Link('/images/sort_desc.png'));
     107    $this->OrderArrowImage = array($System->Link('/images/sort_asc.png'),
     108      $System->Link('/images/sort_desc.png'));
    109109    $this->DefaultOrder = 0;
    110110    $this->Style = 'BaseTable';
     
    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'];
Note: See TracChangeset for help on using the changeset viewer.