|
...
|
...
|
@@ -105,7 +105,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
}else{
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
...
|
...
|
@@ -134,27 +134,21 @@ class BTemplateLogic extends BaseLogic |
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
|
|
|
|
}
|
|
|
|
$main_html = "<main>{$this->getProductModule()}</main>";
|
|
|
|
$main_style = "<style id='globalsojs-styles'></style>";
|
|
|
|
}else{
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
|
|
|
|
}
|
|
|
|
$main_html = $TemplateInfo['main_html'];
|
|
|
|
$main_style = $TemplateInfo['main_css'];
|
|
|
|
}
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>$source]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html);
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($TemplateInfo);
|
|
...
|
...
|
@@ -231,8 +225,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($param){
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$param['source']]);
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
...
|
...
|
@@ -243,6 +236,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['template_id'];
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $param['source'];
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
...
|
...
|
|