Changeset 32 for trunk/Global.php


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

Legend:

Unmodified
Added
Removed
  • trunk/Global.php

    r4 r32  
    33function HumanDate($Time)
    44{
    5   return(date('j.n.Y', $Time));
     5  return date('j.n.Y', $Time);
    66}
    77
    88function HumanDateTime($Time)
    99{
    10   return(date('j.n.Y H:i:s', $Time));
     10  return date('j.n.Y H:i:s', $Time);
    1111}
    1212
     
    2222  $Result = array();
    2323  $Parts = explode('&', $QueryString);
    24   foreach($Parts as $Part)
     24  foreach ($Parts as $Part)
    2525  {
    26     if($Part != '')
     26    if ($Part != '')
    2727    {
    28       if(!strpos($Part, '=')) $Part .= '=';
     28      if (!strpos($Part, '=')) $Part .= '=';
    2929      $Item = explode('=', $Part);
    3030      $Result[$Item[0]] = $Item[1];
    3131    }
    3232  }
    33   return($Result);
     33  return $Result;
    3434}
    3535
     
    3737{
    3838  $Parts = array();
    39   foreach($QueryStringArray as $Index => $Item)
     39  foreach ($QueryStringArray as $Index => $Item)
    4040  {
    4141    if ($Index != 'lvm') $Parts[] = $Index.'='.$Item;
    4242  }
    43   return(implode('&', $Parts));
     43  return implode('&', $Parts);
    4444}
    4545
     
    5555  $PageCount = floor($TotalCount / $ItemPerPage) + 1;
    5656
    57   if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
    58   if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
    59   if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
    60   if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     57  if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     58  if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     59  if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     60  if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
    6161  $CurrentPage = $_SESSION['Page'];
    6262
     
    6565
    6666  $Result = '';
    67   if($PageCount > 1)
     67  if ($PageCount > 1)
    6868  {
    69     if($CurrentPage > 0)
     69    if ($CurrentPage > 0)
    7070    {
    7171      $QueryItems['page'] = 0;
     
    7676    $PagesMax = $PageCount - 1;
    7777    $PagesMin = 0;
    78     if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
    79     if($PagesMin < ($CurrentPage - $Around))
     78    if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     79    if ($PagesMin < ($CurrentPage - $Around))
    8080    {
    8181      $Result.= ' ... ';
    8282      $PagesMin = $CurrentPage - $Around;
    8383    }
    84     for($i = $PagesMin; $i <= $PagesMax; $i++)
     84    for ($i = $PagesMin; $i <= $PagesMax; $i++)
    8585    {
    86       if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     86      if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
    8787      else {
    8888       $QueryItems['page'] = $i;
     
    9090      }
    9191    }
    92     if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
    93     if($CurrentPage < ($PageCount - 1))
     92    if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     93    if ($CurrentPage < ($PageCount - 1))
    9494    {
    9595      $QueryItems['page'] = ($CurrentPage + 1);
     
    100100  }
    101101  $Result = '<div style="text-align: center">'.$Result.'</div>';
    102   return(array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
     102  return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
    103103    'Page' => $CurrentPage,
    104104    'Output' => $Result,
    105   ));
     105  );
    106106}
    107107
     
    113113  global $OrderDirSQL, $OrderArrowImage, $Config;
    114114
    115   if(array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
    116   if(array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))
     115  if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
     116  if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))
    117117    $_SESSION['OrderDir'] = $_GET['OrderDir'];
    118   if(!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
    119   if(!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
     118  if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
     119  if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
    120120
    121121  // Check OrderCol
    122122  $Found = false;
    123   foreach($Columns as $Column)
     123  foreach ($Columns as $Column)
    124124  {
    125     if($Column['Name'] == $_SESSION['OrderCol'])
     125    if ($Column['Name'] == $_SESSION['OrderCol'])
    126126    {
    127127      $Found = true;
     
    129129    }
    130130  }
    131   if($Found == false)
     131  if ($Found == false)
    132132  {
    133133    $_SESSION['OrderCol'] = $DefaultColumn;
     
    135135  }
    136136  // Check OrderDir
    137   if(($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
     137  if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
    138138
    139139  $Result = '';
    140140  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    141   foreach($Columns as $Index => $Column)
     141  foreach ($Columns as $Index => $Column)
    142142  {
    143143    $QueryItems['OrderCol'] = $Column['Name'];
    144144    $QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
    145     if($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.
     145    if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '<img style="vertical-align: middle; border: 0px;" src="'.
    146146      Link2('/images/'.$OrderArrowImage[$_SESSION['OrderDir']]).'" alt="order arrow"/>';
    147147      else $ArrowImage = '';
    148     if($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
     148    if ($Column['Name'] == '') $Result .= '<th>'.$Column['Title'].'</th>';
    149149      else $Result .= '<th><a href="?'.SetQueryStringArray($QueryItems).'">'.$Column['Title'].$ArrowImage.'</a></th>';
    150150  }
    151   return(array(
     151  return array(
    152152    'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
    153153    'Output' => '<tr>'.$Result.'</tr>',
    154154    'Column' => $_SESSION['OrderCol'],
    155155    'Direction' => $_SESSION['OrderDir'],
    156   ));
     156  );
    157157}
Note: See TracChangeset for help on using the changeset viewer.