summaryrefslogtreecommitdiffstats
path: root/templates/list_header.inc
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
commitbcad40a05ab2dc2a341a3227e30b96668bce4500 (patch)
tree6fca27588d53a1b24705bd2834e9e643bb729bd1 /templates/list_header.inc
downloadampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.gz
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.bz2
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.zip
New Import
Diffstat (limited to 'templates/list_header.inc')
-rw-r--r--templates/list_header.inc99
1 files changed, 99 insertions, 0 deletions
diff --git a/templates/list_header.inc b/templates/list_header.inc
new file mode 100644
index 00000000..658d0972
--- /dev/null
+++ b/templates/list_header.inc
@@ -0,0 +1,99 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2005 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; ?>&amp;offset=<?php echo $offset1; ?>&amp;keep_view=true">[&nbsp;<?php echo _("Prev"); ?>&nbsp;]</a>&nbsp;
+ </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 ; ?>&amp;sort_type=<?php echo $view->sort_type ; ?>&amp;offset=<?php echo $offset_pages ; ?>&amp;keep_view=true"><b><?php echo $counter; ?></b></a>&nbsp;
+ <?php
+ } else {
+ ?>
+ <a href="<?php echo $script; ?>?<?php echo $action; ?>&amp;sort_type=<?php echo $view->sort_type; ?>&amp;offset=<?php echo $offset_pages; ?>&amp;keep_view=true"><?php echo $counter; ?></a>&nbsp;
+ <?php
+ }
+ $offset_pages += $view->offset_limit;
+ $counter++;
+ }
+ ?>
+ </td>
+ <td align="center" valign="top">
+ <a href="<?php echo $script; ?>?<?php echo $action; ?>&amp;offset=<?php echo $offset3; ?>&amp;keep_view=true">[&nbsp;<?php echo _("Next"); ?>&nbsp;]</a>&nbsp;
+ </td>
+ </tr>
+</table>
+
+<?php } // if ?>