|
@@ -15,6 +15,7 @@ use App\Models\Project\PageSetting; |
|
@@ -15,6 +15,7 @@ use App\Models\Project\PageSetting; |
|
15
|
use App\Models\Project\Project;
|
15
|
use App\Models\Project\Project;
|
|
16
|
use App\Models\RouteMap\RouteMap;
|
16
|
use App\Models\RouteMap\RouteMap;
|
|
17
|
use App\Models\Service\Service as ServiceSettingModel;
|
17
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
18
|
+use App\Models\Template\BTemplateCom;
|
|
18
|
use App\Models\Template\BTemplateCommon;
|
19
|
use App\Models\Template\BTemplateCommon;
|
|
19
|
use App\Models\Template\BTemplateMain;
|
20
|
use App\Models\Template\BTemplateMain;
|
|
20
|
use App\Models\Template\Setting;
|
21
|
use App\Models\Template\Setting;
|
|
@@ -68,11 +69,11 @@ class BTemplateLogic extends BaseLogic |
|
@@ -68,11 +69,11 @@ class BTemplateLogic extends BaseLogic |
|
68
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
69
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
|
69
|
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
|
70
|
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
|
|
70
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
71
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
|
71
|
- if($templateInfo === false){
|
72
|
+ if($templateInfo === false){//todo::无装修数据处理
|
|
72
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
73
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
73
|
- $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
74
|
- if($html !== false){
|
|
|
|
75
|
- return $this->success($html);
|
74
|
+ $data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
75
|
+ if($data !== false){
|
|
|
|
76
|
+ return $this->success($data);
|
|
76
|
}
|
77
|
}
|
|
77
|
}
|
78
|
}
|
|
78
|
//非定制初始中间部分
|
79
|
//非定制初始中间部分
|
|
@@ -83,11 +84,14 @@ class BTemplateLogic extends BaseLogic |
|
@@ -83,11 +84,14 @@ class BTemplateLogic extends BaseLogic |
|
83
|
}
|
84
|
}
|
|
84
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
85
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
85
|
}
|
86
|
}
|
|
86
|
- $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
87
|
+ $commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部
|
|
87
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
88
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
88
|
$html = $this->getHeadFooter($html);
|
89
|
$html = $this->getHeadFooter($html);
|
|
89
|
$result = ['html'=>$html,'template_id'=>$template_id];
|
90
|
$result = ['html'=>$html,'template_id'=>$template_id];
|
|
90
|
- if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
|
91
|
+ if($templateInfo !== false) {
|
|
|
|
92
|
+ $result['id'] = $templateInfo['id'];
|
|
|
|
93
|
+ $result['updated_at'] = $templateInfo['updated_at'];
|
|
|
|
94
|
+ }
|
|
91
|
return $this->success($result);
|
95
|
return $this->success($result);
|
|
92
|
}
|
96
|
}
|
|
93
|
|
97
|
|
|
@@ -100,11 +104,11 @@ class BTemplateLogic extends BaseLogic |
|
@@ -100,11 +104,11 @@ class BTemplateLogic extends BaseLogic |
|
100
|
*/
|
104
|
*/
|
|
101
|
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
|
105
|
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
|
|
102
|
if($is_custom == BTemplate::IS_CUSTOM){
|
106
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
103
|
- $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
|
107
|
+ $commonInfo = $this->getTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部
|
|
104
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
108
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
105
|
}else{
|
109
|
}else{
|
|
106
|
- $type = $this->getCustomizedType($this->param['source'],$is_list);
|
|
|
|
107
|
- $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
110
|
+ $type = $this->getCustomizedType($templateInfo['source'],$is_list);
|
|
|
|
111
|
+ $commonInfo = $this->getTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
|
|
108
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
112
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
109
|
}
|
113
|
}
|
|
110
|
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
114
|
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
|
@@ -174,7 +178,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -174,7 +178,7 @@ class BTemplateLogic extends BaseLogic |
|
174
|
if($customHtmlInfo === false){
|
178
|
if($customHtmlInfo === false){
|
|
175
|
$this->fail('定制页面,请先上传代码块');
|
179
|
$this->fail('定制页面,请先上传代码块');
|
|
176
|
}
|
180
|
}
|
|
177
|
- $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
|
181
|
+ $commonInfo = $this->getTemplateComHtml($source,$is_custom,$is_list);//获取定制头部
|
|
178
|
if($commonInfo !== false){
|
182
|
if($commonInfo !== false){
|
|
179
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
183
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
180
|
}
|
184
|
}
|
|
@@ -254,7 +258,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -254,7 +258,7 @@ class BTemplateLogic extends BaseLogic |
|
254
|
if($customHtmlInfo === false){
|
258
|
if($customHtmlInfo === false){
|
|
255
|
$this->fail('定制页面,请先上传代码块');
|
259
|
$this->fail('定制页面,请先上传代码块');
|
|
256
|
}
|
260
|
}
|
|
257
|
- $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
261
|
+ $commonInfo = $this->getTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
|
|
258
|
if($commonInfo !== false){
|
262
|
if($commonInfo !== false){
|
|
259
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
263
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
260
|
}
|
264
|
}
|
|
@@ -263,6 +267,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -263,6 +267,7 @@ class BTemplateLogic extends BaseLogic |
|
263
|
return false;
|
267
|
return false;
|
|
264
|
}
|
268
|
}
|
|
265
|
|
269
|
|
|
|
|
270
|
+
|
|
266
|
/**
|
271
|
/**
|
|
267
|
* @remark :定制项目获取头部底部
|
272
|
* @remark :定制项目获取头部底部
|
|
268
|
* @name :getCustomizedCommonHtml
|
273
|
* @name :getCustomizedCommonHtml
|
|
@@ -270,49 +275,25 @@ class BTemplateLogic extends BaseLogic |
|
@@ -270,49 +275,25 @@ class BTemplateLogic extends BaseLogic |
|
270
|
* @method :post
|
275
|
* @method :post
|
|
271
|
* @time :2023/12/29 13:13
|
276
|
* @time :2023/12/29 13:13
|
|
272
|
*/
|
277
|
*/
|
|
273
|
- public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
|
|
|
|
274
|
- $data = [
|
|
|
|
275
|
- 'template_id' => 0,
|
|
|
|
276
|
- 'project_id' => $this->user['project_id'],
|
|
|
|
277
|
- 'type'=>$type,
|
|
|
|
278
|
- 'is_custom'=>$is_custom,
|
|
|
|
279
|
- 'is_list'=>$is_list
|
|
|
|
280
|
- ];
|
|
|
|
281
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
282
|
- return $commonTemplateModel->read($data);
|
|
|
|
283
|
- }
|
|
|
|
284
|
-
|
|
|
|
285
|
- /**
|
|
|
|
286
|
- * @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
287
|
- * @name :getType
|
|
|
|
288
|
- * @author :lyh
|
|
|
|
289
|
- * @method :post
|
|
|
|
290
|
- * @time :2023/11/16 11:20
|
|
|
|
291
|
- */
|
|
|
|
292
|
- public function getCustomizedType($source,$is_list){
|
|
|
|
293
|
- $type = BTemplate::TYPE_HOME;
|
|
|
|
294
|
- if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
295
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
296
|
- $type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
297
|
- }else{
|
|
|
|
298
|
- $type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
299
|
- }
|
|
|
|
300
|
- }
|
|
|
|
301
|
- if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
302
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
303
|
- $type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
304
|
- }else{
|
|
|
|
305
|
- $type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
306
|
- }
|
|
|
|
307
|
- }
|
|
|
|
308
|
- if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
309
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
310
|
- $type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
311
|
- }else{
|
|
|
|
312
|
- $type = BTemplate::TYPE_NEWS_DETAIL;
|
278
|
+ public function getTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
|
|
|
|
279
|
+ $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
|
|
|
|
280
|
+ $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
|
|
|
|
281
|
+ $commonTemplateModel = new BTemplateCom();
|
|
|
|
282
|
+ $commonList = $commonTemplateModel->list($param);
|
|
|
|
283
|
+ if(!empty($commonList)){
|
|
|
|
284
|
+ foreach ($commonList as $v){
|
|
|
|
285
|
+ if($v['common_type'] == BTemplate::COMMON_HEAD){
|
|
|
|
286
|
+ $data['head_html'] = $v['html'];
|
|
|
|
287
|
+ $data['head_style'] = $v['html_style'];
|
|
|
|
288
|
+ }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
|
|
|
|
289
|
+ $data['footer_html'] = $v['html'];
|
|
|
|
290
|
+ $data['footer_style'] = $v['html_style'];
|
|
|
|
291
|
+ }else{
|
|
|
|
292
|
+ $data['other'] = $v['html'];
|
|
|
|
293
|
+ }
|
|
313
|
}
|
294
|
}
|
|
314
|
}
|
295
|
}
|
|
315
|
- return $type;
|
296
|
+ return $this->success($data);
|
|
316
|
}
|
297
|
}
|
|
317
|
|
298
|
|
|
318
|
/**
|
299
|
/**
|
|
@@ -351,37 +332,9 @@ class BTemplateLogic extends BaseLogic |
|
@@ -351,37 +332,9 @@ class BTemplateLogic extends BaseLogic |
|
351
|
if($info === false){
|
332
|
if($info === false){
|
|
352
|
$this->fail('请先选择模版');
|
333
|
$this->fail('请先选择模版');
|
|
353
|
}
|
334
|
}
|
|
354
|
- $template_id = $info['template_id'];
|
|
|
|
355
|
- return $this->success($template_id);
|
|
|
|
356
|
- }
|
|
|
|
357
|
-
|
|
|
|
358
|
- /**
|
|
|
|
359
|
- * @remark :根据类型获取公共头和底
|
|
|
|
360
|
- * @name :getCommonPage
|
|
|
|
361
|
- * @author :lyh
|
|
|
|
362
|
- * @method :post
|
|
|
|
363
|
- * @time :2023/10/21 16:55
|
|
|
|
364
|
- */
|
|
|
|
365
|
- public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
|
|
|
|
366
|
- $type = $this->getType($source,$is_list,$is_custom);
|
|
|
|
367
|
- $data = [
|
|
|
|
368
|
- 'template_id' => $template_id,
|
|
|
|
369
|
- 'project_id' => $this->user['project_id'],
|
|
|
|
370
|
- 'type'=>$type,
|
|
|
|
371
|
- 'is_custom'=>0,
|
|
|
|
372
|
- ];
|
|
|
|
373
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
374
|
- $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
375
|
- if($commonInfo === false){
|
|
|
|
376
|
- $data['type'] = BTemplate::SOURCE_HOME;
|
|
|
|
377
|
- $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
378
|
- }
|
|
|
|
379
|
- return $this->success($commonInfo);
|
335
|
+ return $this->success($info['template_id']);
|
|
380
|
}
|
336
|
}
|
|
381
|
|
337
|
|
|
382
|
-
|
|
|
|
383
|
-
|
|
|
|
384
|
-
|
|
|
|
385
|
/**
|
338
|
/**
|
|
386
|
* @remark :保存修改后的模版
|
339
|
* @remark :保存修改后的模版
|
|
387
|
* @name :templateSave
|
340
|
* @name :templateSave
|
|
@@ -409,14 +362,12 @@ class BTemplateLogic extends BaseLogic |
|
@@ -409,14 +362,12 @@ class BTemplateLogic extends BaseLogic |
|
409
|
'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
|
362
|
'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
|
|
410
|
'is_list'=>$this->param['is_list']
|
363
|
'is_list'=>$this->param['is_list']
|
|
411
|
];
|
364
|
];
|
|
412
|
- $data = [
|
|
|
|
413
|
- 'section_list_id'=>$this->param['section_list_id']
|
|
|
|
414
|
- ];
|
365
|
+ $data = ['section_list_id'=>$this->param['section_list_id']];
|
|
415
|
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
|
366
|
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
|
|
416
|
$this->model->edit($data,$condition);
|
367
|
$this->model->edit($data,$condition);
|
|
417
|
}
|
368
|
}
|
|
418
|
//更新头部信息
|
369
|
//更新头部信息
|
|
419
|
- $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
|
370
|
+ $this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']);
|
|
420
|
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
|
371
|
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
421
|
//通知更新
|
372
|
//通知更新
|
|
422
|
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
|
373
|
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
@@ -446,119 +397,69 @@ class BTemplateLogic extends BaseLogic |
|
@@ -446,119 +397,69 @@ class BTemplateLogic extends BaseLogic |
|
446
|
* @time :2023/12/15 10:59
|
397
|
* @time :2023/12/15 10:59
|
|
447
|
*/
|
398
|
*/
|
|
448
|
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
|
399
|
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
|
|
449
|
- if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
|
400
|
+ //TODO::扩展模块定制单独处理
|
|
|
|
401
|
+ if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
402
|
+ $customModuleModel = new CustomModule();
|
|
|
|
403
|
+ $info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
404
|
+ if($info === false){
|
|
|
|
405
|
+ $this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
406
|
+ }
|
|
|
|
407
|
+ //todo::扩展模块(列表页/详情页)定制
|
|
|
|
408
|
+ if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
409
|
+ $data['html'] = $html;
|
|
|
|
410
|
+ $data['type'] = BTemplate::ALL_HTML;
|
|
|
|
411
|
+ return $this->success($data);
|
|
|
|
412
|
+ }
|
|
|
|
413
|
+ }
|
|
|
|
414
|
+ if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){
|
|
450
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
415
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
451
|
- //查看当前页面是否定制,是否开启可视化
|
|
|
|
452
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
416
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
453
|
- if (in_array($type, $page_array)) {//当前页面是定制界面
|
417
|
+ if(in_array($type, $page_array)){
|
|
454
|
$data['html'] = $html;
|
418
|
$data['html'] = $html;
|
|
455
|
$data['type'] = BTemplate::ALL_HTML;
|
419
|
$data['type'] = BTemplate::ALL_HTML;
|
|
456
|
- }else{
|
|
|
|
457
|
- //TODO::扩展模块定制单独处理
|
|
|
|
458
|
- if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
459
|
- $customModuleModel = new CustomModule();
|
|
|
|
460
|
- $info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
461
|
- if($info === false){
|
|
|
|
462
|
- $this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
463
|
- }
|
|
|
|
464
|
- //todo::扩展模块(列表页/详情页)定制
|
|
|
|
465
|
- if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
466
|
- $data['html'] = $html;
|
|
|
|
467
|
- $data['type'] = BTemplate::ALL_HTML;
|
|
|
|
468
|
- }
|
|
|
|
469
|
- }
|
|
|
|
470
|
- $mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
471
|
- $data['main_html'] = $mainInfo['main_html'];
|
|
|
|
472
|
- $data['main_css'] = $mainInfo['main_css'];
|
420
|
+ return $this->success($data);
|
|
473
|
}
|
421
|
}
|
|
474
|
- }else{
|
|
|
|
475
|
- $mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
476
|
- $data['main_html'] = $mainInfo['main_html'];
|
|
|
|
477
|
- $data['main_css'] = $mainInfo['main_css'];
|
|
|
|
478
|
}
|
422
|
}
|
|
479
|
- return $data;
|
423
|
+ $data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
424
|
+ $data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
425
|
+ return $this->success($data);
|
|
480
|
}
|
426
|
}
|
|
481
|
|
427
|
|
|
482
|
/**
|
428
|
/**
|
|
483
|
- * @remark :保存公共头部底部
|
|
|
|
484
|
- * @name :saveCommonHtml
|
429
|
+ * @remark :保存公共部分(头部。底部。连接部分)
|
|
|
|
430
|
+ * @name :saveTemplateCom
|
|
485
|
* @author :lyh
|
431
|
* @author :lyh
|
|
486
|
* @method :post
|
432
|
* @method :post
|
|
487
|
- * @time :2023/12/13 17:05
|
433
|
+ * @time :2024/4/29 10:32
|
|
488
|
*/
|
434
|
*/
|
|
489
|
- public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
|
|
|
|
490
|
- //TODO::定制扩展模块单独处理
|
|
|
|
491
|
- if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
492
|
- $code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);
|
|
|
|
493
|
- if($code === false){
|
|
|
|
494
|
- return $this->success();
|
|
|
|
495
|
- }
|
|
|
|
496
|
- }
|
|
|
|
497
|
- //其他情况
|
|
|
|
498
|
- $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
499
|
- if($template_id == 0){//定制页面默认为独立头部
|
|
|
|
500
|
- $type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
|
|
|
|
501
|
- }
|
|
|
|
502
|
- $templateCommonModel = new BTemplateCommon();
|
|
|
|
503
|
- $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在
|
435
|
+ public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
|
|
|
|
436
|
+ $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
|
|
504
|
$handleInfo = $this->handleCommonParam($html);
|
437
|
$handleInfo = $this->handleCommonParam($html);
|
|
505
|
- if($commonInfo === false){
|
|
|
|
506
|
- $data = [
|
|
|
|
507
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
508
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
509
|
- 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
510
|
- ];
|
|
|
|
511
|
- $templateCommonModel->add($data);
|
|
|
|
512
|
- }else{
|
|
|
|
513
|
- $data = [
|
|
|
|
514
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
515
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
516
|
- ];
|
|
|
|
517
|
- $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
518
|
- }
|
|
|
|
519
|
- //更新所有界面的other
|
|
|
|
520
|
- if($template_id != 0){
|
|
|
|
521
|
- return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
522
|
- }
|
|
|
|
523
|
- }
|
|
|
|
524
|
-
|
|
|
|
525
|
- /**
|
|
|
|
526
|
- * @remark :扩展模块定制保存头部处理
|
|
|
|
527
|
- * @name :saveCustomModuleCommonHtml
|
|
|
|
528
|
- * @author :lyh
|
|
|
|
529
|
- * @method :post
|
|
|
|
530
|
- * @time :2024/1/10 11:33
|
|
|
|
531
|
- */
|
|
|
|
532
|
- public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){
|
|
|
|
533
|
- $customModuleModel = new CustomModule();
|
|
|
|
534
|
- $info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
535
|
- if($info === false){
|
|
|
|
536
|
- $this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
537
|
- }
|
|
|
|
538
|
- //todo::扩展模块(列表页/详情页)定制
|
|
|
|
539
|
- if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
540
|
- $data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];
|
|
|
|
541
|
- $templateCommonModel = new BTemplateCommon();
|
|
|
|
542
|
- $commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在
|
|
|
|
543
|
- $handleInfo = $this->handleCommonParam($html);
|
|
|
|
544
|
- if($commonInfo === false){
|
|
|
|
545
|
- $data = [
|
|
|
|
546
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
547
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
548
|
- 'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
549
|
- 'is_custom'=>$is_custom,'is_list'=>$is_list,
|
|
|
|
550
|
- ];
|
|
|
|
551
|
- $templateCommonModel->add($data);
|
438
|
+ $templateComModel = new BTemplateCom();
|
|
|
|
439
|
+ foreach ($typeArr as $type){
|
|
|
|
440
|
+ if($type == BTemplate::COMMON_HEAD){
|
|
|
|
441
|
+ $param['html'] = $handleInfo['head_html'];
|
|
|
|
442
|
+ $param['html_style'] = $handleInfo['head_style'];
|
|
|
|
443
|
+ $typeSource = $this->getType($source,$is_list,$is_custom,$type);//头部是否为独立头部
|
|
|
|
444
|
+ }elseif ($type == BTemplate::COMMON_FOOTER){
|
|
|
|
445
|
+ $param['html'] = $handleInfo['footer_html'];
|
|
|
|
446
|
+ $param['html_style'] = $handleInfo['footer_style'];
|
|
|
|
447
|
+ $typeSource = $this->getType($source,$is_list,$is_custom,$type);
|
|
552
|
}else{
|
448
|
}else{
|
|
553
|
- $data = [
|
|
|
|
554
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
555
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
556
|
- ];
|
|
|
|
557
|
- $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
449
|
+ $param['html'] = $handleInfo['other'];
|
|
|
|
450
|
+ $typeSource = $this->getType($source,$is_list,$is_custom);
|
|
|
|
451
|
+ }
|
|
|
|
452
|
+ //查看当前数据是否还存在
|
|
|
|
453
|
+ $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
|
|
|
|
454
|
+ $info = $templateComModel->read($condition);
|
|
|
|
455
|
+ if($info === false){
|
|
|
|
456
|
+ $param = array_merge($param,$condition);
|
|
|
|
457
|
+ $this->model->add($param);
|
|
|
|
458
|
+ }else{
|
|
|
|
459
|
+ $this->model->edit($param,$condition);
|
|
558
|
}
|
460
|
}
|
|
559
|
- return false;
|
|
|
|
560
|
}
|
461
|
}
|
|
561
|
- return true;
|
462
|
+ return $this->success();
|
|
562
|
}
|
463
|
}
|
|
563
|
|
464
|
|
|
564
|
/**
|
465
|
/**
|
|
@@ -595,47 +496,31 @@ class BTemplateLogic extends BaseLogic |
|
@@ -595,47 +496,31 @@ class BTemplateLogic extends BaseLogic |
|
595
|
}
|
496
|
}
|
|
596
|
|
497
|
|
|
597
|
/**
|
498
|
/**
|
|
598
|
- * @remark :保存时字符串处理
|
|
|
|
599
|
- * @name :handleSaveParam
|
|
|
|
600
|
- * @author :lyh
|
|
|
|
601
|
- * @method :post
|
|
|
|
602
|
- * @time :2023/6/29 15:35
|
|
|
|
603
|
- */
|
|
|
|
604
|
- public function handleTemplateHtml($html){
|
|
|
|
605
|
- //字符串截取
|
|
|
|
606
|
- $param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
607
|
- $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
608
|
- return $this->success($param);
|
|
|
|
609
|
- }
|
|
|
|
610
|
-
|
|
|
|
611
|
- /**
|
|
|
|
612
|
* @remark :(非定制)保存时获取获取设置的类型
|
499
|
* @remark :(非定制)保存时获取获取设置的类型
|
|
613
|
* @name :getType
|
500
|
* @name :getType
|
|
614
|
* @author :lyh
|
501
|
* @author :lyh
|
|
615
|
* @method :post
|
502
|
* @method :post
|
|
616
|
* @time :2023/10/21 17:29
|
503
|
* @time :2023/10/21 17:29
|
|
617
|
*/
|
504
|
*/
|
|
618
|
- public function getType($source,$is_list,$is_custom = 0){
|
505
|
+ public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD){
|
|
619
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
506
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
620
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
507
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
621
|
- if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
508
|
+ if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
|
|
622
|
return $this->success($type);
|
509
|
return $this->success($type);
|
|
623
|
}
|
510
|
}
|
|
624
|
//查看页面是否设置自定义头部底部
|
511
|
//查看页面是否设置自定义头部底部
|
|
625
|
- if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
626
|
- $pageSettingModel = new PageSetting();
|
|
|
|
627
|
- $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
628
|
- if ($pageInfo === false) {
|
|
|
|
629
|
- return $this->success($type);
|
|
|
|
630
|
- }
|
|
|
|
631
|
- if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
632
|
- else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
633
|
- if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
634
|
- else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
635
|
- if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
636
|
- else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
637
|
- if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
512
|
+ $pageSettingModel = new PageSetting();
|
|
|
|
513
|
+ $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
|
|
|
|
514
|
+ if ($pageInfo === false) {
|
|
|
|
515
|
+ return $this->success($type);
|
|
638
|
}
|
516
|
}
|
|
|
|
517
|
+ if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
|
|
|
|
518
|
+ else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
|
|
|
|
519
|
+ if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
|
|
|
|
520
|
+ else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
|
|
|
|
521
|
+ if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
|
|
|
|
522
|
+ else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
|
|
|
|
523
|
+ if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
639
|
return $this->success($type);
|
524
|
return $this->success($type);
|
|
640
|
}
|
525
|
}
|
|
641
|
|
526
|
|
|
@@ -956,4 +841,37 @@ class BTemplateLogic extends BaseLogic |
|
@@ -956,4 +841,37 @@ class BTemplateLogic extends BaseLogic |
|
956
|
}
|
841
|
}
|
|
957
|
return $this->success();
|
842
|
return $this->success();
|
|
958
|
}
|
843
|
}
|
|
|
|
844
|
+
|
|
|
|
845
|
+ /**
|
|
|
|
846
|
+ * @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
847
|
+ * @name :getType
|
|
|
|
848
|
+ * @author :lyh
|
|
|
|
849
|
+ * @method :post
|
|
|
|
850
|
+ * @time :2023/11/16 11:20
|
|
|
|
851
|
+ */
|
|
|
|
852
|
+ public function getCustomizedType($source,$is_list){
|
|
|
|
853
|
+ $type = BTemplate::TYPE_HOME;
|
|
|
|
854
|
+ if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
855
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
856
|
+ $type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
857
|
+ }else{
|
|
|
|
858
|
+ $type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
859
|
+ }
|
|
|
|
860
|
+ }
|
|
|
|
861
|
+ if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
862
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
863
|
+ $type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
864
|
+ }else{
|
|
|
|
865
|
+ $type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
866
|
+ }
|
|
|
|
867
|
+ }
|
|
|
|
868
|
+ if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
869
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
870
|
+ $type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
871
|
+ }else{
|
|
|
|
872
|
+ $type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
873
|
+ }
|
|
|
|
874
|
+ }
|
|
|
|
875
|
+ return $type;
|
|
|
|
876
|
+ }
|
|
959
|
} |
877
|
} |