作者 lyh

gx

@@ -305,10 +305,10 @@ class BTemplateLogic extends BaseLogic @@ -305,10 +305,10 @@ class BTemplateLogic extends BaseLogic
305 */ 305 */
306 public function saveTemplateHtml($param){ 306 public function saveTemplateHtml($param){
307 //TODO::自定义默认默认取首页的头部底部,不需要保存头部底部 307 //TODO::自定义默认默认取首页的头部底部,不需要保存头部底部
308 - if(!isset($param['is_custom']) || ($param['is_custom'] == 0)){ 308 + if($param['is_custom'] == 0){
309 $this->saveCommonTemplate($param); 309 $this->saveCommonTemplate($param);
310 } 310 }
311 - $info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom'] ?? 0); 311 + $info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom']);
312 $param['project_id'] = $this->user['project_id']; 312 $param['project_id'] = $this->user['project_id'];
313 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']); 313 unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
314 if($info === false){ 314 if($info === false){
@@ -398,7 +398,7 @@ class BTemplateLogic extends BaseLogic @@ -398,7 +398,7 @@ class BTemplateLogic extends BaseLogic
398 'main_css'=>$param['main_css'], 398 'main_css'=>$param['main_css'],
399 'footer_html'=>$param['footer_html'], 399 'footer_html'=>$param['footer_html'],
400 'footer_css'=>$param['footer_css'], 400 'footer_css'=>$param['footer_css'],
401 - 'is_custom'=>$param['is_custom'] ?? 0 401 + 'is_custom'=>$param['is_custom']
402 ]; 402 ];
403 $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'));
404 $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);
@@ -458,7 +458,7 @@ class BTemplateLogic extends BaseLogic @@ -458,7 +458,7 @@ class BTemplateLogic extends BaseLogic
458 } 458 }
459 return $html; 459 return $html;
460 } 460 }
461 - 461 +
462 /** 462 /**
463 * @remark :保存时字符串处理 463 * @remark :保存时字符串处理
464 * @name :handleSaveParam 464 * @name :handleSaveParam
@@ -324,7 +324,10 @@ class VisualizationLogic extends BaseLogic @@ -324,7 +324,10 @@ class VisualizationLogic extends BaseLogic
324 if(in_array($type,$page_array)){//定制页面 324 if(in_array($type,$page_array)){//定制页面
325 $this->saveVisualizationHtml($type); 325 $this->saveVisualizationHtml($type);
326 }else{ 326 }else{
327 - $this->saveTemplateHtml(); 327 + if(!isset($this->param['is_custom'])){
  328 + $this->param['is_custom'] = 0;
  329 + }
  330 + $this->saveTemplateHtml($this->param);
328 } 331 }
329 }catch (\Exception $e){ 332 }catch (\Exception $e){
330 $this->fail('系统错误,请联系管理员'); 333 $this->fail('系统错误,请联系管理员');
@@ -397,26 +400,27 @@ class VisualizationLogic extends BaseLogic @@ -397,26 +400,27 @@ class VisualizationLogic extends BaseLogic
397 * @method :post 400 * @method :post
398 * @time :2023/12/5 15:44 401 * @time :2023/12/5 15:44
399 */ 402 */
400 - public function saveTemplateHtml(){ 403 + public function saveTemplateHtml($param){
401 $bTemplateModel = new BTemplate(); 404 $bTemplateModel = new BTemplate();
402 $templateInfo = $bTemplateModel->read([ 405 $templateInfo = $bTemplateModel->read([
403 - 'source'=>$this->param['source'], 406 + 'source'=>$param['source'],
404 'project_id'=>$this->user['project_id'], 407 'project_id'=>$this->user['project_id'],
405 - 'source_id'=>$this->param['source_id'],  
406 - 'template_id'=>$this->param['template_id'], 408 + 'source_id'=>$param['source_id'],
  409 + 'template_id'=>$param['template_id'],
  410 + 'is_custom'=>$param['is_custom']
407 ]); 411 ]);
408 - $this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');  
409 - $this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); 412 + $this->param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
  413 + $this->param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
410 //保存头部 414 //保存头部
411 - $this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']); 415 + $this->saveCommonTemplate($param['html'],$param['source'],$param['source_id'],$param['template_id']);
412 if($templateInfo === false){ 416 if($templateInfo === false){
413 - $this->param['project_id'] = $this->user['project_id'];  
414 - $bTemplateModel->add($this->param); 417 + $param['project_id'] = $this->user['project_id'];
  418 + $bTemplateModel->add($param);
415 }else{ 419 }else{
416 - $bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]); 420 + $bTemplateModel->edit($param,['source'=>$param['source'],'source_id'=>$param['source_id'],'is_custom'=>$param['is_custom']]);
417 } 421 }
418 - $this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);  
419 - $this->homeOrProduct($this->param['source'],$this->param['source_id']); 422 + $this->setTemplateLog($param['template_id'],$param['html'],$param['source'],$param['source_id'],$param['is_custom']);
  423 + $this->homeOrProduct($param['source'],$param['source_id'],$param['is_custom']);
420 } 424 }
421 425
422 /** 426 /**
@@ -426,33 +430,24 @@ class VisualizationLogic extends BaseLogic @@ -426,33 +430,24 @@ class VisualizationLogic extends BaseLogic
426 * @method :post 430 * @method :post
427 * @time :2023/7/31 16:05 431 * @time :2023/7/31 16:05
428 */ 432 */
429 - public function homeOrProduct($source,$source_id = ''){  
430 - if($source == BTemplate::SOURCE_HOME){  
431 - $type = 'index';  
432 - $route = '';  
433 - //路由映射  
434 - RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);  
435 - }else{  
436 - //其他界面通知更新  
437 - if($source == 2 && $source_id != 0){ 433 + public function homeOrProduct($source,$source_id = '',$is_custom = 0){
  434 + if($is_custom == 0){
  435 + if($source == BTemplate::SOURCE_HOME){
  436 + RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
  437 + $type = RouteMap::SOURCE_INDEX;
  438 + }elseif($source == BTemplate::SOURCE_PRODUCT){
438 $type = RouteMap::SOURCE_PRODUCT; 439 $type = RouteMap::SOURCE_PRODUCT;
439 - $productModel = new Product();  
440 - $productInfo = $productModel->read(['id'=>$source_id],['route']);  
441 - $route = $productInfo['route'];  
442 - }elseif($source == 3 && $source_id != 0){ 440 + }elseif($source == BTemplate::SOURCE_BLOG){
443 $type = RouteMap::SOURCE_BLOG; 441 $type = RouteMap::SOURCE_BLOG;
444 - $blogModel = new Blog();  
445 - $blogInfo = $blogModel->read(['id'=>$source_id],['url']);  
446 - $route = $blogInfo['url'];  
447 - }elseif($source == 4 && $source_id != 0){ 442 + }elseif($source == BTemplate::SOURCE_NEWS){
448 $type = RouteMap::SOURCE_NEWS; 443 $type = RouteMap::SOURCE_NEWS;
449 - $newsModel = new News();  
450 - $newsInfo = $newsModel->read(['id'=>$source_id],['url']);  
451 - $route = $newsInfo['url'];  
452 }else{ 444 }else{
453 $type = 'all'; 445 $type = 'all';
454 - $route = 'all';  
455 } 446 }
  447 + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
  448 + }else{
  449 + $type = RouteMap::SOURCE_MODULE;
  450 + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
456 } 451 }
457 $this->addUpdateNotify($type,$route); 452 $this->addUpdateNotify($type,$route);
458 return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); 453 return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
@@ -465,7 +460,7 @@ class VisualizationLogic extends BaseLogic @@ -465,7 +460,7 @@ class VisualizationLogic extends BaseLogic
465 * @method :post 460 * @method :post
466 * @time :2023/8/23 11:16 461 * @time :2023/8/23 11:16
467 */ 462 */
468 - public function setTemplateLog($template_id,$html,$source,$source_id){ 463 + public function setTemplateLog($template_id,$html,$source,$source_id,$is_custom){
469 $data = [ 464 $data = [
470 'template_id'=>$template_id, 465 'template_id'=>$template_id,
471 'project_id'=>$this->user['project_id'], 466 'project_id'=>$this->user['project_id'],
@@ -479,6 +474,7 @@ class VisualizationLogic extends BaseLogic @@ -479,6 +474,7 @@ class VisualizationLogic extends BaseLogic
479 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), 474 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
480 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), 475 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
481 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), 476 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
  477 + 'is_custom'=>$is_custom
482 ]; 478 ];
483 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); 479 $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
484 $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); 480 $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);