aboutsummaryrefslogtreecommitdiffstats
path: root/root/base/pager
blob: cde0ce4d723bc5b9879356c0cc6aa8244a7780d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
[%

main_block    = 'pager_main';

start_block   = 'pager_start';
prev_block    = 'pager_prev';
current_block = 'pager_current';
next_block    = 'pager_next';
end_block     = 'pager_end';
list_block    = 'pager_list';

start_label_block   = 'pager_start_label';
prev_label_block    = 'pager_prev_label';
current_label_block = 'pager_current_label';
next_label_block    = 'pager_next_label';
end_label_block     = 'pager_end_label';
list_label_block    = 'pager_list_label';

BLOCK pager_main;

  '<div>[ ';
  data = [];

  str = BLOCK; include( 'start_block' ); END;
  data.push(str) IF str;

  str = BLOCK; include( 'prev_block' ); END;
  data.push(str) IF str;

  str = BLOCK; include( 'current_block' ); END;
  data.push(str) IF str;

  str = BLOCK; include( 'next_block' ); END;
  data.push(str) IF str;

  str = BLOCK; include( 'end_block' ); END;
  data.push(str) IF str;

  data.join(" |\n");
  " ]</div>\n";

END;

BLOCK pager_start;

  %]<a [% connect_href(self, 'page' => self.pager.first_page); process_attrs(attrs) %]>[%
  include( 'start_label_block' ) %]</a>[%

END;

BLOCK pager_start_label;

  loc('Start'); ' ('; self.pager.first_page; ')';

END;

BLOCK pager_prev;

  IF self.pager.current_page != 1;
    %]<a [% connect_href(self, 'page' => self.pager.previous_page); process_attrs(attrs) %]>[%
    include( 'prev_label_block' ) %]</a>[%
  END;

END;

BLOCK pager_prev_label;

  loc('Previous'); ' ('; self.pager.previous_page; ')';

END;

BLOCK pager_current;

  %]<a [% connect_href(self, 'page' => self.pager.current_page); process_attrs(attrs) %]>[%
  include( 'current_label_block' ) %]</a>[%

END;

BLOCK pager_current_label;

  loc('Current'); ' ('; self.pager.current_page; ')';

END;

BLOCK pager_next;

  IF self.pager.current_page != self.pager.last_page;
    %]<a [% connect_href(self, 'page' => self.pager.next_page); process_attrs(attrs) %]>[%
    include( 'next_label_block' ) %]</a>[%
  END;

END;

BLOCK pager_next_label;

  loc('Next'); ' ('; self.pager.next_page; ')';

END;

BLOCK pager_end;

  %]<a [% connect_href(self, 'page' => self.pager.last_page); process_attrs(attrs) %]>[%
  include( 'end_label_block' ) %]</a>[%

END;

BLOCK pager_end_label;

  loc('End'); ' ('; self.pager.last_page; ')';

END;

BLOCK pager_list;

  FOREACH page IN self.pager.list;
    '<a'; connect_href(self, 'page' => page); process_attrs(attrs); '>';
    include( 'list_label_block' ); "</a>\n";
  END;

END;

BLOCK pager_list_label;

  page;

END;

%]