Ignore:
Timestamp:
Apr 7, 2020, 12:55:39 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r37 r55  
    77  function Show()
    88  {
    9     return('');
     9    return '';
    1010  }
    1111}
     
    1515  function GetCell($Y, $X)
    1616  {
    17     return('');
     17    return '';
    1818  }
    1919
     
    2828  function RowsCount()
    2929  {
    30     return(0);
     30    return 0;
    3131  }
    3232}
     
    3838  function GetCell($Y, $X)
    3939  {
    40     return($this->Cells[$Y][$X]);
     40    return $this->Cells[$Y][$X];
    4141  }
    4242
    4343  function RowsCount()
    4444  {
    45     return(count($this->Cells));
     45    return count($this->Cells);
    4646  }
    4747}
     
    5555  function GetCell($Y, $X)
    5656  {
    57     return($this->Cells[$Y][$X]);
     57    return $this->Cells[$Y][$X];
    5858  }
    5959
     
    6262    $this->Cells = array();
    6363    $DbResult = $this->Database->query($this->Query);
    64     while($DbRow = $DbResult->fetch_row())
     64    while ($DbRow = $DbResult->fetch_row())
    6565    {
    6666      $this->Cells[] = $DbRow;
     
    7575  function RowsCount()
    7676  {
    77     return(count($this->Cells));
     77    return count($this->Cells);
    7878  }
    7979}
     
    114114  {
    115115    $this->Columns = array();
    116     foreach($Columns as $Column)
     116    foreach ($Columns as $Column)
    117117    {
    118118      $NewCol = new TableColumn();
     
    121121      $this->Columns[] = $NewCol;
    122122    }
    123     if(count($this->Columns) > 0)
     123    if (count($this->Columns) > 0)
    124124      $this->DefaultColumn = $this->Columns[0]->Name;
    125125      else $this->DefaultColumn = '';
     
    131131    $Output .= $this->GetOrderHeader();
    132132    $this->Table->BeginRead();
    133     for($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
     133    for ($Y = 0; $Y < $this->Table->RowsCount(); $Y++)
    134134    {
    135135      $Output .= '<tr>';
    136136
    137       for($X = 0; $X < count($this->Columns); $X++)
     137      for ($X = 0; $X < count($this->Columns); $X++)
    138138      {
    139139        $Cell = $this->Table->GetCell($Y, $X);
    140         if($Cell == '') $Output .= '<td>&nbsp;</td>';
     140        if ($Cell == '') $Output .= '<td>&nbsp;</td>';
    141141          else $Output .= '<td>'.$Cell.'</td>';
    142142      }
     
    145145    $this->Table->EndRead();
    146146    $Output .= '</table>';
    147     return($Output);
     147    return $Output;
    148148  }
    149149
    150150  function GetOrderHeader()
    151151  {
    152     if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
    153     if(array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
    154     if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
    155     if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
     152    if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
     153    if (array_key_exists('OrderDir', $_GET)) $_SESSION['OrderDir'] = $_GET['OrderDir'];
     154    if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $this->DefaultColumn;
     155    if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $this->DefaultOrder;
    156156
    157157    // Check OrderCol
    158158    $Found = false;
    159     foreach($this->Columns as $Column)
     159    foreach ($this->Columns as $Column)
    160160    {
    161       if($Column->Name == $_SESSION['OrderCol'])
     161      if ($Column->Name == $_SESSION['OrderCol'])
    162162      {
    163163        $Found = true;
     
    165165      }
    166166    }
    167     if($Found == false)
     167    if ($Found == false)
    168168    {
    169169      $_SESSION['OrderCol'] = $this->DefaultColumn;
     
    171171    }
    172172    // Check OrderDir
    173     if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
     173    if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1))
    174174      $_SESSION['OrderDir'] = 0;
    175175
    176176    $Result = '';
    177177    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    178     foreach($this->Columns as $Index => $Column)
     178    foreach ($this->Columns as $Index => $Column)
    179179    {
    180180      $QueryItems['OrderCol'] = $Column->Name;
    181181      $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
    182       if($Column->Name == $_SESSION['OrderCol'])
     182      if ($Column->Name == $_SESSION['OrderCol'])
    183183        $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.$this->OrderArrowImage[$_SESSION['OrderDir']].'" alt="order arrow">';
    184184        else $ArrowImage = '';
    185       if($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
     185      if ($Column->Name == '') $Result .= '<th>'.$Column->Title.'</th>';
    186186        else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column->Title.$ArrowImage.'</a></th>';
    187187    }
     
    190190    $this->OrderDirection = $_SESSION['OrderDir'];
    191191
    192     return('<tr>'.$Result.'</tr>');
     192    return '<tr>'.$Result.'</tr>';
    193193  }
    194194}
Note: See TracChangeset for help on using the changeset viewer.