Linux lhjmq-records 5.15.0-118-generic #128-Ubuntu SMP Fri Jul 5 09:28:59 UTC 2024 x86_64
Your IP : 3.137.159.163
<?php
/*********************************************************************
Author: Mathieu Dumoulin
Date: 8 avril 2003
Info: This class is in charge of drawing page number arrays
for the user to select.
Version: 2.0.0
*********************************************************************/
if(!defined("CLS_PAGEDRAW")) {
define("CLS_PAGEDRAW","");
class pagearray{
var $url = "";
var $currentpage = 0;
var $res = 0;
var $max = 0;
var $pack = 0;
var $page_sep = " - ";
var $sel_open = "<STRONG>(";
var $sel_close = ")</STRONG>";
var $pack_open = "[ ";
var $pack_close = " ]";
/*constructor*/
function pagearray($url, $currentpage, $res, $max, $pack, $page_sep, $sel_open, $sel_close, $pack_open, $pack_close){
//Save the data
$this->url = $url;
$this->currentpage = $currentpage;
$this->res = $res;
$this->max = $max;
$this->pack = $pack;
$this->page_sep = $page_sep;
$this->sel_open = $sel_open;
$this->sel_close = $sel_close;
$this->pack_open = $pack_open;
$this->pack_close = $pack_close;
}
/*Quick call*/
function drawpages(){
//Call the complex_drawpages
cdrawpages($this->url, $this->currentpage, $this->res, $this->max, $this->pack, $this->page_sep, $this->sel_open, $this->sel_close, $this->pack_open, $this->pack_close);
}
/*Draws a page array*/
function cdrawpages($url, $currentpage, $res, $max, $pack, $page_sep, $sel_open, $sel_close, $pack_open, $pack_close){
//Formatting
//Return 1 if no other page
if($res <= $max){
return $pack_open . " 1 " . $pack_close;
}
//Get the max page and the package this page is in
$nbpages = ceil($res / $max);
$maxPagePack = ceil($nbpages / $pack);
//Get the package of pages this page is in
$selPagePack = ceil($currentpage / $pack);
//Loop each page until all pages looped
for($curPagePack=1; $curPagePack<=$maxPagePack; $curPagePack++){
//Compare this page package to the current page one
if($selPagePack == $curPagePack){
//Draw each page seperatly, get the first page num and the last page num
$pipeSep = '';
$pages .= $pack_open;
$packFirstPage = (($curPagePack * $pack) - ($pack - 1));
$packLastPage = ($curPagePack * $pack);
//Check that the last page doesn't over flow
if($packLastPage > $nbpages){
$packLastPage = $nbpages;
}
for($i=$packFirstPage;$i<=$packLastPage;$i++){
//Is it the current page
if($i == $currentpage){
//Draw as selected page
$pages .= $pipeSep . '<A HREF="' . $url . $i . '" class="lnkBase11px">' . $sel_open . $i . $sel_close . '</a>';
$pipeSep = $page_sep;
}else{
//Draw normal page
$pages .= $pipeSep . '<A HREF="' . $url . $i . '" class="lnkBase11px">' . $i . '</a>';
$pipeSep = $page_sep;
}
}
$pages .= $pack_close;
}else{
$pipeSep = '';
$pages .= $pack_open;
//Draw a block of pages, get the first page num
$packFirstPage = (($curPagePack * $pack) - ($pack - 1));
$packLastPage = ($curPagePack * $pack);
//Check that the last page doesn't over flow
if($packLastPage > $nbpages){
$packLastPage = $nbpages;
}
//Draw the block of pages
$pages .= $pipeSep . '<A HREF="' . $url . $packFirstPage . '" class="lnkBase11px">' . $packFirstPage . '-' . $packLastPage . '</a>';
$pipeSep = $page_sep;
$pages .= $pack_close;
}
}
return $pages;
}
}
}
?>
|