正在显示
1 个修改的文件
包含
36 行增加
和
0 行删除
| @@ -87,6 +87,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -87,6 +87,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 87 | */ | 87 | */ |
| 88 | public function saveHtml(){ | 88 | public function saveHtml(){ |
| 89 | $html = $this->param['html']; | 89 | $html = $this->param['html']; |
| 90 | + $this->saveCommonTemplate($html); | ||
| 90 | $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s'); | 91 | $this->param['html'] = characterTruncation($html,'/<main>(.*?)<\/main>/s'); |
| 91 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 92 | $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); |
| 92 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); | 93 | $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); |
| @@ -101,6 +102,38 @@ class CustomTemplateLogic extends BaseLogic | @@ -101,6 +102,38 @@ class CustomTemplateLogic extends BaseLogic | ||
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | /** | 104 | /** |
| 105 | + * @remark :保存头部公共数据 | ||
| 106 | + * @name :saveCommonTemplate | ||
| 107 | + * @author :lyh | ||
| 108 | + * @method :post | ||
| 109 | + * @time :2023/10/13 14:27 | ||
| 110 | + */ | ||
| 111 | + public function saveCommonTemplate($html){ | ||
| 112 | + //获取设置的默认模版 | ||
| 113 | + $bSettingModel = new Setting(); | ||
| 114 | + $settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 115 | + if($settingInfo === false){ | ||
| 116 | + $this->fail('请先设置模版'); | ||
| 117 | + } | ||
| 118 | + //查看当前 | ||
| 119 | + $templateCommonModel = new BTemplateCommon(); | ||
| 120 | + $commonInfo = $templateCommonModel->read(['template_id'=>$settingInfo['template_id'],'project_id'=>$this->user['project_id']]); | ||
| 121 | + if($commonInfo === false){ | ||
| 122 | + $this->fail('请先装修首页'); | ||
| 123 | + } | ||
| 124 | + $data = [ | ||
| 125 | + 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 126 | + 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 127 | + 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 128 | + 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 129 | + 'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")), | ||
| 130 | + ]; | ||
| 131 | + $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | ||
| 132 | + return $this->success(); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + | ||
| 136 | + /** | ||
| 104 | * @remark :查看路由是否更新 | 137 | * @remark :查看路由是否更新 |
| 105 | * @name :editProduct | 138 | * @name :editProduct |
| 106 | * @author :lyh | 139 | * @author :lyh |
| @@ -187,6 +220,9 @@ class CustomTemplateLogic extends BaseLogic | @@ -187,6 +220,9 @@ class CustomTemplateLogic extends BaseLogic | ||
| 187 | //获取设置的默认模版 | 220 | //获取设置的默认模版 |
| 188 | $bSettingModel = new Setting(); | 221 | $bSettingModel = new Setting(); |
| 189 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | 222 | $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); |
| 223 | + if($info === false){ | ||
| 224 | + $this->fail('请先设置模版'); | ||
| 225 | + } | ||
| 190 | //兼容老数据 | 226 | //兼容老数据 |
| 191 | $commonTemplateModel = new BTemplateCommon(); | 227 | $commonTemplateModel = new BTemplateCommon(); |
| 192 | $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); | 228 | $commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]); |
-
请 注册 或 登录 后发表评论