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 | include_once(dirname(__FILE__).'/Process.php');
|
---|
22 | include_once(dirname(__FILE__).'/Generics.php');
|
---|
23 | include_once(dirname(__FILE__).'/BigInt.php');
|
---|
24 | include_once(dirname(__FILE__).'/Int128.php');
|
---|
25 |
|
---|
26 | class PackageCommon
|
---|
27 | {
|
---|
28 | public string $Name;
|
---|
29 | public string $Version;
|
---|
30 | public int $ReleaseDate;
|
---|
31 | public string $License;
|
---|
32 | public string $Creator;
|
---|
33 | public string $Homepage;
|
---|
34 |
|
---|
35 | function __construct()
|
---|
36 | {
|
---|
37 | $this->Name = 'Common';
|
---|
38 | $this->Version = '1.2';
|
---|
39 | $this->ReleaseDate = strtotime('2020-03-29');
|
---|
40 | $this->Creator = 'Chronos';
|
---|
41 | $this->License = 'GNU/GPL';
|
---|
42 | $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/';
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | class Paging
|
---|
47 | {
|
---|
48 | public int $TotalCount;
|
---|
49 | public int $ItemPerPage;
|
---|
50 | public int $Around;
|
---|
51 | public string $SQLLimit;
|
---|
52 | public int $Page;
|
---|
53 |
|
---|
54 | function __construct()
|
---|
55 | {
|
---|
56 | global $System;
|
---|
57 |
|
---|
58 | $this->ItemPerPage = $System->Config['Web']['ItemsPerPage'];
|
---|
59 | $this->Around = $System->Config['Web']['VisiblePagingItems'];
|
---|
60 | }
|
---|
61 |
|
---|
62 | function Show(): string
|
---|
63 | {
|
---|
64 | $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
|
---|
65 |
|
---|
66 | $Result = '';
|
---|
67 | if (array_key_exists('all', $QueryItems))
|
---|
68 | {
|
---|
69 | $PageCount = 1;
|
---|
70 | $ItemPerPage = $this->TotalCount;
|
---|
71 | } else
|
---|
72 | {
|
---|
73 | $ItemPerPage = $this->ItemPerPage;
|
---|
74 | $Around = round($this->Around / 2);
|
---|
75 | $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
|
---|
76 | }
|
---|
77 |
|
---|
78 | if (!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
|
---|
79 | if (array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
|
---|
80 | if ($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
|
---|
81 | if ($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
|
---|
82 | $CurrentPage = $_SESSION['Page'];
|
---|
83 |
|
---|
84 | $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> Stránky: ';
|
---|
85 |
|
---|
86 | $Result = '';
|
---|
87 | if ($PageCount > 1)
|
---|
88 | {
|
---|
89 | if ($CurrentPage > 0)
|
---|
90 | {
|
---|
91 | $QueryItems['page'] = 0;
|
---|
92 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><<</a> ';
|
---|
93 | $QueryItems['page'] = ($CurrentPage - 1);
|
---|
94 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'"><</a> ';
|
---|
95 | }
|
---|
96 | $PagesMax = $PageCount - 1;
|
---|
97 | $PagesMin = 0;
|
---|
98 | if ($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
|
---|
99 | if ($PagesMin < ($CurrentPage - $Around))
|
---|
100 | {
|
---|
101 | $Result.= ' ... ';
|
---|
102 | $PagesMin = $CurrentPage - $Around;
|
---|
103 | }
|
---|
104 | for ($i = $PagesMin; $i <= $PagesMax; $i++)
|
---|
105 | {
|
---|
106 | if ($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
|
---|
107 | else {
|
---|
108 | $QueryItems['page'] = $i;
|
---|
109 | $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
|
---|
110 | }
|
---|
111 | }
|
---|
112 | if ($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
|
---|
113 | if ($CurrentPage < ($PageCount - 1))
|
---|
114 | {
|
---|
115 | $QueryItems['page'] = ($CurrentPage + 1);
|
---|
116 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">></a> ';
|
---|
117 | $QueryItems['page'] = ($PageCount - 1);
|
---|
118 | $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">>></a>';
|
---|
119 | }
|
---|
120 | }
|
---|
121 | $QueryItems['all'] = '1';
|
---|
122 | if ($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
|
---|
123 |
|
---|
124 | $Result = '<div style="text-align: center">'.$Result.'</div>';
|
---|
125 | $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
|
---|
126 | $this->Page = $CurrentPage;
|
---|
127 | return $Result;
|
---|
128 | }
|
---|
129 | }
|
---|