|
...
|
...
|
@@ -25,7 +25,7 @@ class VisualizationLogic extends BaseLogic |
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->model = new Visualization();
|
|
|
|
$this->model = new BTemplateMain();
|
|
|
|
$this->param = $this->requestAll;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -38,11 +38,36 @@ class VisualizationLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function saveVisualization(){
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->model->add($this->param);
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
$typeArray = [1,3,5,7];//单页数据
|
|
|
|
if(in_array($type,$typeArray)){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read(['source'=>$this->param['source'],'template_id'=>0]);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$data = [
|
|
|
|
'html'=>$this->param['html'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
'section_list_id'=>$this->param['section_list_id'],
|
|
|
|
];
|
|
|
|
$bTemplateModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit(['html'=>$this->param['html']],['id'=>$templateInfo['id']]);
|
|
|
|
}
|
|
|
|
}else{//模块数据
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$mainData = [
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'type'=>$type,
|
|
|
|
'main_html'=>$this->param['html']
|
|
|
|
];
|
|
|
|
$bTemplateMainModel->add($mainData);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
...
|
...
|
@@ -58,54 +83,51 @@ 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 = (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']);
|
|
|
|
if($info === false){
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);//获取类型
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取定制界面
|
|
|
|
//查看当前类型是否是定制界面
|
|
|
|
if(in_array($type,$page_array)){//是定制界面
|
|
|
|
if(in_array($type,[1,3,5,7])){//单页
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->fail('请先上传定制代码块');
|
|
|
|
}
|
|
|
|
return $info['html'];
|
|
|
|
}else{//非定制界面
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
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']]);
|
|
|
|
$commonInfo = $this->saveHomeHeaderFooter($settingInfo['template_id'],$aTemplateInfo);
|
|
|
|
return ['html'=>$templateInfo['html']];
|
|
|
|
}else{//模块页
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前页面是否可视化
|
|
|
|
if($templateInfo === false){//获取代码块
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$this->fail('请先上传定制代码块');
|
|
|
|
}
|
|
|
|
return ['html'=>$mainInfo['main_html']];
|
|
|
|
}
|
|
|
|
return ['html'=>$templateInfo['html']];
|
|
|
|
}
|
|
|
|
}else{//非定制界面
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($settingInfo === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);//查看当前页面是否可视化
|
|
|
|
if($templateInfo === false){
|
|
|
|
//根据类型在获取中间部分
|
|
|
|
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
|
|
|
|
//拼接数据
|
|
|
|
$html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if($TemplateInfo['template_id'] != 0){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($settingInfo === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
//获取头部信息
|
|
|
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
|
|
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
}else{
|
|
|
|
return $TemplateInfo['html'];
|
|
|
|
$mainData = [
|
|
|
|
'main_html'=>$templateInfo['main_html'],
|
|
|
|
'main_css'=>$templateInfo['main_css']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
//获取公共头部底部
|
|
|
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
|
|
//拼接数据
|
|
|
|
$html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -139,14 +161,16 @@ class VisualizationLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:21
|
|
|
|
*/
|
|
|
|
public function getWebTemplate($source,$source_id){
|
|
|
|
public function getWebTemplate($source,$source_id,$template_id = 0){
|
|
|
|
//查询可视化是否第一次保存
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
return $bTemplateModel->read([
|
|
|
|
$param = [
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
]);
|
|
|
|
'template_id'=>$template_id
|
|
|
|
];
|
|
|
|
return $bTemplateModel->read($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -203,36 +227,43 @@ class VisualizationLogic extends BaseLogic |
|
|
|
public function saveHtml(){
|
|
|
|
$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)){//定制页面
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
]);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
'template_id'=>$this->param['template_id'],
|
|
|
|
]);
|
|
|
|
$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){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($this->param);
|
|
|
|
if(in_array($type,$page_array)){//定制页面
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
]);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($this->param);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit(['html'=>$this->param['html']],['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
'template_id'=>$this->param['template_id'],
|
|
|
|
]);
|
|
|
|
$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']);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($this->param);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit($this->param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误请联系管理员');
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success();
|
|
|
|
|
|
|
|
}
|
|
...
|
...
|
@@ -282,8 +313,7 @@ class VisualizationLogic extends BaseLogic |
|
|
|
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
|
|
|
|
if ($source == 5) {$type = 8;}
|
|
|
|
//查询有没有公共详情模板
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$mainInfo = $this->model->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['main_html'] = $this->getModule($type);
|
|
|
|
$data['main_css'] = "<style id='globalsojs-styles'></style>";
|
...
|
...
|
|