Avail feature updated
[ninja.git] / application / libraries / CountlessPagination.php
blob404b2b636206d95d26ede3bad539efa939ff9398
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
2 /**
3 * A Pagination library that doesn't require you to count() millions of rows
4 */
5 class CountlessPagination extends Pagination {
6 public function initialize($config = array()) {
7 if( isset( $config['query_string'] ) ) {
8 $this->query_string = $config['query_string'];
9 } else {
10 $this->query_string = 'page'; /* Ehum... TODO? This is ugly... */
13 $this->current_page = isset($_GET[$this->query_string]) ? (int) $_GET[$this->query_string] : 1;
14 if( isset( $config['items_per_page'] ) ) {
15 $this->items_per_page = $config['items_per_page'];
17 if(!isset($config['style'])) {
18 $config['style'] = 'digg-pageless';
20 $config['total_items'] = ($this->current_page + 1) * $this->items_per_page;
21 parent::initialize($config);
22 if (isset($config['extra_params'])) {
23 $base_url = ($this->base_url === '') ? Router::$current_uri : $this->base_url;
24 $this->url = url::site($base_url).'?'.$config['extra_params'].'&amp;page={page}';