作者 lyh

Merge branch 'master-edit-com' of http://47.244.231.31:8099/zhl/globalso-v6

... ... @@ -278,4 +278,5 @@ class BaseController extends Controller
];
return http_post($c_url, json_encode($param));
}
}
... ...
<?php
/**
* @remark :
* @name :BProjectIsComController.php
* @name :BProjectComConfigController.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:24
... ... @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BProjectIsComLogic;
use App\Http\Logic\Bside\BTemplate\BProjectComConfigLogic;
class BProjectIsComController extends BaseController
class BProjectComConfigController extends BaseController
{
/**
* @remark :获取头部底部配置
... ... @@ -22,7 +22,7 @@ class BProjectIsComController extends BaseController
* @method :post
* @time :2024/8/1 15:08
*/
public function getIsComConfig(BProjectIsComLogic $logic){
public function getIsComConfig(BProjectComConfigLogic $logic){
$data = $logic->getIsComConfig();
$this->response('success',Code::SUCCESS,$data);
}
... ... @@ -34,7 +34,7 @@ class BProjectIsComController extends BaseController
* @method :post
* @time :2024/8/1 15:38
*/
public function saveComConfig(BProjectIsComLogic $logic){
public function saveComConfig(BProjectComConfigLogic $logic){
$this->request->validate([
'data'=>'required',
],[
... ...
... ... @@ -13,6 +13,7 @@ use App\Http\Logic\Aside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\IsCom\ProjectComConfig;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -156,6 +157,9 @@ class CustomModuleLogic extends BaseLogic
$this->fail('当前模块拥有分类不允许删除');
}
$rs = (new CustomModule())->del($this->param);
//对应删除项目头部底部配置
$projectComConfigModel = new ProjectComConfig();
$projectComConfigModel->del(['source'=>$this->param['id'],'is_custom'=>1]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
... ...
... ... @@ -7,7 +7,7 @@ use App\Models\Manage\Manage;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\Template;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
... ... @@ -210,25 +210,34 @@ class ATemplateLogic extends BaseLogic
$templateInfo = $this->model->read(['id'=>$template_id]);
ProjectServer::useProject($project_id);
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]);
$info = $bTemplateModel->read(['source'=>BTemplate::SOURCE_HOME,'template_id'=>$template_id]);
if($info === false){
$data = [
'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'source'=>BTemplate::SOURCE_HOME, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id,
];
$bTemplateModel->add($data);
}
//保存一次公共头部信息
$bCommonTemplateModel = new BTemplateCommon();
$commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]);
if($commonInfo === false){
$commonData = [
'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'],
'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'],
'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id,
'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$bCommonTemplateModel->add($commonData);
//保存一次公共头部+底部+other信息
$bComTemplateModel = new BTemplateCom();
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];
$headInfo = $bComTemplateModel->read($condition);
if($headInfo === false){
$headData = ['html'=>$templateInfo['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$headData));
}
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_FOOTER,'source'=>BTemplate::SOURCE_COM];
$footerInfo = $bComTemplateModel->read($condition);
if($footerInfo === false){
$footerData = ['html'=>$templateInfo['footer_html'], 'html_style'=>$templateInfo['footer_css'], 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$footerData));
}
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_OTHER,'source'=>BTemplate::SOURCE_COM];
$footerInfo = $bComTemplateModel->read($condition);
if($footerInfo === false){
$other = str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$otherData = ['html'=>$other, 'html_style'=>'', 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$otherData));
}
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id);
DB::disconnect('custom_mysql');
... ...
<?php
/**
* @remark :
* @name :BProjectIsComLogic.php
* @name :BProjectComConfigLogic.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:25
... ... @@ -11,17 +11,17 @@ namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\IsCom\ProjectIsCom;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Template\BTemplate;
/**
* @remark :独立头部——底部设置
* @name :BProjectIsComLogic
* @name :BProjectComConfigLogic
* @author :lyh
* @method :post
* @time :2024/8/1 14:43
*/
class BProjectIsComLogic extends BaseLogic
class BProjectComConfigLogic extends BaseLogic
{
/**
* 初始化数据
... ... @@ -29,7 +29,7 @@ class BProjectIsComLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->model = new ProjectIsCom();
$this->model = new ProjectComConfig();
$this->param = $this->requestAll;
}
... ... @@ -70,7 +70,7 @@ class BProjectIsComLogic extends BaseLogic
$is_list = [self::IS_LIST,self::IS_DETAIL];
foreach ($is_list as $isValue){
//查询当前数据是否已保存
$info = $this->model->read(['source'=>$pValue,'is_list'=>$isValue,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']);
$info = $this->model->read(['source'=>$pValue,'is_list'=>$isValue,'is_custom'=>BTemplate::IS_NO_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
... ... @@ -98,7 +98,7 @@ class BProjectIsComLogic extends BaseLogic
public function initPageParamData(&$data){
$initPageParam = $this->model->initPageParam;
foreach($initPageParam as $key => $value){
$info = $this->model->read(['source'=>$value,'is_list'=>self::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']);
$info = $this->model->read(['source'=>$value,'is_list'=>self::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
... ...
... ... @@ -10,9 +10,11 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateLog;
use App\Models\Template\Setting;
... ... @@ -64,13 +66,18 @@ class BTemplateLogLogic extends BaseLogic
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],$condition);
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
];
$type = $this->getCustomizedType($info['source'],$info['is_list']);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
$commonTemplateModel = new BTemplateCom();
//还原头部
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']];
$condition['common_type'] = BTemplate::COMMON_HEAD;
$commonTemplateModel->edit(['html'=>$info['head_html'], 'html_style'=>$info['head_css']],$condition);
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$commonTemplateModel->edit(['html'=>$info['footer_html'], 'html_style'=>$info['footer_css']],$condition);
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$condition['common_type'] = BTemplate::COMMON_OTHER;
$commonTemplateModel->edit(['html'=>$other, 'html_style'=>''],$condition);
return $this->success();
}
... ... @@ -99,18 +106,9 @@ class BTemplateLogLogic extends BaseLogic
$bTemplateModel->edit($data,$condition);
//还原头部+底部
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_style'=>$info['footer_css'],'other'=>$info['other']
];
$commonTemplateModel = new BTemplateCommon();
$type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}else{
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]);
}
$this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
... ... @@ -118,36 +116,40 @@ class BTemplateLogLogic extends BaseLogic
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
* @time :2024/4/29 10:32
*/
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;
public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}
}
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;
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
$templateComModel->edit($param,$condition);
}
}
return $type;
return $this->success();
}
/**
... ... @@ -157,26 +159,28 @@ class BTemplateLogLogic extends BaseLogic
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === false){
return $this->success($type);
}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
... ...
... ... @@ -6,12 +6,13 @@ use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\BlogCategory;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\IsCom\ProjectComConfig;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
... ... @@ -76,11 +77,11 @@ class BTemplateLogic extends BaseLogic
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
if($templateInfo === false){
if($templateInfo === false){//todo::无装修数据处理
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($html !== false){
return $this->success($html);
$data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($data !== false){
return $this->success($data);
}
}
//非定制初始中间部分
... ... @@ -91,15 +92,89 @@ class BTemplateLogic extends BaseLogic
}
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部
$html = $commonInfo['head_style'].$mainInfo['main_css'].$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
$result = ['html'=>$html,'template_id'=>$template_id];
if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
if($templateInfo !== false) {
$result['id'] = $templateInfo['id'];
$result['updated_at'] = $templateInfo['updated_at'];
}
return $this->success($result);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
$condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
$headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_OTHER;
$condition['source'] = $headComInfo['source'];
$condition['is_list'] = $headComInfo['is_list'];
$otherInfo = $bTemplateComModel->read($condition);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员222');
}
$footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
$data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
return $this->success($data);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
$commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $commonHead;
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$condition['source'] = BTemplate::SOURCE_COM;
$condition['is_list'] = BTemplate::IS_DETAIL;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员1111');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$condition['source'] = BTemplate::SOURCE_COM;
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :获取整个html代码
* @name :getCustomizeAllHtml
* @author :lyh
... ... @@ -108,11 +183,11 @@ class BTemplateLogic extends BaseLogic
*/
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM){
$commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}else{
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$type = $this->getCustomizedType($templateInfo['source'],$is_list);
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
... ... @@ -149,11 +224,12 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//扩展模块定制
//扩展模块定制列表
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
}
//扩展模块定制详情
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
return $this->success(['html'=>$html,'template_id'=>$template_id]);
... ... @@ -182,7 +258,7 @@ class BTemplateLogic extends BaseLogic
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($source,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ... @@ -262,7 +338,7 @@ class BTemplateLogic extends BaseLogic
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ... @@ -278,49 +354,25 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
}
/**
* @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;
public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
$data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
$param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
$commonTemplateModel = new BTemplateCom();
$commonList = $commonTemplateModel->list($param);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['common_type'] == BTemplate::COMMON_HEAD){
$data['head_html'] = $v['html'];
$data['head_style'] = $v['html_style'];
}elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
$data['footer_html'] = $v['html'];
$data['footer_style'] = $v['html_style'];
}else{
$data['other'] = $v['html'];
}
}
}
return $type;
return $this->success($data);
}
/**
... ... @@ -359,37 +411,9 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
}
return $this->success($commonInfo);
return $this->success($info['template_id']);
}
/**
* @remark :保存修改后的模版
* @name :templateSave
... ... @@ -417,14 +441,12 @@ class BTemplateLogic extends BaseLogic
'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
'is_list'=>$this->param['is_list']
];
$data = [
'section_list_id'=>$this->param['section_list_id']
];
$data = ['section_list_id'=>$this->param['section_list_id']];
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
$this->model->edit($data,$condition);
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
$this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
... ... @@ -454,117 +476,73 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
return $this->success($data);
}
}else{
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
return $this->success($data);
}
}else{
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//当前页面是定制界面
if(in_array($type, $page_array)){
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
return $this->success($data);
}
}
}
$mainInfo = $this->handleTemplateHtml($html);
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
$data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($data);
}
/**
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/12/13 17:05
* @time :2024/4/29 10:32
*/
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
//TODO::定制扩展模块单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);
if($code === false){
return $this->success();
}
}
//todo::其他情况
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
if($template_id == 0){//定制页面默认为独立头部
$type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在
public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
//更新所有界面的other
if($template_id != 0){
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
}
}
/**
* @remark :扩展模块定制保存头部处理
* @name :saveCustomModuleCommonHtml
* @author :lyh
* @method :post
* @time :2024/1/10 11:33
*/
public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list,
];
$templateCommonModel->add($data);
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
}
$list_is = $is_list;
($typeSource == 99) ? $list_is = 0 : $list_is;
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$list_is,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$templateComModel->edit($param,$condition);
}
return false;
}
return true;
return $this->success();
}
/**
... ... @@ -593,59 +571,46 @@ class BTemplateLogic extends BaseLogic
//字符串截取
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
return $this->success($param);
}
/**
* @remark :保存时字符串处理
* @name :handleSaveParam
* @author :lyh
* @method :post
* @time :2023/6/29 15:35
*/
public function handleTemplateHtml($html){
//字符串截取
$param['main_html'] = characterTruncationStr($html,"<main","</main>");
$param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($param);
}
/**
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @remark :获取类型
* @name :getTypes
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
* @time :2024/8/1 16:01
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === false){
return $this->success($type);
}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
/**
* @remark :生成记录
* @name :setTemplateLog
... ... @@ -946,22 +911,35 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :设置模版
* @name :setCustomTemplate
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2024/5/24 15:55
* @time :2023/11/16 11:20
*/
public function setCustomTemplate(){
$templateModel = new Template();
$templateInfo = $templateModel->read(['id'=>$this->param['template_id']],['id','main_html','main_css']);
if($templateInfo === false){
$this->fail('未获取到模版数据');
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(empty($templateInfo['main_html']) || empty($templateInfo['main_css'])){
$this->fail('当前模版替换数据错误');
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
$this->model->edit(['html'=>$templateInfo['main_html'],'html_style'=>$templateInfo['main_css']],['id'=>$this->param['id']]);
return $this->success();
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
}
... ...
... ... @@ -3,11 +3,12 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateLog;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
... ... @@ -50,13 +51,81 @@ class CustomTemplateLogic extends BaseLogic
$this->fail('当前数据不存在');
}
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
$html = $this->getBodyHeaderFooter($info['html'],$info['html_style']);
$html = $this->getTemplateComHtml($info['html'],$info['html_style']);
$info['html'] = $this->getHeadFooter($html);
}
return $this->success($info);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($html,$html_style){
$headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]);
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_OTHER;
$condition['source'] = $headComInfo['source'];
$otherInfo = $bTemplateComModel->read($condition);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员');
}
$footerComInfo = $this->getFooterComHtml();
$commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
$html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html'];
return $this->success($html);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition){
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $this->getType();
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$condition['source'] = BTemplate::SOURCE_COM;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml(){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType(BTemplate::COMMON_FOOTER);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$condition['source'] = BTemplate::SOURCE_COM;
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :保存自定义界面
* @name :customTemplateSave
* @author :lyh
... ... @@ -126,11 +195,13 @@ class CustomTemplateLogic extends BaseLogic
if($bSettingInfo === false){
$this->fail('请先选择模版');
}
$handleInfo = $this->handleResultParam($html);
if(!isset($this->param['template_status'])){//代表直接替换模版 不更新头部底部
$this->saveCommonTemplate($html,$bSettingInfo['template_id']);
$this->saveTemplateCom($handleInfo,$bSettingInfo['template_id']);
}
$this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$this->param['html'] = $handleInfo['main_html'];
$this->param['html_style'] = $handleInfo['main_style'];
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]);
if($rs === false){
... ... @@ -151,6 +222,7 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/8/23 11:16
*/
public function setTemplateLog($template_id,$html,$source_id){
$handleInfo = $this->handleResultParam($html);
$data = [
'template_id'=>$template_id,
'project_id'=>$this->user['project_id'],
... ... @@ -158,71 +230,109 @@ class CustomTemplateLogic extends BaseLogic
'text'=>$html,
'source'=>9,
'source_id'=>$source_id,
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'head_html'=>$handleInfo['head_html'],
'head_css'=>$handleInfo['head_style'],
'footer_html'=>$handleInfo['footer_html'],
'footer_css'=>$handleInfo['footer_style'],
'main_html' => $handleInfo['main_html'],
'main_css' => $handleInfo['main_style'],
'other'=>$handleInfo['other']
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @remark :截取数据返回
* @name :handleResultParam
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
* @time :2024/5/6 14:14
*/
public function saveCommonTemplate($html,$template_id){
$type = $this->getType();
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
public function handleResultParam($html){
$handleInfo = [
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'head_style'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'footer_style'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncationStr($html,"<main","</main>"),
'main_style' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
if($info === false){
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
$handleInfo['other'] = $other;
return $this->success($handleInfo);
}
/**
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2024/4/29 10:32
*/
public function saveTemplateCom($handleInfo,$template_id){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($type);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($type);
}else{
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$type == BTemplate::COMMON_HEAD;
$typeSource = $this->getType($type);
}
//查看当前数据是否还存在
$condition = ['template_id'=>$template_id,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$rs = $templateComModel->add($data);
}else{
$rs = $templateComModel->edit($param,$condition);
}
if($rs === false){
$this->fail('保存错误,请联系管理员');
}
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
/**
* @remark :获取设置的类型
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType(){
$type = 1;//首页公共头部底部
public function getType($commonType = BTemplate::COMMON_HEAD){
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_head == BTemplate::IS_NO_HEADER){
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
if ($pageInfo['page_list'] != 0) {
$type = 9;
}
}
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>9,'is_list'=>0,'is_custom'=>0]);
if ($configInfo === false) {
return $this->success($type);
}
return $type;
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : 9);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : 9);
}
return $this->success($type);
}
/**
... ... @@ -290,59 +400,6 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :获取body的详情
* @name :getBodyHeaderFooter
* @author :lyh
* @method :post
* @time :2023/7/21 18:08
*/
public function getBodyHeaderFooter($preg_html,$html_style){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html_style = "<style id='globalsojs-styles'></style>";
}
//获取设置的默认模版
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先设置模版');
}
//获取type类型
$commonInfo = $this->getCommonPage($info['template_id']);
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
return $this->success($html);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonPage($template_id){
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//查看页面是否设置自定义头部底部
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
$commonTemplateModel = new BTemplateCommon();
if ($pageInfo['page_list'] != 0) {
//使用独立头和底
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]);
}
}
}
if(!isset($commonInfo) || $commonInfo === false){
//获取首页公共的头部和底部
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
}
return $commonInfo;
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ... @@ -423,27 +480,37 @@ class CustomTemplateLogic extends BaseLogic
* @name :copyCustomTemplateInfo
* @author :lyh
* @method :post
* @time :2024/5/24 14:47
* @time :2024/4/28 16:16
*/
public function copyCustomTemplateInfo(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在');
}
$param = [
'name'=>$info['name'].'-copy',
'status'=>$info['status'],
'url'=>$info['url'].'-copy',
'html'=>$info['html'],
'html_style'=>$info['html_style'],
'project_id'=>$info['project_id'],
'is_visualization'=>$info['is_visualization'],
'six_read'=>$info['six_read'],
'is_upgrade'=>$info['is_upgrade'],
$param = $this->setCustomTemplateParams($info);
$save_id = $this->model->insertGetId($param);
$route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$save_id]);
return $this->success(['id'=>$save_id]);
}
/**
* @remark :组装数据
* @name :setCustomTemplateParams
* @author :lyh
* @method :post
* @time :2024/4/28 16:18
*/
public function setCustomTemplateParams($info)
{
return [
'name' => $info['name'] . '-copy',
'status' => $info['status'],
'url' => $info['url'],
'html' => $info['html'],
'html_style' => $info['html_style'],
'project_id' => $info['project_id'],
'section_list_id' => $info['section_list_id'],
'is_visualization' => $info['is_visualization'],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
];
$id = $this->model->addReturnId($param);
$route = RouteMap::setRoute($param['url'],RouteMap::SOURCE_PAGE,$id,$param['project_id']);
$this->model->edit(['url'=>$route],['id'=>$id]);
return $this->success(['id'=>$id]);
}
}
... ...
... ... @@ -10,11 +10,12 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\TemplateTypeMain;
... ... @@ -51,14 +52,83 @@ class InitHtmlLogic extends BaseLogic
$data['id'] = $mainInfo['id'];
$data['updated_at'] = $mainInfo['updated_at'];
}
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$commonInfo = $this->getTemplateComHtml($this->param['type'],$is_list,$is_custom,$template_id); //获取头部
$html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
$data['html'] = $html;
return $this->success($data);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
$condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
$headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_OTHER;
$condition['source'] = $headComInfo['source'];
$otherInfo = $bTemplateComModel->read($condition);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员');
}
$footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
$data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
return $this->success($data);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
$commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $commonHead;
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$condition['source'] = BTemplate::SOURCE_COM;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$condition['source'] = BTemplate::SOURCE_COM;
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ... @@ -116,96 +186,82 @@ class InitHtmlLogic extends BaseLogic
];
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
}
$this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
$this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
return $this->success();
}
/**
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/12/13 17:05
* @time :2024/4/29 10:32
*/
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
//更新所有界面的other
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
}
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$templateComModel->edit($param,$condition);
}
}
return $this->success($commonInfo);
return $this->success();
}
/**
* @remark :保存时获取获取设置的类型
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
return $this->success($type);
}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === false){
return $this->success($type);
}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
/**
* @remark :保存时字符串处理
* @name :handleCommonParam
... ... @@ -217,8 +273,8 @@ class InitHtmlLogic extends BaseLogic
//字符串截取
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
return $this->success($param);
... ... @@ -271,24 +327,42 @@ class InitHtmlLogic extends BaseLogic
if($info === false){
$html = '';
}else{
//扩展模块获取头部
if($is_custom == BTemplate::IS_CUSTOM){
$type = $this->param['type'];
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
$html = $info['main_html'];
$commonInfo = $this->getCustomizeTemplateComHtml($this->param['type'],$is_custom,$is_list);
$html = $this->handleAllHtml($commonInfo,$info['main_html']);
}
//更新头部底部
return $this->success(['html'=>$html]);
}
/**
* @remark :定制获取头部底部
* @name :getCustomizedCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
$data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
$param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
$commonTemplateModel = new BTemplateCom();
$commonList = $commonTemplateModel->list($param);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['common_type'] == BTemplate::COMMON_HEAD){
$data['head_html'] = $v['html'];
$data['head_style'] = $v['html_style'];
}elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
$data['footer_html'] = $v['html'];
$data['footer_style'] = $v['html_style'];
}else{
$data['other'] = $v['html'];
}
}
}
return $this->success($data);
}
/**
* @remark :返回整个html截取代码
* @name :handleAllHtml
* @author :lyh
... ... @@ -331,7 +405,7 @@ class InitHtmlLogic extends BaseLogic
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom);
$this->saveTemplateCom($this->param['html'],0,$this->param['type'],$is_list,$is_custom);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -339,73 +413,6 @@ class InitHtmlLogic extends BaseLogic
}
/**
* @remark :定制代码更新头部信息
* @name :saveCustomizeCommon
* @author :lyh
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list,$is_custom){
if($is_custom == BTemplate::IS_CUSTOM){
$type = $source;
}else{
$type = $this->getCustomizedType($source,$is_list);
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
return $this->success();
}
/**
* @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;
}
/**
* @remark :前端获取设置模块(侧边栏)
* @name :getInitModuleMain
* @author :lyh
... ...
<?php
/**
* @remark :
* @name :ProjectIsCom.php
* @name :ProjectComConfig.php
* @author :lyh
* @method :post
* @time :2024/8/1 11:50
... ... @@ -16,14 +16,16 @@ use App\Models\Template\Template;
/**
* @remark :是否为独立头部+底部
* @name :ProjectIsCom
* @name :ProjectComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 11:51
*/
class ProjectIsCom extends Base
class ProjectComConfig extends Base
{
protected $table = 'gl_project_com_config';
//连接数据库
protected $connection = 'custom_mysql';
/**
* @name :(包含详情页+列表页)
... ...
... ... @@ -24,7 +24,7 @@ class BTemplate extends Base
const SOURCE_NEWS = 4;//新闻详情页
const SOURCE_KEYWORD = 5;//聚合页
const SOURCE_PAGE = 6;//单页面
const SOURCE_PAGE = 9;//单页面
const SOURCE_CUSTOM = 7;//自定义模块
/**
... ...
... ... @@ -556,8 +556,8 @@ Route::middleware(['bloginauth'])->group(function () {
});
//设置公共头部+底部配置
Route::prefix('com_config')->group(function () {
Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectIsComController::class, 'getIsComConfig'])->name('com_config_getIsComConfig');
Route::any('/saveComConfig', [\App\Http\Controllers\Bside\Template\BProjectIsComController::class, 'saveComConfig'])->name('com_config_getIsComConfig');
Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'getIsComConfig'])->name('com_config_getIsComConfig');
Route::any('/saveComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'saveComConfig'])->name('com_config_getIsComConfig');
});
});
... ...