load->model('admin_model','admin');
$this->load->model('news_model','news');
}
public function index()
{
if(!$this->checkAdminLogin())
{
$this->load->view('adminLoginView');
} else {
$type = $this->input->get('type');
$items = $this->news->all($type);
$exa = $this->config->item("NEWS");
$data['exa'] = $exa;
$data['items'] = $items;
$data['type'] = $type;
$this->load->view('newsView' , $data);
}
}
public function add()
{
$action = $this->input->get('action');
$type = $this->input->get('type');
$exa = $this->config->item("NEWS");
$data['exa'] = $exa;
$data['type'] = $type;
if($action == 'insert'){
$_POST[] = $this->security->xss_clean($_POST);
$parm['type'] = $type;
$parm['title'] = trim($_POST['title']);
$parm['author'] = trim($_POST['author']);
$parm['from'] = trim($_POST['from']);
$parm['pv'] = trim($_POST['pv']);
$parm['publishtime'] = strtotime(trim($_POST['publishtime']));
$parm['addtime'] = time();
$parm['img'] = trim($_POST['img']);
$parm['desc'] = str_replace("\n", "
", trim($_POST['desc']));
$parm['content'] = trim($_POST['content']);
if($this->news->insert($parm)){
exit('');
}
else
exit('');
}
$this->load->view('newsAddView' , $data);
}
public function edit()
{
$id = $this->input->get('id' , true);
$action = $this->input->get('action');
$type = $this->input->get('type');
$exa = $this->config->item("NEWS");
$data['exa'] = $exa;
$data['type'] = $type;
if($action == 'update'){
$_POST[] = $this->security->xss_clean($_POST);
$id = $_POST['id'];
$parm['type'] = trim($_POST['type']);
$parm['title'] = trim($_POST['title']);
$parm['author'] = trim($_POST['author']);
$parm['from'] = trim($_POST['from']);
$parm['pv'] = trim($_POST['pv']);
$parm['publishtime'] = strtotime(trim($_POST['publishtime']));
$parm['addtime'] = time();
$parm['img'] = trim($_POST['img']);
$parm['desc'] = str_replace("\n", "
", trim($_POST['desc']));
$parm['content'] = trim($_POST['content']);
if($this->news->update($id , $parm)){
exit('');
}
else{
exit('');
}
}
$item = $this->news->get($id);
$data['item'] = $item;
$this->load->view('newsEditView' , $data);
}
public function del()
{
$id = $this->input->get('id' , true);
if($this->news->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->news->get($id);
// $parm1 = $this->news->get($last_id);
// $temp = $parm['ord'];
// $parm['ord'] = $parm1['ord'];
// $parm1['ord'] = $temp;
// if($this->news->update($id , $parm) && $this->news->update($last_id , $parm1)){
// exit('');
// }
// else
// exit('');
// }
}