load->model('admin_model','admin'); $this->load->model('example_model','example'); } public function index() { if(!$this->checkAdminLogin()) { $this->load->view('adminLoginView'); } else { $type = $this->input->get('type'); $items = $this->example->all($type); $exa = $this->config->item("EXAMPLE"); $data['exa'] = $exa; $data['items'] = $items; $data['type'] = $type; $this->load->view('exampleView' , $data); } } public function add() { $action = $this->input->get('action'); $type = $this->input->get('type'); $exa = $this->config->item("EXAMPLE"); $data['exa'] = $exa; $data['type'] = $type; if($action == 'insert'){ $_POST[] = $this->security->xss_clean($_POST); $parm['type'] = $type; $parm['name'] = trim($_POST['name']); $parm['url'] = trim($_POST['url']); $parm['content'] = $_POST['content']; $parm['ord'] = $this->example->max_ord($type) + 1; if($this->example->insert($parm)){ exit(''); } else exit(''); } $this->load->view('exampleAddView' , $data); } public function edit() { $id = $this->input->get('id' , true); $action = $this->input->get('action'); $type = $this->input->get('type'); $exa = $this->config->item("EXAMPLE"); $data['exa'] = $exa; $data['type'] = $type; if($action == 'update'){ $_POST[] = $this->security->xss_clean($_POST); $id = trim($_POST['id']); $parm['type'] = $type; $parm['name'] = trim($_POST['name']); $parm['url'] = trim($_POST['url']); $parm['content'] = $_POST['content']; if($this->example->update($id , $parm)){ exit(''); } else exit(''); } $item = $this->example->get($id); $data['item'] = $item; $this->load->view('exampleEditView' , $data); } public function del() { $id = $this->input->get('id' , true); if($this->example->delete($id)){ exit(''); } else exit(''); } public function update_ord() { $type = $this->input->get('type'); $id = $this->input->get('id' , true); $last_id = $this->input->get('last_id' , true); $parm = $this->example->get($id); $parm1 = $this->example->get($last_id); $temp = $parm['ord']; $parm['ord'] = $parm1['ord']; $parm1['ord'] = $temp; if($this->example->update($id , $parm) && $this->example->update($last_id , $parm1)){ exit(''); } else exit(''); } }