|
...
|
...
|
@@ -268,7 +268,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
//字符串截取
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
$this->saveTemplateHtml($this->param);
|
|
|
|
$this->setTemplateLog($this->param);
|
|
|
|
DB::commit();
|
|
...
|
...
|
@@ -277,7 +277,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
//通知更新
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -304,14 +304,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/12/12 10:23
|
|
|
|
*/
|
|
|
|
public function saveTemplateHtml($param){
|
|
|
|
//自定义模块
|
|
|
|
if(!isset($param['is_custom']) || empty($param['is_custom'])){
|
|
|
|
$param['is_custom'] = 0;
|
|
|
|
}
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom']);
|
|
|
|
if($param['is_custom'] != 0){//TODO::自定义默认默认取首页的头部底部,不需要保存头部底部
|
|
|
|
//TODO::自定义默认默认取首页的头部底部,不需要保存头部底部
|
|
|
|
if(!isset($param['is_custom']) || ($param['is_custom'] == 0)){
|
|
|
|
$this->saveCommonTemplate($param);
|
|
|
|
}
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom'] ?? 0);
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
|
|
|
|
if($info === false){
|
|
...
|
...
|
@@ -416,33 +413,24 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/31 16:05
|
|
|
|
*/
|
|
|
|
public function homeOrProduct($source,$source_id = ''){
|
|
|
|
if($source == BTemplate::SOURCE_HOME){
|
|
|
|
$type = 'index';
|
|
|
|
$route = 'index';
|
|
|
|
//路由映射
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
//其他界面通知更新
|
|
|
|
if($source == 2 && $source_id != 0){
|
|
|
|
public function homeOrProduct($source,$source_id = '',$is_custom = 0){
|
|
|
|
if($is_custom == 0){
|
|
|
|
if($source == BTemplate::SOURCE_HOME){
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
$type = RouteMap::SOURCE_INDEX;
|
|
|
|
}elseif($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
$type = RouteMap::SOURCE_PRODUCT;
|
|
|
|
$productModel = new Product();
|
|
|
|
$productInfo = $productModel->read(['id'=>$source_id],['route']);
|
|
|
|
$route = $productInfo['route'];
|
|
|
|
}elseif($source == 3 && $source_id != 0){
|
|
|
|
}elseif($source == BTemplate::SOURCE_BLOG){
|
|
|
|
$type = RouteMap::SOURCE_BLOG;
|
|
|
|
$blogModel = new Blog();
|
|
|
|
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $blogInfo['url'];
|
|
|
|
}elseif($source == 4 && $source_id != 0){
|
|
|
|
}elseif($source == BTemplate::SOURCE_NEWS){
|
|
|
|
$type = RouteMap::SOURCE_NEWS;
|
|
|
|
$newsModel = new News();
|
|
|
|
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $newsInfo['url'];
|
|
|
|
}else{
|
|
|
|
$type = 'all';
|
|
|
|
$route = 'all';
|
|
|
|
}
|
|
|
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
$type = RouteMap::SOURCE_MODULE;
|
|
|
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
|
|
|
}
|
|
|
|
$this->addUpdateNotify($type,$route);
|
|
|
|
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
|
...
|
...
|
@@ -470,15 +458,15 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :字符串处理
|
|
|
|
* @name :StringProcessing
|
|
|
|
* @remark :保存时字符串处理
|
|
|
|
* @name :handleSaveParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function stringProcessing($param){
|
|
|
|
public function handleSaveParam($param){
|
|
|
|
//字符串截取
|
|
|
|
$param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
|
|
$param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
...
|
...
|
@@ -486,6 +474,9 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
$param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
$param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
|
|
|
if(!isset($param['is_custom'])){
|
|
|
|
$param['is_custom'] = 0;
|
|
|
|
}
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -581,7 +572,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$this->param['test_model'] = 2;//未审核模版
|
|
|
|
$this->param['operator_id'] = $this->user['manager_id'] ?? 0;
|
|
|
|
$this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
$publicTemplateModel = new Template();
|
|
|
|
$rs = $publicTemplateModel->add($this->param);
|
|
|
|
if($rs === false){
|
...
|
...
|
|