正在显示
1 个修改的文件
包含
25 行增加
和
34 行删除
| @@ -268,7 +268,7 @@ class BTemplateLogic extends BaseLogic | @@ -268,7 +268,7 @@ class BTemplateLogic extends BaseLogic | ||
| 268 | DB::beginTransaction(); | 268 | DB::beginTransaction(); |
| 269 | try { | 269 | try { |
| 270 | //字符串截取 | 270 | //字符串截取 |
| 271 | - $this->param = $this->stringProcessing($this->param); | 271 | + $this->param = $this->handleSaveParam($this->param); |
| 272 | $this->saveTemplateHtml($this->param); | 272 | $this->saveTemplateHtml($this->param); |
| 273 | $this->setTemplateLog($this->param); | 273 | $this->setTemplateLog($this->param); |
| 274 | DB::commit(); | 274 | DB::commit(); |
| @@ -277,7 +277,7 @@ class BTemplateLogic extends BaseLogic | @@ -277,7 +277,7 @@ class BTemplateLogic extends BaseLogic | ||
| 277 | $this->fail('系统错误,请联系管理员'); | 277 | $this->fail('系统错误,请联系管理员'); |
| 278 | } | 278 | } |
| 279 | //通知更新 | 279 | //通知更新 |
| 280 | - $this->homeOrProduct($this->param['source'],$this->param['source_id']); | 280 | + $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']); |
| 281 | return $this->success(); | 281 | return $this->success(); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| @@ -304,14 +304,11 @@ class BTemplateLogic extends BaseLogic | @@ -304,14 +304,11 @@ class BTemplateLogic extends BaseLogic | ||
| 304 | * @time :2023/12/12 10:23 | 304 | * @time :2023/12/12 10:23 |
| 305 | */ | 305 | */ |
| 306 | public function saveTemplateHtml($param){ | 306 | public function saveTemplateHtml($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::自定义默认默认取首页的头部底部,不需要保存头部底部 | 307 | + //TODO::自定义默认默认取首页的头部底部,不需要保存头部底部 |
| 308 | + if(!isset($param['is_custom']) || ($param['is_custom'] == 0)){ | ||
| 313 | $this->saveCommonTemplate($param); | 309 | $this->saveCommonTemplate($param); |
| 314 | } | 310 | } |
| 311 | + $info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom'] ?? 0); | ||
| 315 | $param['project_id'] = $this->user['project_id']; | 312 | $param['project_id'] = $this->user['project_id']; |
| 316 | 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']); |
| 317 | if($info === false){ | 314 | if($info === false){ |
| @@ -416,33 +413,24 @@ class BTemplateLogic extends BaseLogic | @@ -416,33 +413,24 @@ class BTemplateLogic extends BaseLogic | ||
| 416 | * @method :post | 413 | * @method :post |
| 417 | * @time :2023/7/31 16:05 | 414 | * @time :2023/7/31 16:05 |
| 418 | */ | 415 | */ |
| 419 | - public function homeOrProduct($source,$source_id = ''){ | ||
| 420 | - if($source == BTemplate::SOURCE_HOME){ | ||
| 421 | - $type = 'index'; | ||
| 422 | - $route = 'index'; | ||
| 423 | - //路由映射 | ||
| 424 | - RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 425 | - }else{ | ||
| 426 | - //其他界面通知更新 | ||
| 427 | - if($source == 2 && $source_id != 0){ | 416 | + public function homeOrProduct($source,$source_id = '',$is_custom = 0){ |
| 417 | + if($is_custom == 0){ | ||
| 418 | + if($source == BTemplate::SOURCE_HOME){ | ||
| 419 | + RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']); | ||
| 420 | + $type = RouteMap::SOURCE_INDEX; | ||
| 421 | + }elseif($source == BTemplate::SOURCE_PRODUCT){ | ||
| 428 | $type = RouteMap::SOURCE_PRODUCT; | 422 | $type = RouteMap::SOURCE_PRODUCT; |
| 429 | - $productModel = new Product(); | ||
| 430 | - $productInfo = $productModel->read(['id'=>$source_id],['route']); | ||
| 431 | - $route = $productInfo['route']; | ||
| 432 | - }elseif($source == 3 && $source_id != 0){ | 423 | + }elseif($source == BTemplate::SOURCE_BLOG){ |
| 433 | $type = RouteMap::SOURCE_BLOG; | 424 | $type = RouteMap::SOURCE_BLOG; |
| 434 | - $blogModel = new Blog(); | ||
| 435 | - $blogInfo = $blogModel->read(['id'=>$source_id],['url']); | ||
| 436 | - $route = $blogInfo['url']; | ||
| 437 | - }elseif($source == 4 && $source_id != 0){ | 425 | + }elseif($source == BTemplate::SOURCE_NEWS){ |
| 438 | $type = RouteMap::SOURCE_NEWS; | 426 | $type = RouteMap::SOURCE_NEWS; |
| 439 | - $newsModel = new News(); | ||
| 440 | - $newsInfo = $newsModel->read(['id'=>$source_id],['url']); | ||
| 441 | - $route = $newsInfo['url']; | ||
| 442 | }else{ | 427 | }else{ |
| 443 | $type = 'all'; | 428 | $type = 'all'; |
| 444 | - $route = 'all'; | ||
| 445 | } | 429 | } |
| 430 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 431 | + }else{ | ||
| 432 | + $type = RouteMap::SOURCE_MODULE; | ||
| 433 | + $route = RouteMap::getRoute($type,$source_id,$this->user['project_id']); | ||
| 446 | } | 434 | } |
| 447 | $this->addUpdateNotify($type,$route); | 435 | $this->addUpdateNotify($type,$route); |
| 448 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); | 436 | return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); |
| @@ -470,15 +458,15 @@ class BTemplateLogic extends BaseLogic | @@ -470,15 +458,15 @@ class BTemplateLogic extends BaseLogic | ||
| 470 | } | 458 | } |
| 471 | return $html; | 459 | return $html; |
| 472 | } | 460 | } |
| 473 | - | 461 | + |
| 474 | /** | 462 | /** |
| 475 | - * @remark :字符串处理 | ||
| 476 | - * @name :StringProcessing | 463 | + * @remark :保存时字符串处理 |
| 464 | + * @name :handleSaveParam | ||
| 477 | * @author :lyh | 465 | * @author :lyh |
| 478 | * @method :post | 466 | * @method :post |
| 479 | * @time :2023/6/29 15:35 | 467 | * @time :2023/6/29 15:35 |
| 480 | */ | 468 | */ |
| 481 | - public function stringProcessing($param){ | 469 | + public function handleSaveParam($param){ |
| 482 | //字符串截取 | 470 | //字符串截取 |
| 483 | $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); | 471 | $param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'); |
| 484 | $param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); | 472 | $param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'); |
| @@ -486,6 +474,9 @@ class BTemplateLogic extends BaseLogic | @@ -486,6 +474,9 @@ class BTemplateLogic extends BaseLogic | ||
| 486 | $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'); | 474 | $param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'); |
| 487 | $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 475 | $param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'); |
| 488 | $param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | 476 | $param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'); |
| 477 | + if(!isset($param['is_custom'])){ | ||
| 478 | + $param['is_custom'] = 0; | ||
| 479 | + } | ||
| 489 | return $this->success($param); | 480 | return $this->success($param); |
| 490 | } | 481 | } |
| 491 | 482 | ||
| @@ -581,7 +572,7 @@ class BTemplateLogic extends BaseLogic | @@ -581,7 +572,7 @@ class BTemplateLogic extends BaseLogic | ||
| 581 | $this->param['test_model'] = 2;//未审核模版 | 572 | $this->param['test_model'] = 2;//未审核模版 |
| 582 | $this->param['operator_id'] = $this->user['manager_id'] ?? 0; | 573 | $this->param['operator_id'] = $this->user['manager_id'] ?? 0; |
| 583 | $this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s'); | 574 | $this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s'); |
| 584 | - $this->param = $this->stringProcessing($this->param); | 575 | + $this->param = $this->handleSaveParam($this->param); |
| 585 | $publicTemplateModel = new Template(); | 576 | $publicTemplateModel = new Template(); |
| 586 | $rs = $publicTemplateModel->add($this->param); | 577 | $rs = $publicTemplateModel->add($this->param); |
| 587 | if($rs === false){ | 578 | if($rs === false){ |
-
请 注册 或 登录 后发表评论