MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mgridnavigator.class
Ir para a documentação deste ficheiro.
1
<?php
2
define(
'PN_PAGE'
,
'pn_page'
);
6
class
MGridNavigator
extends
MControl
7
{
8
var
$pageLength
;
9
var
$pageNumber
;
10
var
$action
;
11
var
$range
;
12
var
$rowCount
;
13
var
$gridCount
;
14
var
$pageCount
;
15
var
$idxFirst
;
16
var
$idxLast
;
17
var
$showPageNo
=
false
;
18
var
$linktype
;
// hyperlink or linkbutton
19
var
$grid
;
20
21
function
__construct
($length = 20,
// Number of records per page
22
$total = 0,
// Number total of records
23
$action
=
'?'
,
// Action URL
24
$grid
= NULL
// The grid which contains this component
25
)
26
{
27
global $state;
28
29
parent::__construct();
30
$this->pageLength = $length;
31
$this->gridCount = $length;
32
$this->
SetRowCount
($total);
33
$this->grid =
$grid
;
34
/*
35
if (urldecode($this->page->Request('gridName')) == $this->grid->name)
36
{
37
$this->SetPageNumber($this->page->Request(PN_PAGE));
38
$state->set('pn_page', $this->page->Request(PN_PAGE), $this->grid->name);
39
}
40
else
41
{
42
$this->SetPageNumber($state->get('pn_page', $this->grid->name));
43
}
44
*/
45
46
$this->SetPageNumber( $state->get(
'pn_page'
, $this->grid->name) );
47
48
49
// $this->grid->pageNumber = MUtil::NVL($state->get('pn_page', $this->grid->name),1);
50
// $this->grid->prevPage = MUtil::NVL($state->get('grid_page', $this->grid->name),1);
51
52
// $this->grid->HandlerSelecteds();
53
54
// $state->set('grid_page', $this->getPageNumber(), $this->grid->name);
55
56
$this->action =
$action
;
57
$this->linktype =
'hyperlink'
;
58
59
}
60
61
function
SetAction
(
$url
)
62
{
63
$this->action =
$url
;
64
}
65
66
function
SetLinkType
(
$linktype
)
67
{
68
$this->linktype =
$linktype
;
69
}
70
71
function
SetRowCount
(
$rowCount
)
72
{
73
$this->rowCount =
$rowCount
;
74
$this->pageCount = ($this->pageLength > 0) ? (
int
)(($this->rowCount + $this->pageLength - 1) / $this->pageLength) : 1;
75
}
76
77
function
SetGridCount
(
$gridCount
)
78
{
79
$this->gridCount =
$gridCount
;
80
}
81
82
function
setPageNumber
($num)
83
{
84
global $state;
85
86
if
( (
int
) $state->get(
'pn_page'
, $this->grid->name) > (
int
) $this->pageCount )
87
{
88
$num =
$this->pageCount
;
89
}
90
91
$this->pageNumber = (int)($num ? $num : 1);
92
$this->range =
new
MRange
($this->pageNumber, $this->pageLength, $this->rowCount);
93
$this->
SetIndexes
();
94
}
95
96
function
setCurrentPage
( $pageNumber )
97
{
98
$this->
setPageNumber
( $pageNumber );
99
}
100
101
function
SetIndexes
()
102
{
103
$this->range->
__construct
($this->pageNumber, $this->pageLength, $this->rowCount);
104
$this->idxFirst = $this->range->offset;
105
$this->idxLast = $this->range->offset + $this->range->rows - 1;
106
$this->
SetGridCount
($this->range->rows);
107
}
108
109
function
SetGridParameters
(
$pageLength
,
$rowCount
,
$action
,
$grid
)
110
{
111
global $state;
112
$this->pageLength =
$pageLength
;
113
$this->
SetRowCount
($rowCount);
114
$this->action =
$action
;
115
$this->grid =
$grid
;
116
$this->
SetIndexes
();
117
$this->SetPageNumber( $state->get(
'pn_page'
, $this->grid->name) );
118
}
119
120
function
GetRowCount
()
121
{
122
return
$this->rowCount
;
123
}
124
125
function
GetGridCount
()
126
{
127
return
$this->gridCount
;
128
}
129
130
function
GetPageNumber
()
131
{
132
return
$this->pageNumber
;
133
}
134
135
function
getPageCount
()
136
{
137
return
$this->pageCount
;
138
}
139
140
function
GetPagePosition
($showPage =
true
)
141
{
142
$position =
'['
. ($showPage ? _M(
'Page'
) :
''
) .
' '
. $this->
GetPageNumber
() .
' '
. _M(
'of'
) .
' '
143
. $this->GetPageCount() .
"]"
;
144
return
$position;
145
}
146
147
function
GetPageLinks
($showPage =
true
, $limit = 10)
148
{
149
$pageCount
= $this->GetPageCount();
150
$pageNumber
= $this->
GetPageNumber
();
151
$pageLinks = array();
152
153
$p = 0;
154
155
if
(!$this->
GetRowCount
())
156
{
157
$pageLinks[$p] =
new
MLabel
(
' '
);
158
$pageLinks[$p++]->SetClass(
'm-pagenavigator-text'
);
159
}
160
else
161
{
162
if
($showPage)
163
{
164
$pageLinks[$p] =
new
MText
(
''
,
' '
. _M(
'Page'
) .
': '
);
165
$pageLinks[$p++]->SetClass(
'm-pagenavigator-text'
);
166
}
167
168
if
(
$pageNumber
<= $limit)
169
{
170
$o = 1;
171
}
172
else
173
{
174
$o = ((int)((
$pageNumber
- 1) / $limit)) * $limit;
175
$pageLinks[$p] =
new
LinkButton
(
''
,
'...'
, $this->getNavigatorUrlWithClass($o++));
176
$pageLinks[$p++]->SetClass(
'm-pagenavigator-link'
);
177
}
178
179
for
($i = 0; ($i < $limit) && ($o <=
$pageCount
); $i++, $o++)
180
{
181
$pg = $o;
182
if
($o !=
$pageNumber
)
183
{
184
$pageLinks[$p] =
new
LinkButton
(
''
, $pg, $this->getNavigatorUrlWithClass($o));
185
$pageLinks[$p]->SetClass(
'm-pagenavigator-link'
);
186
$pageLinks[$p++]->SetAttribute(
'onMouseOver'
,
"top.status='"
. _M(
'Page'
) .
" $pg'"
);
187
}
188
else
189
{
190
$pageLinks[$p] =
new
LinkButton
(
'pagenavigator'
,
"$pg"
, $this->getNavigatorUrl($o));
191
$pageLinks[$p++]->SetClass(
'm-pagenavigator-selected'
);
192
}
193
}
194
195
if
($o <
$pageCount
)
196
{
197
$pageLinks[$p++] =
new
Label
(
''
);
198
$pageLinks[$p] =
new
LinkButton
(
''
,
'...'
, $this->getNavigatorUrlWithClass($o));
199
$pageLinks[$p++]->SetClass(
'm-pagenavigator-link'
);
200
}
201
}
202
203
return
$pageLinks;
204
}
205
206
private
function
getNavigatorUrl($number)
207
{
208
$orderby = $this->page->request(
'orderby'
);
209
$ordermode = $this->page->request(
'ordermode'
);
210
211
return
$this->action .
'&'
.
PN_PAGE
.
'='
. $number .
'&gridName='
. urlencode($this->grid->name) .
'&orderby='
. $orderby .
'&ordermode='
. $ordermode;
212
}
213
214
private
function
getNavigatorUrlWithClass($number)
215
{
216
return
$this->getNavigatorUrl($number) .
'#m_pagenavigator'
;
217
}
218
219
function
GetPageRange
($subject =
''
)
220
{
221
if
(!$this->
GetRowCount
())
222
{
223
$range = _M(
'No data.'
);
224
}
225
else
226
{
227
$first = $this->idxFirst + 1;
228
$last = $this->idxLast + 1;
229
$range
=
'['
. $first .
'..'
. $last .
'] '
. _M(
'of'
) .
' '
. $this->
GetRowCount
() . $subject;
230
}
231
232
return
new
Span
(
''
,
$range
,
'm-pagenavigator-range'
);
233
}
234
235
function
GetPageRows
($subject =
''
)
236
{
237
$rows = $this->
GetGridCount
() .
' '
. $subject;
238
return
$rows;
239
}
240
241
function
GetPageFirst
()
242
{
243
$pageNumber
= $this->
GetPageNumber
();
244
$attrs
= array(
'border'
=>
'0'
);
245
$btn_first0 =
new
ImageForm
(
'_gnFirst'
,
'Primeira'
, $this->
GetImage
(
"but_pg_primeira.gif"
),
$attrs
);
246
$btn_first1 =
new
ImageButton
(
'_gnFirst'
,
'Primeira'
, $this->getNavigatorUrlWithClass(1), $this->
GetImage
(
"but_pg_primeira_x.gif"
));
247
$btn = (
$pageNumber
> 1 ? $btn_first1 : $btn_first0);
248
return
new
Span
(
''
, $btn,
'm-pagenavigator-image'
);
249
}
250
251
function
GetPagePrev
()
252
{
253
$pageNumber
= $this->
GetPageNumber
();
254
$pagePrev =
$pageNumber
- 1;
255
$attrs
= array(
'border'
=>
'0'
);
256
$btn_prev0 =
new
ImageForm
(
'_gnPrev'
, _M(
'Previous'
), $this->
GetImage
(
"but_pg_anterior.gif"
),
$attrs
);
257
$btn_prev1 =
new
ImageButton
(
'_gnPrev'
, _M(
'Previous'
), $this->getNavigatorUrlWithClass($pagePrev), $this->
GetImage
(
"but_pg_anterior_x.gif"
));
258
$btn = (
$pageNumber
> 1 ? $btn_prev1 : $btn_prev0);
259
return
new
Span
(
''
, $btn,
'm-pagenavigator-image'
);
260
}
261
262
function
GetPageNext
()
263
{
264
$pageNumber
= $this->
GetPageNumber
();
265
$pageNext =
$pageNumber
+ 1;
266
$pageCount
= $this->GetPageCount();
267
$attrs
= array(
'border'
=>
'0'
);
268
$btn_next0 =
new
ImageForm
(
'_gnNext'
, _M(
'Next'
), $this->
GetImage
(
"but_pg_proxima.gif"
),
$attrs
);
269
$btn_next1 =
new
ImageButton
(
'_gnNext'
, _M(
'Next'
), $this->getNavigatorUrlWithClass($pageNext), $this->
GetImage
(
"but_pg_proxima_x.gif"
));
270
$btn = (
$pageNumber
<
$pageCount
? $btn_next1 : $btn_next0);
271
return
new
Span
(
''
, $btn,
'm-pagenavigator-image'
);
272
}
273
274
function
GetPageLast
()
275
{
276
$pageNumber
= $this->
GetPageNumber
();
277
$pageCount = $this->GetPageCount();
278
$attrs
= array(
'border'
=>
'0'
);
279
$btn_last0 =
new
ImageForm
(
'_gnLast'
, _M(
'Last'
), $this->
GetImage
(
"but_pg_ultima.gif"
),
$attrs
);
280
$btn_last1 =
new
ImageButton
(
'_gnLast'
, _M(
'Last'
), $this->getNavigatorUrlWithClass(
$pageCount
), $this->
GetImage
(
"but_pg_ultima_x.gif"
));
281
$btn = (
$pageNumber
<
$pageCount
? $btn_last1 : $btn_last0);
282
return
new
Span
(
''
, $btn,
'm-pagenavigator-image'
);
283
}
284
285
function
GetImage
($image)
286
{
287
$theme =
MIOLO::getInstance
()->getConf(
'theme.main'
);
288
if
($theme !=
'smodern'
)
289
{
290
$image = str_replace(
'gif'
,
'png'
, $image);
291
}
292
293
return
MIOLO::getInstance
()->getUI()->getImageTheme($theme, $image);
294
}
295
296
}
297
?>
ImageButton
Definição
compatibility.class:159
ImageForm
Definição
compatibility.class:126
Label
Definição
compatibility.class:149
LinkButton
Definição
compatibility.class:155
MControl
Definição
mcontrol.class:35
MControl\$attrs
$attrs
Definição
mcontrol.class:100
MGridNavigator
Definição
mgridnavigator.class:7
MGridNavigator\GetPageLast
GetPageLast()
Definição
mgridnavigator.class:274
MGridNavigator\setCurrentPage
setCurrentPage( $pageNumber)
Definição
mgridnavigator.class:96
MGridNavigator\$rowCount
$rowCount
Definição
mgridnavigator.class:12
MGridNavigator\GetPageRows
GetPageRows($subject='')
Definição
mgridnavigator.class:235
MGridNavigator\$idxFirst
$idxFirst
Definição
mgridnavigator.class:15
MGridNavigator\$pageNumber
$pageNumber
Definição
mgridnavigator.class:9
MGridNavigator\GetPagePrev
GetPagePrev()
Definição
mgridnavigator.class:251
MGridNavigator\SetGridParameters
SetGridParameters($pageLength, $rowCount, $action, $grid)
Definição
mgridnavigator.class:109
MGridNavigator\GetPageNumber
GetPageNumber()
Definição
mgridnavigator.class:130
MGridNavigator\$grid
$grid
Definição
mgridnavigator.class:19
MGridNavigator\__construct
__construct($length=20, $total=0, $action='?', $grid=NULL)
Definição
mgridnavigator.class:21
MGridNavigator\$idxLast
$idxLast
Definição
mgridnavigator.class:16
MGridNavigator\$pageLength
$pageLength
Definição
mgridnavigator.class:8
MGridNavigator\GetPagePosition
GetPagePosition($showPage=true)
Definição
mgridnavigator.class:140
MGridNavigator\setPageNumber
setPageNumber($num)
Definição
mgridnavigator.class:82
MGridNavigator\$showPageNo
$showPageNo
Definição
mgridnavigator.class:17
MGridNavigator\SetLinkType
SetLinkType($linktype)
Definição
mgridnavigator.class:66
MGridNavigator\GetRowCount
GetRowCount()
Definição
mgridnavigator.class:120
MGridNavigator\GetPageRange
GetPageRange($subject='')
Definição
mgridnavigator.class:219
MGridNavigator\getPageCount
getPageCount()
Definição
mgridnavigator.class:135
MGridNavigator\$pageCount
$pageCount
Definição
mgridnavigator.class:14
MGridNavigator\$gridCount
$gridCount
Definição
mgridnavigator.class:13
MGridNavigator\$action
$action
Definição
mgridnavigator.class:10
MGridNavigator\GetImage
GetImage($image)
Definição
mgridnavigator.class:285
MGridNavigator\GetPageLinks
GetPageLinks($showPage=true, $limit=10)
Definição
mgridnavigator.class:147
MGridNavigator\SetGridCount
SetGridCount($gridCount)
Definição
mgridnavigator.class:77
MGridNavigator\GetGridCount
GetGridCount()
Definição
mgridnavigator.class:125
MGridNavigator\$range
$range
Definição
mgridnavigator.class:11
MGridNavigator\SetAction
SetAction($url)
Definição
mgridnavigator.class:61
MGridNavigator\GetPageFirst
GetPageFirst()
Definição
mgridnavigator.class:241
MGridNavigator\GetPageNext
GetPageNext()
Definição
mgridnavigator.class:262
MGridNavigator\SetRowCount
SetRowCount($rowCount)
Definição
mgridnavigator.class:71
MGridNavigator\SetIndexes
SetIndexes()
Definição
mgridnavigator.class:101
MGridNavigator\$linktype
$linktype
Definição
mgridnavigator.class:18
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MLabel
Definição
labelcontrols.class:79
MRange
Definição
mrange.class:3
MText
Definição
labelcontrols.class:168
Span
Definição
compatibility.class:67
PN_PAGE
const PN_PAGE
Definição
mgridnavigator.class:2
$url
$url
Definição
base.php:2
classes
ui
controls
mgridnavigator.class
Gerado por
1.10.0