Exemplo n.º 1
0
 public function generate_pagination($key = NULL, $params = array(), $content_id = NULL)
 {
     $total = $this->CI->filter->get_total($key);
     $limit = $this->CI->filter->get_limit($key);
     if (empty($limit)) {
         $limit = 20;
     }
     if (empty($total) || $total <= 0) {
         return '';
     }
     $config['full_tag_open'] = '<div style="margin:0;margin-top:10px;"><center>';
     $config['base_url'] = fetch_request_uri();
     $config['total_rows'] = $total;
     $config['per_page'] = $limit;
     $config['uri_segment'] = request_uri_count() + count($params) + 2;
     $config['num_links'] = 5;
     $config['full_tag_close'] = '</center></div>';
     $config['first_link'] = '&lt;&lt;' . lang('first');
     $config['last_link'] = lang('last') . '&gt;&gt;';
     $config['num_tag_open'] = '<span class="pageOff">';
     $config['num_tag_close'] = '</span>';
     $config['cur_tag_open'] = '<span class="current">';
     $config['cur_tag_close'] = '</span>';
     $config['next_tag_open'] = '<span class="pageOff">';
     $config['next_tag_close'] = '</span>';
     $config['prev_tag_open'] = '<span class="pageOff">';
     $config['prev_tag_close'] = '</span>';
     $config['last_tag_open'] = '<span class="pageOff">';
     $config['last_tag_close'] = '</span>';
     $config['first_tag_open'] = '<span class="pageOff">';
     $config['first_tag_close'] = '</span>';
     $this->CI->pagination->initialize($config);
     return $this->CI->pagination->create_links($params, $key, $content_id);
 }
Exemplo n.º 2
0
 public function set_offset($key = NULL)
 {
     $seg_count = $this->CI->uri->total_segments();
     for ($i = request_uri_count() + 1; $i < $seg_count; $i++) {
         $page = $this->CI->uri->segment($i);
         if ($page == 'page') {
             $this->offset = $this->CI->uri->segment($i + 1);
             if (!is_numeric($this->offset) || $this->offset < 0) {
                 $this->offset = 0;
             }
             break;
         }
     }
     if ($this->CI->filter->get_limit($key)) {
         $this->limit = $this->CI->filter->get_limit($key);
     }
     $this->CI->filter->set_offset($this->offset, $key);
 }