System = $System; $this->ItemPerPage = Core::Cast($this->System)->Config['Web']['ItemsPerPage']; $this->Around = Core::Cast($this->System)->Config['Web']['VisiblePagingItems']; } function Show(): string { $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); $Result = ''; if (array_key_exists('all', $QueryItems)) { $PageCount = 1; $ItemPerPage = $this->TotalCount; } else { $ItemPerPage = $this->ItemPerPage; $Around = round($this->Around / 2); $PageCount = floor($this->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: '.$this->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.= '>>'; } } $QueryItems['all'] = '1'; if ($PageCount > 1) $Result.= ' Vše'; $Result = '
'.$Result.'
'; $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; $this->Page = $CurrentPage; return $Result; } }