|
@@ -57,21 +57,6 @@ class BTemplateLogic extends BaseLogic |
|
@@ -57,21 +57,6 @@ class BTemplateLogic extends BaseLogic |
|
57
|
}
|
57
|
}
|
|
58
|
|
58
|
|
|
59
|
/**
|
59
|
/**
|
|
60
|
- * @remark :获取当前选择使用的模板
|
|
|
|
61
|
- * @name :getModuleTemplate
|
|
|
|
62
|
- * @author :lyh
|
|
|
|
63
|
- * @method :post
|
|
|
|
64
|
- * @time :2023/6/29 9:44
|
|
|
|
65
|
- */
|
|
|
|
66
|
- public function getTemplate(){
|
|
|
|
67
|
- $template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id
|
|
|
|
68
|
- $is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
|
|
|
69
|
- $is_list = $this->param['is_list'] ?? 0;//是否为
|
|
|
|
70
|
- $data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$is_custom);
|
|
|
|
71
|
- return $this->success($data);
|
|
|
|
72
|
- }
|
|
|
|
73
|
-
|
|
|
|
74
|
- /**
|
|
|
|
75
|
* @remark :获取可视化html
|
60
|
* @remark :获取可视化html
|
|
76
|
* @name :getTemplateHtml
|
61
|
* @name :getTemplateHtml
|
|
77
|
* @author :lyh
|
62
|
* @author :lyh
|
|
@@ -79,20 +64,41 @@ class BTemplateLogic extends BaseLogic |
|
@@ -79,20 +64,41 @@ class BTemplateLogic extends BaseLogic |
|
79
|
* @time :2023/12/27 14:48
|
64
|
* @time :2023/12/27 14:48
|
|
80
|
*/
|
65
|
*/
|
|
81
|
public function getTemplateHtml(){
|
66
|
public function getTemplateHtml(){
|
|
82
|
- $template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id
|
|
|
|
83
|
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
67
|
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
|
84
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
68
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
|
85
|
- $templateInfo = $this->model->read(['template_id'=>$template_id, 'source'=>$this->param['source'],'project_id'=>$this->user['project_id'],
|
|
|
|
86
|
- 'source_id'=>$this->param['source_id'], 'is_custom'=>$is_custom, 'is_list'=>$is_list]);
|
69
|
+ $template_id = $this->getSettingTemplate($this->param['source'],$is_list);//设置的模版id
|
|
|
|
70
|
+ $templateInfo = $this->model->read([
|
|
|
|
71
|
+ 'template_id'=>$template_id, 'source'=>$this->param['source'],
|
|
|
|
72
|
+ 'project_id'=>$this->user['project_id'], 'source_id'=>$this->param['source_id'],
|
|
|
|
73
|
+ 'is_custom'=>$is_custom, 'is_list'=>$is_list
|
|
|
|
74
|
+ ]);
|
|
87
|
if($templateInfo === false){
|
75
|
if($templateInfo === false){
|
|
88
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
76
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
89
|
- $html = $this->isCustomizedPage($this->param['source'],$this->param['source_id']);//查看当前页面是否定制
|
77
|
+ $html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
|
|
90
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
78
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
91
|
}
|
79
|
}
|
|
92
|
- $mainInfo = $this->getMAinHtml($this->param['source'],$this->param['source_id'],$is_custom);//获取中间部分代码
|
80
|
+ $mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
|
|
|
|
81
|
+ }else{
|
|
|
|
82
|
+ if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
|
|
|
|
83
|
+ $type = $this->getHeaderType($this->param['source'], $is_list);//获取头部底部类型
|
|
|
|
84
|
+ $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
|
|
|
|
85
|
+ $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
86
|
+ return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
|
93
|
}
|
87
|
}
|
|
94
|
- $data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$is_custom);
|
|
|
|
95
|
- return $this->success($data);
|
88
|
+ $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
89
|
+ }
|
|
|
|
90
|
+ $type = $this->getHeaderType($this->param['source'], $is_list);//获取头部底部类型
|
|
|
|
91
|
+ $commonInfo = $this->getCommonHtml($type,$is_list,$template_id);//获取定制头部
|
|
|
|
92
|
+ $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
93
|
+ $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
94
|
+ $html = $this->getHeadFooter($html);
|
|
|
|
95
|
+ $result = ['html'=>$html,'template_id'=>$template_id];
|
|
|
|
96
|
+ if($templateInfo !== false)
|
|
|
|
97
|
+ {
|
|
|
|
98
|
+ $result['id'] = $templateInfo['id'];
|
|
|
|
99
|
+ $result['updated_at'] = $templateInfo['updated_at'];
|
|
|
|
100
|
+ }
|
|
|
|
101
|
+ return $this->success($result);
|
|
96
|
}
|
102
|
}
|
|
97
|
|
103
|
|
|
98
|
/**
|
104
|
/**
|
|
@@ -102,50 +108,34 @@ class BTemplateLogic extends BaseLogic |
|
@@ -102,50 +108,34 @@ class BTemplateLogic extends BaseLogic |
|
102
|
* @method :post
|
108
|
* @method :post
|
|
103
|
* @time :2023/12/27 15:00
|
109
|
* @time :2023/12/27 15:00
|
|
104
|
*/
|
110
|
*/
|
|
105
|
- public function getMAinHtml($source,$source_id,$is_custom,$is_list){
|
|
|
|
106
|
- //查询有没有公共详情模板
|
111
|
+ public function getMAinHtml($type,$is_custom,$is_list){
|
|
|
|
112
|
+ //获取设置的默认中间部分
|
|
107
|
$bTemplateMainModel = new BTemplateMain();
|
113
|
$bTemplateMainModel = new BTemplateMain();
|
|
108
|
- $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
|
114
|
+ $mainInfo = $bTemplateMainModel->read(['type'=>$type,'is_list'=>$is_list,'is_custom'=>$is_custom]);
|
|
109
|
if($mainInfo === false){
|
115
|
if($mainInfo === false){
|
|
110
|
- $data['main_html'] = $this->getModule($type);
|
|
|
|
111
|
- $data['main_css'] = "<style id='globalsojs-styles'></style>";
|
116
|
+ $main_html = $this->getInitModule($type,$is_custom,$is_list);
|
|
|
|
117
|
+ $main_css = "<style id='globalsojs-styles'></style>";
|
|
112
|
}else{
|
118
|
}else{
|
|
113
|
- $data['main_html'] = $mainInfo['main_html'];
|
|
|
|
114
|
- $data['main_css'] = $mainInfo['main_css'];
|
119
|
+ $main_html = $mainInfo['main_html'];
|
|
|
|
120
|
+ $main_css = $mainInfo['main_css'];
|
|
115
|
}
|
121
|
}
|
|
|
|
122
|
+ return ['main_html'=>$main_html,'main_css'=>$main_css];
|
|
116
|
}
|
123
|
}
|
|
117
|
|
124
|
|
|
118
|
/**
|
125
|
/**
|
|
119
|
- * @remark :获取可视化装修的html
|
|
|
|
120
|
- * @name :getTemplateHtml
|
126
|
+ * @remark :默认复合页数据
|
|
|
|
127
|
+ * @name :getProductModule
|
|
121
|
* @author :lyh
|
128
|
* @author :lyh
|
|
122
|
* @method :post
|
129
|
* @method :post
|
|
123
|
- * @time :2023/12/13 10:47
|
130
|
+ * @time :2023/7/27 15:08
|
|
124
|
*/
|
131
|
*/
|
|
125
|
- public function getHtml($template_id,$source,$source_id,$is_custom){
|
|
|
|
126
|
- $templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom);
|
|
|
|
127
|
- if($templateInfo === false){
|
|
|
|
128
|
- if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
129
|
- $html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制
|
|
|
|
130
|
- return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
132
|
+ public function getInitModule($type,$is_custom,$is_list){
|
|
|
|
133
|
+ if($is_custom == BTemplate::SOURCE_CUSTOM) {
|
|
|
|
134
|
+ $type = BTemplate::TYPE_CUSTOM;
|
|
131
|
}
|
135
|
}
|
|
132
|
- $mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码
|
|
|
|
133
|
- }else{
|
|
|
|
134
|
- if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
|
|
|
|
135
|
- $type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型
|
|
|
|
136
|
- $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部
|
|
|
|
137
|
- $html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
138
|
- return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
|
|
|
139
|
- }
|
|
|
|
140
|
- $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
141
|
- }
|
|
|
|
142
|
- $commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部
|
|
|
|
143
|
- $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
144
|
- $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
145
|
- $html = $this->getHeadFooter($html);
|
|
|
|
146
|
- $result = ['html'=>$html,'template_id'=>$template_id];
|
|
|
|
147
|
- if($templateInfo !== false){$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
|
|
|
|
148
|
- return $this->success($result);
|
136
|
+ $mainModel = new TemplateTypeMain();
|
|
|
|
137
|
+ $info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
|
|
|
|
138
|
+ return $info['main_html'];
|
|
149
|
}
|
139
|
}
|
|
150
|
|
140
|
|
|
151
|
/**
|
141
|
/**
|
|
@@ -172,19 +162,19 @@ class BTemplateLogic extends BaseLogic |
|
@@ -172,19 +162,19 @@ class BTemplateLogic extends BaseLogic |
|
172
|
* @method :post
|
162
|
* @method :post
|
|
173
|
* @time :2023/12/13 10:55
|
163
|
* @time :2023/12/13 10:55
|
|
174
|
*/
|
164
|
*/
|
|
175
|
- public function isCustomizedPage($source,$source_id)
|
165
|
+ public function isCustomizedPage($source,$is_list)
|
|
176
|
{
|
166
|
{
|
|
177
|
- $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
167
|
+ $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
178
|
//查看当前页面是否定制,是否开启可视化
|
168
|
//查看当前页面是否定制,是否开启可视化
|
|
179
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
169
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
180
|
if (in_array($type, $page_array)) {//是定制界面
|
170
|
if (in_array($type, $page_array)) {//是定制界面
|
|
181
|
//TODO::获取初始代码
|
171
|
//TODO::获取初始代码
|
|
182
|
$bTemplateMainModel = new BTemplateMain();
|
172
|
$bTemplateMainModel = new BTemplateMain();
|
|
183
|
- $customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]);
|
173
|
+ $customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list]);
|
|
184
|
if($customHtmlInfo === false){
|
174
|
if($customHtmlInfo === false){
|
|
185
|
$this->fail('定制页面,请先上传代码块');
|
175
|
$this->fail('定制页面,请先上传代码块');
|
|
186
|
}
|
176
|
}
|
|
187
|
- $commonInfo = $this->getCommonPage($type,$this->user['project_id'],0);//获取定制头部
|
177
|
+ $commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
|
|
188
|
if($commonInfo !== false){
|
178
|
if($commonInfo !== false){
|
|
189
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
179
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
190
|
}
|
180
|
}
|
|
@@ -194,22 +184,70 @@ class BTemplateLogic extends BaseLogic |
|
@@ -194,22 +184,70 @@ class BTemplateLogic extends BaseLogic |
|
194
|
}
|
184
|
}
|
|
195
|
|
185
|
|
|
196
|
/**
|
186
|
/**
|
|
197
|
- * @remark :定制界面根据source+source_id获取type类型
|
187
|
+ * @remark :独立头部获取头部底部类型
|
|
|
|
188
|
+ * @name :getHeaderType
|
|
|
|
189
|
+ * @author :lyh
|
|
|
|
190
|
+ * @method :post
|
|
|
|
191
|
+ * @time :2023/12/27 11:36
|
|
|
|
192
|
+ */
|
|
|
|
193
|
+ public function getHeaderType($type,$is_list){
|
|
|
|
194
|
+ $resultType = BTemplate::SOURCE_HOME;
|
|
|
|
195
|
+ if($type == BTemplate::SOURCE_PRODUCT){
|
|
|
|
196
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
197
|
+ $resultType = BTemplate::TYPE_THREE;
|
|
|
|
198
|
+ }else{
|
|
|
|
199
|
+ $resultType = BTemplate::TYPE_TWO;
|
|
|
|
200
|
+ }
|
|
|
|
201
|
+ }
|
|
|
|
202
|
+ if($type == BTemplate::SOURCE_BLOG){
|
|
|
|
203
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
204
|
+ $resultType = BTemplate::TYPE_FIVE;
|
|
|
|
205
|
+ }else{
|
|
|
|
206
|
+ $resultType = BTemplate::TYPE_FOUR;
|
|
|
|
207
|
+ }
|
|
|
|
208
|
+ }
|
|
|
|
209
|
+ if($type == BTemplate::SOURCE_NEWS){
|
|
|
|
210
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
211
|
+ $resultType = BTemplate::TYPE_SEVEN;
|
|
|
|
212
|
+ }else{
|
|
|
|
213
|
+ $resultType = BTemplate::TYPE_SIX;
|
|
|
|
214
|
+ }
|
|
|
|
215
|
+ }
|
|
|
|
216
|
+ if($type == BTemplate::SOURCE_KEYWORD){
|
|
|
|
217
|
+ $resultType = BTemplate::TYPE_EIGHT;
|
|
|
|
218
|
+ }
|
|
|
|
219
|
+ return $this->success($resultType);
|
|
|
|
220
|
+ }
|
|
|
|
221
|
+
|
|
|
|
222
|
+ /**
|
|
|
|
223
|
+ * @remark :定制界面根据source获取type类型
|
|
198
|
* @name :getType
|
224
|
* @name :getType
|
|
199
|
* @author :lyh
|
225
|
* @author :lyh
|
|
200
|
* @method :post
|
226
|
* @method :post
|
|
201
|
* @time :2023/11/16 11:20
|
227
|
* @time :2023/11/16 11:20
|
|
202
|
*/
|
228
|
*/
|
|
203
|
- public function getCustomizedType($source,$source_id){
|
229
|
+ public function getCustomizedType($source,$is_list){
|
|
204
|
$type = BTemplate::TYPE_ONE;
|
230
|
$type = BTemplate::TYPE_ONE;
|
|
205
|
if($source == BTemplate::SOURCE_PRODUCT){
|
231
|
if($source == BTemplate::SOURCE_PRODUCT){
|
|
206
|
- if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
|
232
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
233
|
+ $type = BTemplate::TYPE_THREE;
|
|
|
|
234
|
+ }else{
|
|
|
|
235
|
+ $type = BTemplate::TYPE_TWO;
|
|
|
|
236
|
+ }
|
|
207
|
}
|
237
|
}
|
|
208
|
if($source == BTemplate::SOURCE_BLOG){
|
238
|
if($source == BTemplate::SOURCE_BLOG){
|
|
209
|
- if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
|
239
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
240
|
+ $type = BTemplate::TYPE_FIVE;
|
|
|
|
241
|
+ }else{
|
|
|
|
242
|
+ $type = BTemplate::TYPE_FOUR;
|
|
|
|
243
|
+ }
|
|
210
|
}
|
244
|
}
|
|
211
|
if($source == BTemplate::SOURCE_NEWS){
|
245
|
if($source == BTemplate::SOURCE_NEWS){
|
|
212
|
- if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
|
246
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
247
|
+ $type = BTemplate::TYPE_SEVEN;
|
|
|
|
248
|
+ }else{
|
|
|
|
249
|
+ $type = BTemplate::TYPE_SIX;
|
|
|
|
250
|
+ }
|
|
213
|
}
|
251
|
}
|
|
214
|
return $type;
|
252
|
return $type;
|
|
215
|
}
|
253
|
}
|
|
@@ -221,13 +259,14 @@ class BTemplateLogic extends BaseLogic |
|
@@ -221,13 +259,14 @@ class BTemplateLogic extends BaseLogic |
|
221
|
* @method :post
|
259
|
* @method :post
|
|
222
|
* @time :2023/12/13 10:48
|
260
|
* @time :2023/12/13 10:48
|
|
223
|
*/
|
261
|
*/
|
|
224
|
- public function getSettingTemplate($source,$source_id){
|
262
|
+ public function getSettingTemplate($source,$is_list){
|
|
|
|
263
|
+ $template_id = 0;
|
|
225
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
|
264
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
|
|
226
|
- $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
265
|
+ $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
227
|
//查看当前页面是否定制,是否开启可视化
|
266
|
//查看当前页面是否定制,是否开启可视化
|
|
228
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
267
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
229
|
if (in_array($type, $page_array)) {//是定制界面
|
268
|
if (in_array($type, $page_array)) {//是定制界面
|
|
230
|
- return $this->success(0);
|
269
|
+ return $this->success($template_id);
|
|
231
|
}
|
270
|
}
|
|
232
|
}
|
271
|
}
|
|
233
|
$bSettingModel = new Setting();
|
272
|
$bSettingModel = new Setting();
|
|
@@ -235,188 +274,234 @@ class BTemplateLogic extends BaseLogic |
|
@@ -235,188 +274,234 @@ class BTemplateLogic extends BaseLogic |
|
235
|
if($info === false){
|
274
|
if($info === false){
|
|
236
|
$this->fail('请先选择模版');
|
275
|
$this->fail('请先选择模版');
|
|
237
|
}
|
276
|
}
|
|
238
|
- return $this->success($info['template_id']);
|
277
|
+ $template_id = $info['template_id'];
|
|
|
|
278
|
+ return $this->success($template_id);
|
|
239
|
}
|
279
|
}
|
|
240
|
|
280
|
|
|
241
|
/**
|
281
|
/**
|
|
242
|
- * @remark :根据参数获取数据详情
|
|
|
|
243
|
- * @name :webTemplateInfo
|
282
|
+ * @remark :根据类型获取公共头和底
|
|
|
|
283
|
+ * @name :getCommonPage
|
|
244
|
* @author :lyh
|
284
|
* @author :lyh
|
|
245
|
* @method :post
|
285
|
* @method :post
|
|
246
|
- * @time :2023/7/25 16:41
|
286
|
+ * @time :2023/10/21 16:55
|
|
247
|
*/
|
287
|
*/
|
|
248
|
- public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){
|
|
|
|
249
|
- //查看当前模板是否已编辑保存web_template
|
|
|
|
250
|
- $TemplateInfo = $this->model->read([
|
|
|
|
251
|
- 'template_id'=>$template_id,
|
|
|
|
252
|
- 'source'=>$source,
|
|
|
|
253
|
- 'project_id'=>$this->user['project_id'],
|
|
|
|
254
|
- 'source_id'=>$source_id,
|
|
|
|
255
|
- 'is_custom'=>$is_custom
|
|
|
|
256
|
- ]);
|
|
|
|
257
|
- return $this->success($TemplateInfo);
|
288
|
+ public function getCommonHtml($source,$is_list,$template_id){
|
|
|
|
289
|
+ $is_head = $this->user['configuration']['is_head'] ?? 0;
|
|
|
|
290
|
+ $data = [
|
|
|
|
291
|
+ 'template_id' => $template_id,
|
|
|
|
292
|
+ 'project_id' => $this->user['project_id']
|
|
|
|
293
|
+ ];
|
|
|
|
294
|
+ if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
295
|
+ //查看页面是否设置自定义头部底部
|
|
|
|
296
|
+ $pageSettingModel = new PageSetting();
|
|
|
|
297
|
+ $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
298
|
+ if($pageInfo !== false){
|
|
|
|
299
|
+ $commonInfo = [];
|
|
|
|
300
|
+ if ($source == BTemplate::SOURCE_BLOG) {//产品页
|
|
|
|
301
|
+ $commonInfo = $this->getProductCommonHtml($data,$is_list,$pageInfo);
|
|
|
|
302
|
+ }
|
|
|
|
303
|
+ if ($source == BTemplate::SOURCE_BLOG) {//博客页
|
|
|
|
304
|
+ $commonInfo = $this->getBlogCommonHtml($data,$is_list,$pageInfo);
|
|
|
|
305
|
+ }
|
|
|
|
306
|
+ if ($source == BTemplate::SOURCE_NEWS) {//新闻页
|
|
|
|
307
|
+ $commonInfo = $this->getNewsCommonHtml($data,$is_list,$pageInfo);
|
|
|
|
308
|
+ }
|
|
|
|
309
|
+ if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
|
|
|
|
310
|
+ $commonInfo = $this->getKeywordCommonHtml($data,$pageInfo);
|
|
|
|
311
|
+ }
|
|
|
|
312
|
+ if(!empty($commonInfo)){
|
|
|
|
313
|
+ return $this->success($commonInfo);
|
|
|
|
314
|
+ }
|
|
|
|
315
|
+ }
|
|
|
|
316
|
+ }
|
|
|
|
317
|
+ //获取首页公共的头部和底部
|
|
|
|
318
|
+ $commonInfo = $this->getHomeCommonHtml($data);
|
|
|
|
319
|
+ return $commonInfo;
|
|
258
|
}
|
320
|
}
|
|
259
|
|
321
|
|
|
260
|
/**
|
322
|
/**
|
|
261
|
- * @remark :获取中间公共部分
|
|
|
|
262
|
- * @name :getCommonMain
|
323
|
+ * @remark :获取首页头部底部
|
|
|
|
324
|
+ * @name :getHomeCommonHtml
|
|
263
|
* @author :lyh
|
325
|
* @author :lyh
|
|
264
|
* @method :post
|
326
|
* @method :post
|
|
265
|
- * @time :2023/10/24 15:58
|
327
|
+ * @time :2023/12/27 16:11
|
|
266
|
*/
|
328
|
*/
|
|
267
|
- public function getCommonMain($source,$source_id,$is_custom){
|
|
|
|
268
|
- $data = [];
|
|
|
|
269
|
- if($is_custom == BTemplate::SOURCE_CUSTOM){
|
|
|
|
270
|
- if($source_id != 0){$type = BTemplate::TYPE_CUSTOM;}else{$type = BTemplate::TYPE_CUSTOM_LIST;}
|
|
|
|
271
|
- }else{
|
|
|
|
272
|
- if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}
|
|
|
|
273
|
- if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}
|
|
|
|
274
|
- if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}
|
|
|
|
275
|
- if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;}
|
329
|
+ public function getHomeCommonHtml($data){
|
|
|
|
330
|
+ $data['type'] = BTemplate::SOURCE_HOME;
|
|
|
|
331
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
332
|
+ return $commonTemplateModel->read($data);
|
|
276
|
}
|
333
|
}
|
|
277
|
- //查询有没有公共详情模板
|
|
|
|
278
|
- $bTemplateMainModel = new BTemplateMain();
|
|
|
|
279
|
- $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
280
|
- if($mainInfo === false){
|
|
|
|
281
|
- $data['main_html'] = $this->getModule($type);
|
|
|
|
282
|
- $data['main_css'] = "<style id='globalsojs-styles'></style>";
|
|
|
|
283
|
- }else{
|
|
|
|
284
|
- $data['main_html'] = $mainInfo['main_html'];
|
|
|
|
285
|
- $data['main_css'] = $mainInfo['main_css'];
|
334
|
+
|
|
|
|
335
|
+ /**
|
|
|
|
336
|
+ * @remark :聚合页
|
|
|
|
337
|
+ * @name :getKeywordCommonHtml
|
|
|
|
338
|
+ * @author :lyh
|
|
|
|
339
|
+ * @method :post
|
|
|
|
340
|
+ * @time :2023/12/27 16:09
|
|
|
|
341
|
+ */
|
|
|
|
342
|
+ public function getKeywordCommonHtml($data,$pageInfo){
|
|
|
|
343
|
+ $commonInfo = [];
|
|
|
|
344
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
345
|
+ $data['type'] = BTemplate::TYPE_EIGHT;
|
|
|
|
346
|
+ if ($pageInfo['polymerization'] != 0) {
|
|
|
|
347
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
348
|
+ if($commonInfo === false){
|
|
|
|
349
|
+ $commonInfo = [];
|
|
286
|
}
|
350
|
}
|
|
287
|
- return $data;
|
351
|
+ }
|
|
|
|
352
|
+ return $this->success($commonInfo);
|
|
288
|
}
|
353
|
}
|
|
289
|
|
354
|
|
|
290
|
/**
|
355
|
/**
|
|
291
|
- * @remark :根据类型获取公共头和底
|
|
|
|
292
|
- * @name :getCommonPage
|
356
|
+ * @remark :产品头部底部
|
|
|
|
357
|
+ * @name :getProductCommonHtml
|
|
293
|
* @author :lyh
|
358
|
* @author :lyh
|
|
294
|
* @method :post
|
359
|
* @method :post
|
|
295
|
- * @time :2023/10/21 16:55
|
360
|
+ * @time :2023/12/27 16:01
|
|
296
|
*/
|
361
|
*/
|
|
297
|
- public function getCommonPage($source,$source_id,$template_id){
|
|
|
|
298
|
- if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
299
|
- //查看页面是否设置自定义头部底部
|
|
|
|
300
|
- $pageSettingModel = new PageSetting();
|
|
|
|
301
|
- $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
302
|
- if ($pageInfo != false) {
|
362
|
+ public function getProductCommonHtml($data,$is_list,$pageInfo){
|
|
|
|
363
|
+ $commonInfo = [];
|
|
303
|
$commonTemplateModel = new BTemplateCommon();
|
364
|
$commonTemplateModel = new BTemplateCommon();
|
|
304
|
- $data = [
|
|
|
|
305
|
- 'template_id' => $template_id,
|
|
|
|
306
|
- 'project_id' => $this->user['project_id']
|
|
|
|
307
|
- ];
|
|
|
|
308
|
- if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
|
|
|
|
309
|
- if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
310
|
- else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
311
|
- if ($source == BTemplate::SOURCE_BLOG) {//博客页
|
|
|
|
312
|
- if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
313
|
- else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
314
|
- if ($source == BTemplate::SOURCE_NEWS) {//新闻页
|
|
|
|
315
|
- if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
316
|
- else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
317
|
- if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
|
|
|
|
318
|
- $data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
365
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
366
|
+ $data['type'] = BTemplate::TYPE_THREE;
|
|
|
|
367
|
+ if ($pageInfo['product_list'] != 0) {
|
|
|
|
368
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
369
|
+ if($commonInfo === false){
|
|
|
|
370
|
+ $commonInfo = [];
|
|
319
|
}
|
371
|
}
|
|
320
|
}
|
372
|
}
|
|
321
|
- //获取首页公共的头部和底部
|
|
|
|
322
|
- if(!isset($commonInfo) || $commonInfo === false){
|
|
|
|
323
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
324
|
- $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]);
|
373
|
+ } else {
|
|
|
|
374
|
+ $data['type'] = BTemplate::TYPE_TWO;
|
|
|
|
375
|
+ if ($pageInfo['product_details'] != 0) {
|
|
|
|
376
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
377
|
+ if($commonInfo === false){
|
|
|
|
378
|
+ $commonInfo = [];
|
|
|
|
379
|
+ }
|
|
325
|
}
|
380
|
}
|
|
326
|
- return $commonInfo;
|
381
|
+ }
|
|
|
|
382
|
+ return $this->success($commonInfo);
|
|
327
|
}
|
383
|
}
|
|
328
|
|
384
|
|
|
329
|
/**
|
385
|
/**
|
|
330
|
- * @remark :保存修改后的模版
|
|
|
|
331
|
- * @name :templateSave
|
386
|
+ * @remark :博客头部
|
|
|
|
387
|
+ * @name :getBlogCommonHtml
|
|
332
|
* @author :lyh
|
388
|
* @author :lyh
|
|
333
|
* @method :post
|
389
|
* @method :post
|
|
334
|
- * @time :2023/6/29 11:05
|
390
|
+ * @time :2023/12/27 16:05
|
|
335
|
*/
|
391
|
*/
|
|
336
|
- public function templateSave(){
|
|
|
|
337
|
- //演示项目不允许修改
|
|
|
|
338
|
- $this->showProjectNoEdit($this->param['source']);
|
|
|
|
339
|
- DB::beginTransaction();
|
|
|
|
340
|
- try {
|
|
|
|
341
|
- $this->param = $this->handleDefaultString($this->param);//设置默认字符
|
|
|
|
342
|
- $templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],
|
|
|
|
343
|
- $this->param['source_id'],$this->param['is_custom']);
|
|
|
|
344
|
- if($templateInfo === false){//执行新增
|
|
|
|
345
|
- $this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'],
|
|
|
|
346
|
- $this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']);
|
|
|
|
347
|
- }else{//执行编辑
|
|
|
|
348
|
- $this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'],
|
|
|
|
349
|
- $this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']);
|
392
|
+ public function getBlogCommonHtml($data,$is_list,$pageInfo){
|
|
|
|
393
|
+ $commonInfo = [];
|
|
|
|
394
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
395
|
+ if ($is_list == BTemplate::IS_LIST) {
|
|
|
|
396
|
+ $data['type'] = BTemplate::TYPE_SEVEN;
|
|
|
|
397
|
+ if ($pageInfo['blog_list'] != 0) {
|
|
|
|
398
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
399
|
+ if($commonInfo === false){
|
|
|
|
400
|
+ $commonInfo = [];
|
|
350
|
}
|
401
|
}
|
|
351
|
- //更新头部信息
|
|
|
|
352
|
- $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
|
|
|
353
|
- $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
|
|
|
|
354
|
- DB::commit();
|
|
|
|
355
|
- }catch (\Exception $e){
|
|
|
|
356
|
- DB::rollBack();
|
|
|
|
357
|
- $this->fail('系统错误,请联系管理员');
|
|
|
|
358
|
}
|
402
|
}
|
|
359
|
- //通知更新
|
|
|
|
360
|
- $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']);
|
|
|
|
361
|
- return $this->success();
|
403
|
+ } else {
|
|
|
|
404
|
+ $data['type'] = BTemplate::TYPE_SIX;
|
|
|
|
405
|
+ if ($pageInfo['blog_details'] != 0) {
|
|
|
|
406
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
407
|
+ if($commonInfo === false){
|
|
|
|
408
|
+ $commonInfo = [];
|
|
|
|
409
|
+ }
|
|
|
|
410
|
+ }
|
|
|
|
411
|
+ }
|
|
|
|
412
|
+ return $this->success($commonInfo);
|
|
362
|
}
|
413
|
}
|
|
363
|
|
414
|
|
|
364
|
/**
|
415
|
/**
|
|
365
|
- * @remark :保存数据时设置默认字符
|
|
|
|
366
|
- * @name :saveDefaultString
|
416
|
+ * @remark :新闻头部
|
|
|
|
417
|
+ * @name :getNewsCommonHtml
|
|
367
|
* @author :lyh
|
418
|
* @author :lyh
|
|
368
|
* @method :post
|
419
|
* @method :post
|
|
369
|
- * @time :2023/12/15 10:30
|
420
|
+ * @time :2023/12/27 16:07
|
|
370
|
*/
|
421
|
*/
|
|
371
|
- public function handleDefaultString($param){
|
|
|
|
372
|
- if(!isset($param['template_id'])){
|
|
|
|
373
|
- $param['template_id'] = 0;
|
422
|
+ public function getNewsCommonHtml($data,$is_list,$pageInfo){
|
|
|
|
423
|
+ $commonInfo = [];
|
|
|
|
424
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
425
|
+ if ($is_list == BTemplate::IS_LIST) {
|
|
|
|
426
|
+ $data['type'] = BTemplate::TYPE_SEVEN;
|
|
|
|
427
|
+ if ($pageInfo['news_list'] != 0) {
|
|
|
|
428
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
429
|
+ if($commonInfo === false){
|
|
|
|
430
|
+ $commonInfo = [];
|
|
374
|
}
|
431
|
}
|
|
375
|
- if(!isset($param['is_custom'])){
|
|
|
|
376
|
- $param['is_custom'] = 0;
|
|
|
|
377
|
}
|
432
|
}
|
|
378
|
- if(!isset($param['section_list_id'])){
|
|
|
|
379
|
- $param['section_list_id'] = '';
|
433
|
+ } else {
|
|
|
|
434
|
+ $data['type'] = BTemplate::TYPE_SIX;
|
|
|
|
435
|
+ if ($pageInfo['news_details'] != 0) {
|
|
|
|
436
|
+ $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
437
|
+ if($commonInfo === false){
|
|
|
|
438
|
+ $commonInfo = [];
|
|
|
|
439
|
+ }
|
|
380
|
}
|
440
|
}
|
|
381
|
- return $this->success($param);
|
441
|
+ }
|
|
|
|
442
|
+ return $this->success($commonInfo);
|
|
382
|
}
|
443
|
}
|
|
383
|
|
444
|
|
|
384
|
/**
|
445
|
/**
|
|
385
|
- * @remark :可视化添加数据
|
|
|
|
386
|
- * @name :templateAddHtml
|
446
|
+ * @remark :保存修改后的模版
|
|
|
|
447
|
+ * @name :templateSave
|
|
387
|
* @author :lyh
|
448
|
* @author :lyh
|
|
388
|
* @method :post
|
449
|
* @method :post
|
|
389
|
- * @time :2023/12/15 10:15
|
450
|
+ * @time :2023/6/29 11:05
|
|
390
|
*/
|
451
|
*/
|
|
391
|
- public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
|
452
|
+ public function templateSave(){
|
|
|
|
453
|
+ //演示项目不允许修改
|
|
|
|
454
|
+ $this->showProjectNoEdit($this->param['source']);
|
|
|
|
455
|
+ $this->param = $this->handleDefaultString($this->param);//设置默认数据
|
|
|
|
456
|
+ $templateInfo = $this->model->read([
|
|
|
|
457
|
+ 'template_id'=>$this->param['template_id'],
|
|
|
|
458
|
+ 'source'=>$this->param['source'],
|
|
|
|
459
|
+ 'source_id'=>$this->param['source_id'],
|
|
|
|
460
|
+ 'is_custom'=>$this->param['is_custom'],
|
|
|
|
461
|
+ 'is_list'=>$this->param['is_list']
|
|
|
|
462
|
+ ]);
|
|
|
|
463
|
+ if($templateInfo === false){//执行新增
|
|
392
|
$data = [
|
464
|
$data = [
|
|
393
|
- 'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML,
|
|
|
|
394
|
- 'template_id'=>$template, 'project_id'=>$this->user['project_id'],
|
|
|
|
395
|
- 'section_list_id'=>$section_list_id,'is_custom'=>$is_custom,
|
465
|
+ 'source'=>$this->param['source'], 'source_id'=>$this->param['source_id'],'type'=>BTemplate::PAGE_HTML,
|
|
|
|
466
|
+ 'template_id'=>$this->param['template_id'], 'project_id'=>$this->user['project_id'],
|
|
|
|
467
|
+ 'section_list_id'=>$this->param['section_list_id'],'is_custom'=>$this->param['is_custom'],
|
|
|
|
468
|
+ 'is_list'=>$this->param['is_list']
|
|
396
|
];
|
469
|
];
|
|
397
|
- $data = $this->handleVisualizationParam($html,$source,$source_id,$data);
|
470
|
+ $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
|
|
398
|
$this->model->add($data);
|
471
|
$this->model->add($data);
|
|
399
|
- return true;
|
472
|
+ }else{//执行编辑
|
|
|
|
473
|
+ $condition = [
|
|
|
|
474
|
+ 'source'=>$this->param['source'], 'source_id'=>$this->param['source'],
|
|
|
|
475
|
+ 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
|
|
|
|
476
|
+ 'is_list'=>$this->param['is_list']
|
|
|
|
477
|
+ ];
|
|
|
|
478
|
+ $data = [
|
|
|
|
479
|
+ 'section_list_id'=>$this->param['section_list_id']
|
|
|
|
480
|
+ ];
|
|
|
|
481
|
+ $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$data);
|
|
|
|
482
|
+ $this->model->edit($data,$condition);
|
|
|
|
483
|
+ }
|
|
|
|
484
|
+ //更新头部信息
|
|
|
|
485
|
+ $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']);
|
|
|
|
486
|
+ $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
|
|
|
|
487
|
+ //通知更新
|
|
|
|
488
|
+ $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
|
|
489
|
+ return $this->success();
|
|
400
|
}
|
490
|
}
|
|
401
|
|
491
|
|
|
402
|
/**
|
492
|
/**
|
|
403
|
- * @remark :可视化更新html
|
|
|
|
404
|
- * @name :templateEditHtml
|
493
|
+ * @remark :保存数据时设置默认字符
|
|
|
|
494
|
+ * @name :saveDefaultString
|
|
405
|
* @author :lyh
|
495
|
* @author :lyh
|
|
406
|
* @method :post
|
496
|
* @method :post
|
|
407
|
- * @time :2023/12/15 10:26
|
497
|
+ * @time :2023/12/15 10:30
|
|
408
|
*/
|
498
|
*/
|
|
409
|
- public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
|
|
|
|
410
|
- $condition = [
|
|
|
|
411
|
- 'source'=>$source, 'source_id'=>$source_id,
|
|
|
|
412
|
- 'is_custom'=>$is_custom, 'template_id'=>$template
|
|
|
|
413
|
- ];
|
|
|
|
414
|
- $data = [
|
|
|
|
415
|
- 'section_list_id'=>$section_list_id
|
|
|
|
416
|
- ];
|
|
|
|
417
|
- $data = $this->handleVisualizationParam($html,$source,$source_id,$data);
|
|
|
|
418
|
- $this->model->edit($data,$condition);
|
|
|
|
419
|
- return true;
|
499
|
+ public function handleDefaultString($param){
|
|
|
|
500
|
+ $param['template_id'] = $param['template_id'] ?? 0;
|
|
|
|
501
|
+ $param['is_custom'] = $param['is_custom'] = 0;
|
|
|
|
502
|
+ $param['section_list_id'] = $param['section_list_id'] ?? '';
|
|
|
|
503
|
+ $param['is_list'] = $param['is_list'] ?? 0;
|
|
|
|
504
|
+ return $this->success($param);
|
|
420
|
}
|
505
|
}
|
|
421
|
|
506
|
|
|
422
|
/**
|
507
|
/**
|
|
@@ -426,9 +511,9 @@ class BTemplateLogic extends BaseLogic |
|
@@ -426,9 +511,9 @@ class BTemplateLogic extends BaseLogic |
|
426
|
* @method :post
|
511
|
* @method :post
|
|
427
|
* @time :2023/12/15 10:59
|
512
|
* @time :2023/12/15 10:59
|
|
428
|
*/
|
513
|
*/
|
|
429
|
- public function handleVisualizationParam($html,$source, $source_id,$data){
|
514
|
+ public function handleVisualizationParam($html,$source, $is_list,$data){
|
|
430
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
|
515
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
|
|
431
|
- $type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
516
|
+ $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
432
|
//查看当前页面是否定制,是否开启可视化
|
517
|
//查看当前页面是否定制,是否开启可视化
|
|
433
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
518
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
434
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
519
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
@@ -455,8 +540,8 @@ class BTemplateLogic extends BaseLogic |
|
@@ -455,8 +540,8 @@ class BTemplateLogic extends BaseLogic |
|
455
|
* @method :post
|
540
|
* @method :post
|
|
456
|
* @time :2023/12/13 17:05
|
541
|
* @time :2023/12/13 17:05
|
|
457
|
*/
|
542
|
*/
|
|
458
|
- public function saveCommonHtml($html,$source,$source_id,$template_id){
|
|
|
|
459
|
- $type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面)
|
543
|
+ public function saveCommonHtml($html,$source,$is_list,$template_id){
|
|
|
|
544
|
+ $type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面)
|
|
460
|
$templateCommonModel = new BTemplateCommon();
|
545
|
$templateCommonModel = new BTemplateCommon();
|
|
461
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
546
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
|
462
|
$handleInfo = $this->handleCommonParam($html);
|
547
|
$handleInfo = $this->handleCommonParam($html);
|
|
@@ -525,32 +610,70 @@ class BTemplateLogic extends BaseLogic |
|
@@ -525,32 +610,70 @@ class BTemplateLogic extends BaseLogic |
|
525
|
return $this->success($param);
|
610
|
return $this->success($param);
|
|
526
|
}
|
611
|
}
|
|
527
|
/**
|
612
|
/**
|
|
528
|
- * @remark :获取设置的类型
|
613
|
+ * @remark :保存时获取获取设置的类型
|
|
529
|
* @name :getType
|
614
|
* @name :getType
|
|
530
|
* @author :lyh
|
615
|
* @author :lyh
|
|
531
|
* @method :post
|
616
|
* @method :post
|
|
532
|
* @time :2023/10/21 17:29
|
617
|
* @time :2023/10/21 17:29
|
|
533
|
*/
|
618
|
*/
|
|
534
|
- public function getType($source,$source_id,$template_id){
|
|
|
|
535
|
- $type = 1;//首页公共头部底部
|
619
|
+ public function getType($source,$is_list,$template_id){
|
|
|
|
620
|
+ $type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
621
|
+ $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
536
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
622
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
|
537
|
- $this->user['configuration']['is_head'] == 1;
|
623
|
+ $is_head == BTemplate::IS_HEADER;
|
|
538
|
}
|
624
|
}
|
|
539
|
//查看页面是否设置自定义头部底部
|
625
|
//查看页面是否设置自定义头部底部
|
|
540
|
- if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
626
|
+ if($is_head != BTemplate::IS_NO_HEADER) {
|
|
541
|
$pageSettingModel = new PageSetting();
|
627
|
$pageSettingModel = new PageSetting();
|
|
542
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
628
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
543
|
- if ($pageInfo !== false) {
|
|
|
|
544
|
- if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
|
|
|
|
545
|
- else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
|
|
|
|
546
|
- if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
|
|
|
|
547
|
- else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
|
|
|
|
548
|
- if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
|
|
|
|
549
|
- else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
|
|
|
|
550
|
- if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
|
629
|
+ if ($pageInfo === false) {
|
|
|
|
630
|
+ return $this->success($type);
|
|
551
|
}
|
631
|
}
|
|
|
|
632
|
+ switch ($source){
|
|
|
|
633
|
+ case BTemplate::SOURCE_PRODUCT:
|
|
|
|
634
|
+ if ($is_list != BTemplate::IS_LIST) {
|
|
|
|
635
|
+ if ($pageInfo['product_details'] != 0) {
|
|
|
|
636
|
+ $type = BTemplate::TYPE_TWO;
|
|
|
|
637
|
+ }
|
|
|
|
638
|
+ } else {
|
|
|
|
639
|
+ if ($pageInfo['product_list'] != 0) {
|
|
|
|
640
|
+ $type = BTemplate::TYPE_THREE;
|
|
|
|
641
|
+ }
|
|
|
|
642
|
+ }
|
|
|
|
643
|
+ break;
|
|
|
|
644
|
+ case BTemplate::SOURCE_BLOG:
|
|
|
|
645
|
+ if ($is_list != BTemplate::IS_LIST) {
|
|
|
|
646
|
+ if ($pageInfo['blog_details'] != 0) {
|
|
|
|
647
|
+ $type = BTemplate::TYPE_FOUR;
|
|
|
|
648
|
+ }
|
|
|
|
649
|
+ } else {
|
|
|
|
650
|
+ if ($pageInfo['blog_details'] != 0) {
|
|
|
|
651
|
+ $type = BTemplate::TYPE_FIVE;
|
|
|
|
652
|
+ }
|
|
|
|
653
|
+ }
|
|
|
|
654
|
+ break;
|
|
|
|
655
|
+ case BTemplate::SOURCE_BLOG:
|
|
|
|
656
|
+ if ($is_list != BTemplate::IS_LIST) {
|
|
|
|
657
|
+ if ($pageInfo['news_details'] != 0) {
|
|
|
|
658
|
+ $type = BTemplate::TYPE_SIX;
|
|
|
|
659
|
+ }
|
|
|
|
660
|
+ } else {
|
|
|
|
661
|
+ if ($pageInfo['news_list'] != 0) {
|
|
|
|
662
|
+ $type = BTemplate::TYPE_SEVEN;
|
|
|
|
663
|
+ }
|
|
|
|
664
|
+ }
|
|
|
|
665
|
+ break;
|
|
|
|
666
|
+ case BTemplate::SOURCE_KEYWORD:
|
|
|
|
667
|
+ if ($pageInfo['polymerization'] != 0) {
|
|
|
|
668
|
+ $type = BTemplate::TYPE_EIGHT;
|
|
|
|
669
|
+ }
|
|
|
|
670
|
+ break;
|
|
|
|
671
|
+ default:
|
|
|
|
672
|
+ $type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
673
|
+ break;
|
|
|
|
674
|
+ }
|
|
|
|
675
|
+ return $this->success($type);
|
|
552
|
}
|
676
|
}
|
|
553
|
- return $type;
|
|
|
|
554
|
}
|
677
|
}
|
|
555
|
|
678
|
|
|
556
|
/**
|
679
|
/**
|
|
@@ -561,6 +684,9 @@ class BTemplateLogic extends BaseLogic |
|
@@ -561,6 +684,9 @@ class BTemplateLogic extends BaseLogic |
|
561
|
* @time :2023/8/23 11:16
|
684
|
* @time :2023/8/23 11:16
|
|
562
|
*/
|
685
|
*/
|
|
563
|
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
|
686
|
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
|
|
|
|
687
|
+ if($source != BTemplate::SOURCE_HOME){
|
|
|
|
688
|
+ return true;
|
|
|
|
689
|
+ }
|
|
564
|
$data = [
|
690
|
$data = [
|
|
565
|
'template_id'=>$template_id,
|
691
|
'template_id'=>$template_id,
|
|
566
|
'project_id'=>$this->user['project_id'],
|
692
|
'project_id'=>$this->user['project_id'],
|
|
@@ -590,23 +716,39 @@ class BTemplateLogic extends BaseLogic |
|
@@ -590,23 +716,39 @@ class BTemplateLogic extends BaseLogic |
|
590
|
* @method :post
|
716
|
* @method :post
|
|
591
|
* @time :2023/7/31 16:05
|
717
|
* @time :2023/7/31 16:05
|
|
592
|
*/
|
718
|
*/
|
|
593
|
- public function homeOrProduct($source,$source_id = 0,$is_custom = 0){
|
719
|
+ public function homeOrProduct($source,$source_id = 0,$is_custom = 0,$is_list = 0){
|
|
594
|
if($is_custom == 0){
|
720
|
if($is_custom == 0){
|
|
595
|
if($source == BTemplate::SOURCE_HOME){
|
721
|
if($source == BTemplate::SOURCE_HOME){
|
|
596
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
722
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
597
|
$type = RouteMap::SOURCE_PAGE;
|
723
|
$type = RouteMap::SOURCE_PAGE;
|
|
598
|
}elseif($source == BTemplate::SOURCE_PRODUCT){
|
724
|
}elseif($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
725
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
726
|
+ $type = RouteMap::SOURCE_PRODUCT_CATE;
|
|
|
|
727
|
+ }else{
|
|
599
|
$type = RouteMap::SOURCE_PRODUCT;
|
728
|
$type = RouteMap::SOURCE_PRODUCT;
|
|
|
|
729
|
+ }
|
|
600
|
}elseif($source == BTemplate::SOURCE_BLOG){
|
730
|
}elseif($source == BTemplate::SOURCE_BLOG){
|
|
|
|
731
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
732
|
+ $type = RouteMap::SOURCE_BLOG_CATE;
|
|
|
|
733
|
+ }else{
|
|
601
|
$type = RouteMap::SOURCE_BLOG;
|
734
|
$type = RouteMap::SOURCE_BLOG;
|
|
|
|
735
|
+ }
|
|
602
|
}elseif($source == BTemplate::SOURCE_NEWS){
|
736
|
}elseif($source == BTemplate::SOURCE_NEWS){
|
|
|
|
737
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
738
|
+ $type = RouteMap::SOURCE_NEWS_CATE;
|
|
|
|
739
|
+ }else{
|
|
603
|
$type = RouteMap::SOURCE_NEWS;
|
740
|
$type = RouteMap::SOURCE_NEWS;
|
|
|
|
741
|
+ }
|
|
604
|
}else{
|
742
|
}else{
|
|
605
|
$type = 'all';
|
743
|
$type = 'all';
|
|
606
|
}
|
744
|
}
|
|
607
|
}else{
|
745
|
}else{
|
|
|
|
746
|
+ if($is_list == BTemplate::IS_LIST){
|
|
|
|
747
|
+ $type = RouteMap::SOURCE_MODULE_CATE;
|
|
|
|
748
|
+ }else{
|
|
608
|
$type = RouteMap::SOURCE_MODULE;
|
749
|
$type = RouteMap::SOURCE_MODULE;
|
|
609
|
}
|
750
|
}
|
|
|
|
751
|
+ }
|
|
610
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
752
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
|
611
|
$this->addUpdateNotify($type,$route);
|
753
|
$this->addUpdateNotify($type,$route);
|
|
612
|
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
754
|
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
|
@@ -658,19 +800,6 @@ class BTemplateLogic extends BaseLogic |
|
@@ -658,19 +800,6 @@ class BTemplateLogic extends BaseLogic |
|
658
|
}
|
800
|
}
|
|
659
|
|
801
|
|
|
660
|
/**
|
802
|
/**
|
|
661
|
- * @remark :默认产品模块
|
|
|
|
662
|
- * @name :getProductModule
|
|
|
|
663
|
- * @author :lyh
|
|
|
|
664
|
- * @method :post
|
|
|
|
665
|
- * @time :2023/7/27 15:08
|
|
|
|
666
|
- */
|
|
|
|
667
|
- public function getModule($type){
|
|
|
|
668
|
- $mainModel = new TemplateTypeMain();
|
|
|
|
669
|
- $info = $mainModel->read(['type'=>$type]);
|
|
|
|
670
|
- return $info['main_html'];
|
|
|
|
671
|
- }
|
|
|
|
672
|
-
|
|
|
|
673
|
- /**
|
|
|
|
674
|
* @remark :设置主题公共head
|
803
|
* @remark :设置主题公共head
|
|
675
|
* @name :setHeadInfo
|
804
|
* @name :setHeadInfo
|
|
676
|
* @author :lyh
|
805
|
* @author :lyh
|
|
@@ -866,76 +995,4 @@ class BTemplateLogic extends BaseLogic |
|
@@ -866,76 +995,4 @@ class BTemplateLogic extends BaseLogic |
|
866
|
}
|
995
|
}
|
|
867
|
return $this->success();
|
996
|
return $this->success();
|
|
868
|
}
|
997
|
}
|
|
869
|
-
|
|
|
|
870
|
-
|
|
|
|
871
|
- /**
|
|
|
|
872
|
- * @remark :保存详情模板数据
|
|
|
|
873
|
- * @name :saveDetail
|
|
|
|
874
|
- * @author :lyh
|
|
|
|
875
|
- * @method :post
|
|
|
|
876
|
- * @time :2023/10/24 11:53
|
|
|
|
877
|
- */
|
|
|
|
878
|
- public function saveDetail(){
|
|
|
|
879
|
- $bSettingModel = new Setting();
|
|
|
|
880
|
- $bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
881
|
- if($bSettingInfo === false){
|
|
|
|
882
|
- $this->fail('请先设置模板');
|
|
|
|
883
|
- }
|
|
|
|
884
|
- $is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
|
|
|
|
885
|
- $data = [
|
|
|
|
886
|
- 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
887
|
- 'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
888
|
- ];
|
|
|
|
889
|
- $data['section_list_id'] = $this->param['section_list_id'];
|
|
|
|
890
|
- //保存中间部分
|
|
|
|
891
|
- $bTemplateMainModel = new BTemplateMain();
|
|
|
|
892
|
- $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);
|
|
|
|
893
|
- if($mainInfo === false){
|
|
|
|
894
|
- $data['project_id'] = $this->user['project_id'];
|
|
|
|
895
|
- $data['type'] = $this->param['type'];
|
|
|
|
896
|
- $data['is_custom'] = $is_custom;
|
|
|
|
897
|
- $bTemplateMainModel->add($data);
|
|
|
|
898
|
- }else{
|
|
|
|
899
|
- $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
900
|
- }
|
|
|
|
901
|
- $this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);
|
|
|
|
902
|
- return $this->success();
|
|
|
|
903
|
- }
|
|
|
|
904
|
-
|
|
|
|
905
|
- /**
|
|
|
|
906
|
- * @remark :保存详情页模版头部底部
|
|
|
|
907
|
- * @name :saveDetailCommonHtml
|
|
|
|
908
|
- * @author :lyh
|
|
|
|
909
|
- * @method :post
|
|
|
|
910
|
- * @time :2023/12/15 18:12
|
|
|
|
911
|
- */
|
|
|
|
912
|
- public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){
|
|
|
|
913
|
- $publicData = [
|
|
|
|
914
|
- 'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
915
|
- 'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
916
|
- 'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
917
|
- 'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
918
|
- 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
919
|
- ];
|
|
|
|
920
|
- //查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
921
|
- if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块
|
|
|
|
922
|
- $this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;
|
|
|
|
923
|
- }
|
|
|
|
924
|
- $templateCommonModel = new BTemplateCommon();
|
|
|
|
925
|
- if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
926
|
- $templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
927
|
- if($templateCommonInfo === false){
|
|
|
|
928
|
- $publicData['type'] = $type;
|
|
|
|
929
|
- $publicData['project_id'] = $this->user['project_id'];
|
|
|
|
930
|
- $publicData['template_id'] = $template_id;
|
|
|
|
931
|
- $templateCommonModel->add($publicData);
|
|
|
|
932
|
- }else{
|
|
|
|
933
|
- $templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
|
|
|
|
934
|
- }
|
|
|
|
935
|
- }else{
|
|
|
|
936
|
- //更新首页头部底部
|
|
|
|
937
|
- $templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
938
|
- }
|
|
|
|
939
|
- return true;
|
|
|
|
940
|
- }
|
|
|
|
941
|
} |
998
|
} |