274 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			274 lines
		
	
	
		
			9.6 KiB
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace app\controller\manager;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								use app\model\{Category, Article, Block, DownloadModel, Log, History, Honour, NoticeModel, PositionModel, ProductModel};
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								class Content extends Base
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    //文章
							 | 
						|||
| 
								 | 
							
								    public function article()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id');
							 | 
						|||
| 
								 | 
							
								        $keyword    = input('param.keyword');
							 | 
						|||
| 
								 | 
							
								        $param      = input('param.param/a', []);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->error('无此栏目');
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $order = ['a.top' => 'desc', 'a.sort' => 'desc'];
							 | 
						|||
| 
								 | 
							
								        $list = Article::getList($categoryId, 20, $keyword, $param, -1, $order);
							 | 
						|||
| 
								 | 
							
								        $list = Article::convertRecommendOther([$categoryId], $list, true);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['list']          = $list;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']      = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['keyword']       = $keyword;
							 | 
						|||
| 
								 | 
							
								        $this->data['param']         = $param;
							 | 
						|||
| 
								 | 
							
								        $this->data['attributeList'] = Article::getAttributeList([$categoryId]);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //做页面跳转
							 | 
						|||
| 
								 | 
							
								    public function index()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $items = Category::getList();
							 | 
						|||
