Guest User

front

a guest
Jun 9th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Front extends CI_Controller {
  5.  
  6.     public function __construct() {
  7.         parent::__construct();
  8.     }
  9.  
  10.     public function index() {
  11.         $data = [
  12.             'title' => 'Ini halaman edit',
  13.             'author' => 'Abdurrahman',
  14.             'date' => date('Y-m-d H:i:s'),
  15.             'content' => 'Ini adalah contoh dari penggunaan variable, yakni bypass variable lewat view'
  16.         ];
  17.         $this->load->view('index', $data);
  18.     }
  19.  
  20.     public function category_page() {
  21.         $this->load->view('category_page');
  22.     }
  23.  
  24.     public function add_article($param=null){
  25.         if ($param == 'add') {
  26.             $post = $this->input->post();
  27.  
  28.             if (!empty($post['title']) && !empty($post['author']) && !empty($post['content'])) {
  29.                 $this->load->model('Post');
  30.                 $data = [
  31.                     'title' => $post['title'],
  32.                     'author' => $post['author'],
  33.                     'date' => date('Y-m-d'),
  34.                     'content' => $post['content']
  35.                 ];
  36.                 $this->Post->insert('post', $data);
  37.                 $this->load->view('add_article_done', $data);
  38.             } else {
  39.                 $this->load->view('add_article_fail', $data);
  40.             }
  41.         } else {
  42.             $this->load->view('add_article');
  43.         }
  44.     }
  45.  
  46.     public function image_lib_test(){
  47.         $config['image_library'] = 'gd2';
  48.         $config['source_image'] = dirname(__FILE__).'/assets/images/14.jpg';
  49.         $config['create_thumb'] = TRUE;
  50.         $config['maintain_ratio'] = TRUE;
  51.         $config['width']         = 75;
  52.         $config['height']       = 50;
  53.  
  54.         var_dump(file_exists($config['source_image']));
  55.  
  56.         $this->load->library('image_lib', $config);
  57.  
  58.         if (!$this->image_lib->resize()) {
  59.             echo $this->image_lib->display_errors();
  60.         } else {
  61.             echo 'It Works!';
  62.         }
  63.     }
  64.  
  65.     public function pagination_lib_test(){
  66.         $this->load->library('pagination');
  67.  
  68.         $config['base_url'] = base_url('front/pagination_lib_test/hal/');
  69.         $config['total_rows'] = 200;
  70.         $config['per_page'] = 20;
  71.  
  72.         $this->pagination->initialize($config);
  73.  
  74.         echo $this->pagination->create_links();
  75.     }
  76.  
  77.     public function login() {
  78.         $this->load->helper('url');
  79.         echo '<a href="' . base_url('front/login_success') . '">Klik untuk login</a>';
  80.     }
  81. }
  82.  
  83.  
  84. // public function gets($id) {
  85. //  echo $id;
  86. // }
  87. /* End of file Front.php */
  88. /* Location: ./application/controllers/Front.php */
Advertisement
Add Comment
Please, Sign In to add comment