Name = 'Common'; $this->Version = '1.2'; $this->ReleaseDate = strtotime('2016-01-22'); $this->Creator = 'Chronos'; $this->License = 'GNU/GPL'; $this->Homepage = 'http://svn.zdechov.net/svn/PHPlib/Common/'; } } class Paging { var $TotalCount; var $ItemPerPage; var $Around; var $SQLLimit; var $Page; function __construct(System $System) { $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; $this->Around = $System->Config['Web']['VisiblePagingItems']; } function Show() { $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 = '