|
@@ -105,7 +105,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -105,7 +105,7 @@ class BTemplateLogic extends BaseLogic |
|
105
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
105
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
106
|
}else{
|
106
|
}else{
|
|
107
|
$commonTemplateModel = new BTemplateCommon();
|
107
|
$commonTemplateModel = new BTemplateCommon();
|
|
108
|
- $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
108
|
+ $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]);
|
|
109
|
if($commonInfo !== false){
|
109
|
if($commonInfo !== false){
|
|
110
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
110
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
111
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
111
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
@@ -134,27 +134,21 @@ class BTemplateLogic extends BaseLogic |
|
@@ -134,27 +134,21 @@ class BTemplateLogic extends BaseLogic |
|
134
|
//查看当前模板是否已编辑保存web_template
|
134
|
//查看当前模板是否已编辑保存web_template
|
|
135
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
135
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
136
|
if($TemplateInfo === false){
|
136
|
if($TemplateInfo === false){
|
|
137
|
- //兼容老数据
|
|
|
|
138
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
139
|
- $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
140
|
- if($commonInfo !== false){
|
|
|
|
141
|
- $html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
142
|
- $commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
|
|
|
|
143
|
- }else{
|
|
|
|
144
|
- $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
|
|
|
|
145
|
- $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
|
|
|
|
146
|
- }
|
137
|
+ $main_html = "<main>{$this->getProductModule()}</main>";
|
|
|
|
138
|
+ $main_style = "<style id='globalsojs-styles'></style>";
|
|
147
|
}else{
|
139
|
}else{
|
|
148
|
- //兼容老数据
|
|
|
|
149
|
- $commonTemplateModel = new BTemplateCommon();
|
|
|
|
150
|
- $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
151
|
- if($commonInfo !== false){
|
|
|
|
152
|
- $html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
153
|
- $commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
154
|
- }else{
|
|
|
|
155
|
- $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
|
|
|
|
156
|
- $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
|
|
|
|
157
|
- }
|
140
|
+ $main_html = $TemplateInfo['main_html'];
|
|
|
|
141
|
+ $main_style = $TemplateInfo['main_css'];
|
|
|
|
142
|
+ }
|
|
|
|
143
|
+ //兼容老数据
|
|
|
|
144
|
+ $commonTemplateModel = new BTemplateCommon();
|
|
|
|
145
|
+ $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]);
|
|
|
|
146
|
+ if($commonInfo !== false){
|
|
|
|
147
|
+ $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
148
|
+ $commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
149
|
+ }else{
|
|
|
|
150
|
+ $html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']);
|
|
|
|
151
|
+ $html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html);
|
|
158
|
}
|
152
|
}
|
|
159
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
153
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
160
|
return $this->success($TemplateInfo);
|
154
|
return $this->success($TemplateInfo);
|
|
@@ -231,8 +225,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -231,8 +225,7 @@ class BTemplateLogic extends BaseLogic |
|
231
|
*/
|
225
|
*/
|
|
232
|
public function saveCommonTemplate($param){
|
226
|
public function saveCommonTemplate($param){
|
|
233
|
$templateCommonModel = new BTemplateCommon();
|
227
|
$templateCommonModel = new BTemplateCommon();
|
|
234
|
- $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
235
|
-// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
|
228
|
+ $info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$param['source']]);
|
|
236
|
$data = [
|
229
|
$data = [
|
|
237
|
'head_html'=>$param['head_html'],
|
230
|
'head_html'=>$param['head_html'],
|
|
238
|
'head_css'=>$param['head_css'],
|
231
|
'head_css'=>$param['head_css'],
|
|
@@ -243,6 +236,7 @@ class BTemplateLogic extends BaseLogic |
|
@@ -243,6 +236,7 @@ class BTemplateLogic extends BaseLogic |
|
243
|
if($info === false){
|
236
|
if($info === false){
|
|
244
|
$data['template_id'] = $param['template_id'];
|
237
|
$data['template_id'] = $param['template_id'];
|
|
245
|
$data['project_id'] = $this->user['project_id'];
|
238
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
239
|
+ $data['type'] = $param['source'];
|
|
246
|
$templateCommonModel->add($data);
|
240
|
$templateCommonModel->add($data);
|
|
247
|
}else{
|
241
|
}else{
|
|
248
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
242
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|