Changeset 791 for trunk/Packages/Common/Common.php
- Timestamp:
- Jan 22, 2016, 5:31:05 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.php
r790 r791 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 … … 21 24 var $Name; 22 25 var $Version; 26 var $ReleaseDate; 23 27 var $License; 24 28 var $Creator; … … 28 32 { 29 33 $this->Name = 'Common'; 30 $this->Version = '1.1'; 34 $this->Version = '1.2'; 35 $this->ReleaseDate = strtotime('2016-01-22'); 31 36 $this->Creator = 'Chronos'; 32 37 $this->License = 'GNU/GPL'; … … 34 39 } 35 40 } 41 42 class Paging 43 { 44 var $TotalCount; 45 var $ItemPerPage; 46 var $Around; 47 var $SQLLimit; 48 var $Page; 49 50 function __construct() 51 { 52 global $System; 53 54 $this->ItemPerPage = $System->Config['Web']['ItemsPerPage']; 55 $this->Around = $System->Config['Web']['VisiblePagingItems']; 56 } 57 58 function Show() 59 { 60 $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']); 61 62 $Result = ''; 63 if(array_key_exists('all', $QueryItems)) 64 { 65 $PageCount = 1; 66 $ItemPerPage = $this->TotalCount; 67 } else 68 { 69 $ItemPerPage = $this->ItemPerPage; 70 $Around = round($this->Around / 2); 71 $PageCount = floor($this->TotalCount / $ItemPerPage) + 1; 72 } 73 74 if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0; 75 if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1; 76 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0; 77 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1; 78 $CurrentPage = $_SESSION['Page']; 79 80 $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: '; 81 82 $Result = ''; 83 if($PageCount > 1) 84 { 85 if($CurrentPage > 0) 86 { 87 $QueryItems['page'] = 0; 88 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> '; 89 $QueryItems['page'] = ($CurrentPage - 1); 90 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> '; 91 } 92 $PagesMax = $PageCount - 1; 93 $PagesMin = 0; 94 if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around; 95 if($PagesMin < ($CurrentPage - $Around)) 96 { 97 $Result.= ' ... '; 98 $PagesMin = $CurrentPage - $Around; 99 } 100 for($i = $PagesMin; $i <= $PagesMax; $i++) 101 { 102 if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> '; 103 else { 104 $QueryItems['page'] = $i; 105 $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> '; 106 } 107 } 108 if($PagesMax < ($PageCount - 1)) $Result .= ' ... '; 109 if($CurrentPage < ($PageCount - 1)) 110 { 111 $QueryItems['page'] = ($CurrentPage + 1); 112 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> '; 113 $QueryItems['page'] = ($PageCount - 1); 114 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>'; 115 } 116 } 117 $QueryItems['all'] = '1'; 118 if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>'; 119 120 $Result = '<div style="text-align: center">'.$Result.'</div>'; 121 $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage; 122 $this->Page = $CurrentPage; 123 return($Result); 124 } 125 }
Note:
See TracChangeset
for help on using the changeset viewer.