64 public function __construct($total_items, $items_perpage, $current_start, $start_name =
"start", $extra_arg =
"")
66 $this->total = intval($total_items);
67 $this->perpage = intval($items_perpage);
68 $this->current = intval($current_start);
69 $this->extra = $extra_arg;
70 if ($extra_arg !=
'' && (substr($extra_arg, - 5) !=
'&' || substr($extra_arg, - 1) !=
'&')) {
71 $this->extra =
'&' . $extra_arg;
73 $this->url =
$_SERVER[
'PHP_SELF'] .
'?' . trim($start_name) .
'=';
87 public function renderNav($offset = 4, $size =
"", $align =
"right", $prev_text =
"«", $next_text =
"»")
92 if ($this->total <= $this->perpage) {
95 if (($this->total != 0) && ($this->perpage != 0)) {
96 $total_pages = ceil($this->total / $this->perpage);
97 if ($total_pages > 1) {
100 $xoops->tpl()->assign(
'prev_text', $prev_text);
101 $xoops->tpl()->assign(
'prev_url', $this->url . $prev . $this->extra);
110 $current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
111 while ($counter <= $total_pages) {
112 if ($counter == $current_page) {
113 $nav[
'text'] = $counter;
116 } elseif (($counter > $current_page - $offset && $counter < $current_page + $offset) || $counter == 1 || $counter == $total_pages) {
117 if ($counter == $total_pages && $current_page < $total_pages - $offset) {
118 $nav[
'text'] =
'...';
122 $last_text = $counter;
123 $last_url = $this->url . (($counter - 1) * $this->perpage) .
$this->extra;
125 $nav[
'text'] = $counter;
126 $nav[
'url'] = $this->url . (($counter - 1) * $this->perpage) .
$this->extra;
129 if ($counter == 1 && $current_page > 1 + $offset) {
130 $nav[
'text'] =
'...';
134 $first_text = $counter;
135 $first_url = $this->url . (($counter - 1) * $this->perpage) .
$this->extra;
138 $xoops->tpl()->appendByRef(
'xo_nav', $nav);
142 $xoops->tpl()->assign(
'last', $last);
143 $xoops->tpl()->assign(
'last_text', $last_text);
144 $xoops->tpl()->assign(
'last_url', $last_url);
145 $xoops->tpl()->assign(
'first', $first);
146 $xoops->tpl()->assign(
'first_text', $first_text);
147 $xoops->tpl()->assign(
'first_url', $first_url);
150 if ($this->total > $next) {
151 $xoops->tpl()->assign(
'next_text', $next_text);
152 $xoops->tpl()->assign(
'next_url', $this->url . $next . $this->extra);
157 $size =
' pagination-' . $size;
159 $xoops->tpl()->assign(
'size', $size);
160 $xoops->tpl()->assign(
'align',
' pagination-' . $align);
161 $xoops->tpl()->assign(
'pagination_nav',
true);
162 $ret =
$xoops->tpl()->fetch(
'module:system/system_pagenav.tpl');
163 $xoops->tpl()->clearAssign(
'xo_nav');
178 if ($this->total < $this->perpage) {
181 $total_pages = ceil($this->total / $this->perpage);
182 if ($total_pages > 1) {
184 $current_page = intval(floor(($this->current + $this->perpage) / $this->perpage));
185 while ($counter <= $total_pages) {
186 $select[
'text'] = $counter;
187 $select[
'value'] = $this->url . (($counter - 1) * $this->perpage) .
$this->extra;
188 if ($counter == $current_page) {
189 $select[
'selected'] = 1;
191 $select[
'selected'] = 0;
193 $xoops->tpl()->appendByRef(
'xo_select', $select);
198 $xoops->tpl()->assign(
'onchange',
"location=this.options[this.options.selectedIndex].value;");
199 $xoops->tpl()->assign(
'pagination_select',
true);
200 $xoops->tpl()->assign(
'showbutton', $showbutton);
201 $xoops->tpl()->assign(
'align',
' pagination-' . $align);
202 $ret =
$xoops->tpl()->fetch(
'module:system/system_pagenav.tpl');
203 $xoops->tpl()->clearAssign(
'xo_select');
217 $xoops->deprecated(
'renderImageNav() is deprecated since 2.6.0. Please use renderNav()');
renderSelect($align="right", $showbutton=false)
renderImageNav($offset=4)
renderNav($offset=4, $size="", $align="right", $prev_text="«", $next_text="»")
__construct($total_items, $items_perpage, $current_start, $start_name="start", $extra_arg="")