Changeset 69 for trunk/Packages/Common/Common.php
- Timestamp:
- Feb 28, 2016, 10:54:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.php
r61 r69 10 10 include_once(dirname(__FILE__).'/VarDumper.php'); 11 11 include_once(dirname(__FILE__).'/Error.php'); 12 include_once(dirname(__FILE__).'/Base.php'); 13 include_once(dirname(__FILE__).'/Application.php'); 14 include_once(dirname(__FILE__).'/AppModule.php'); 15 include_once(dirname(__FILE__).'/Config.php'); 16 include_once(dirname(__FILE__).'/Page.php'); 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'); 12 21 13 22 class PackageCommon … … 15 24 var $Name; 16 25 var $Version; 26 var $ReleaseDate; 17 27 var $License; 18 28 var $Creator; … … 22 32 { 23 33 $this->Name = 'Common'; 24 $this->Version = '1.1'; 34 $this->Version = '1.2'; 35 $this->ReleaseDate = strtotime('2016-01-22'); 25 36 $this->Creator = 'Chronos'; 26 37 $this->License = 'GNU/GPL'; … … 28 39 } 29 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(System $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.