作者 lyh

gx

@@ -41,10 +41,8 @@ class CustomTemplateLogic extends BaseLogic @@ -41,10 +41,8 @@ class CustomTemplateLogic extends BaseLogic
41 */ 41 */
42 public function customTemplateInfo(){ 42 public function customTemplateInfo(){
43 $info = $this->model->read(['id'=>$this->param['id']]); 43 $info = $this->model->read(['id'=>$this->param['id']]);
44 - if(!empty($info['html'])){  
45 - $html = $this->getBodyHeaderFooter();  
46 - $info['html'] = $this->getHeadFooter($html);  
47 - } 44 + $html = $this->getBodyHeaderFooter($info['html']);
  45 + $info['html'] = $this->getHeadFooter($html);
48 if($info === false){ 46 if($info === false){
49 $this->fail('error'); 47 $this->fail('error');
50 } 48 }
@@ -61,7 +59,7 @@ class CustomTemplateLogic extends BaseLogic @@ -61,7 +59,7 @@ class CustomTemplateLogic extends BaseLogic
61 public function customTemplateSave(){ 59 public function customTemplateSave(){
62 if(isset($this->param['id']) && !empty($this->param['id'])){ 60 if(isset($this->param['id']) && !empty($this->param['id'])){
63 if(isset($this->param['html']) && !empty($this->param['html'])){ 61 if(isset($this->param['html']) && !empty($this->param['html'])){
64 - $this->param['html'] = $this->getHeadFooter(characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/footer>/s')); 62 + $this->param['html'] = $this->getHeadFooter(characterTruncation($this->param['html'],'/<main>(.*?)<\/main>/s'));
65 } 63 }
66 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]); 64 $rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
67 }else{ 65 }else{
@@ -96,8 +94,7 @@ class CustomTemplateLogic extends BaseLogic @@ -96,8 +94,7 @@ class CustomTemplateLogic extends BaseLogic
96 * @method :post 94 * @method :post
97 * @time :2023/7/21 18:08 95 * @time :2023/7/21 18:08
98 */ 96 */
99 - public function getBodyHeaderFooter(){  
100 - $html = ''; 97 + public function getBodyHeaderFooter($preg_html){
101 //获取设置的默认模版 98 //获取设置的默认模版
102 $bSettingModel = new BSetting(); 99 $bSettingModel = new BSetting();
103 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); 100 $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
@@ -108,7 +105,10 @@ class CustomTemplateLogic extends BaseLogic @@ -108,7 +105,10 @@ class CustomTemplateLogic extends BaseLogic
108 'project_id'=>$this->user['project_id'], 105 'project_id'=>$this->user['project_id'],
109 'source'=>1//首页 106 'source'=>1//首页
110 ]); 107 ]);
111 - $TemplateInfo['html'] = preg_replace('/<main>.*<\/main>/', "<main></main>", $TemplateInfo['html']); 108 + if(empty($preg_html)){
  109 + $preg_html = "<main></main>";
  110 + }
  111 + $html = preg_replace('/<main>.*<\/main>/', $preg_html, $TemplateInfo['html']);
112 return $html; 112 return $html;
113 } 113 }
114 114