<?php
namespace Admin\Controller;
use Think\Controller;
class InfoController extends CommController {
public function index(){
$tag=M("adminTag");
$systemtag=$tag->select();
$this->assign("systemtag",$systemtag);
$this->display();
}
public function indexpage(){
$this->display();
}
public function postInfo(){
$articDb=D("adminArticle");
if ($articDb->create()){
$result=$articDb->add();
if($result) {
$this->success('操作成功!',U("Info/managementInfo"));
}else{
$this->error('写入错误!');
}
}else{
$this->error($articDb->getError());
}
}
public function managementInfo(){
$articDb=D("adminArticle");
$count=$articDb->count();
$Page = new \Think\Page($count,20);
$Page->setConfig('theme','%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
$Page->setConfig('prev','上一页');
$Page->setConfig('next','下一页');
$show = $Page->show();
$info=$articDb->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign("info",$info);
$this->assign('page',$show);
$this->display();
}
public function deteleInfo(){
$Article_id=I("post.article_id");
$articDb=M("adminArticle");
$result=array("success"=>false,"error"=>"");
$resu=$articDb->delete($Article_id);
if($resu){
$result=array("success"=>true,"error"=>"");
}else{
$result=array("success"=>false,"error"=>"delete fail");
}
echo json_encode($result);
}
public function editInfo(){
$article_id=I("get.article_id");
$articDb=M("adminArticle");
$data=$articDb->find($article_id);
$tag=M("adminTag");
$systemtag=$tag->select();
$this->assign("systemtag",$systemtag);
$this->assign("art",$data);
$this->display();
}
public function editSaveInfo(){
$AdarticDb=D("adminArticle");
if ($AdarticDb->create()){
$result=$AdarticDb->save();
if($result) {
$this->success('操作成功!',U("Info/managementInfo"));
}else{
$this->error('修改错误!');
}
}else{
$this->error($AdarticDb->getError());
}
}
}