|
...
|
...
|
@@ -63,7 +63,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function getTemplate(){
|
|
|
|
$settingInfo = $this->getSettingTemplate();//模版详情
|
|
|
|
$data = $this->getTemplateHtml($settingInfo,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
|
|
|
|
$data = $this->getHtml($settingInfo,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -74,7 +74,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:47
|
|
|
|
*/
|
|
|
|
public function getTemplateHtml($settingInfo,$source,$source_id,$is_custom = 0){
|
|
|
|
public function getHtml($settingInfo,$source,$source_id,$is_custom = 0){
|
|
|
|
$templateInfo = $this->webTemplateInfo($settingInfo['template_id'],$source,$source_id,$is_custom);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
...
|
...
|
@@ -327,6 +327,56 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :可视化保存html
|
|
|
|
* @name :saveHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 17:02
|
|
|
|
*/
|
|
|
|
public function saveHtml($html,$source,$source_id,$template_id = 0,$is_custom = 0){
|
|
|
|
$this->saveCommonHtml($html,$source,$source_id,$template_id);//保存头部底部
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$source,$source_id,$is_custom);
|
|
|
|
if($info === false){
|
|
|
|
$data = [];
|
|
|
|
$this->model->add($data);
|
|
|
|
}else{
|
|
|
|
$data = [];
|
|
|
|
$this->model->edit($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存公共头部底部
|
|
|
|
* @name :saveCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
*/
|
|
|
|
public function saveCommonHtml($html,$source,$source_id,$template_id){
|
|
|
|
$type = $this->getType($source,$source_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);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
];
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
|
|
|
|
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
|
|
|
|
];
|
|
|
|
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
|
|
|
|
}
|
|
|
|
//更新所有界面的other
|
|
|
|
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :演示项目不允许修改首页
|
|
|
|
* @name :showProject
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -397,6 +447,24 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存时字符串处理
|
|
|
|
* @name :handleSaveParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function handleCommonParam($html){
|
|
|
|
//字符串截取
|
|
|
|
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
|
|
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
|
|
|
|
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取设置的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
...
|
...
|
|