作者 lyh

gx

... ... @@ -199,10 +199,10 @@ class BTemplateLogic extends BaseLogic
*/
public function getCommonMain($source,$source_id){
$data = [];
if ($source == 2) {if ($source_id != 0) {$type = 2;} else {$type = 3;}}
if ($source == 3) {if ($source_id != 0) {$type = 4;} else {$type = 5;}}
if ($source == 4) {if ($source_id != 0) {$type = 6;} else {$type = 7;}}
if ($source == 5) {$type = 8;}
if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}
if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}
if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}
if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;}
//查询有没有公共详情模板
$bTemplateMainModel = new BTemplateMain();
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
... ... @@ -234,23 +234,23 @@ class BTemplateLogic extends BaseLogic
'template_id' => $template_id,
'project_id' => $this->user['project_id']
];
if ($source == 2) {//产品页
if($source_id != 0){$data['type'] = 2;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 3;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 3) {//博客页
if ($source_id != 0) {$data['type'] = 4;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 5;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 4) {//新闻页
if ($source_id != 0) {$data['type'] = 6;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = 7;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == 5) {//聚合页
$data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_BLOG) {//博客页
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_NEWS) {//新闻页
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
$data['type'] = BTemplate::TYPE_EIGHT;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
}
}
//获取首页公共的头部和底部
if(!isset($commonInfo) || $commonInfo === false){
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]);
}
return $commonInfo;
}
... ... @@ -269,13 +269,8 @@ class BTemplateLogic extends BaseLogic
try {
//字符串截取
$this->param = $this->stringProcessing($this->param);
//自定义模块单独处理
if(isset($this->param['is_custom']) && ($this->param['is_custom'] == 1)){
$this->customSaveTemplateHtml($this->param);
}else{
$this->saveTemplateHtml($this->param);
$this->setTemplateLog($this->param);
}
$this->saveTemplateHtml($this->param);
$this->setTemplateLog($this->param);
DB::commit();
}catch (\Exception $e){
DB::rollBack();
... ... @@ -287,17 +282,6 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :自定义模块保存
* @name :customSaveTemplateHtml
* @author :lyh
* @method :post
* @time :2023/12/12 11:41
*/
public function customSaveTemplateHtml(){
}
/**
* @remark :演示项目不允许修改首页
* @name :showProject
* @author :lyh
... ... @@ -320,9 +304,14 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/12 10:23
*/
public function saveTemplateHtml($param){
$info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id']);
//保存头部信息
$this->saveCommonTemplate($param);
//自定义模块
if(!isset($param['is_custom']) || empty($param['is_custom'])){
$param['is_custom'] = 0;
}
$info = $this->webTemplateInfo($this->param['template_id'],$param['source'],$param['source_id'],$param['is_custom']);
if($param['is_custom'] != 0){//TODO::自定义默认默认取首页的头部底部
$this->saveCommonTemplate($param);
}
$param['project_id'] = $this->user['project_id'];
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
if($info === false){
... ... @@ -409,6 +398,7 @@ class BTemplateLogic extends BaseLogic
'main_css'=>$param['main_css'],
'footer_html'=>$param['footer_html'],
'footer_css'=>$param['footer_css'],
'is_custom'=>$param['is_custom'] ?? 0
];
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
... ...
... ... @@ -21,8 +21,8 @@ class BTemplate extends Base
const SOURCE_CUSTOM = 1;//自定义模块
const STATUS = 0;
const TYPE_ONE = 1;
const TYPE_TWO = 2;
const TYPE_ONE = 1;//首页类型
const TYPE_TWO = 2;//
const TYPE_THREE = 3;
const TYPE_FOUR = 4;
const TYPE_FIVE = 5;
... ...