|
@@ -110,29 +110,25 @@ class CustomTemplateLogic extends BaseLogic |
|
@@ -110,29 +110,25 @@ class CustomTemplateLogic extends BaseLogic |
|
110
|
* @method :post
|
110
|
* @method :post
|
|
111
|
* @time :2023/10/13 14:27
|
111
|
* @time :2023/10/13 14:27
|
|
112
|
*/
|
112
|
*/
|
|
113
|
- public function saveCommonTemplate($html){
|
113
|
+ public function saveCommonTemplate($param){
|
|
114
|
$type = $this->getType();
|
114
|
$type = $this->getType();
|
|
115
|
- //获取设置的默认模版
|
|
|
|
116
|
- $bSettingModel = new Setting();
|
|
|
|
117
|
- $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
118
|
- if($settingInfo === false){
|
|
|
|
119
|
- $this->fail('请先设置模版');
|
|
|
|
120
|
- }
|
|
|
|
121
|
- //查看当前
|
|
|
|
122
|
$templateCommonModel = new BTemplateCommon();
|
115
|
$templateCommonModel = new BTemplateCommon();
|
|
123
|
- $commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
124
|
- if($commonInfo === false){
|
|
|
|
125
|
- $this->fail('请先装修首页');
|
|
|
|
126
|
- }
|
116
|
+ $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
127
|
$data = [
|
117
|
$data = [
|
|
128
|
- 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
129
|
- 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
130
|
- 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
131
|
- 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
132
|
- 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
133
|
- 'type'=>$type
|
118
|
+ 'head_html'=>$param['head_html'],
|
|
|
|
119
|
+ 'head_css'=>$param['head_css'],
|
|
|
|
120
|
+ 'footer_html'=>$param['footer_html'],
|
|
|
|
121
|
+ 'footer_css'=>$param['footer_css'],
|
|
|
|
122
|
+ 'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
134
|
];
|
123
|
];
|
|
135
|
- $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
124
|
+ if($info === false){
|
|
|
|
125
|
+ $data['template_id'] = $param['template_id'];
|
|
|
|
126
|
+ $data['project_id'] = $this->user['project_id'];
|
|
|
|
127
|
+ $data['type'] = $type;
|
|
|
|
128
|
+ $templateCommonModel->add($data);
|
|
|
|
129
|
+ }else{
|
|
|
|
130
|
+ $templateCommonModel->edit($data,['id'=>$info['id']]);
|
|
|
|
131
|
+ }
|
|
136
|
return $this->success();
|
132
|
return $this->success();
|
|
137
|
}
|
133
|
}
|
|
138
|
|
134
|
|
|
@@ -249,8 +245,7 @@ class CustomTemplateLogic extends BaseLogic |
|
@@ -249,8 +245,7 @@ class CustomTemplateLogic extends BaseLogic |
|
249
|
$this->fail('请先设置模版');
|
245
|
$this->fail('请先设置模版');
|
|
250
|
}
|
246
|
}
|
|
251
|
//获取type类型
|
247
|
//获取type类型
|
|
252
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
253
|
- $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
248
|
+ $commonInfo = $this->getCommonPage($info['template_id']);
|
|
254
|
$html = '';
|
249
|
$html = '';
|
|
255
|
if($commonInfo !== false){
|
250
|
if($commonInfo !== false){
|
|
256
|
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
|
251
|
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
@@ -273,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic |
|
@@ -273,6 +268,34 @@ class CustomTemplateLogic extends BaseLogic |
|
273
|
}
|
268
|
}
|
|
274
|
|
269
|
|
|
275
|
/**
|
270
|
/**
|
|
|
|
271
|
+ * @remark :根据类型获取公共头和底
|
|
|
|
272
|
+ * @name :getCommonPage
|
|
|
|
273
|
+ * @author :lyh
|
|
|
|
274
|
+ * @method :post
|
|
|
|
275
|
+ * @time :2023/10/21 16:55
|
|
|
|
276
|
+ */
|
|
|
|
277
|
+ public function getCommonPage($template_id){
|
|
|
|
278
|
+ if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
279
|
+ //查看页面是否设置自定义头部底部
|
|
|
|
280
|
+ $pageSettingModel = new PageSetting();
|
|
|
|
281
|
+ $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
282
|
+ if ($pageInfo !== false) {
|
|
|
|
283
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
284
|
+ if ($pageInfo['page_list'] != 0) {
|
|
|
|
285
|
+ //使用独立头和底
|
|
|
|
286
|
+ $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]);
|
|
|
|
287
|
+ }
|
|
|
|
288
|
+ }
|
|
|
|
289
|
+ }
|
|
|
|
290
|
+ if(!isset($commonInfo) || $commonInfo === false){
|
|
|
|
291
|
+ //获取首页公共的头部和底部
|
|
|
|
292
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
293
|
+ $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
294
|
+ }
|
|
|
|
295
|
+ return $commonInfo;
|
|
|
|
296
|
+ }
|
|
|
|
297
|
+
|
|
|
|
298
|
+ /**
|
|
276
|
* @remark :拼接获取公共头部底部
|
299
|
* @remark :拼接获取公共头部底部
|
|
277
|
* @name :getHeadFooter
|
300
|
* @name :getHeadFooter
|
|
278
|
* @author :lyh
|
301
|
* @author :lyh
|