$Item)
{
if ($Index != 'lvm') $Parts[] = $Index.'='.$Item;
}
return implode('&', $Parts);
}
function GetPageList($TotalCount)
{
global $Config;
$QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
$ItemPerPage = $Config['ItemsPerPage'];
$Around = round($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 = '
'.$Result.'
';
return array('SQLLimit' => ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage,
'Page' => $CurrentPage,
'Output' => $Result,
);
}
$OrderDirSQL = array('ASC', 'DESC');
$OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
function GetOrderTableHeader($Columns, $DefaultColumn, $DefaultOrder = 0)
{
global $OrderDirSQL, $OrderArrowImage, $Config;
if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
if (array_key_exists('OrderDir', $_GET) and (array_key_exists($_GET['OrderDir'], $OrderArrowImage)))
$_SESSION['OrderDir'] = $_GET['OrderDir'];
if (!array_key_exists('OrderCol', $_SESSION)) $_SESSION['OrderCol'] = $DefaultColumn;
if (!array_key_exists('OrderDir', $_SESSION)) $_SESSION['OrderDir'] = $DefaultOrder;
// Check OrderCol
$Found = false;
foreach ($Columns as $Column)
{
if ($Column['Name'] == $_SESSION['OrderCol'])
{
$Found = true;
break;
}
}
if ($Found == false)
{
$_SESSION['OrderCol'] = $DefaultColumn;
$_SESSION['OrderDir'] = $DefaultOrder;
}
// Check OrderDir
if (($_SESSION['OrderDir'] != 0) and ($_SESSION['OrderDir'] != 1)) $_SESSION['OrderDir'] = 0;
$Result = '';
$QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
foreach ($Columns as $Index => $Column)
{
$QueryItems['OrderCol'] = $Column['Name'];
$QueryItems['OrderDir'] = 1 - $_SESSION['OrderDir'];
if ($Column['Name'] == $_SESSION['OrderCol']) $ArrowImage = '';
else $ArrowImage = '';
if ($Column['Name'] == '') $Result .= ''.$Column['Title'].' | ';
else $Result .= ''.$Column['Title'].$ArrowImage.' | ';
}
return array(
'SQL' => ' ORDER BY `'.$_SESSION['OrderCol'].'` '.$OrderDirSQL[$_SESSION['OrderDir']],
'Output' => ''.$Result.'
',
'Column' => $_SESSION['OrderCol'],
'Direction' => $_SESSION['OrderDir'],
);
}