49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			49 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								namespace app\controller;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use app\model\Category;
							 | 
						||
| 
								 | 
							
								use app\model\Link;
							 | 
						||
| 
								 | 
							
								use app\model\System;
							 | 
						||
| 
								 | 
							
								use app\repository\BlockRepository;
							 | 
						||
| 
								 | 
							
								use app\repository\CmsRepository;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * 控制器基础类
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								class Base extends BaseController
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    //需要向模板传递的值
							 | 
						||
| 
								 | 
							
								    protected $data = [];
							 | 
						||
| 
								 | 
							
								    //系统配置信息
							 | 
						||
| 
								 | 
							
								    protected $system = [];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    protected $auth = [];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    protected $authId = 0;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    protected $aboutCategory = [];
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    // 初始化
							 | 
						||
| 
								 | 
							
								    protected function initialize()
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $this->auth                = session('frontend_auth') ?? [];
							 | 
						||
| 
								 | 
							
								        $this->data['auth']        = $this->auth;
							 | 
						||
| 
								 | 
							
								        $this->authId              = $this->auth['id'] ?? 0;
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //设置SEO信息
							 | 
						||
| 
								 | 
							
								    protected function setSeo($title = '', $keywords = '', $description = '')
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $this->data['seoTitle']       = $title ?: $this->system['seo_title'] ?? '';
							 | 
						||
| 
								 | 
							
								        $this->data['seoKeywords']    = $keywords ?: $this->system['seo_keywords'] ?? '';
							 | 
						||
| 
								 | 
							
								        $this->data['seoDescription'] = $description ?: $this->system['seo_description'] ?? '';
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								    //模板
							 | 
						||
| 
								 | 
							
								    protected function view($template = '')
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        return view($template)->assign($this->data);
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |