作者 lyh

gx

@@ -199,10 +199,10 @@ class BTemplateLogic extends BaseLogic @@ -199,10 +199,10 @@ class BTemplateLogic extends BaseLogic
199 */ 199 */
200 public function getCommonMain($source,$source_id){ 200 public function getCommonMain($source,$source_id){
201 $data = []; 201 $data = [];
202 - if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}}  
203 - if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}}  
204 - if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}  
205 - if ($source == 5) {$type = 8;} 202 + if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}
  203 + if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}
  204 + if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}
  205 + if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;}
206 //查询有没有公共详情模板 206 //查询有没有公共详情模板
207 $bTemplateMainModel = new BTemplateMain(); 207 $bTemplateMainModel = new BTemplateMain();
208 $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]); 208 $mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
@@ -234,23 +234,23 @@ class BTemplateLogic extends BaseLogic @@ -234,23 +234,23 @@ class BTemplateLogic extends BaseLogic
234 'template_id' => $template_id, 234 'template_id' => $template_id,
235 'project_id' => $this->user['project_id'] 235 'project_id' => $this->user['project_id']
236 ]; 236 ];
237 - if ($source == 2) {//产品页  
238 - if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
239 - else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
240 - if ($source == 3) {//博客页  
241 - if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
242 - else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
243 - if ($source == 4) {//新闻页  
244 - if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}  
245 - else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}  
246 - if ($source == 5) {//聚合页  
247 - $data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}} 237 + if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
  238 + if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
  239 + else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
  240 + if ($source == BTemplate::SOURCE_BLOG) {//博客页
  241 + if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
  242 + else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
  243 + if ($source == BTemplate::SOURCE_NEWS) {//新闻页
  244 + if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
  245 + else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
  246 + if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
  247 + $data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
248 } 248 }
249 } 249 }
250 //获取首页公共的头部和底部 250 //获取首页公共的头部和底部
251 if(!isset($commonInfo) || $commonInfo === false){ 251 if(!isset($commonInfo) || $commonInfo === false){
252 $commonTemplateModel = new BTemplateCommon(); 252 $commonTemplateModel = new BTemplateCommon();
253 - $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); 253 + $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]);
254 } 254 }
255 return $commonInfo; 255 return $commonInfo;
256 } 256 }
@@ -269,13 +269,8 @@ class BTemplateLogic extends BaseLogic @@ -269,13 +269,8 @@ class BTemplateLogic extends BaseLogic
269 try { 269 try {
270 //字符串截取 270 //字符串截取
271 $this->param = $this->stringProcessing($this->param); 271 $this->param = $this->stringProcessing($this->param);
272 - //自定义模块单独处理  
273 - if(isset($this->param['is_custom']) && ($this->param['is_custom'] == 1)){  
274 - $this->customSaveTemplateHtml($this->param);  
275 - }else{  
276 - $this->saveTemplateHtml($this->param);  
277 - $this->setTemplateLog($this->param);  
278 - } 272 + $this->saveTemplateHtml($this->param);
  273 + $this->setTemplateLog($this->param);
279 DB::commit(); 274 DB::commit();
280 }catch (\Exception $e){ 275 }catch (\Exception $e){
281 DB::rollBack(); 276 DB::rollBack();
@@ -287,17 +282,6 @@ class BTemplateLogic extends BaseLogic @@ -287,17 +282,6 @@ class BTemplateLogic extends BaseLogic
287 } 282 }
288 283
289 /** 284 /**
290 - * @remark :自定义模块保存  
291 - * @name :customSaveTemplateHtml  
292 - * @author :lyh  
293 - * @method :post  
294 - * @time :2023/12/12 11:41  
295 - */  
296 - public function customSaveTemplateHtml(){  
297 -  
298 - }  
299 -  
300 - /**  
301 * @remark :演示项目不允许修改首页 285 * @remark :演示项目不允许修改首页
302 * @name :showProject 286 * @name :showProject
303 * @author :lyh 287 * @author :lyh
@@ -320,9 +304,14 @@ class BTemplateLogic extends BaseLogic @@ -320,9 +304,14 @@ class BTemplateLogic extends BaseLogic
320 * @time :2023/12/12 10:23 304 * @time :2023/12/12 10:23
321 */ 305 */
322 public function saveTemplateHtml($param){ 306 public function saveTemplateHtml($param){
323 - $info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id']);  
324 - //保存头部信息  
325 - $this->saveCommonTemplate($param); 307 + //自定义模块
  308 + if(!isset($param['is_custom']) || empty($param['is_custom'])){
  309 + $param['is_custom'] = 0;
  310 + }
  311 + $info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom']);
  312 + if($param['is_custom'] != 0){//TODO::自定义默认默认取首页的头部底部
  313 + $this->saveCommonTemplate($param);
  314 + }
326 $param['project_id'] = $this->user['project_id']; 315 $param['project_id'] = $this->user['project_id'];
327 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']); 316 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
328 if($info === false){ 317 if($info === false){
@@ -409,6 +398,7 @@ class BTemplateLogic extends BaseLogic @@ -409,6 +398,7 @@ class BTemplateLogic extends BaseLogic
409 'main_css'=>$param['main_css'], 398 'main_css'=>$param['main_css'],
410 'footer_html'=>$param['footer_html'], 399 'footer_html'=>$param['footer_html'],
411 'footer_css'=>$param['footer_css'], 400 'footer_css'=>$param['footer_css'],
  401 + 'is_custom'=>$param['is_custom'] ?? 0
412 ]; 402 ];
413 $footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s')); 403 $footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
414 $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 404 $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
@@ -21,8 +21,8 @@ class BTemplate extends Base @@ -21,8 +21,8 @@ class BTemplate extends Base
21 const SOURCE_CUSTOM = 1;//自定义模块 21 const SOURCE_CUSTOM = 1;//自定义模块
22 const STATUS = 0; 22 const STATUS = 0;
23 23
24 - const TYPE_ONE = 1;  
25 - const TYPE_TWO = 2; 24 + const TYPE_ONE = 1;//首页类型
  25 + const TYPE_TWO = 2;//
26 const TYPE_THREE = 3; 26 const TYPE_THREE = 3;
27 const TYPE_FOUR = 4; 27 const TYPE_FOUR = 4;
28 const TYPE_FIVE = 5; 28 const TYPE_FIVE = 5;