Changeset 635 for trunk/Common/Global.php
- Timestamp:
- Jan 19, 2014, 9:36:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Global.php
r627 r635 13 13 include_once(dirname(__FILE__).'/Mail.php'); 14 14 include_once(dirname(__FILE__).'/Page.php'); 15 include_once(dirname(__FILE__).'/Table.php'); 15 16 include_once(dirname(__FILE__).'/Form/Form.php'); 16 17 include_once(dirname(__FILE__).'/Config.php'); … … 136 137 } 137 138 139 class Pageing 140 { 141 var $TotalCount; 142 var $ItemPerPage; 143 var $Around; 144 145 function __construct() 146 { 147 global $System; 148 149 $this->ItemPerPage = 5; //$System->Config['Web']['ItemsPerPage']; 150 $this->Around = $System->Config['Web']['VisiblePagingItems']; 151 } 152 153 function Show() 154 { 155 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 156 157 $Result = ''; 158 if(array_key_exists('all', $QueryItems)) 159 { 160 $PageCount = 1; 161 $ItemPerPage = $this->TotalCount; 162 } else 163 { 164 $ItemPerPage = $this->ItemPerPage; 165 $Around = round($this->Around / 2); 166 $PageCount = floor($this->TotalCount / $ItemPerPage) + 1; 167 } 168 169 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 170 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 171 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 172 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 173 $CurrentPage = $_SESSION['Page']; 174 175 $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: '; 176 177 $Result = ''; 178 if($PageCount > 1) 179 { 180 if($CurrentPage > 0) 181 { 182 $QueryItems['page'] = 0; 183 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 184 $QueryItems['page'] = ($CurrentPage - 1); 185 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> '; 186 } 187 $PagesMax = $PageCount - 1; 188 $PagesMin = 0; 189 if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 190 if($PagesMin < ($CurrentPage - $Around)) 191 { 192 $Result.= ' ... '; 193 $PagesMin = $CurrentPage - $Around; 194 } 195 for($i = $PagesMin; $i <= $PagesMax; $i++) 196 { 197 if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 198 else { 199 $QueryItems['page'] = $i; 200 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 201 } 202 } 203 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 204 if($CurrentPage < ($PageCount - 1)) 205 { 206 $QueryItems['page'] = ($CurrentPage + 1); 207 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> '; 208 $QueryItems['page'] = ($PageCount - 1); 209 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>'; 210 } 211 } 212 $QueryItems['all'] = '1'; 213 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 214 215 $Result = '<div style="text-align: center">'.$Result.'</div>'; 216 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 217 $this->Page = $CurrentPage; 218 return($Result); 219 } 220 } 221 138 222 function GetPageList($TotalCount) 139 223 {
Note:
See TracChangeset
for help on using the changeset viewer.