作者 lyh

gx

... ... @@ -87,6 +87,7 @@ class CustomTemplateLogic extends BaseLogic
*/
public function saveHtml(){
$html = $this->param['html'];
$this->saveCommonTemplate($html);
$this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
... ... @@ -101,6 +102,38 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
*/
public function saveCommonTemplate($html){
//获取设置的默认模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先设置模版');
}
//查看当前
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]);
if($commonInfo === false){
$this->fail('请先装修首页');
}
$data = [
'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")),
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
return $this->success();
}
/**
* @remark :查看路由是否更新
* @name :editProduct
* @author :lyh
... ... @@ -187,6 +220,9 @@ class CustomTemplateLogic extends BaseLogic
//获取设置的默认模版
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先设置模版');
}
//兼容老数据
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
... ...