Changeset 2723

Show
Ignore:
Timestamp:
05/31/2008 04:47:04 AM (4 months ago)
Author:
Geert
Message:

Follow-up to r2717

All pagination config groups now inherit and overwrite the default group. This allows you to only overwrite some settings in custom groups while keeping sitewide defaults.

Files:
1 modified

Legend:

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

    r2717 r2723  
    1818        protected $uri_segment    = 3; 
    1919        protected $query_string   = ''; 
    20         protected $items_per_page = 10; 
     20        protected $items_per_page = 20; 
    2121        protected $total_items    = 0; 
    2222        protected $auto_hide      = FALSE; 
     
    5656        public function __construct($group = NULL, $config = array()) 
    5757        { 
    58                 // No group name given, only array with custom config 
     58                // No group name given, only array with custom config items 
    5959                // Allows for backward compatibility as well 
    6060                if (is_array($group)) 
     
    7373                        throw new Kohana_Exception('pagination.undefined_group', $group); 
    7474 
    75                 // Merge custom config items with group defaults 
     75                // All pagination config groups inherit default config group 
     76                if ($group !== 'default') 
     77                { 
     78                        // Load and validate default config group 
     79                        if ( ! is_array($default_config = Config::item('pagination.default'))) 
     80                                throw new Kohana_Exception('pagination.undefined_group', 'default'); 
     81 
     82                        // Merge config group with default config group 
     83                        $group_config += $default_config; 
     84                } 
     85 
     86                // Merge custom config items with config group 
    7687                $config += $group_config; 
    7788