|
...
|
...
|
@@ -718,20 +718,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页');
|
|
|
|
}
|
|
|
|
//判断当前项目是否有设置独立头部的权限
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//有权限时,获取独立头部
|
|
|
|
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($commonTypeInfo !== false){
|
|
|
|
$commonInfo = $commonTypeInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
|
|
|
|
$commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$is_custom);
|
|
|
|
//获取设置的默认中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
...
|
...
|
@@ -749,6 +737,31 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据type获取html
|
|
|
|
* @name :getHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:06
|
|
|
|
*/
|
|
|
|
public function getTypeCommonHtml($template_id,$is_custom){
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
//判断当前项目是否有设置独立头部的权限
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM){
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//有权限时,获取独立头部
|
|
|
|
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($commonTypeInfo !== false){
|
|
|
|
$commonInfo = $commonTypeInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情模板数据
|
|
|
|
* @name :saveDetail
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -761,6 +774,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
|
|
|
|
$data = [
|
|
|
|
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
...
|
...
|
@@ -768,37 +782,53 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$data['section_list_id'] = $this->param['section_list_id'];
|
|
|
|
//保存中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $this->param['type'];
|
|
|
|
$data['is_custom'] = $is_custom;
|
|
|
|
$bTemplateMainModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情页模版头部底部
|
|
|
|
* @name :saveDetailCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:12
|
|
|
|
*/
|
|
|
|
public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){
|
|
|
|
$publicData = [
|
|
|
|
'head_html' => characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'head_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html' => characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css' => characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
'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'),
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
];
|
|
|
|
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块
|
|
|
|
$this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;
|
|
|
|
}
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
if($templateCommonInfo === false){
|
|
|
|
$publicData['type'] = $this->param['type'];
|
|
|
|
$publicData['type'] = $type;
|
|
|
|
$publicData['project_id'] = $this->user['project_id'];
|
|
|
|
$publicData['template_id'] = $bSettingInfo['template_id'];
|
|
|
|
$publicData['template_id'] = $template_id;
|
|
|
|
$templateCommonModel->add($publicData);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//更新首页头部底部
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|