<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {
	
	public function __construct()
    {
        parent::__construct();
    }

	public function index()
	{
		$d['judul'] = "Berita ".$this->config->item('nama_aplikasi_full');
        $d['bawah'] = $this->config->item('footer');
        $d['judul_lengkap'] = $d['judul'];
		$d['i_isi'] = $d['judul'];
        $d['kunci'] = "news icc, news kuliner, berita kursus masak".$this->config->item('kunci');
        
        
        $config['total_rows'] = $this->profil->blog_hal($this->config->item('kode'));
		$config['per_page'] = 10;
		$config['uri_segment'] = 3;
		$config['full_tag_open'] = '<ul class="pagination margin-top-none">';
		$config['full_tag_close'] = '</ul>';
		$config['prev_link'] = '&lt;';
		$config['prev_tag_open'] = '<li>';
		$config['prev_tag_close'] = '</li>';
		$config['next_link'] = '&gt;';
		$config['next_tag_open'] = '<li>';
		$config['next_tag_close'] = '</li>';
		$config['cur_tag_open'] = '<li class="active"><a href="#">';
		$config['cur_tag_close'] = '</a></li>';
		$config['num_tag_open'] = '<li>';
		$config['num_tag_close'] = '</li>';
		 
		$config['first_tag_open'] = '<li>';
		$config['first_tag_close'] = '</li>';
		$config['last_tag_open'] = '<li>';
		$config['last_tag_close'] = '</li>';
		 
		$config['first_link'] = '&lt;&lt;';
		$config['last_link'] = '&gt;&gt;';
		$config['base_url'] = base_url()."index.php/news/index/";
		$this->pagination->initialize($config);
		
		
		
		$hal = $this->uri->segment(3);
		 if($hal==""){
			 $hal=0;
		}
           
        
		$d['page'] = $this->pagination->create_links();
		$d['no'] = $hal;
        
        $d['blog'] = $this->profil->berita_semua("", $this->config->item('kode'), "limit $hal, $config[per_page]");
        
        
		$this->load->view('theme/at_atas.php',$d);
        $this->load->view('news/at_tampil.php',$d);
        $this->load->view('theme/at_bawah.php',$d);
	}
	
	public function detail($id=null)
	{
		$kali=balik("at_berita", "dibaca", "id", $id)+1;
        mysql_query("UPDATE `at_berita` SET `dibaca`='".$kali."' WHERE (`id`='$id') LIMIT 1");
		
		
		
        
        
        if($this->session->userdata('language')=="en"){
            $d['i_judul']=balik("at_berita", "judul_ing", "id", $id);
            $d['i_isi']=balik("at_berita", "isi_ing", "id", $id);
			$d['kunci'] = balik("at_berita", "judul_ing", "id", $id)." Berita masak, berita kursus masak ".$this->config->item('kunci');
        }
        if($this->session->userdata('language')==""){
            $d['i_judul']=balik("at_berita", "judul_ind", "id", $id);
            $d['i_isi']=balik("at_berita", "isi_ind", "id", $id);
			$d['kunci'] = balik("at_berita", "judul_ind", "id", $id)." Berita masak, berita kursus masak ".$this->config->item('kunci');
        }
		
		$d['judul'] = $d['i_judul']." - ".$this->config->item('nama_aplikasi_full');
        $d['bawah'] = $this->config->item('footer');
        $d['judul_lengkap'] = $d['judul'];
		
        $d['foto']=balik("at_berita", "foto", "id", $id);
		$d['tanggal']=balik("at_berita", "tanggal", "id", $id);
		$d['dibaca']=balik("at_berita", "dibaca", "id", $id);
		$d['oleh']=balik("at_berita", "oleh", "id", $id);
		
		
        
        
		$this->load->view('theme/at_atas.php',$d);
        $this->load->view('news/at_detail.php',$d);
        $this->load->view('theme/at_bawah.php',$d);
	}
	

	
}
