|
...
|
...
|
@@ -324,7 +324,10 @@ class VisualizationLogic extends BaseLogic |
|
|
|
if(in_array($type,$page_array)){//定制页面
|
|
|
|
$this->saveVisualizationHtml($type);
|
|
|
|
}else{
|
|
|
|
$this->saveTemplateHtml();
|
|
|
|
if(!isset($this->param['is_custom'])){
|
|
|
|
$this->param['is_custom'] = 0;
|
|
|
|
}
|
|
|
|
$this->saveTemplateHtml($this->param);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
...
|
...
|
@@ -397,26 +400,27 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 15:44
|
|
|
|
*/
|
|
|
|
public function saveTemplateHtml(){
|
|
|
|
public function saveTemplateHtml($param){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'source'=>$param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
'template_id'=>$this->param['template_id'],
|
|
|
|
'source_id'=>$param['source_id'],
|
|
|
|
'template_id'=>$param['template_id'],
|
|
|
|
'is_custom'=>$param['is_custom']
|
|
|
|
]);
|
|
|
|
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
$this->param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$this->param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
//保存头部
|
|
|
|
$this->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
|
|
|
$this->saveCommonTemplate($param['html'],$param['source'],$param['source_id'],$param['template_id']);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($this->param);
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($param);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
|
|
$bTemplateModel->edit($param,['source'=>$param['source'],'source_id'=>$param['source_id'],'is_custom'=>$param['is_custom']]);
|
|
|
|
}
|
|
|
|
$this->setTemplateLog($this->param['template_id'],$this->param['html'],$this->param['source'],$this->param['source_id']);
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
|
|
|
|
$this->setTemplateLog($param['template_id'],$param['html'],$param['source'],$param['source_id'],$param['is_custom']);
|
|
|
|
$this->homeOrProduct($param['source'],$param['source_id'],$param['is_custom']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -426,33 +430,24 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/31 16:05
|
|
|
|
*/
|
|
|
|
public function homeOrProduct($source,$source_id = ''){
|
|
|
|
public function homeOrProduct($source,$source_id = '',$is_custom = 0){
|
|
|
|
if($is_custom == 0){
|
|
|
|
if($source == BTemplate::SOURCE_HOME){
|
|
|
|
$type = 'index';
|
|
|
|
$route = '';
|
|
|
|
//路由映射
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
//其他界面通知更新
|
|
|
|
if($source == 2 && $source_id != 0){
|
|
|
|
$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]);
|
|
...
|
...
|
@@ -465,7 +460,7 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/23 11:16
|
|
|
|
*/
|
|
|
|
public function setTemplateLog($template_id,$html,$source,$source_id){
|
|
|
|
public function setTemplateLog($template_id,$html,$source,$source_id,$is_custom){
|
|
|
|
$data = [
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
...
|
...
|
@@ -479,6 +474,7 @@ class VisualizationLogic extends BaseLogic |
|
|
|
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
'is_custom'=>$is_custom
|
|
|
|
];
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
...
|
...
|
|