source: web/Packages/Common/Common.php

Last change on this file was 17, checked in by chronos, 8 years ago
  • Modified: Old database class replaced by newer from Common package to fix compatibility with PHP7.
File size: 3.9 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/Database.php');
4include_once(dirname(__FILE__).'/Image.php');
5include_once(dirname(__FILE__).'/Mail.php');
6include_once(dirname(__FILE__).'/NetworkAddress.php');
7include_once(dirname(__FILE__).'/PrefixMultiplier.php');
8include_once(dirname(__FILE__).'/RSS.php');
9include_once(dirname(__FILE__).'/UTF8.php');
10include_once(dirname(__FILE__).'/VarDumper.php');
11include_once(dirname(__FILE__).'/Error.php');
12include_once(dirname(__FILE__).'/Base.php');
13include_once(dirname(__FILE__).'/Application.php');
14include_once(dirname(__FILE__).'/AppModule.php');
15include_once(dirname(__FILE__).'/Config.php');
16include_once(dirname(__FILE__).'/Page.php');
17include_once(dirname(__FILE__).'/Locale.php');
18include_once(dirname(__FILE__).'/Update.php');
19include_once(dirname(__FILE__).'/Setup.php');
20include_once(dirname(__FILE__).'/Table.php');
21
22class 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
42class 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> &nbsp; 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).'">&lt;&lt;</a> ';
87 $QueryItems['page'] = ($CurrentPage - 1);
88 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</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).'">&gt;</a> ';
111 $QueryItems['page'] = ($PageCount - 1);
112 $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</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 TracBrowser for help on using the repository browser.