XOOPS
2.6.0
Main Page
Related Pages
Classes
Files
Examples
File List
File Members
function.xoPageNav.php
Go to the documentation of this file.
1
<?php
2
/*
3
itemsCount: Total number of items in the current list
4
pageSize: Number of items in each page
5
offset: Index of the 1st item currently displayed
6
linksCount: Number of direct links to show (default to 5)
7
url: URL mask used to generate links (%s will be replace by offset)
8
itemsCount=$items_count pageSize=$module_config.perpage offset=$offset
9
url="viewcat.php?cid=`$entity.cid`&orderby=`$sort_order`&offset=%s"
10
*/
11
12
function
smarty_function_xoPageNav
($params, &$smarty)
13
{
14
$xoops
=
Xoops::getInstance
();
15
16
extract($params);
17
if
($pageSize < 1) {
18
$pageSize = 10;
19
}
20
$pagesCount = intval($itemsCount / $pageSize);
21
if
($itemsCount <= $pageSize || $pagesCount < 2) {
22
return
''
;
23
}
24
$str =
''
;
25
$currentPage = intval($offset / $pageSize) + 1;
26
$lastPage = intval($itemsCount / $pageSize) + 1;
27
28
$minPage = min(1, ceil($currentPage - $linksCount / 2));
29
$maxPage = max($lastPage, floor($currentPage + $linksCount / 2));
30
31
//TODO Remove this hardocded strings
32
if
($currentPage > 1) {
33
$str .=
'<a href="'
.
$xoops
->url(str_replace(
'%s'
, $offset - $pageSize,
$url
)) .
'">Previous</a>'
;
34
}
35
for
(
$i
= $minPage;
$i
<= $maxPage; ++
$i
) {
36
$tgt = htmlspecialchars(
$xoops
->url(str_replace(
'%s'
, (
$i
- 1) * $pageSize,
$url
)), ENT_QUOTES);
37
$str .=
"<a href='$tgt'>$i</a>"
;
38
}
39
if
($currentPage < $lastPage) {
40
$str .=
'<a href="'
.
$xoops
->url(str_replace(
'%s'
, $offset + $pageSize,
$url
)) .
'">Next</a>'
;
41
}
42
$class = @!empty($class) ? htmlspecialchars($class, ENT_QUOTES) :
'pagenav'
;
43
44
$str =
"<div class='{$class}'>{$str}</div>"
;
45
return
$str;
46
47
}
$i
$i
Definition:
dialog.php:68
Xoops\getInstance
static getInstance()
Definition:
Xoops.php:160
$xoops
$xoops
Definition:
admin.php:25
$url
$url
Definition:
register.php:72
smarty_function_xoPageNav
smarty_function_xoPageNav($params, &$smarty)
Definition:
function.xoPageNav.php:12
usr64
htdocs
xoops_lib
smarty
xoops_plugins
function.xoPageNav.php
Generated on Fri May 22 2015 03:07:04 for XOOPS by
1.8.9.1