UPGRADE NOTE: Do not edit or add to this file if you wish to upgrade AbanteCart to newer versions in the future. If you wish to customize AbanteCart for your needs please refer to http://www.AbanteCart.com for more information. ------------------------------------------------------------------------------*/ if (! defined ( 'DIR_CORE' )) { header ( 'Location: static_pages/' ); } final class APagination { public $total = 0; public $page = 1; public $limit = 20; public $split = 5; public $limits = array(); public $num_links = 10; public $url = ''; public $text = 'Showing {start} to {end} of {total} ({pages} Pages)'; public $text_limit = 'Per Page'; public $text_first = '|<'; public $text_last = '>|'; public $text_next = '>'; public $text_prev = '<'; public $style_links = 'links'; public $style_results = 'results'; public $style_limits = 'limits'; public function render() { $total = $this->total; if ($this->page < 1) { $page = 1; } else { $page = $this->page; } if (!$this->limit) { $limit = 10; } else { $limit = $this->limit; } if(!$this->limits){ $registry = Registry::getInstance(); $this->limits[0] = $x = ( $this->split ? $this->split : $registry->get('config')->get('config_catalog_limit') ); while($x<=50){ $this->limits[] = $x; $x += 10; } } $this->url = str_replace('{limit}',$limit,$this->url); $num_links = $this->num_links; $num_pages = ceil($total / $limit); $stdout = ''; if ($page > 1) { $stdout .= ' ' . $this->text_first . ' '; } if ($num_pages > 1) { if ($num_pages <= $num_links) { $start = 1; $end = $num_pages; } else { $start = $page - floor($num_links / 2); $end = $page + floor($num_links / 2); if ($start < 1) { $end += abs($start) + 1; $start = 1; } if ($end > $num_pages) { $start -= ($end - $num_pages); $end = $num_pages; } } if ($start > 1) { $stdout .= ' .... '; } for ($i = $start; $i <= $end; $i++) { if ($page == $i) { $stdout .= ' ' . $i . ' '; } else { $stdout .= ' ' . $i . ' '; } } if ($end < $num_pages) { $stdout .= ' .... '; } } if ($page < $num_pages) { $stdout .= ' ' . $this->text_last . ' '; } $find = array( '{start}', '{end}', '{total}', '{pages}', '{limit}' ); $replace = array( ($total) ? (($page - 1) * $limit) + 1 : 0, ((($page - 1) * $limit) > ($total - $limit)) ? $total : ((($page - 1) * $limit) + $limit), $total, $num_pages ); $registry = Registry::getInstance(); if ( !in_array($this->limit, $this->limits) ) { $this->limits[] = $this->limit; sort($this->limits); } $options = array(); foreach($this->limits as $item){ $options[$item] = $item; } $limit_select = $registry->get('html')->buildSelectbox( array( 'name' => 'limit', 'value'=> $this->limit, 'options' => $options, 'style' => '', 'attr' => ' onchange="location=\'' . str_replace('{page}', 1, $this->url) . '&limit=\'+this.value;"', ) ); $limit_select = str_replace('&', '&', $limit_select); $limit_select .= '  ' . $this->text_limit; return ($limit_select ? '
' . $limit_select . '
' : '') . ($stdout ? '' : '') . '
' . str_replace($find, $replace, $this->text) . '
'; } } ?>