load->model('admin_model','admin');
$this->load->model('homepage_model','homepage');
$this->load->model('web_setting_model','web_setting');
}
public function index()
{
if(!$this->checkAdminLogin())
{
$this->load->view('adminLoginView');
} else {
$items = $this->homepage->all();
$data['items'] = $items;
$this->load->view('indexView' , $data);
}
}
public function add()
{
$action = $this->input->get('action');
if($action == 'insert'){
$_POST[] = $this->security->xss_clean($_POST);
$parm['name'] = trim($_POST['name']);
$parm['url'] = trim($_POST['url']);
$parm['ord'] = $this->homepage->max_ord() + 1;
if($this->homepage->insert($parm)){
exit('');
}
else
exit('');
}
$this->load->view('indexAddView');
}
public function edit()
{
$id = $this->input->get('id' , true);
$action = $this->input->get('action');
if($action == 'update'){
$_POST[] = $this->security->xss_clean($_POST);
$id = trim($_POST['id']);
$parm['name'] = trim($_POST['name']);
$parm['url'] = trim($_POST['url']);
if($this->homepage->update($id , $parm)){
exit('');
}
else
exit('');
}
$item = $this->homepage->get($id);
$data['item'] = $item;
$this->load->view('indexEditView' , $data);
}
public function del()
{
$id = $this->input->get('id' , true);
if($this->homepage->delete($id)){
exit('');
}
else
exit('');
}
public function update_ord()
{
$id = $this->input->get('id' , true);
$last_id = $this->input->get('last_id' , true);
$parm = $this->homepage->get($id);
$parm1 = $this->homepage->get($last_id);
$temp = $parm['ord'];
$parm['ord'] = $parm1['ord'];
$parm1['ord'] = $temp;
if($this->homepage->update($id , $parm) && $this->homepage->update($last_id , $parm1)){
exit('');
}
else
exit('');
}
public function slider()
{
$action = $this->input->get('action');
$name = 'slider';
if($action == 'update'){
$_POST[] = $this->security->xss_clean($_POST);
if (is_array($_POST['url']) && count($_POST['url']) > 0) {
foreach ($_POST['url'] as $key => $value) {
$t['url'] = $value;
$t['img'] = $_POST['img'][$key];
$parm[] = $t;
}
if($this->web_setting->update($name , array("name"=>$name, "value"=>json_encode($parm)))){
exit('');
}
else
exit('');
}
}
$item = $this->web_setting->getValueByName($name);
$data['item'] = json_decode($item[0]['value'] , true);
$this->load->view('indexSliderView' , $data);
}
}