<?php
/**
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
*/
/**
* Copyright (C) der Modifizierung 2006 [url]http://www.wt-scriptarchiv.de[/url]
*/
class PageNav {
var $limitstart = null;
var $limit = null;
var $total = null;
function PageNav( $total, $limitstart, $limit ) {
$this->total = intval( $total );
$this->limitstart = max( $limitstart, 0 );
$this->limit = max( $limit, 0 );
}
/**
* Writes the html for the pages counter, eg, Results 1-10 of x
*/
function writePagesCounter() {
$txt =->';
$from_result = $this->limitstart+1;
if ($this->limitstart + $this->limit < $this->total) {
$to_result = $this->limitstart + $this->limit;
} else {
$to_result = $this->total;
}
if ($this->total > 0) {
$txt .= Ergebnisse . $from_result . - . $to_result . von . $this->total;
}
return $txt;
}
/**
* Writes the html links for pages, eg, previous, next, 1 2 3 ... x
* @param string The basic link to include in the href
*/
function writePagesLinks( $link ) {
$txt =->';
$displayed_pages = 10;
$total_pages = ceil( $this->total / $this->limit );
$this_page = ceil( ($this->limitstart+1) / $this->limit );
$start_loop = (floor(($this_page-1)/$displayed_pages))*$displayed_pages+1;
if ($start_loop + $displayed_pages - 1 < $total_pages) {
$stop_loop = $start_loop + $displayed_pages - 1;
} else {
$stop_loop = $total_pages;
}
$link .=->&amp;limit='. $this->limit;
if ($this_page > 1) {
$page = ($this_page - 2) * $this->limit;
$txt .=-><a href='. $link .'&amp;limitstart=0 class=pagenav title=first page>[&nbsp;&lt;&lt;&nbsp;]</a>->;
$txt .=-><a href='. $link .'&amp;limitstart='. $page .' class=pagenav title=previous page>[&nbsp;&lt;&nbsp;]</a>->;
} else {
$txt .=-><span class=pagenav>[&nbsp;&lt;&lt;&nbsp;]</span>->;
$txt .=-><span class=pagenav>[&nbsp;&lt;&nbsp;]</span>->;
}
for ($i=$start_loop; $i <= $stop_loop; $i++) {
$page = ($i - 1) * $this->limit;
if ($i == $this_page) {
$txt .=-><span class=pagenav>&nbsp;'. $i .'&nbsp;</span>->;
} else {
$txt .=-><a href='. $link .'&amp;limitstart='. $page .' class=pagenav><strong>[&nbsp;'. $i .'&nbsp;]</strong></a>->;
}
}
if ($this_page < $total_pages) {
$page = $this_page * $this->limit;
$end_page = ($total_pages-1) * $this->limit;
$txt .=-><a href='. $link .'&amp;limitstart='. $page .' class=pagenav title=next page>[&nbsp;&gt;&nbsp;]</a>->;
$txt .=-><a href='. $link .'&amp;limitstart='. $end_page .' class=pagenav title=end page>[&nbsp;&gt;&gt;&nbsp;]</a>';
} else {
$txt .=-><span class=pagenav>[&nbsp;&gt;&nbsp;]</span>->;
$txt .=-><span class=pagenav>[&nbsp;&gt;&nbsp;]</span>';
}
return $txt;
}
}
?>