UpdateHtml.php 5.1 KB
<?php
/**
 * @remark :
 * @name   :UpdateHtml.php
 * @author :lyh
 * @method :post
 * @time   :2024/2/2 10:11
 */

namespace App\Http\Controllers\Html;

use App\Http\Controllers\Controller;
use App\Models\Com\NoticeLog;
use App\Models\CustomModule\CustomModule;
use App\Models\Project\Project;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;

class UpdateHtml extends Controller
{
    protected $param;
    protected $project_id;
    public function __construct($data){
        $this->param = $data;//Todo::传递的参数
        $this->project_id = $data['project_id'];
    }

    /**
     * @remark :更新界面
     * @name   :updateHtml
     * @author :lyh
     * @method :post
     * @time   :2024/2/2 10:12
     */
    public function updateHtml(){
        ProjectServer::useProject($this->project_id);
        if(isset($this->param['route']) && $this->param['route'] == 'all'){
            //TODO::更新所有界面
        }else{
            //TODO::更新单页
            $routeMapModel = new RouteMap();
        }
        DB::disconnect('custom_mysql');
    }

    /**
     * @remark :获取页面是否为 定制/非定制 页面
     * @name   :getPageHtmlIsCustomized
     * @param  :source:类型;is_list:是否为列表页 1:列表页面
     * @author :lyh
     * @method :post
     * @time   :2024/2/2 11:03
     */
    public function getPageHtmlIsCustomized($source,$is_list,$is_custom){
        if($is_custom == BTemplate::IS_CUSTOM){
            $customModuleModel = new CustomModule();
            $info = $customModuleModel->read(['id'=>$source]);
            if($info === false){
                $this->fail('当前扩展模块不存在或已被删除');
            }
            //扩展模块定制
            if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
                return BTemplate::IS_VISUALIZATION;
            }
            if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
                return BTemplate::IS_VISUALIZATION;
            }
        }else{
            $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
            //查看当前页面是否定制,是否开启可视化
            $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
            if (in_array($type, $page_array)) {//是定制界面
                return BTemplate::IS_VISUALIZATION;
            }
        }
        return BTemplate::IS_NO_VISUALIZATION;
    }

    /**
     * @remark :获取头部底部公共部分代码
     * @name   :getTemplateCommon
     * @author :lyh
     * @method :post
     * @time   :2024/2/2 11:02
     */
    public function getTemplateCommon(){

    }

    /**
     * @remark :获取装修中间内容
     * @name   :getTemplateMainHtml
     * @author :lyh
     * @method :post
     * @time   :2024/2/2 11:01
     */
    public function getTemplateMainHtml(){

    }

    /**
     * @remark :获取项目详情
     * @name   :getProjectInfo
     * @author :lyh
     * @method :post
     * @time   :2024/2/2 10:50
     */
    public function getProjectInfo($project_id){
        $projectModel = new Project();
        $info = $projectModel->read(['id'=>$project_id],['id','is_customized']);
        return $info;
    }

    /**
     * @remark :拼接获取公共头部底部
     * @name   :getHeadFooter
     * @author :lyh
     * @method :post
     * @time   :2023/7/21 17:22
     */
    public function getHeadFooter($html){
        //获取公共主题头部底部
        $serviceSettingModel = new ServiceSettingModel();
        $list = $serviceSettingModel->list(['type'=>2],'created_at');
        //拼接html
        foreach ($list as $v){
            if($v['key'] == 'head'){
                $html = $v['values'].$html;
            }
            if($v['key'] == 'footer'){
                $html = $html.$v['values'];
            }
        }
        return $html;
    }

    /**
     * @remark :定制页面头部类型---根据source获取type类型
     * @name   :getType
     * @author :lyh
     * @method :post
     * @time   :2023/11/16 11:20
     */
    public function getCustomizedType($source,$is_list){
        $type = BTemplate::TYPE_HOME;
        if($source == BTemplate::SOURCE_PRODUCT){
            if($is_list == BTemplate::IS_LIST){
                $type = BTemplate::TYPE_PRODUCT_LIST;
            }else{
                $type = BTemplate::TYPE_PRODUCT_DETAIL;
            }
        }
        if($source == BTemplate::SOURCE_BLOG){
            if($is_list == BTemplate::IS_LIST){
                $type = BTemplate::TYPE_BLOG_LIST;
            }else{
                $type = BTemplate::TYPE_BLOG_DETAIL;
            }
        }
        if($source == BTemplate::SOURCE_NEWS){
            if($is_list == BTemplate::IS_LIST){
                $type = BTemplate::TYPE_NEWS_LIST;
            }else{
                $type = BTemplate::TYPE_NEWS_DETAIL;
            }
        }
        return $type;
    }
}