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/Modules/Measure/Page.php

    r92 r95  
    4444    $this->Time = time();
    4545  }
    46  
    47   function GetTimeRange()
     46
     47  function GetTimeRange(): string
    4848  {
    4949    if (!array_key_exists($_SESSION['Period'], $this->GraphTimeRanges))
    5050      $_SESSION['Period'] = 'day';
    51    
     51
    5252    $Result = $this->GraphTimeRanges[$_SESSION['Period']]['period'];
    5353    if ($Result == -1)
     
    6161  }
    6262
    63   function EditTime($Time)
     63  function EditTime($Time): string
    6464  {
    6565    $Output = '<form style="display: inline;" action="?Operation=SetTime&amp;Time='.$Time.'" method="post">';
     
    119119    return $Output;
    120120  }
    121  
    122   function GetFirstMeasure($Measure)
     121
     122  function GetFirstMeasure($Measure): array
    123123  {
    124124    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` ASC LIMIT 1');
     
    135135  }
    136136
    137   function GetLastMeasure($Measure)
     137  function GetLastMeasure($Measure): array
    138138  {
    139139    $Result2 = $this->Database->select($Measure['DataTable'], '`Time`, `Avg`', '(`Measure`='.$Measure['Id'].') AND (`Level`=0) ORDER BY `Time` DESC LIMIT 1');
     
    149149    return array('Time' => $LastMeasureTime, 'Value' => $LastMeasureValue);
    150150  }
    151  
    152   function LoadMeasure($Id)
     151
     152  function LoadMeasure($Id): array
    153153  {
    154154    $DbResult = $this->Database->select('Measure', '*', '( `Enabled`=1) AND (`Id`='.$Id.') AND ((`PermissionView`="all") OR (`PermissionView`="'.
    155       gethostbyaddr($_SERVER['REMOTE_ADDR']).'"))');   
     155      gethostbyaddr($_SERVER['REMOTE_ADDR']).'"))');
    156156    $DbRow = $DbResult->fetch_array();
    157157    return $DbRow;
    158158  }
    159  
     159
    160160  /* Produce table with available measures */
    161   function ShowMeasureTable()
     161  function ShowMeasureTable(): string
    162162  {
    163163    $PrefixMultiplier = new PrefixMultiplier();
     
    195195        $LastMeasureValue.'</td><td align="center">'.$LastMeasureTime.'</td><td align="center">'.
    196196        $Interpolate.'</td><td>'.$Measure['Info'].'</td>';
    197       if (array_key_exists('Debug', $_GET)) 
     197      if (array_key_exists('Debug', $_GET))
    198198        $Output .= '<td>'.$RowCount.'</td><td>'.$GenerationTime.'</td>';
    199199      $Output .= '</tr>';
     
    203203  }
    204204
    205   function ShowGraph()
     205  function ShowGraph(): string
    206206  {
    207207    $Output = '<strong>Graf:</strong><br>';
     
    217217  }
    218218
    219   function ShowTimeRange()
     219  function ShowTimeRange(): string
    220220  {
    221221    $Output = '';
     
    269269
    270270  }
    271  
    272   function HandleURL()
    273   {
    274     global $Config;
    275    
    276     foreach ($Config['DefaultVariables'] as $Index => $Variable)
     271
     272  function HandleURL(): void
     273  {
     274    foreach ($this->System->Config['DefaultVariables'] as $Index => $Variable)
    277275    {
    278276      if (!array_key_exists($Index, $_SESSION)) $_SESSION[$Index] = $Variable;
     
    285283      $_SESSION['Period'] = $_GET['Period'];
    286284      // Update time start according time period
    287       if ($_SESSION['Period'] == 'all') 
     285      if ($_SESSION['Period'] == 'all')
    288286      {
    289287        $Measure = $this->LoadMeasure($_SESSION['Measure']);
     
    322320      $_SESSION['TimeSpecify'] = $_GET['TimeSpecify'];
    323321    }
    324    
     322
    325323    if (array_key_exists('Move', $_GET))
    326324    {
    327325      $Move = $_GET['Move'];
    328       if ($Move == 'Left') 
     326      if ($Move == 'Left')
    329327      {
    330328        $_SESSION['TimeStart'] = $_SESSION['TimeStart'] - $this->GetTimeRange();
    331329        $_SESSION['TimeEnd'] = $_SESSION['TimeEnd'] - $this->GetTimeRange();
    332330      } else
    333       if ($Move == 'Right') 
     331      if ($Move == 'Right')
    334332      {
    335333        $_SESSION['TimeStart'] = $_SESSION['TimeStart'] + $this->GetTimeRange();
    336334        $_SESSION['TimeEnd'] = $_SESSION['TimeEnd'] + $this->GetTimeRange();
    337       } else 
     335      } else
    338336      if ($Move == 'Now')
    339337      {
     
    358356  }
    359357
    360   function Show()
     358  function Show(): string
    361359  {
    362360    global $Config;
     
    364362    $Debug = 0;
    365363    $this->HandleURL();
    366    
     364
    367365    $Output = '<div style="text-align: center"><div class="Title">'.$Config['Web']['Title'].'</div>';
    368366
Note: See TracChangeset for help on using the changeset viewer.