$Item)
{
if ($Index != 'lvm') $Parts[] = $Index.'='.$Item;
}
return implode('&', $Parts);
}
function HumanSize(int $Value): string
{
global $UnitNames;
$UnitIndex = 0;
while ($Value > 1024)
{
$Value = round($Value / 1024, 3);
$UnitIndex++;
}
return $Value.' '.$UnitNames[$UnitIndex];
}
function GetPageList(int $TotalCount): array
{
global $Config;
$QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
$ItemPerPage = (int)$Config['ItemsPerPage'];
$Around = round((int)$Config['VisiblePagingItems'] / 2);
$Result = '';
$PageCount = floor($TotalCount / $ItemPerPage) + 1;
if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
$CurrentPage = $_SESSION['Page'];
$Result .= 'Počet položek: '.$TotalCount.' Stránky: ';
$Result = '';
if ($PageCount > 1)
{
if ($CurrentPage > 0)
{
$QueryItems['page'] = 0;
$Result.= '<< ';
$QueryItems['page'] = ($CurrentPage - 1);
$Result.= '< ';
}
$PagesMax = $PageCount - 1;
$PagesMin = 0;
if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
if ($PagesMin < ($CurrentPage - $Around))
{
$Result.= ' ... ';
$PagesMin = $CurrentPage - $Around;
}
for ($i = $PagesMin; $i <= $PagesMax; $i++)
{
if ($i == $CurrentPage) $Result.= ''.($i + 1).' ';
else {
$QueryItems['page'] = $i;
$Result .= ''.($i + 1).' ';
}
}
if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
if ($CurrentPage < ($PageCount - 1))
{
$QueryItems['page'] = ($CurrentPage + 1);
$Result.= '> ';
$QueryItems['page'] = ($PageCount - 1);
$Result.= '>>';
}
}
$Result = '
';
foreach ($this->Items as $Item)
{
if ($Item['Type'] == 'String')
{
$Output .= '
'.
'
'.$Item['Title'].'
'.
'
'.
'
';
} else
if ($Item['Type'] == 'Boolean')
{
$Output .= '
';
$Output .= '';
$Output .= '
';
} else
if ($Item['Type'] == 'Enumeration')
{
$Output .= '
'.
'
'.$Item['Title'].'
';
foreach ($Item['States'] as $EnumIndex => $EnumItem)
{
$Output .= '
';
}
$Output .= '
';
} else
if ($Item['Type'] == 'Integer')
{
$Output .= '
'.
'
'.$Item['Title'].'
'.
'
'.
'
-
'.
'
';
if (array_key_exists('Units', $Item))
{
$Output .= '
'.$Item['Units'].'
';
}
$Output .= '
';
}
}
$Output .= '
';
}
return $Output;
}
function GetWhere(Database $Database): string
{
$Where = '';
foreach ($this->Items as $Item)
{
if ($Item['DbName'] != '')
{
if ($Item['Type'] == 'String')
{
if ($_SESSION[$Item['Name']] != '')
$Where .= ' AND ('.$Item['DbName'].' LIKE "%'.$Database->real_escape_string($_SESSION[$Item['Name']]).'%")';
} else
if ($Item['Type'] == 'Boolean')
{
if ($_SESSION[$Item['Name']] != '')
$Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')';
} else
if ($Item['Type'] == 'Enumeration')
{
if ($_SESSION[$Item['Name']] != '')
$Where .= ' AND ('.$Item['DbName'].' = '.$Database->real_escape_string($_SESSION[$Item['Name']]).')';
} else
if ($Item['Type'] == 'Integer')
{
if ($_SESSION[$Item['Name'].'od'] != '')
$Where .= ' AND ('.$Item['DbName'].' >= '.$Database->real_escape_string($_SESSION[$Item['Name'].'od']).')';
if ($_SESSION[$Item['Name'].'do'] != '')
$Where .= ' AND ('.$Item['DbName'].' <= '.$Database->real_escape_string($_SESSION[$Item['Name'].'do']).')';
}
}
}
if (substr($Where, 0, 4) == ' AND')
$Where = substr($Where, 4);
if ($Where == '') $Where = '1';
return $Where;
}
}