MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
pagenavigator.class
Ir para a documentação deste ficheiro.
1
<?php
2
// +-----------------------------------------------------------------+
3
// | MIOLO - Miolo Development Team - UNIVATES Centro Universitário |
4
// +-----------------------------------------------------------------+
5
// | CopyLeft (L) 2001-2002 UNIVATES, Lajeado/RS - Brasil |
6
// +-----------------------------------------------------------------+
7
// | Licensed under GPL: see COPYING.TXT or FSF at www.fsf.org for |
8
// | further details |
9
// | |
10
// | Site: http://miolo.codigolivre.org.br |
11
// | E-mail: vgartner@univates.br |
12
// | ts@interact2000.com.br |
13
// +-----------------------------------------------------------------+
14
// | Abstract: This file contains the navigation elements definitions|
15
// | |
16
// | Created: 2001/08/14 Thomas Spriestersbach, |
17
// | Vilson Cristiano Gärtner |
18
// | |
19
// | History: Initial Revision |
20
// +-----------------------------------------------------------------+
21
22
define(
'PN_PAGE'
,
'pn_page'
);
23
32
class
PageNavigator
33
{
37
var
$pageLength
;
38
42
var
$pageNumber
;
43
47
var
$pageLinks
;
48
52
var
$action
;
53
57
var
$queryRange
;
58
62
var
$rowCount
;
63
67
var
$pnCount
;
68
72
var
$showPageNo
=
false
;
73
77
var
$pageNo
;
78
82
var
$linktype
;
// hyperlink or linkbutton
83
87
var
$aButtons
;
88
92
var
$aControls
;
93
103
function
PageNavigator
($length = 20,
// Number of records per page
104
$action
=
'?'
// Action URL
105
)
106
{
107
$this->pageNumber = $_GET[
PN_PAGE
] ? $_GET[
PN_PAGE
] : $_POST[
PN_PAGE
];
108
$this->pageLength = $length;
109
$this->pnCount = $length;
110
111
$this->action =
$action
;
112
113
$this->queryRange =
new
QueryRange
($this->pageNumber, $this->pageLength);
114
$this->rowCount = $this->queryRange->total;
115
$this->linktype =
'hyperlink'
;
116
$aButtons
=
null
;
117
}
118
128
function
SetAction
(
$url
)
129
{
130
$this->action =
$url
;
131
}
132
142
function
SetButtons
(
$aButtons
)
143
{
144
if
(!is_array(
$aButtons
))
145
$aButtons
= array(
$aButtons
);
146
147
$this->aButtons =
$aButtons
;
148
}
149
159
function
SetControls
(
$aControls
)
160
{
161
if
(!is_array(
$aControls
))
162
$aControls
= array(
$aControls
);
163
164
$this->aControls =
$aControls
;
165
}
166
174
function
SetShowPageNo
()
175
{
176
$this->showPageNo =
true
;
177
}
178
188
function
SetLinkType
(
$linktype
)
189
{
190
$this->linktype =
$linktype
;
191
}
192
200
function
GetPageNo
()
201
{
202
$this->pageNo =
'['
. _M(
'Page'
) .
' '
. ($this->
GetCurrentPage
() + 1) .
' '
. _M(
'of'
) .
' '
203
. $this->
GetTotalPages
() .
"]"
;
204
return
($this->pageNo);
205
}
206
207
function
&
GetQueryRange
()
208
{
209
return
$this->queryRange
;
210
}
211
219
function
GetTotalRows
()
220
{
221
// return $this->queryRange->total;
222
return
$this->rowCount
;
223
}
224
232
function
GetCurrentPage
()
233
{
234
return
(
int
)
$this->pageNumber
;
235
}
236
246
function
SetCurrentPage
($num)
247
{
248
$this->pageNumber = (int)$num;
249
250
$this->queryRange =
new
QueryRange
($this->pageNumber, $this->pageLength);
251
}
252
260
function
GetTotalPages
()
261
{
262
return
(
int
)(($this->rowCount + $this->pageLength - 1) / $this->pageLength);
263
}
264
272
function
Generate
()
273
{
274
// $rowCount = $this->queryRange->total;
275
$rowCount
=
$this->rowCount
;
276
277
$btn_first0 =
'<img src="images/but_pg_primeira.gif" border="0">'
;
278
$btn_first1 =
'<img src="images/but_pg_primeira_x.gif" border="0">'
;
279
$btn_prev0 =
'<img src="images/but_pg_anterior.gif" border="0">'
;
280
$btn_prev1 =
'<img src="images/but_pg_anterior_x.gif" border="0">'
;
281
$btn_next0 =
'<img src="images/but_pg_proxima.gif" border="0">'
;
282
$btn_next1 =
'<img src="images/but_pg_proxima_x.gif" border="0">'
;
283
$btn_last0 =
'<img src="images/but_pg_ultima.gif" border="0">'
;
284
$btn_last1 =
'<img src="images/but_pg_ultima_x.gif" border="0">'
;
285
286
echo
"<!-- PageNavigator -->\n"
;
287
echo
"<table class=\"pageNavigator\" align=\"center\">\n"
;
288
echo
" <tr>\n"
;
289
290
if
($this->pageNumber > 0)
291
{
292
if
($this->linktype ==
'hyperlink'
)
293
{
294
echo
" <td><a href=\"$this->action&"
.
PN_PAGE
.
"=0\">$btn_first1</a></td>\n"
;
295
echo
" <td><a href=\"$this->action&"
.
PN_PAGE
.
"="
. ($this->pageNumber
296
- 1) .
"\">$btn_prev1</a></td>\n"
;
297
}
298
else
299
{
300
$action
=
"$this->action&"
.
PN_PAGE
.
"=0"
;
301
echo
" <td><a href=\"javascript:_MIOLO_LinkButton(document.forms[0].name, '{$action}','')\">$btn_first1</a></td>\n"
;
302
$action
=
"$this->action&"
.
PN_PAGE
.
"="
. ($this->pageNumber - 1);
303
echo
" <td><a href=\"javascript:_MIOLO_LinkButton(document.forms[0].name, '{$action}','')\">$btn_prev1</a></td>\n"
;
304
}
305
}
306
else
307
{
308
echo
" <td>$btn_first0</td>\n"
;
309
echo
" <td>$btn_prev0</td>\n"
;
310
}
311
312
//Total number of pages
313
$pageCount = (int)((
$rowCount
+ $this->pageLength - 1) /
$this->pageLength
);
314
315
echo
" <td width=\"100%\" align=\"center\">"
;
316
317
if
($pageCount >= 2)
318
{
319
if
($this->pageNumber < 10)
320
{
321
$o = 0;
322
}
323
else
324
{
325
$o = $this->pageNumber - 10;
326
327
if
($o > 0)
328
{
329
$this->pageLinks
330
.=
" <a class=\"pageNavigatorLink\" href=\"$this->action&"
.
PN_PAGE
.
"="
. ($o
331
- 1)
332
.
"\">...</a> "
;
333
}
334
}
335
336
for
($i = 0; $i < 11 && $o < $pageCount; $i++, $o++)
337
{
338
if
($i > 0)
339
{
340
$this->pageLinks .=
" "
;
341
}
342
343
$p = $o + 1;
344
345
if
($o != $this->pageNumber)
346
{
347
if
($this->linktype ==
'hyperlink'
)
348
{
349
$this->pageLinks
350
.=
"<a href=\"$this->action&"
.
PN_PAGE
351
.
"=$o\" class=\"pageNavigatorLink\" onMouseOver=\"top.status='"
. _M(
'Page'
) .
" $p'\">$p</a>"
;
352
}
353
else
354
{
355
$action
=
"$this->action&"
.
PN_PAGE
.
"=$o"
;
356
$this->pageLinks
357
.=
"<a href=\"javascript:_MIOLO_LinkButton(document.forms[0].name,'{$action}','')\" class=\"pageNavigatorLink\" onMouseOver=\"top.status='"
. _M(
'Page'
) .
" $p'\">$p</a>"
;
358
}
359
}
360
else
361
{
362
$this->pageLinks .=
"<span class=\"pageNavigatorSelected\">$p</span>"
;
363
}
364
}
365
366
if
($o < $pageCount)
367
{
368
$this->pageLinks
369
.=
" <a class=\"pageNavigatorLink\" href=\"$this->action&"
.
PN_PAGE
.
"=$p\">...</a>"
;
370
}
371
372
if
($this->ShowPageNo)
373
{
374
echo
$this->pageLinks
;
375
}
376
}
377
else
378
{
379
echo
" "
;
380
}
381
382
if
($this->aButtons)
383
{
384
for
($i = 0; $i < count($this->aButtons); $i++)
385
{
386
echo $this->aButtons[$i]->Generate();
387
echo
" "
;
388
}
389
}
390
391
if
($this->aControls)
392
{
393
for
($i = 0; $i < count($this->aControls); $i++)
394
{
395
echo $this->aControls[$i]->Generate();
396
echo
" "
;
397
}
398
}
399
400
echo
"</td>\n"
;
401
402
$maxRow = $this->pageNumber * $this->pageLength + $this->pageLength - 1;
403
404
if
($maxRow + 1 <
$rowCount
)
405
{
406
if
($this->linktype ==
'hyperlink'
)
407
{
408
echo
" <td><a href=\"$this->action&"
.
PN_PAGE
.
"="
. ($this->pageNumber
409
+ 1) .
"\">$btn_next1</a></td>\n"
;
410
echo
" <td><a href=\"$this->action&"
.
PN_PAGE
.
"="
. ($pageCount - 1) .
"\">$btn_last1</a></td>\n"
;
411
}
412
else
413
{
414
$action
=
"$this->action&"
.
PN_PAGE
.
"="
. ($this->pageNumber + 1);
415
echo
" <td><a href=\"javascript:_MIOLO_LinkButton(document.forms[0].name, '{$action}','')\">$btn_next1</a></td>\n"
;
416
$action
=
"$this->action&"
.
PN_PAGE
.
"="
. ($pageCount - 1);
417
echo
" <td><a href=\"javascript:_MIOLO_LinkButton(document.forms[0].name, '{$action}','')\">$btn_last1</a></td>\n"
;
418
}
419
}
420
else
421
{
422
echo
" <td>$btn_next0</td>\n"
;
423
echo
" <td>$btn_last0</td>\n"
;
424
}
425
426
echo
" </tr>\n"
;
427
echo
" <tr>\n"
;
428
echo
" <td align=\"center\" colspan=\"5\" class=\"pageNavigatorText\">\n"
;
429
430
if
($this->showPageNo)
431
{
432
echo
" "
. $this->pageNo .
"\n"
;
433
}
434
435
echo
" </td>\n"
;
436
echo
" </tr>\n"
;
437
echo
"</table>\n"
;
438
}
439
}
440
?>
PageNavigator
Definição
pagenavigator.class:33
PageNavigator\$rowCount
$rowCount
Definição
pagenavigator.class:62
PageNavigator\SetShowPageNo
SetShowPageNo()
Definição
pagenavigator.class:174
PageNavigator\GetTotalRows
GetTotalRows()
Definição
pagenavigator.class:219
PageNavigator\$pageNumber
$pageNumber
Definição
pagenavigator.class:42
PageNavigator\PageNavigator
PageNavigator($length=20, $action='?')
Definição
pagenavigator.class:103
PageNavigator\GetTotalPages
GetTotalPages()
Definição
pagenavigator.class:260
PageNavigator\Generate
Generate()
Definição
pagenavigator.class:272
PageNavigator\$pageNo
$pageNo
Definição
pagenavigator.class:77
PageNavigator\$pageLength
$pageLength
Definição
pagenavigator.class:37
PageNavigator\$queryRange
$queryRange
Definição
pagenavigator.class:57
PageNavigator\$showPageNo
$showPageNo
Definição
pagenavigator.class:72
PageNavigator\$aControls
$aControls
Definição
pagenavigator.class:92
PageNavigator\SetControls
SetControls($aControls)
Definição
pagenavigator.class:159
PageNavigator\SetLinkType
SetLinkType($linktype)
Definição
pagenavigator.class:188
PageNavigator\GetCurrentPage
GetCurrentPage()
Definição
pagenavigator.class:232
PageNavigator\$aButtons
$aButtons
Definição
pagenavigator.class:87
PageNavigator\$action
$action
Definição
pagenavigator.class:52
PageNavigator\SetAction
SetAction($url)
Definição
pagenavigator.class:128
PageNavigator\SetButtons
SetButtons($aButtons)
Definição
pagenavigator.class:142
PageNavigator\GetPageNo
GetPageNo()
Definição
pagenavigator.class:200
PageNavigator\$pnCount
$pnCount
Definição
pagenavigator.class:67
PageNavigator\$linktype
$linktype
Definição
pagenavigator.class:82
PageNavigator\GetQueryRange
& GetQueryRange()
Definição
pagenavigator.class:207
PageNavigator\$pageLinks
$pageLinks
Definição
pagenavigator.class:47
PageNavigator\SetCurrentPage
SetCurrentPage($num)
Definição
pagenavigator.class:246
QueryRange
Definição
compatibility.class:45
PN_PAGE
const PN_PAGE
Definição
pagenavigator.class:22
$url
$url
Definição
base.php:2
classes
ui
controls
pagenavigator.class
Gerado por
1.10.0