}
+ private function splitLimit($limit) {
+ return strpos($limit,',')!==false
+ ? preg_split('/\s*,\s*/',$limit)
+ : [0,$limit]
+ ;
+ }
+
public function nav($count,$tot,$limit) {
$html = '';
if ($count<$tot) {
- list($x,$y) = strpos($limit,',')!==false
- ? preg_split('/\s*,\s*/',$limit)
- : [0,$limit]
- ;
+ list($x,$y) = $this->splitLimit($limit);
$prev = $x - $y;
$next = $x + $y;
if ($prev>=0) $html .= '<span class="prev"><a href="'.$this->url_list('limit',preg_replace('/^0,/','',"$prev,$y")).'"><<</a></span> ';
- $html .= '<span class="count">'.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.'</span>';
+ $html .= '<span class="count">'.($tot ? ($x+1) : 0).' - '.( $tot<($x+$y) ? $tot : ($x+$y) ).' / '.$tot.'</span>';
if ($next<$tot) $html .= ' <span class="prev"><a href="'.$this->url_list('limit',"$next,$y").'">>></a></span>';
if ($this->p('orderby') and !$count) $sql .= ' ORDER BY '.$this->p('orderby');
- if ($_limit = $limit = $this->db()->limit) {
- $_limit = str_replace(' OFFSET ',',',$_limit);
- $_limit = str_replace(',',' OFFSET ',$_limit);
- $sql .= ' LIMIT '.$_limit;
+ if ($limit = $this->db()->limit) {
+ $sql .= ' LIMIT ' . join(' OFFSET ',array_reverse($this->splitLimit($limit)));
} else {
$limit = '';
}
'total_pages' => ceil($this->tot / $limit) // calculate pages count
]);
- #$this->_html_table->display_tablenav('top');
$this->_html_table->display();
- #$this->_html_table->display_tablenav('bottom');
unset($this->_html_table);
return '';
}