BlogController.class.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Controller;
  15. use Admin\Model\BlogModel;
  16. class BlogController extends CommonController{
  17. protected function _initialize(){
  18. parent::_initialize();
  19. $this->breadcrumb1='插件';
  20. $this->breadcrumb2='帮助列表';
  21. $this->blog_type = array('seller' => '商家后台','pinjie' => '拼团介绍','question' => '常见问题','pc_news' => 'PC端关于我们');
  22. }
  23. public function index(){
  24. $model=new BlogModel();
  25. $data=$model->show_blog_page();
  26. $this->assign('empty',$data['empty']);// 赋值数据集
  27. $this->assign('list',$data['list']);// 赋值数据集
  28. $this->assign('page',$data['page']);// 赋值分页输出
  29. /**/
  30. $this->display();
  31. }
  32. function add(){
  33. if(IS_POST){
  34. $model=new BlogModel();
  35. $data=I('post.');
  36. $return=$model->add_blog($data);
  37. echo json_encode($return);
  38. die();
  39. //$this->osc_alert($return);
  40. }
  41. $this->action=U('Blog/add');
  42. $this->crumbs='新增';
  43. $this->display('edit');
  44. }
  45. function edit(){
  46. $model=new BlogModel();
  47. if(IS_POST){
  48. $data=I('post.');
  49. $return=$model->edit_blog($data);
  50. echo json_encode($return);
  51. die();
  52. //$this->osc_alert($return);
  53. }
  54. $this->crumbs='编辑';
  55. $this->action=U('Blog/edit');
  56. $this->blog_content=M('blog_content')->where(array('blog_id'=>I('id')))->find();
  57. $this->blog=$model->get_blog_data(I('id'));
  58. $this->blog_images=$model->get_blog_image_data(I('id'));
  59. $this->blog_categories=$model->get_blog_category_data(I('id'));
  60. $this->display('edit');
  61. }
  62. function del(){
  63. $model=new BlogModel();
  64. $return=$model->del_blog(I('get.id'));
  65. $this->osc_alert($return);
  66. }
  67. }
  68. ?>