<?php 
class news extends CI_Controller {
	function news()	 
	{  
    parent::__construct();	
    $this->load->library('session');
    $this->load->Model('functions', 'fun');  //function in model
    $this->load->library('pagination'); 


    } 



	
	
	public function index()
{
       $config['base_url'] = base_url().'news/index';

		$config['total_rows'] = $this->fun->get_num('news');

		$config['per_page'] = 5;

		$config['num_links'] = 3; 

		$config['uri_segment'] = 3;	

		$config['full_tag_open']=' <div class="paginations"> <ul id="pagin">';

		$config['full_tag_close'] = '</ul></div>';

		$config['next_link'] = 'Next';

		$config['prev_link'] = 'Prev';

		$config['next_tag_open'] = '<li>';

		$config['next_tag_close'] = '</li>';

		$config['prev_tag_open'] = '<li>';

		$config['prev_tag_close'] = '</li>';

		$config['num_tag_open'] = '<li>';

		$config['num_tag_close'] = '</li>';

		$config['cur_tag_open'] = '<li><a href="#" class="current">';

		$config['cur_tag_close'] = '</a></li>';		

		$offset = $this->uri->segment(3,0);

		$this->session->set_userdata('offset',$offset);

		$this->pagination->initialize($config);

		$q= $this->fun->getall_pag('posts','news',$config['per_page'],$config['uri_segment']);

		$data['posts']=$q;

		if($this->session->userdata('lang')=='en')
	    {
	    $this->load->view('header');
		$this->load->view('news',$data);
		$this->load->view('footer');

	    }
	    else
	    {
		$this->load->view('header_ar');
		$this->load->view('news_ar',$data);
		$this->load->view('footer_ar');
		}

	}
	
	
	
	public function details($name,$id,$lang='')

	{     $data['id']=$id;
    
	    if($lang=='ar')
	   {
	   $this->session->set_userdata('lang','ar');
	   }
	   if($lang=='en')
	   {
	   $this->session->set_userdata('lang','en');
	   }
 
	
	    if($this->session->userdata('lang')=='en')
	    {

                $this->load->view('header');
				$this->load->view('news_details',$data);
				$this->load->view('footer');
	   }else
	   {
	            $this->load->view('header_ar');
				$this->load->view('news_details_ar',$data);
				$this->load->view('footer_ar');


	   }
	

	}




	
}



?>