| 
								 | 
							
								        if (!empty($items)) {
							 | 
						|||
| 
								 | 
							
								            $items = Category::getCates($items);
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        if (!empty($items)) {
							 | 
						|||
| 
								 | 
							
								            $first = array_shift($items);
							 | 
						|||
| 
								 | 
							
								            if (isset($first['children'])) {
							 | 
						|||
| 
								 | 
							
								                $childrenFirst = array_shift($first['children']);
							 | 
						|||
| 
								 | 
							
								                $url           = url('manager.content/'.$childrenFirst['manager'], ['category_id' => $childrenFirst['id']]);
							 | 
						|||
| 
								 | 
							
								            } else {
							 | 
						|||
| 
								 | 
							
								                $url = url('manager.content/'.$first['manager'], ['category_id' => $first['id']]);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($url)) {
							 | 
						|||
| 
								 | 
							
								                return $this->redirect($url);
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        } else {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.category/add'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    //单页
							 | 
						|||
| 
								 | 
							
								    public function page()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        if ($this->request->isAjax()) {
							 | 
						|||
| 
								 | 
							
								            $blocks     = input('post.block/a');    //所有文本信息
							 | 
						|||
| 
								 | 
							
								            $texts      = input('post.text/a');      //所有富文本信息
							 | 
						|||
| 
								 | 
							
								            $codes      = input('post.code/a');      //所有代码信息
							 | 
						|||
| 
								 | 
							
								            $categoryId = input('post.category_id/d');
							 | 
						|||
| 
								 | 
							
								            $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								            unset($_POST['block']);
							 | 
						|||
| 
								 | 
							
								            unset($_POST['text']);
							 | 
						|||
| 
								 | 
							
								            unset($_POST['file']);
							 | 
						|||
| 
								 | 
							
								            unset($_POST['code']);
							 | 
						|||
| 
								 | 
							
								            $imgs     = [];     //图片信息
							 | 
						|||
| 
								 | 
							
								            $videos   = [];   //视频信息
							 | 
						|||
| 
								 | 
							
								            $groups   = [];   //组图信息
							 | 
						|||
| 
								 | 
							
								            $groupIds = input('post.groupIds/a', []);
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            $videoGroup   = [];   //视频组信息
							 | 
						|||
| 
								 | 
							
								            $videoGroupIds = input('post.videoGroupIds/a', []);
							 | 
						|||
| 
								 | 
							
								            foreach ($_POST as $key => $val) {
							 | 
						|||
| 
								 | 
							
								                if (strpos($key, '_') !== false) {
							 | 
						|||
| 
								 | 
							
								                    $keys = explode('_', $key);
							 | 
						|||
| 
								 | 
							
								                    if ($keys[1] == 'img') {  //图片
							 | 
						|||
| 
								 | 
							
								                        $imgs[$keys[2]] = $val;
							 | 
						|||
| 
								 | 
							
								                    } elseif ($keys[1] == 'video') {   //视频
							 | 
						|||
| 
								 | 
							
								                        $videos[$keys[2]][$keys[0]] = $val;
							 | 
						|||
| 
								 | 
							
								                    } elseif ($keys[1] == 'videos') {   //视频组
							 | 
						|||
| 
								 | 
							
								                        $videoGroup[$keys[2]] = $val;
							 | 
						|||
| 
								 | 
							
								                    } elseif ($keys[1] == 'group') {    //组图
							 | 
						|||
| 
								 | 
							
								                        $groups[$keys[2]] = $val;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            $data = [];
							 | 
						|||
| 
								 | 
							
								            if (!empty($blocks)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($blocks as $key => $block) {
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $key,
							 | 
						|||
| 
								 | 
							
								                        'value' => $block
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($texts)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($texts as $key => $text) {
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $key,
							 | 
						|||
| 
								 | 
							
								                        'value' => $text
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($codes)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($codes as $key => $code) {
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $key,
							 | 
						|||
| 
								 | 
							
								                        'value' => $code
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($imgs)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($imgs as $key => $img) {
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $key,
							 | 
						|||
| 
								 | 
							
								                        'value' => $img
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($videos)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($videos as $key => $video) {
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $key,
							 | 
						|||
| 
								 | 
							
								                        'img'   => $video['img'],
							 | 
						|||
| 
								 | 
							
								                        'value' => $video['video']
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($groupIds)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($groupIds as $key => $groupId) {
							 | 
						|||
| 
								 | 
							
								                    $group  = $groups[$groupId] ?? [];
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $groupId,
							 | 
						|||
| 
								 | 
							
								                        'value' => json_encode($group)
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            if (!empty($videoGroupIds)) {
							 | 
						|||
| 
								 | 
							
								                foreach ($videoGroupIds as $key => $groupId) {
							 | 
						|||
| 
								 | 
							
								                    $group  = $videoGroup[$groupId] ?? [];
							 | 
						|||
| 
								 | 
							
								                    $data[] = [
							 | 
						|||
| 
								 | 
							
								                        'id'    => $groupId,
							 | 
						|||
| 
								 | 
							
								                        'value' => json_encode($group)
							 | 
						|||
| 
								 | 
							
								                    ];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            $block = new Block;
							 | 
						|||
| 
								 | 
							
								            $block->saveAll($data);
							 | 
						|||
| 
								 | 
							
								            Log::write('content', 'page', "单页编辑,栏目ID:{$category['id']} ,标题:{$category['title']}");
							 | 
						|||
| 
								 | 
							
								            return $this->json();
							 | 
						|||
| 
								 | 
							
								        } else {
							 | 
						|||
| 
								 | 
							
								            $categoryId = input('param.category_id');
							 | 
						|||
| 
								 | 
							
								            $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								            /*
							 | 
						|||
| 
								 | 
							
								             * 单页栏目允许父级栏目配置,不自动跳转到第一个子栏目
							 | 
						|||
| 
								 | 
							
								            $children   = Category::getChildrenByParentId($categoryId);
							 | 
						|||
| 
								 | 
							
								            if(!empty($children)){
							 | 
						|||
| 
								 | 
							
								                $child = Category::getChildrenByParentId($children[0]['id']);
							 | 
						|||
| 
								 | 
							
								                if(empty($child)){
							 | 
						|||
| 
								 | 
							
								                    $category = $children[0];
							 | 
						|||
| 
								 | 
							
								                }else{
							 | 
						|||
| 
								 | 
							
								                    $category = $child[0];
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								             */
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								                return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            $blocks                   = Block::getByCategoryId($category['id']);
							 | 
						|||
| 
								 | 
							
								            $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								            $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								            $this->data['blocks']     = $blocks;
							 | 
						|||
| 
								 | 
							
								            $this->data['groupId']    = session('auth.groupId');
							 | 
						|||
| 
								 | 
							
								            $this->data['types']      = Block::getTypes();
							 | 
						|||
| 
								 | 
							
								            return $this->view();
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 发展历程
							 | 
						|||
| 
								 | 
							
								    public function history()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = History::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 荣誉资质
							 | 
						|||
| 
								 | 
							
								    public function honour()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = Honour::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 产品
							 | 
						|||
| 
								 | 
							
								    public function product()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = ProductModel::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 下载中心
							 | 
						|||
| 
								 | 
							
								    public function download()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = DownloadModel::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 招聘职位
							 | 
						|||
| 
								 | 
							
								    public function position()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('param.category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = PositionModel::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    // 公示公告
							 | 
						|||
| 
								 | 
							
								    public function notice()
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        $categoryId = input('category_id/d', 0);
							 | 
						|||
| 
								 | 
							
								        $category   = Category::getById($categoryId);
							 | 
						|||
| 
								 | 
							
								        if (empty($category)) {
							 | 
						|||
| 
								 | 
							
								            return $this->redirect(url('manager.content/index'));
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        $this->data['categoryId'] = $categoryId;
							 | 
						|||
| 
								 | 
							
								        $this->data['category']   = $category;
							 | 
						|||
| 
								 | 
							
								        $this->data['items']      = NoticeModel::getPaginateList($categoryId, 20, false);
							 | 
						|||
| 
								 | 
							
								        return $this->view();
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |