ad = db('Ad'); $this->adplace = db('AdPlace'); } /** * 插件列表 */ public function index() { $map = array(); $order = "id desc"; $list = db('AdPlace')->where($map)->order($order)->paginate(10); $data = array( 'list' => $list, 'page' => $list->render(), ); $this->assign($data); $this->setMeta("幻灯管理"); return $this->fetch(); } /** * 幻灯位添加 */ public function add() { $place = model('AdPlace'); if (IS_POST) { $result = $place->change(); if (false !== false) { return $this->success("添加成功!"); } else { return $this->error($place->getError()); } } else { $data = array( 'keyList' => $place->keyList, ); $this->assign($data); $this->setMeta("添加幻灯"); return $this->fetch('public/edit'); } } public function edit($id = null) { $place = model('AdPlace'); if (IS_POST) { $result = $place->change(); if ($result) { return $this->success("修改成功!", url('admin/ad/index')); } else { return $this->error($this->adplace->getError()); } } else { $info = db('AdPlace')->where(array('id' => $id))->find(); if (!$info) { return $this->error("非法操作!"); } $data = array( 'info' => $info, 'keyList' => $place->keyList, ); $this->assign($data); $this->setMeta("编辑幻灯"); return $this->fetch('public/edit'); } } public function del() { $id = $this->getArrayParam('id'); if (empty($id)) { return $this->error("非法操作!"); } $map['id'] = array('IN', $id); $result = $this->adplace->where($map)->delete(); if ($result) { return $this->success("删除成功!"); } else { return $this->error("删除失败!"); } } public function lists($id = null) { $map['place_id'] = $id; $order = "id desc"; $list = db('Ad')->where($map)->order($order)->paginate(10); $Metatitle = db('AdPlace')->where('id',$id)->value('title'); $data = array( 'id' => $id, 'list' => $list, 'page' => $list->render(), ); $this->assign($data); $this->setMeta($Metatitle."管理"); return $this->fetch(); } public function addad($id) { $ad = model('ad'); if (IS_POST) { $result = $ad->change(); if ($result) { return $this->success("添加成功!", url('admin/focus/lists', array('id' => $this->param['place_id']))); } else { return $this->error($ad->getError()); } } else { $info['place_id'] = $id; if($id==3){ $modelid = array('name'=>'model', 'title'=>'模型', 'type'=>'select', 'help'=>'', 'option'=>array('1'=>'小说','2'=>'漫画')); array_push($ad->keyList,$modelid); } $data = array( 'info' => $info, 'keyList' => $ad->keyList, ); $Metatitle = db('AdPlace')->where('id',$id)->value('title'); $this->assign($data); $this->setMeta("添加".$Metatitle); return $this->fetch('public/edit'); } } public function editad($id = null) { $ad = model('ad'); if (IS_POST) { $result = $ad->change(); if ($result) { return $this->success("修改成功!", url('admin/focus/lists', array('id' => $this->param['place_id']))); } else { return $this->error($ad->getError()); } } else { $info = db('ad')->where(array('id' => $id))->find(); if (!$info) { return $this->error("非法操作!"); } if($info['place_id']==3){ $modelid = array('name'=>'model', 'title'=>'模型', 'type'=>'select', 'help'=>'', 'option'=>array('1'=>'小说','2'=>'漫画')); array_push($ad->keyList,$modelid); } $data = array( 'info' => $info, 'keyList' => $ad->keyList, ); $this->assign($data); $this->setMeta("编辑"); return $this->fetch('public/edit'); } } public function delad() { $id = $this->getArrayParam('id'); if (empty($id)) { return $this->error("非法操作!"); } $map['id'] = array('IN', $id); $result = db('ad')->where($map)->delete(); if ($result) { return $this->success("删除成功!"); } else { return $this->error("删除失败!"); } } }