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