|
...
|
...
|
@@ -57,10 +57,9 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @time :2023/11/15 11:30
|
|
|
|
*/
|
|
|
|
public function getHtml(){
|
|
|
|
//查询可视化是否第一次保存
|
|
|
|
$TemplateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
$page_array = $this->user['is_visualization']['page_array'];
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
if(in_array($type,$page_array)){//定制页面
|
|
|
|
$info = $this->model->read(['source'=>$type],['html','source','id','project_id']);
|
|
...
|
...
|
@@ -74,15 +73,19 @@ class VisualizationLogic extends BaseLogic |
|
|
|
if($settingInfo === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
//获取公共头部底部
|
|
|
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
|
|
if($commonInfo === false){
|
|
|
|
//保存一次首页头部底部
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$aTemplateInfo = $ATemplateModel->read(['id'=>$settingInfo['template_id']]);
|
|
|
|
//截取链接部分
|
|
|
|
$other = str_replace('<header','',characterTruncation($aTemplateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
|
|
|
|
$commonInfo = $this->saveHomeHeaderFooter($settingInfo['template_id'],$aTemplateInfo);
|
|
|
|
}
|
|
|
|
//根据类型在获取中间部分
|
|
|
|
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
|
|
|
|
//拼接数据
|
|
|
|
$html = $aTemplateInfo['head_css'].$mainData['main_css'].$aTemplateInfo['footer_css'].$other.
|
|
|
|
$aTemplateInfo['head_html'].$mainData['main_html'].$aTemplateInfo['footer_html'];
|
|
|
|
$html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}else{
|
|
...
|
...
|
@@ -172,7 +175,6 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @time :2023/11/15 11:47
|
|
|
|
*/
|
|
|
|
public function saveHtml(){
|
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(11111, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
if(in_array($type,$page_array)){//定制页面
|
|
...
|
...
|
@@ -192,6 +194,8 @@ class VisualizationLogic extends BaseLogic |
|
|
|
]);
|
|
|
|
$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->saveCommonTemplate($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
if($templateInfo === false){
|
|
...
|
...
|
@@ -214,19 +218,19 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($param){
|
|
|
|
$type = $this->getSaveType($param['source'],$param['source_id']);
|
|
|
|
public function saveCommonTemplate($html,$source,$source_id,$template_id){
|
|
|
|
$type = $this->getSaveType($source,$source_id);
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'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'),
|
|
|
|
];
|
|
|
|
$other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
|
|
|
|
$other = str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s"));
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['template_id'];
|
|
|
|
$data['template_id'] = $template_id;
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $type;
|
|
|
|
$templateCommonModel->add($data);
|
|
...
|
...
|
@@ -239,49 +243,6 @@ class VisualizationLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :字符串处理
|
|
|
|
* @name :StringProcessing
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function stringProcessing($param){
|
|
|
|
//字符串截取
|
|
|
|
$param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
|
|
$param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$param['footer_html'] = characterTruncation($param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s');
|
|
|
|
$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');
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存首页头部底部信息
|
|
|
|
* @name :saveHomeHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:14
|
|
|
|
*/
|
|
|
|
public function saveHomeHeaderFooter($template_id,$aTemplateInfo){
|
|
|
|
$data = [
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($aTemplateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
'head_html'=>$aTemplateInfo['head_html'],
|
|
|
|
'footer_html'=>$aTemplateInfo['footer_html'],
|
|
|
|
'head_css'=>$aTemplateInfo['head_css'],
|
|
|
|
'footer_css'=>$aTemplateInfo['footer_css'],
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>1,
|
|
|
|
];
|
|
|
|
//保存首页头部信息
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
//查询头部是否存在
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取中间公共部分
|
|
|
|
* @name :getCommonMain
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -359,4 +320,28 @@ class VisualizationLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $commonInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存首页头部底部信息
|
|
|
|
* @name :saveHomeHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:14
|
|
|
|
*/
|
|
|
|
public function saveHomeHeaderFooter($template_id,$aTemplateInfo){
|
|
|
|
$data = [
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($aTemplateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
'head_html'=>$aTemplateInfo['head_html'],
|
|
|
|
'footer_html'=>$aTemplateInfo['footer_html'],
|
|
|
|
'head_css'=>$aTemplateInfo['head_css'],
|
|
|
|
'footer_css'=>$aTemplateInfo['footer_css'],
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>1,
|
|
|
|
];
|
|
|
|
//保存首页头部信息
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|