|
@@ -14,7 +14,7 @@ use App\Models\Project\PageSetting; |
|
@@ -14,7 +14,7 @@ use App\Models\Project\PageSetting; |
|
14
|
use App\Models\RouteMap\RouteMap;
|
14
|
use App\Models\RouteMap\RouteMap;
|
|
15
|
use App\Models\Service\Service as ServiceSettingModel;
|
15
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
16
|
use App\Models\Template\BTemplate;
|
16
|
use App\Models\Template\BTemplate;
|
|
17
|
-use App\Models\Template\BTemplateCommon;
|
17
|
+use App\Models\Template\BTemplateCom;
|
|
18
|
use App\Models\Template\BTemplateMain;
|
18
|
use App\Models\Template\BTemplateMain;
|
|
19
|
use App\Models\Template\Setting;
|
19
|
use App\Models\Template\Setting;
|
|
20
|
use App\Models\Template\TemplateTypeMain;
|
20
|
use App\Models\Template\TemplateTypeMain;
|
|
@@ -51,14 +51,83 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -51,14 +51,83 @@ class InitHtmlLogic extends BaseLogic |
|
51
|
$data['id'] = $mainInfo['id'];
|
51
|
$data['id'] = $mainInfo['id'];
|
|
52
|
$data['updated_at'] = $mainInfo['updated_at'];
|
52
|
$data['updated_at'] = $mainInfo['updated_at'];
|
|
53
|
}
|
53
|
}
|
|
54
|
- $commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
|
|
|
|
55
|
- $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
54
|
+ $commonInfo = $this->getTemplateComHtml($this->param['type'],$is_list,$is_custom,$template_id); //获取头部
|
|
|
|
55
|
+ $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
56
|
$html = $this->getHeadFooter($html);//组装数据
|
56
|
$html = $this->getHeadFooter($html);//组装数据
|
|
57
|
$data['html'] = $html;
|
57
|
$data['html'] = $html;
|
|
58
|
return $this->success($data);
|
58
|
return $this->success($data);
|
|
59
|
}
|
59
|
}
|
|
60
|
|
60
|
|
|
61
|
/**
|
61
|
/**
|
|
|
|
62
|
+ * @remark :非定制获取头部+底部
|
|
|
|
63
|
+ * @name :getTemplateComHtml
|
|
|
|
64
|
+ * @author :lyh
|
|
|
|
65
|
+ * @method :post
|
|
|
|
66
|
+ * @time :2024/4/29 16:53
|
|
|
|
67
|
+ */
|
|
|
|
68
|
+ public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
|
|
|
|
69
|
+ $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
|
|
|
|
70
|
+ $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
|
|
|
|
71
|
+ $bTemplateComModel = new BTemplateCom();
|
|
|
|
72
|
+ $condition['common_type'] = BTemplate::COMMON_OTHER;
|
|
|
|
73
|
+ $condition['source'] = $headComInfo['source'];
|
|
|
|
74
|
+ $otherInfo = $bTemplateComModel->read($condition);
|
|
|
|
75
|
+ if($otherInfo === false){
|
|
|
|
76
|
+ $this->fail('获取失败,请联系管理员');
|
|
|
|
77
|
+ }
|
|
|
|
78
|
+ $footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
|
|
|
|
79
|
+ $data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
|
|
|
|
80
|
+ 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
|
|
|
|
81
|
+ return $this->success($data);
|
|
|
|
82
|
+ }
|
|
|
|
83
|
+
|
|
|
|
84
|
+ /**
|
|
|
|
85
|
+ * @remark :公共头部
|
|
|
|
86
|
+ * @name :HeadComHtml
|
|
|
|
87
|
+ * @author :lyh
|
|
|
|
88
|
+ * @method :post
|
|
|
|
89
|
+ * @time :2024/4/29 17:20
|
|
|
|
90
|
+ */
|
|
|
|
91
|
+ public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
|
|
|
|
92
|
+ $commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
|
|
|
|
93
|
+ $bTemplateComModel = new BTemplateCom();
|
|
|
|
94
|
+ $condition['source'] = $commonHead;
|
|
|
|
95
|
+ $condition['common_type'] = BTemplate::COMMON_HEAD;
|
|
|
|
96
|
+ $headComInfo = $bTemplateComModel->read($condition);
|
|
|
|
97
|
+ if($headComInfo === false){
|
|
|
|
98
|
+ //取默认公共的
|
|
|
|
99
|
+ $condition['source'] = BTemplate::SOURCE_COM;
|
|
|
|
100
|
+ $headComInfo = $bTemplateComModel->read($condition);
|
|
|
|
101
|
+ if($headComInfo === false){
|
|
|
|
102
|
+ $this->fail('获取失败,请联系管理员');
|
|
|
|
103
|
+ }
|
|
|
|
104
|
+ }
|
|
|
|
105
|
+ return $this->success($headComInfo);
|
|
|
|
106
|
+ }
|
|
|
|
107
|
+ /**
|
|
|
|
108
|
+ * @remark :公共底部
|
|
|
|
109
|
+ * @name :footerComHtml
|
|
|
|
110
|
+ * @author :lyh
|
|
|
|
111
|
+ * @method :post
|
|
|
|
112
|
+ * @time :2024/4/29 17:18
|
|
|
|
113
|
+ */
|
|
|
|
114
|
+ public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
|
|
|
|
115
|
+ $bTemplateComModel = new BTemplateCom();
|
|
|
|
116
|
+ $condition['common_type'] = BTemplate::COMMON_FOOTER;
|
|
|
|
117
|
+ $condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
|
|
|
|
118
|
+ $footerComInfo = $bTemplateComModel->read($condition);
|
|
|
|
119
|
+ if($footerComInfo === false){
|
|
|
|
120
|
+ //取默认首页的
|
|
|
|
121
|
+ $condition['source'] = BTemplate::SOURCE_COM;
|
|
|
|
122
|
+ $footerComInfo = $bTemplateComModel->read($condition);
|
|
|
|
123
|
+ if($footerComInfo === false){
|
|
|
|
124
|
+ $this->fail('获取失败,请联系管理员');
|
|
|
|
125
|
+ }
|
|
|
|
126
|
+ }
|
|
|
|
127
|
+ return $this->success($footerComInfo);
|
|
|
|
128
|
+ }
|
|
|
|
129
|
+
|
|
|
|
130
|
+ /**
|
|
62
|
* @remark :拼接获取公共头部底部
|
131
|
* @remark :拼接获取公共头部底部
|
|
63
|
* @name :getHeadFooter
|
132
|
* @name :getHeadFooter
|
|
64
|
* @author :lyh
|
133
|
* @author :lyh
|
|
@@ -97,7 +166,7 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -97,7 +166,7 @@ class InitHtmlLogic extends BaseLogic |
|
97
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
166
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
|
98
|
if($mainInfo === false){
|
167
|
if($mainInfo === false){
|
|
99
|
$data = [
|
168
|
$data = [
|
|
100
|
- 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
169
|
+ 'main_html'=>characterTruncationStr($this->param['html'],"<main","</main>"),
|
|
101
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
170
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
102
|
'section_list_id'=>$this->param['section_list_id'] ?? '',
|
171
|
'section_list_id'=>$this->param['section_list_id'] ?? '',
|
|
103
|
'project_id'=>$this->user['project_id'],
|
172
|
'project_id'=>$this->user['project_id'],
|
|
@@ -108,99 +177,86 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -108,99 +177,86 @@ class InitHtmlLogic extends BaseLogic |
|
108
|
$bTemplateMainModel->add($data);
|
177
|
$bTemplateMainModel->add($data);
|
|
109
|
}else{
|
178
|
}else{
|
|
110
|
$data = [
|
179
|
$data = [
|
|
111
|
- 'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
180
|
+ 'main_html'=>characterTruncationStr($this->param['html'],"<main","</main>"),
|
|
112
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
181
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
113
|
'section_list_id'=>$this->param['section_list_id'] ?? '',
|
182
|
'section_list_id'=>$this->param['section_list_id'] ?? '',
|
|
114
|
];
|
183
|
];
|
|
115
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
184
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
116
|
}
|
185
|
}
|
|
117
|
- $this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
|
186
|
+ $this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
|
|
118
|
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
|
187
|
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
|
|
119
|
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
188
|
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
|
120
|
return $this->success();
|
189
|
return $this->success();
|
|
121
|
}
|
190
|
}
|
|
122
|
|
191
|
|
|
123
|
/**
|
192
|
/**
|
|
124
|
- * @remark :保存公共头部底部
|
|
|
|
125
|
- * @name :saveCommonHtml
|
193
|
+ * @remark :保存公共部分(头部。底部。连接部分)
|
|
|
|
194
|
+ * @name :saveTemplateCom
|
|
126
|
* @author :lyh
|
195
|
* @author :lyh
|
|
127
|
* @method :post
|
196
|
* @method :post
|
|
128
|
- * @time :2023/12/13 17:05
|
197
|
+ * @time :2024/4/29 10:32
|
|
129
|
*/
|
198
|
*/
|
|
130
|
- public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
|
|
|
|
131
|
- $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
132
|
- $templateCommonModel = new BTemplateCommon();
|
|
|
|
133
|
- $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
199
|
+ public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
|
|
|
|
200
|
+ $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
|
|
134
|
$handleInfo = $this->handleCommonParam($html);
|
201
|
$handleInfo = $this->handleCommonParam($html);
|
|
135
|
- if($commonInfo === false){
|
|
|
|
136
|
- $data = [
|
|
|
|
137
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
138
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
139
|
- 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
140
|
- ];
|
|
|
|
141
|
- $templateCommonModel->add($data);
|
|
|
|
142
|
- }else{
|
|
|
|
143
|
- $data = [
|
|
|
|
144
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
145
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
146
|
- ];
|
|
|
|
147
|
- $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
148
|
- }
|
|
|
|
149
|
- //更新所有界面的other
|
|
|
|
150
|
- return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
151
|
- }
|
|
|
|
152
|
-
|
|
|
|
153
|
- /**
|
|
|
|
154
|
- * @remark :根据类型获取公共头和底
|
|
|
|
155
|
- * @name :getCommonPage
|
|
|
|
156
|
- * @author :lyh
|
|
|
|
157
|
- * @method :post
|
|
|
|
158
|
- * @time :2023/10/21 16:55
|
|
|
|
159
|
- */
|
|
|
|
160
|
- public function getCommonHtml($source,$is_list,$template_id,$is_custom){
|
|
|
|
161
|
- $type = $this->getType($source,$is_list,$is_custom);
|
|
|
|
162
|
- $data = [
|
|
|
|
163
|
- 'template_id' => $template_id,
|
|
|
|
164
|
- 'project_id' => $this->user['project_id'],
|
|
|
|
165
|
- 'type'=>$type
|
|
|
|
166
|
- ];
|
|
|
|
167
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
168
|
- $commonInfo = $commonTemplateModel->read($data);
|
|
|
|
169
|
- if($commonInfo === false){
|
|
|
|
170
|
- $data['type'] = BTemplate::SOURCE_HOME;
|
|
|
|
171
|
- $commonInfo = $commonTemplateModel->read($data);
|
202
|
+ $templateComModel = new BTemplateCom();
|
|
|
|
203
|
+ foreach ($typeArr as $type){
|
|
|
|
204
|
+ if($type == BTemplate::COMMON_HEAD){
|
|
|
|
205
|
+ $param['html'] = $handleInfo['head_html'];
|
|
|
|
206
|
+ $param['html_style'] = $handleInfo['head_style'];
|
|
|
|
207
|
+ $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
|
|
|
|
208
|
+ }elseif ($type == BTemplate::COMMON_FOOTER){
|
|
|
|
209
|
+ $param['html'] = $handleInfo['footer_html'];
|
|
|
|
210
|
+ $param['html_style'] = $handleInfo['footer_style'];
|
|
|
|
211
|
+ $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
|
|
|
|
212
|
+ }else{
|
|
|
|
213
|
+ $param['html'] = $handleInfo['other'];
|
|
|
|
214
|
+ $param['html_style'] = null;
|
|
|
|
215
|
+ $typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
|
|
|
|
216
|
+ }
|
|
|
|
217
|
+ //查看当前数据是否还存在
|
|
|
|
218
|
+ $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
|
|
|
|
219
|
+ $info = $templateComModel->read($condition);
|
|
|
|
220
|
+ if($info === false){
|
|
|
|
221
|
+ $data = array_merge($param,$condition);
|
|
|
|
222
|
+ $templateComModel->add($data);
|
|
|
|
223
|
+ }else{
|
|
|
|
224
|
+ $templateComModel->edit($param,$condition);
|
|
|
|
225
|
+ }
|
|
172
|
}
|
226
|
}
|
|
173
|
- return $this->success($commonInfo);
|
227
|
+ return $this->success();
|
|
174
|
}
|
228
|
}
|
|
175
|
|
229
|
|
|
176
|
/**
|
230
|
/**
|
|
177
|
- * @remark :保存时获取获取设置的类型
|
231
|
+ * @remark :(非定制)保存时获取获取设置的类型
|
|
178
|
* @name :getType
|
232
|
* @name :getType
|
|
179
|
* @author :lyh
|
233
|
* @author :lyh
|
|
180
|
* @method :post
|
234
|
* @method :post
|
|
181
|
* @time :2023/10/21 17:29
|
235
|
* @time :2023/10/21 17:29
|
|
182
|
*/
|
236
|
*/
|
|
183
|
- public function getType($source,$is_list,$is_custom = 0){
|
|
|
|
184
|
- $type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
237
|
+ public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD,$template_id = 0){
|
|
|
|
238
|
+ if($template_id == 0){
|
|
|
|
239
|
+ return $this->success($source);
|
|
|
|
240
|
+ }
|
|
|
|
241
|
+ $type = BTemplate::SOURCE_COM;//公共头部底部
|
|
185
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
242
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
186
|
- if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
243
|
+ if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
|
|
187
|
return $this->success($type);
|
244
|
return $this->success($type);
|
|
188
|
}
|
245
|
}
|
|
189
|
//查看页面是否设置自定义头部底部
|
246
|
//查看页面是否设置自定义头部底部
|
|
190
|
- if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
191
|
- $pageSettingModel = new PageSetting();
|
|
|
|
192
|
- $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
193
|
- if ($pageInfo === false) {
|
|
|
|
194
|
- return $this->success($type);
|
|
|
|
195
|
- }
|
|
|
|
196
|
- if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
197
|
- else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
198
|
- if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
199
|
- else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
200
|
- if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
201
|
- else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
202
|
- if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
247
|
+ $pageSettingModel = new PageSetting();
|
|
|
|
248
|
+ $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
|
|
|
|
249
|
+ if ($pageInfo === false) {
|
|
|
|
250
|
+ return $this->success($type);
|
|
203
|
}
|
251
|
}
|
|
|
|
252
|
+ if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
|
|
|
|
253
|
+ if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
|
|
|
|
254
|
+ else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
|
|
|
|
255
|
+ if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
|
|
|
|
256
|
+ else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
|
|
|
|
257
|
+ if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
|
|
|
|
258
|
+ else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
|
|
|
|
259
|
+ if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::SOURCE_KEYWORD;}}
|
|
204
|
return $this->success($type);
|
260
|
return $this->success($type);
|
|
205
|
}
|
261
|
}
|
|
206
|
|
262
|
|
|
@@ -215,8 +271,8 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -215,8 +271,8 @@ class InitHtmlLogic extends BaseLogic |
|
215
|
//字符串截取
|
271
|
//字符串截取
|
|
216
|
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
|
272
|
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
217
|
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
|
273
|
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
|
|
218
|
- $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
219
|
- $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
274
|
+ $param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
275
|
+ $param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
|
220
|
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
|
276
|
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
221
|
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
277
|
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
|
222
|
return $this->success($param);
|
278
|
return $this->success($param);
|
|
@@ -269,24 +325,42 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -269,24 +325,42 @@ class InitHtmlLogic extends BaseLogic |
|
269
|
if($info === false){
|
325
|
if($info === false){
|
|
270
|
$html = '';
|
326
|
$html = '';
|
|
271
|
}else{
|
327
|
}else{
|
|
272
|
- //扩展模块获取头部
|
|
|
|
273
|
- if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
274
|
- $type = $this->param['type'];
|
|
|
|
275
|
- }else{
|
|
|
|
276
|
- $type = $this->getCustomizedType($this->param['type'],$is_list);
|
|
|
|
277
|
- }
|
|
|
|
278
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
279
|
- $commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
|
|
|
280
|
- if($commonInfo !== false){
|
|
|
|
281
|
- $info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
|
|
|
|
282
|
- }
|
|
|
|
283
|
- $html = $info['main_html'];
|
328
|
+ $commonInfo = $this->getCustomizeTemplateComHtml($this->param['type'],$is_custom,$is_list);
|
|
|
|
329
|
+ $html = $this->handleAllHtml($commonInfo,$info['main_html']);
|
|
284
|
}
|
330
|
}
|
|
285
|
//更新头部底部
|
331
|
//更新头部底部
|
|
286
|
return $this->success(['html'=>$html]);
|
332
|
return $this->success(['html'=>$html]);
|
|
287
|
}
|
333
|
}
|
|
288
|
|
334
|
|
|
289
|
/**
|
335
|
/**
|
|
|
|
336
|
+ * @remark :定制获取头部底部
|
|
|
|
337
|
+ * @name :getCustomizedCommonHtml
|
|
|
|
338
|
+ * @author :lyh
|
|
|
|
339
|
+ * @method :post
|
|
|
|
340
|
+ * @time :2023/12/29 13:13
|
|
|
|
341
|
+ */
|
|
|
|
342
|
+ public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
|
|
|
|
343
|
+ $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
|
|
|
|
344
|
+ $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
|
|
|
|
345
|
+ $commonTemplateModel = new BTemplateCom();
|
|
|
|
346
|
+ $commonList = $commonTemplateModel->list($param);
|
|
|
|
347
|
+ if(!empty($commonList)){
|
|
|
|
348
|
+ foreach ($commonList as $v){
|
|
|
|
349
|
+ if($v['common_type'] == BTemplate::COMMON_HEAD){
|
|
|
|
350
|
+ $data['head_html'] = $v['html'];
|
|
|
|
351
|
+ $data['head_style'] = $v['html_style'];
|
|
|
|
352
|
+ }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
|
|
|
|
353
|
+ $data['footer_html'] = $v['html'];
|
|
|
|
354
|
+ $data['footer_style'] = $v['html_style'];
|
|
|
|
355
|
+ }else{
|
|
|
|
356
|
+ $data['other'] = $v['html'];
|
|
|
|
357
|
+ }
|
|
|
|
358
|
+ }
|
|
|
|
359
|
+ }
|
|
|
|
360
|
+ return $this->success($data);
|
|
|
|
361
|
+ }
|
|
|
|
362
|
+
|
|
|
|
363
|
+ /**
|
|
290
|
* @remark :返回整个html截取代码
|
364
|
* @remark :返回整个html截取代码
|
|
291
|
* @name :handleAllHtml
|
365
|
* @name :handleAllHtml
|
|
292
|
* @author :lyh
|
366
|
* @author :lyh
|
|
@@ -329,7 +403,7 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -329,7 +403,7 @@ class InitHtmlLogic extends BaseLogic |
|
329
|
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
403
|
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
|
330
|
}
|
404
|
}
|
|
331
|
//更新头部底部
|
405
|
//更新头部底部
|
|
332
|
- $this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom);
|
406
|
+ $this->saveTemplateCom($this->param['html'],0,$this->param['type'],$is_list,$is_custom);
|
|
333
|
}catch (\Exception $exception){
|
407
|
}catch (\Exception $exception){
|
|
334
|
$this->fail('保存失败,请联系开发人员');
|
408
|
$this->fail('保存失败,请联系开发人员');
|
|
335
|
}
|
409
|
}
|
|
@@ -337,73 +411,6 @@ class InitHtmlLogic extends BaseLogic |
|
@@ -337,73 +411,6 @@ class InitHtmlLogic extends BaseLogic |
|
337
|
}
|
411
|
}
|
|
338
|
|
412
|
|
|
339
|
/**
|
413
|
/**
|
|
340
|
- * @remark :定制代码更新头部信息
|
|
|
|
341
|
- * @name :saveCustomizeCommon
|
|
|
|
342
|
- * @author :lyh
|
|
|
|
343
|
- * @method :post
|
|
|
|
344
|
- * @time :2024/1/6 10:29
|
|
|
|
345
|
- */
|
|
|
|
346
|
- public function saveCustomizeCommon($html,$source,$is_list,$is_custom){
|
|
|
|
347
|
- if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
348
|
- $type = $source;
|
|
|
|
349
|
- }else{
|
|
|
|
350
|
- $type = $this->getCustomizedType($source,$is_list);
|
|
|
|
351
|
- }
|
|
|
|
352
|
- $templateCommonModel = new BTemplateCommon();
|
|
|
|
353
|
- $commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在
|
|
|
|
354
|
- $handleInfo = $this->handleCommonParam($html);
|
|
|
|
355
|
- if($commonInfo === false){
|
|
|
|
356
|
- $data = [
|
|
|
|
357
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
|
|
|
|
358
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
359
|
- 'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
|
|
|
|
360
|
- 'is_custom'=>$is_custom,'is_list'=>$is_list
|
|
|
|
361
|
- ];
|
|
|
|
362
|
- $templateCommonModel->add($data);
|
|
|
|
363
|
- }else{
|
|
|
|
364
|
- $data = [
|
|
|
|
365
|
- 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
|
|
|
|
366
|
- 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
367
|
- ];
|
|
|
|
368
|
- $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
369
|
- }
|
|
|
|
370
|
- return $this->success();
|
|
|
|
371
|
- }
|
|
|
|
372
|
-
|
|
|
|
373
|
- /**
|
|
|
|
374
|
- * @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
375
|
- * @name :getType
|
|
|
|
376
|
- * @author :lyh
|
|
|
|
377
|
- * @method :post
|
|
|
|
378
|
- * @time :2023/11/16 11:20
|
|
|
|
379
|
- */
|
|
|
|
380
|
- public function getCustomizedType($source,$is_list){
|
|
|
|
381
|
- $type = BTemplate::TYPE_HOME;
|
|
|
|
382
|
- if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
383
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
384
|
- $type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
385
|
- }else{
|
|
|
|
386
|
- $type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
387
|
- }
|
|
|
|
388
|
- }
|
|
|
|
389
|
- if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
390
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
391
|
- $type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
392
|
- }else{
|
|
|
|
393
|
- $type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
394
|
- }
|
|
|
|
395
|
- }
|
|
|
|
396
|
- if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
397
|
- if($is_list == BTemplate::IS_LIST){
|
|
|
|
398
|
- $type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
399
|
- }else{
|
|
|
|
400
|
- $type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
401
|
- }
|
|
|
|
402
|
- }
|
|
|
|
403
|
- return $type;
|
|
|
|
404
|
- }
|
|
|
|
405
|
-
|
|
|
|
406
|
- /**
|
|
|
|
407
|
* @remark :前端获取设置模块(侧边栏)
|
414
|
* @remark :前端获取设置模块(侧边栏)
|
|
408
|
* @name :getInitModuleMain
|
415
|
* @name :getInitModuleMain
|
|
409
|
* @author :lyh
|
416
|
* @author :lyh
|