Show
Ignore:
Timestamp:
08/29/2007 12:02:58 PM (15 months ago)
Author:
Geert
Message:
  • More bug fixes
  • I added a temporary pagination example to the welcome controller. Go check it out!
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Pagination.php

    r413 r443  
    33class Pagination_Core { 
    44         
    5         public $base_url; 
     5        public $base_url           = ''; 
    66        public $style              = 'classic'; 
    77        public $uri_segment        = 3; 
     
    4040                } 
    4141                 
     42                // Explode the base_url into segments 
     43                $this->base_url = explode('/', trim($this->base_url, '/')); 
     44 
    4245                // If a uri_label is given, look for the corresponding uri_segment 
    4346                if (isset($this->uri_label)) 
    4447                { 
    45                         $uri_label_segment = array_search($this->uri_label, Kohana::instance()->uri->segment_array()); 
     48                        $uri_label_segment = array_search($this->uri_label, $this->base_url); 
    4649                         
    4750                        if ($uri_label_segment !== FALSE) 
    4851                        { 
    49                                 $this->uri_segment = $uri_label_segment + 1; 
     52                                $this->uri_segment = $uri_label_segment + 2; 
    5053                        } 
    5154                } 
    5255                 
    5356                // Create a generic base_url with {page} placeholder 
    54                 $this->base_url = (isset($this->base_url)) ? $this->base_url : Kohana::instance()->uri->string(); 
    55                 $this->base_url = explode('/', $this->base_url); 
    5657                $this->base_url[$this->uri_segment - 1] = '{page}'; 
    5758                $this->base_url = implode('/', $this->base_url); 
     
    8990                $style = (isset($style)) ? $style : $this->style; 
    9091                 
    91                 return (string) new View('views/pagination/'.$style, get_object_vars($this)); 
     92                return (string) new View('pagination/'.$style, get_object_vars($this)); 
    9293        } 
    9394         
     
    9899 
    99100        /** 
    100          * Returns a URL with the specified page number 
     101         * Returns the base_url with the specified page number 
    101102         * 
    102103         * @access  public 
     
    106107        public function url($page = NULL) 
    107108        { 
    108                 $page = (int) (isset($page)) ? $this->current_page : $page; 
     109                $page = (int) (isset($page)) ? $page : $this->current_page; 
    109110                 
    110111                return str_replace('{page}', $page, $this->base_url);