20 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
46 function XoopsPageNav($total_items, $items_perpage, $current_start, $start_name =
"start", $extra_arg =
"")
48 $this->total = intval($total_items);
49 $this->perpage = intval($items_perpage);
50 $this->current = intval($current_start);
51 $this->extra = $extra_arg;
52 if ($extra_arg !=
'' && (substr($extra_arg, - 5) !=
'&' || substr($extra_arg, - 1) !=
'&')) {
53 $this->extra =
'&' . $extra_arg;
55 $this->url =
$_SERVER[
'PHP_SELF'] .
'?' . trim($start_name) .
'=';
64 function renderNav($offset = 4)
67 if ($this->total <= $this->perpage) {
70 if(($this->total != 0) && ($this->perpage != 0)) {
71 $total_pages = ceil($this->total / $this->perpage);
72 if ($total_pages > 1) {
73 $ret .=
'<div id="xo-pagenav">';
74 $prev = $this->current - $this->perpage;
76 $ret .=
'<a class="xo-pagarrow" href="' . $this->url . $prev . $this->extra .
'"><u>«</u></a> ';
79 $current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
80 while ($counter <= $total_pages) {
81 if ($counter == $current_page) {
82 $ret .=
'<strong class="xo-pagact" >(' . $counter .
')</strong> ';
83 } elseif (($counter > $current_page - $offset && $counter < $current_page + $offset) || $counter == 1 || $counter == $total_pages) {
84 if ($counter == $total_pages && $current_page < $total_pages - $offset) {
87 $ret .=
'<a class="xo-counterpage" href="' . $this->url . (($counter - 1) * $this->perpage) . $this->extra .
'">' . $counter .
'</a> ';
88 if ($counter == 1 && $current_page > 1 + $offset) {
94 $next = $this->current + $this->perpage;
95 if ($this->total >
$next) {
96 $ret .=
'<a class="xo-pagarrow" href="' . $this->url .
$next . $this->extra .
'"><u>»</u></a> ';
110 function renderSelect($showbutton =
false)
112 if ($this->total < $this->perpage) {
115 $total_pages = ceil($this->total / $this->perpage);
117 if ($total_pages > 1) {
118 $ret =
'<form name="pagenavform">';
119 $ret .=
'<select name="pagenavselect" onchange="location=this.options[this.options.selectedIndex].value;">';
121 $current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
122 while ($counter <= $total_pages) {
123 if ($counter == $current_page) {
124 $ret .=
'<option value="' . $this->url . (($counter - 1) * $this->perpage) . $this->extra .
'" selected="selected">' . $counter .
'</option>';
126 $ret .=
'<option value="' . $this->url . (($counter - 1) * $this->perpage) . $this->extra .
'">' . $counter .
'</option>';
132 $ret .=
' <input type="submit" value="' .
_GO .
'" />';
145 function renderImageNav($offset = 4)
147 if ($this->total < $this->perpage) {
150 $total_pages = ceil($this->total / $this->perpage);
152 if ($total_pages > 1) {
153 $ret =
'<table><tr>';
154 $prev = $this->current - $this->perpage;
156 $ret .=
'<td class="pagneutral"><a href="' . $this->url . $prev . $this->extra .
'"><</a></td><td><img src="' . XOOPS_URL .
'/images/blank.gif" width="6" alt="" /></td>';
158 $ret .=
'<td class="pagno"></a></td><td><img src="' . XOOPS_URL .
'/images/blank.gif" width="6" alt="" /></td>';
161 $current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
162 while ($counter <= $total_pages) {
163 if ($counter == $current_page) {
164 $ret .=
'<td class="pagact"><strong>' . $counter .
'</strong></td>';
165 } elseif (($counter > $current_page - $offset && $counter < $current_page + $offset) || $counter == 1 || $counter == $total_pages) {
166 if ($counter == $total_pages && $current_page < $total_pages - $offset) {
167 $ret .=
'<td class="paginact">...</td>';
169 $ret .=
'<td class="paginact"><a href="' . $this->url . (($counter - 1) * $this->perpage) . $this->extra .
'">' . $counter .
'</a></td>';
170 if ($counter == 1 && $current_page > 1 + $offset) {
171 $ret .=
'<td class="paginact">...</td>';
176 $next = $this->current + $this->perpage;
177 if ($this->total >
$next) {
178 $ret .=
'<td><img src="' . XOOPS_URL .
'/images/blank.gif" width="6" alt="" /></td><td class="pagneutral"><a href="' . $this->url .
$next . $this->extra .
'">></a></td>';
180 $ret .=
'<td><img src="' . XOOPS_URL .
'/images/blank.gif" width="6" alt="" /></td><td class="pagno"></td>';
182 $ret .=
'</tr></table>';