|
...
|
...
|
@@ -110,29 +110,25 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($html){
|
|
|
|
public function saveCommonTemplate($param){
|
|
|
|
$type = $this->getType();
|
|
|
|
//获取设置的默认模版
|
|
|
|
$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'],'type'=>$type]);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
}
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$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")),
|
|
|
|
'type'=>$type
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
];
|
|
|
|
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['template_id'];
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $type;
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -249,8 +245,7 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
$this->fail('请先设置模版');
|
|
|
|
}
|
|
|
|
//获取type类型
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
$commonInfo = $this->getCommonPage($info['template_id']);
|
|
|
|
$html = '';
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
...
|
...
|
@@ -273,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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
|
...
|
...
|
|