| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | include_once(dirname(__FILE__).'/Database.php');
|
|---|
| 4 | include_once(dirname(__FILE__).'/Image.php');
|
|---|
| 5 | include_once(dirname(__FILE__).'/Mail.php');
|
|---|
| 6 | include_once(dirname(__FILE__).'/NetworkAddress.php');
|
|---|
| 7 | include_once(dirname(__FILE__).'/PrefixMultiplier.php');
|
|---|
| 8 | include_once(dirname(__FILE__).'/RSS.php');
|
|---|
| 9 | include_once(dirname(__FILE__).'/UTF8.php');
|
|---|
| 10 | include_once(dirname(__FILE__).'/VarDumper.php');
|
|---|
| 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');
|
|---|
| 21 |
|
|---|
| 22 | class PackageCommon
|
|---|
| 23 | {
|
|---|
| 24 | var $Name;
|
|---|
| 25 | var $Version;
|
|---|
| 26 | var $ReleaseDate;
|
|---|
| 27 | var $License;
|
|---|
| 28 | var $Creator;
|
|---|
| 29 | var $Homepage;
|
|---|
| 30 |
|
|---|
| 31 | function __construct()
|
|---|
| 32 | {
|
|---|
| 33 | $this->Name = 'Common';
|
|---|
| 34 | $this->Version = '1.2';
|
|---|
| 35 | $this->ReleaseDate = strtotime('2016-01-22');
|
|---|
| 36 | $this->Creator = 'Chronos';
|
|---|
| 37 | $this->License = 'GNU/GPL';
|
|---|
| 38 | $this->Homepage = 'http://svn.zdechov.net/svn/PHPlib/Common/';
|
|---|
| 39 | }
|
|---|
| 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 | }
|
|---|