ArticleController.class.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. namespace Admin\Controller;
  3. class ArticleController extends AdminController
  4. {
  5. protected function _initialize(){
  6. parent::_initialize();
  7. $allow_action=array("index","edit","wenzhangimg","ggeditup","taxggeditup","setstatus","taxtxt","taxedit");
  8. if(!in_array(ACTION_NAME,$allow_action)){
  9. $this->error("页面不存在!");
  10. }
  11. }
  12. //新增或编辑处理
  13. public function taxggeditup($title=null,$img=null,$content=null,$status=null,$id=null){
  14. if($id <= 0){
  15. $_POST['addtime'] = date("Y-m-d H:i:s",time());
  16. $re = M("taxtxt")->add($_POST);
  17. if($re){
  18. $this->success("公告添加成功");
  19. }else{
  20. $this->error("公告添加失败");
  21. }
  22. }else{
  23. $re = M("taxtxt")->where(array('id'=>$id))->save($_POST);
  24. if($re){
  25. $this->success("公告修改成功");
  26. }else{
  27. $this->error("公告修改失败");
  28. }
  29. }
  30. }
  31. //纳税公告
  32. public function taxtxt($name = NULL, $field = NULL, $status = NULL){
  33. $where = array();
  34. $count = M('taxtxt')->where($where)->count();
  35. $Page = new \Think\Page($count, 15);
  36. $show = $Page->show();
  37. $list = M('taxtxt')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  38. $this->assign('list', $list);
  39. $this->assign('page', $show);
  40. $this->display();
  41. }
  42. //新增或编辑纳税公告
  43. public function taxedit($id = NULL, $type = NULL){
  44. if($id > 0){
  45. $info = M("taxtxt")->where(array('id'=>$id))->find();
  46. $this->assign('data',$info);
  47. }
  48. $this->display();
  49. }
  50. //删除公告记录
  51. public function setstatus($id=null){
  52. $where = array();
  53. if(empty($id)){
  54. $this->error("缺少重要参数");exit();
  55. }
  56. $where['id'] = array('in',$id);
  57. $list = M("content")->where($where)->field("id,title")->select();
  58. if(!empty($list)){
  59. foreach($list as $key=>$vo){
  60. $oid = $vo['id'];
  61. M("content")->where(array('id'=>$oid))->delete();
  62. }
  63. $this->success("删除成功");exit();
  64. }else{
  65. $this->error("没有选择数据");exit();
  66. }
  67. }
  68. //公告中心
  69. public function index($name = NULL, $field = NULL, $status = NULL){
  70. $where = array();
  71. $count = M('content')->where($where)->count();
  72. $Page = new \Think\Page($count, 15);
  73. $show = $Page->show();
  74. $list = M('content')->where($where)->order('id desc')->limit($Page->firstRow . ',' . $Page->listRows)->select();
  75. $this->assign('list', $list);
  76. $this->assign('page', $show);
  77. $this->display();
  78. }
  79. //新增或编辑公告页面
  80. public function edit($id = NULL, $type = NULL){
  81. if($id > 0){
  82. $info = M("content")->where(array('id'=>$id))->find();
  83. $this->assign('data',$info);
  84. }
  85. $this->display();
  86. }
  87. //新增或编辑处理
  88. public function ggeditup($title=null,$img=null,$content=null,$status=null,$id=null){
  89. if($id <= 0){
  90. $_POST['addtime'] = date("Y-m-d H:i:s",time());
  91. $re = M("content")->add($_POST);
  92. if($re){
  93. $this->success("公告添加成功");
  94. }else{
  95. $this->error("公告添加失败");
  96. }
  97. }else{
  98. $re = M("content")->where(array('id'=>$id))->save($_POST);
  99. if($re){
  100. $this->success("公告修改成功");
  101. }else{
  102. $this->error("公告修改失败");
  103. }
  104. }
  105. }
  106. //上传图片
  107. public function wenzhangimg(){
  108. $upload = new \Think\Upload();
  109. $upload->maxSize = 3145728;
  110. $upload->exts = array('jpg', 'gif', 'png', 'jpeg');
  111. $upload->rootPath = './Upload/article/';
  112. $upload->autoSub = false;
  113. $info = $upload->upload();
  114. foreach ($info as $k => $v) {
  115. $path = $v['savepath'] . $v['savename'];
  116. echo $path;
  117. exit();
  118. }
  119. }
  120. }
  121. ?>