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