Server : Apache/2.4.18 (Ubuntu) System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64 User : oppastar ( 1041) PHP Version : 7.0.33-0ubuntu0.16.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, Directory : /var/www/blue-sky.co.id/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Custom_url extends Admin_Controller { function __construct() { parent::__construct(); $this->load->model('custom_url_m'); } public function index() { //Add pagination $this->load->helper('pagination_helper'); add_pagination(base_url() . 'admin/custom_url/index', $this->custom_url_m->record_count(), 100, 4); //get parent menus only $this->data['get_all_custom_url'] = $this->custom_url_m->get_all_custom_url(100, $this->uri->segment(4)); //load view $this->data['subview'] = 'admin/custom_url/index'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } public function edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->custom_url_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['get_all_custom_url'] = $this->custom_url_m->get($id); //validation check in action $rules = $this->custom_url_m->rules; $config = $this->check_form_validation($rules, $_POST); $this->load->library('form_validation'); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); //above is to add class to form validation error, to be styled $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run($this) == TRUE) { $data = array( "page_name"=>$this->input->post('page_name'), "button_name"=>$this->input->post('button_name'), "val"=>$this->input->post('val'), ); $this->custom_url_m->edit_custom_url($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Custom URL Berhasil Diedit</p>'); redirect('admin/custom_url'); } $this->data['subview'] = 'admin/custom_url/edit'; $this->load->view('admin/templates/header', $this->data_header); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer'); } private function check_form_validation($config, $post_data) { if (isset($post_data['page_name'])) { $config[] = array( 'field' => 'page_name', 'label' => 'page_name', 'rules' => 'trim|required' ); } if (isset($post_data['button_name'])) { $config[] = array( 'field' => 'button_name', 'label' => 'button_name', 'rules' => 'trim|required' ); } if (isset($post_data['val'])) { $config[] = array( 'field' => 'val', 'label' => 'val', 'rules' => 'trim|required' ); } return $config; } }