正在显示
1 个修改的文件
包含
22 行增加
和
11 行删除
| @@ -63,13 +63,8 @@ class BTemplateLogic extends BaseLogic | @@ -63,13 +63,8 @@ class BTemplateLogic extends BaseLogic | ||
| 63 | */ | 63 | */ |
| 64 | public function getTemplate(){ | 64 | public function getTemplate(){ |
| 65 | $settingInfo = $this->getSettingTemplate();//模版详情 | 65 | $settingInfo = $this->getSettingTemplate();//模版详情 |
| 66 | - if($this->param['source'] == $this->model::SOURCE_HOME){//首页 | ||
| 67 | - $TemplateInfo = $this->homeHtml($settingInfo,$this->param['source'],$this->param['source_id']); | ||
| 68 | - }else{ | ||
| 69 | - $TemplateInfo = $this->otherHtml($settingInfo,$this->param['source'],$this->param['source_id']); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - return $this->success($TemplateInfo); | 66 | + $data = $this->getTemplateHtml($settingInfo,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0); |
| 67 | + return $this->success($data); | ||
| 73 | } | 68 | } |
| 74 | 69 | ||
| 75 | /** | 70 | /** |
| @@ -89,14 +84,30 @@ class BTemplateLogic extends BaseLogic | @@ -89,14 +84,30 @@ class BTemplateLogic extends BaseLogic | ||
| 89 | } | 84 | } |
| 90 | } | 85 | } |
| 91 | } | 86 | } |
| 92 | - if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 | ||
| 93 | - return ['html'=>$templateInfo['html'],'template_id'=>$settingInfo['template_id']]; | ||
| 94 | - } | ||
| 95 | $commonInfo = $this->getCommonPage($source,$source_id,$settingInfo['template_id']);//获取头部 | 87 | $commonInfo = $this->getCommonPage($source,$source_id,$settingInfo['template_id']);//获取头部 |
| 96 | $mainInfo = $this->getCommonMain($source,$source_id);//获取中间部分代码 | 88 | $mainInfo = $this->getCommonMain($source,$source_id);//获取中间部分代码 |
| 89 | + if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码 | ||
| 90 | + $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | ||
| 91 | + return ['html'=>$html,'template_id'=>$settingInfo['template_id']]; | ||
| 92 | + } | ||
| 97 | $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. | 93 | $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. |
| 98 | $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | 94 | $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; |
| 99 | - return ['html'=>$templateInfo['html'],'template_id'=>$settingInfo['template_id']]; | 95 | + return ['html'=>$html,'template_id'=>$settingInfo['template_id']]; |
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * @remark :返回整个html截取代码 | ||
| 100 | + * @name :handleAllHtml | ||
| 101 | + * @author :lyh | ||
| 102 | + * @method :post | ||
| 103 | + * @time :2023/12/13 15:39 | ||
| 104 | + */ | ||
| 105 | + public function handleAllHtml($commonInfo,$html){ | ||
| 106 | + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html); | ||
| 107 | + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html); | ||
| 108 | + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html); | ||
| 109 | + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html); | ||
| 110 | + return $html; | ||
| 100 | } | 111 | } |
| 101 | 112 | ||
| 102 | /** | 113 | /** |
-
请 注册 或 登录 后发表评论