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/kanvakanva.com/public_html/application/controllers/admin/ |
Upload File : |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Themes extends Admin_Controller { //this property is used for validating existing themes title on call back edit themes protected $themes_current_id; function __construct() { parent::__construct(); $this->load->model('themes_m'); } //this is to list all themes public function index() { //pagination in action. 50 results per page $this->load->library('pagination'); $config['base_url'] = base_url() . 'admin/themes/index'; $config['per_page'] = 50; $config["uri_segment"] = 4; $config['num_tag_open'] = '<span style="padding-left:10px; padding-right:10px">'; $config['num_tag_close'] = '</span>'; //fetch all themes $config['total_rows'] = $this->themes_m->record_count(); $this->pagination->initialize($config); $this->data['themes'] = $this->themes_m->get_all_themes($config["per_page"], $this->uri->segment(4)); //load view $this->data['subview'] = 'admin/themes/index'; $this->load->view('admin/templates/header', $this->data); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } //to add a new themes public function add() { $this->data['themes'] = $this->themes_m->get_new(); //validation in action //validation check in action $config = $this->themes_m->rules; $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == TRUE) { $data = $this->table_data_processing($this->input->post('themes'), $this->input->post('priority')); $this->themes_m->add_themes($data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Themes Add Successful</p>'); redirect('admin/themes'); } $this->data['subview'] = 'admin/themes/edit'; $this->load->view('admin/templates/header', $this->data); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } //to edit themes in admin public function edit($id = NULL) { //check if id exist. If not exist, show 404. $count = $this->themes_m->count_exist($id); if ($count == 0) { //page not exist show_404(); } $this->data['themes'] = $this->themes_m->get($id); $this->themes_current_id = (int) $this->data['themes']->id_themes; //validation check in action $config = $this->themes_m->rules; $this->form_validation->set_rules($config); $this->form_validation->set_error_delimiters('<div class="error">', '</div>'); if($this->form_validation->run() == TRUE) { $data = $this->table_data_processing($this->input->post('themes'), $this->input->post('priority')); $this->themes_m->edit_themes($id, $data); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Themes Edit Successful</p>'); redirect('admin/themes'); } $this->data['subview'] = 'admin/themes/edit'; $this->load->view('admin/templates/header', $this->data); $this->load->view('admin/_layout_main', $this->data); $this->load->view('admin/templates/footer', $this->data); } //to delete a themes public function delete($id) { //delete themes $this->themes_m->delete($id); $this->session->set_flashdata('success', '<br><p style="background:green; color:white; padding:5px; font-weight:bold;">Themes Delete Successful</p>'); redirect('admin/themes'); } private function table_data_processing($themes, $priority) { $data = array( 'themes' => $this->security->xss_clean($themes), 'priority' => (int) $priority, ); return $data; } //callback function validation add new themes public function _cek_existing_themes_title($str) { $num_rows = $this->themes_m->cek_existing_themes_title($str, $this->themes_current_id); if ($num_rows != 0 ) { $this->form_validation->set_message('_cek_existing_themes_title', 'themes attribute already exist !'); return FALSE; } else { return TRUE; } } }