Viewing file: paginationSystem.class.php (5.59 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/********************************************************************************
- MemHT Portal -
Copyright (C) 2007-2008 by Miltenovik Manojlo
http://www.memht.com
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 opinion) 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, see <http://www.gnu.org/licenses/> (GPLv2)
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA02110-1301, USA.
********************************************************************************/
// I 10 1 B 1 10 E
// Page 7/40 |< << < 4 5 6 7 8 9 10 > >> >|
class paginationSystem {
//==============================
//DEFAULT CONFIGURATION
//==============================
/*Use CSS style*/
var $use_style = true;
/*Show the page position label: "Page N of TOT"*/
var $positon_label = true;
/*Show first and last page links*/
var $show_limits = true;
/*Page url: "index.php?page=name&op=example&pg={{N}}&salute=bye..."*/
var $url = "index.php?pg={{N}}";
/*Num items per page*/
var $items = 20;
/*Indicate manually the pages number*/
var $override_query = false;
/*Style*/
var $box_attribute = " style='margin-top:10px;' align='center'";
var $item_attribute = " class='box'";
/*Store and return or print*/
var $store = false;
//==============================
//DO NOT EDIT
//==============================
var $actpg;
var $query;
var $tot_items;
var $storeval;
//PHP5 Constructor
function __construct() {
$this->actpg = 0;
$this->query = "";
$this->pages = 0;
}
//PHP4 Constructor
function paginationSystem() {
$this->actpg = 0;
$this->query = "";
$this->pages = 0;
}
function show() {
global $dblink;
$numitems = ($this->override_query) ? $this->tot_items : $dblink->get_num($this->query) ;
$numpages = ceil($numitems/$this->items);
if ($numpages>1) {
$this->storeval .= "<table border='0'".$this->box_attribute."><tr><td>\n";
$first = 1;
$prev_big = $this->actpg-10;
$prev = $this->actpg-1;
$next = $this->actpg+1;
$next_big = $this->actpg+10;
$last = $numpages;
//Label
if ($this->positon_label) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= _PAGE_." ". $this->actpg."/$numpages";
$this->storeval .= "</span>\n";
}
//First page
if ($this->show_limits AND $first<$prev) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$first,$this->url)."' title='"._PAGE_." $first'>|<</a>";
$this->storeval .= "</span>\n";
}
//-10
if ($prev_big>0) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$prev_big,$this->url)."' title='"._PAGE_." $prev_big'><<</a>";
$this->storeval .= "</span>\n";
}
//-1
if ($prev>0) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$prev,$this->url)."' title='"._PAGE_." $prev'><</a>";
$this->storeval .= "</span>\n";
}
//Previous pages
for ($i=3;$i>0;$i--) {
$item = $this->actpg-$i;
if ($item>0) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$item,$this->url)."' title='"._PAGE_." $item'>$item</a>";
$this->storeval .= "</span>\n";
}
}
//Actual page
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$this->actpg,$this->url)."' title='"._PAGE_." ".$this->actpg."'><b>".$this->actpg."</b></a>";
$this->storeval .= "</span>\n";
//Next pages
for ($i=1;$i<=3;$i++) {
$item = $this->actpg+$i;
if ($item<=$last) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$item,$this->url)."' title='"._PAGE_." $item'>$item</a>";
$this->storeval .= "</span>\n";
}
}
//+1
if ($next<=$last) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$next,$this->url)."' title='"._PAGE_." $next'>></a>";
$this->storeval .= "</span>\n";
}
//+10
if ($next_big<=$last) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$next_big,$this->url)."' title='"._PAGE_." $next_big'>>></a>";
$this->storeval .= "</span>\n";
}
//Last page
if ($this->show_limits AND $last>$next) {
$this->storeval .= "<span".$this->item_attribute.">\n";
$this->storeval .= "<a href='".str_replace("{{N}}",$last,$this->url)."' title='"._PAGE_." $last'>>|</a>";
$this->storeval .= "</span>\n";
}
$this->storeval .= "</td></tr></table>\n";
if ($this->store==true) {
return $this->storeval;
} else {
echo $this->storeval;
}
}
}
}
?>
|