Changeset 858 for trunk/Packages/Common/Common.php
- Timestamp:
- Jan 21, 2016, 9:54:58 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.php
r856 r858 16 16 include_once(dirname(__FILE__).'/Page.php'); 17 17 include_once(dirname(__FILE__).'/Locale.php'); 18 include_once(dirname(__FILE__).'/Update.php'); 19 include_once(dirname(__FILE__).'/Setup.php'); 20 include_once(dirname(__FILE__).'/Table.php'); 18 21 19 22 class PackageCommon … … 34 37 } 35 38 } 39 40 class Paging 41 { 42 var $TotalCount; 43 var $ItemPerPage; 44 var $Around; 45 var $SQLLimit; 46 var $Page; 47 48 function __construct() 49 { 50 global $System; 51 52 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 53 $this->Around = $System->Config['Web']['VisiblePagingItems']; 54 } 55 56 function Show() 57 { 58 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 59 60 $Result = ''; 61 if(array_key_exists('all', $QueryItems)) 62 { 63 $PageCount = 1; 64 $ItemPerPage = $this->TotalCount; 65 } else 66 { 67 $ItemPerPage = $this->ItemPerPage; 68 $Around = round($this->Around / 2); 69 $PageCount = floor($this->TotalCount / $ItemPerPage) + 1; 70 } 71 72 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 73 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 74 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 75 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 76 $CurrentPage = $_SESSION['Page']; 77 78 $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: '; 79 80 $Result = ''; 81 if($PageCount > 1) 82 { 83 if($CurrentPage > 0) 84 { 85 $QueryItems['page'] = 0; 86 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 87 $QueryItems['page'] = ($CurrentPage - 1); 88 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> '; 89 } 90 $PagesMax = $PageCount - 1; 91 $PagesMin = 0; 92 if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 93 if($PagesMin < ($CurrentPage - $Around)) 94 { 95 $Result.= ' ... '; 96 $PagesMin = $CurrentPage - $Around; 97 } 98 for($i = $PagesMin; $i <= $PagesMax; $i++) 99 { 100 if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 101 else { 102 $QueryItems['page'] = $i; 103 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 104 } 105 } 106 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 107 if($CurrentPage < ($PageCount - 1)) 108 { 109 $QueryItems['page'] = ($CurrentPage + 1); 110 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> '; 111 $QueryItems['page'] = ($PageCount - 1); 112 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>'; 113 } 114 } 115 $QueryItems['all'] = '1'; 116 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 117 118 $Result = '<div style="text-align: center">'.$Result.'</div>'; 119 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 120 $this->Page = $CurrentPage; 121 return($Result); 122 } 123 }
Note:
See TracChangeset
for help on using the changeset viewer.