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

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

	public function index()
	{
		$d['judul'] = "Artikel ".$this->config->item('nama_aplikasi_full');
        $d['bawah'] = $this->config->item('footer');
        $d['judul_lengkap'] = $d['judul'];
        $d['kunci'] = "artikel, ".$this->config->item('kunci');
        
        
        $config['total_rows'] = $this->profil->promo_hal($this->config->item('kode'));
		$config['per_page'] = 12;
		$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/artikel/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->promo_semua("", $this->config->item('kode'), "limit $hal, $config[per_page]");
        
        
		$this->load->view('theme/at_atas.php',$d);
        $this->load->view('promo/at_tampil.php',$d);
        $this->load->view('theme/at_bawah.php',$d);
	}
	
	public function detail($id=null)
	{
		$kali=balik("at_promo", "dibaca", "id", $id)+1;
        mysql_query("UPDATE `at_promo` SET `dibaca`='".$kali."' WHERE (`id`='$id') LIMIT 1");
		
		$d['judul'] = $this->config->item('nama_aplikasi_full');
        $d['bawah'] = $this->config->item('footer');
        $d['judul_lengkap'] = $d['judul'];
        
        
        if($this->session->userdata('language')=="en"){
            $d['i_judul']=balik("at_promo", "judul_ing", "id", $id);
            $d['i_isi']=balik("at_promo", "isi_ing", "id", $id);
			$d['kunci'] = balik("at_promo", "judul_ing", "id", $id)." Promo masak, berita kursus masak ".$this->config->item('kunci');
        }
        if($this->session->userdata('language')==""){
            $d['i_judul']=balik("at_promo", "judul_ind", "id", $id);
            $d['i_isi']=balik("at_promo", "isi_ind", "id", $id);
			$d['kunci'] = balik("at_promo", "judul_ind", "id", $id)." Berita masak, berita kursus masak ".$this->config->item('kunci');
        }
		
        $d['foto']=balik("at_promo", "foto", "id", $id);
		$d['tanggal']=balik("at_promo", "tanggal", "id", $id);
		$d['dibaca']=balik("at_promo", "dibaca", "id", $id);
		$d['oleh']=balik("at_promo", "oleh", "id", $id);
        
        
        
        
		$this->load->view('theme/at_atas.php',$d);
        $this->load->view('promo/at_detail.php',$d);
        $this->load->view('theme/at_bawah.php',$d);
	}
	

	
}
