source: trunk/Packages/CoolWeb/Modules/UPageList.pas

Last change on this file was 5, checked in by chronos, 12 years ago
  • Added: Required packages.
File size: 2.9 KB
Line 
1unit UPageList;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, UHtmlClasses;
9
10type
11 TPageList = class
12 TotalCount: Integer;
13 Page: Integer;
14 PageCount: Integer;
15 Output: string;
16 SQLLimit: string;
17 ItemPerPage: Integer;
18 VisiblePageItems: Integer;
19 HTMLId: string;
20 QueryItems: TQueryString;
21 Around: Integer;
22 constructor Create;
23 function Hyperlink: string;
24 function Process: string;
25 end;
26
27
28implementation
29
30constructor TPageList.Create;
31begin
32 ItemPerPage := 40;
33 VisiblePageItems := 30;
34 QueryItems := TQueryString.Create;
35 QueryItems.SetStringServer;
36 HTMLId := '';
37end;
38
39function TPageList.Hyperlink: string;
40begin
41 // Create hyperlink
42 if HTMLId = '' then Hyperlink := 'href="?' + QueryItems.GetString + '"'
43 else begin
44 QueryItems.Data.Values['Panel'] := '1';
45 Hyperlink := 'href="" onclick="ReloadElement(''' + HTMLId + ''', ''?' + QueryItems.GetString + ''');return false;"';
46 end;
47 Result := Hyperlink;
48end;
49
50function TPageList.Process: string;
51begin
52(* Around := Round(VisiblePageItems / 2);
53 Output := '';
54 PageCount := Trunc(TotalCount / ItemPerPage) + 1;
55
56 if not array_key_exists('Page', $_SESSION)) $_SESSION['Page'] := 0;
57 if(array_key_exists('Page', $_GET)) $_SESSION['Page'] := $_GET['Page'] * 1;
58 if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
59 if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] := PageCount - 1;
60 Page := $_SESSION['Page'];
61
62 Output := Output + 'Počet poloşek: <strong>' + IntToStr(TotalCount) + '</strong> &nbsp; Stránky: ';
63
64 Output := '';
65 if PageCount > 1 then begin
66 if Page > 0 then begin
67 QueryItems.Data['Page'] := 0;
68 Output := Output + '<a ' + Hyperlink + '>&lt;&lt;</a> ';
69 QueryItems.Data['Page'] := (Page - 1);
70 Output := Output + '<a ' + Hyperlink + '>&lt;</a> ';
71 end;
72 PagesMax := PageCount - 1;
73 PagesMin := 0;
74 if PagesMax > (Page + Around) then PagesMax := Page + Around;
75 if PagesMin < (Page - Around) then begin
76 Output := Output + ' ... ';
77 PagesMin := Page - Around;
78 end;
79 for I := PagesMin to PagesMax - 1 do begin
80 if I = Page then Output := Output + '<strong>' + IntToStr(I + 1) '</strong> ';
81 else begin
82 QueryItems.Data['Page'] := I;
83 Output := Output + '<a ' + Hyperlink + '>' + IntToStr(I + 1) + '</a> ';
84 end;
85 end;
86 if PagesMax < (PageCount - 1) then Output := Output + ' ... ';
87 if Page < (PageCount - 1) then begin
88 QueryItems.Data.Values['Page'] := (Page + 1);
89 Output := Output + '<a ' + Hyperlink + '>&gt;</a> ';
90 QueryItems.Data.Values['Page'] := (PageCount - 1);
91 Output := Output + '<a ' + Hyperlink + '>&gt;&gt;</a>';
92 end;
93 end;
94 if Output <> '' Output := '<div style="text-align: center">' + Output + '</div>';
95 SQLLimit := ' LIMIT ' + IntToStr(Page * ItemPerPage) + ', ' + IntToStr(ItemPerPage);
96 end;*)
97end;
98
99end.
100
Note: See TracBrowser for help on using the repository browser.