|
...
|
...
|
@@ -62,8 +62,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 9:44
|
|
|
|
*/
|
|
|
|
public function getTemplate(){
|
|
|
|
$settingInfo = $this->getSettingTemplate();//模版详情
|
|
|
|
$data = $this->getHtml($settingInfo,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
|
|
|
|
$template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id
|
|
|
|
$data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -74,14 +74,12 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:47
|
|
|
|
*/
|
|
|
|
public function getHtml($settingInfo,$source,$source_id,$is_custom = 0){
|
|
|
|
$templateInfo = $this->webTemplateInfo($settingInfo['template_id'],$source,$source_id,$is_custom);
|
|
|
|
public function getHtml($template_id,$source,$source_id,$is_custom){
|
|
|
|
$templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$result = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制
|
|
|
|
if($result !== true){
|
|
|
|
return ['html'=>$result['html'],'template_id'=>$result['template_id']];
|
|
|
|
}
|
|
|
|
$html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
$mainInfo = $this->getCommonMain($source,$source_id);//获取中间部分代码
|
|
|
|
}else{
|
|
...
|
...
|
@@ -91,13 +89,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型
|
|
|
|
$commonInfo = $this->getCommonPage(['template_id'=>0,'project_id'=>$this->user['project_id'],'type'=>$type]);//获取定制头部
|
|
|
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonPage($source,$source_id,$settingInfo['template_id']);//获取头部
|
|
|
|
$commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部
|
|
|
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
return ['html'=>$html,'template_id'=>$settingInfo['template_id']];
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -134,7 +132,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
}
|
|
|
|
return ['html'=>$customHtmlInfo['html']];
|
|
|
|
return $customHtmlInfo['html'];
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
...
|
...
|
@@ -167,13 +165,21 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:48
|
|
|
|
*/
|
|
|
|
public function getSettingTemplate(){
|
|
|
|
public function getSettingTemplate($source,$source_id){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
|
|
|
|
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//是定制界面
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
return $info;
|
|
|
|
return $info['template_id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -390,7 +396,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
*/
|
|
|
|
public function saveCommonHtml($html,$source,$source_id,$template_id){
|
|
|
|
$type = $this->getType($source,$source_id);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
$type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
|
|
|
$handleInfo = $this->handleCommonParam($html);
|
|
...
|
...
|
@@ -465,8 +471,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($source,$source_id){
|
|
|
|
public function getType($source,$source_id,$template_id){
|
|
|
|
$type = 1;//首页公共头部底部
|
|
|
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
|
|
|
$this->user['configuration']['is_head'] == 1;
|
|
|
|
}
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
...
|
...
|
@@ -500,8 +509,16 @@ class BTemplateLogic extends BaseLogic |
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>$is_custom,
|
|
|
|
'source'=>$source,
|
|
|
|
'source_id'=>$source_id
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
$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);
|
|
|
|
$bTemplateLogModel = new BTemplateLog();
|
|
|
|
return $bTemplateLogModel->add($data);
|
|
|
|
}
|
...
|
...
|
|