blob: 488b55f6a371b0f14fc3a9a6fac8e3fd7ef2e603 (
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
92
|
<?php
/*
Copyright (c) 2001 - 2006 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/*!
@header
The default pager widget for moving through a list of many items.
This relies heavily on the View object to get pieces about how
to layout this page.
*/
if (!$total_items) { $total_items = $_SESSION['view_total_items']; }
// do some math here
if ($view->offset >= $view->offset_limit) {
$offset2 = $view->offset - 25;
}
else {
$offset2 = $view->offset;
if (!$view->offset) { $offset2 = "0"; }
}
// Get the prev page offset
$offset1 = $view->offset - $view->offset_limit;
if ($offset1 < 1) { $offset1 = 0; }
// since we have an array of objects, let's build a purdy thingie
$pages = ceil($total_items/$view->offset_limit);
$offset4 = ($pages - 1);
$offset4 = ($offset4 * $view->offset_limit);
//We do this one last to make sure we don't go beyond offset4
$offset3 = $view->offset + $view->offset_limit;
if ($offset3 >= $offset4) { $offset3 = $offset4; }
//setup the next action
preg_match("/.*\/(.+\.php)$/", $_SERVER['SCRIPT_NAME'], $matches);
$action = "action=" . scrub_in($_REQUEST['action']);
$script = conf('web_path') . "/" . $admin_menu . $matches[1];
// are there enough items to even need this view?
if (($pages > 1) && ($_SESSION['view_script'])) {
?>
<table border="0" cellpadding="2" cellspacing="0" width="100%">
<tr>
<td align="center" valign="top">
<a href="<?php echo $script; ?>?<?php echo $action; ?>&offset=<?php echo $offset1; ?>&keep_view=true">[ <?php echo _("Prev"); ?> ]</a>
</td>
<td align="center">
<?php
$counter = 1;
$offset_pages = 0;
while ($counter <= $pages) {
if ($view->offset == $offset_pages) {
?> <a href="<?php echo $script; ?>?<?php echo $action ; ?>&sort_type=<?php echo $view->sort_type ; ?>&offset=<?php echo $offset_pages ; ?>&keep_view=true"><b><?php echo $counter; ?></b></a>
<?php
} else { ?>
<a href="<?php echo $script; ?>?<?php echo $action; ?>&sort_type=<?php echo $view->sort_type; ?>&offset=<?php echo $offset_pages; ?>&keep_view=true"><?php echo $counter; ?></a>
<?php
} // end if ($view->offset == $offset_pages) and else
$offset_pages += $view->offset_limit;
$counter++;
} // end while ($counter <= $pages) ?>
</td>
<td align="center" valign="top">
<a href="<?php echo $script; ?>?<?php echo $action; ?>&offset=<?php echo $offset3; ?>&keep_view=true">[ <?php echo _("Next"); ?> ]</a>
</td>
</tr>
</table>
<?php
} // if (($pages > 1) && ($_SESSION['view_script']))
?>
|