blob: 589acae02a7fa36ae063c5b9bf7d208991e958ff (
plain)
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
|
<?php
/**
* Elgg pagination
*
* @package Elgg
* @subpackage Core
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Curverider Ltd
* @copyright Curverider Ltd 2008
* @link http://elgg.org/
*
*/
if (!isset($vars['offset'])) {
$offset = 0;
} else {
$offset = $vars['offset'];
}
if (!isset($vars['limit'])) {
$limit = 10;
} else {
$limit = $vars['limit'];
}
if (!isset($vars['count'])) {
$count = 0;
} else {
$count = $vars['count'];
}
if (!isset($vars['word'])) {
$word = "offset";
} else {
$word = $vars['word'];
}
$totalpages = ceil($count / $limit);
$currentpage = ceil($offset / $limit) + 1;
$baseurl = preg_replace('/[\&\?]'.$word.'\=[0-9]*/',"",$vars['baseurl']);
?>
<div class="pagination">
<p>
<?php
if ($count == 0) {
static $notfounddisplayed;
if (!isset($notfounddisplayed)) {
echo elgg_echo("notfound");
$notfounddisplayed = true;
}
}
if ($offset > 0) {
$prevoffset = $offset - $limit;
if ($prevoffset < 0) $prevoffset = 0;
$prevurl = $baseurl;
if (substr_count($baseurl,'?')) {
$prevurl .= "&{$word}=" . $prevoffset;
} else {
$prevurl .= "?{$word}=" . $prevoffset;
}
echo "<a href=\"{$prevurl}\">« ". elgg_echo("previous") ."</a> ";
}
if ($offset < ($count - $limit)) {
$nextoffset = $offset + $limit;
if ($nextoffset >= $count) $nextoffset--;
$nexturl = $baseurl;
if (substr_count($baseurl,'?')) {
$nexturl .= "&{$word}=" . $nextoffset;
} else {
$nexturl .= "?{$word}=" . $nextoffset;
}
echo " <a href=\"{$nexturl}\">" . elgg_echo("next") . " »</a>";
}
?>
</p>
</div>
|