作者 lyh

gx

... ... @@ -39,38 +39,41 @@ class BTemplateLogLogic extends BaseLogic
$this->fail('error');
}
$bTemplateModel = new BTemplate();
if($info['template_id'] == 0){//定制项目
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
return $this->success();
}
//演示项目,不允许其他号码编辑
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$bTemplateModel->mobile)) && ($info['source'] == 1)){
$this->fail('演示项目仅支持演示功能,无法更改首页');
}
//获取当前项目的模版
if($info['template_id'] == 0){//todo::定制项目
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
return $this->success();
}
//TODO::非定制项目,获取当前项目的模版
$bSettingModel = new Setting();
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($settingInfo === false){
$this->fail('请先选择模版');
}
try {
//切换模版
if($info['template_id'] != $settingInfo['template_id']){
$bSettingModel->edit(['template_id'=>$info['template_id']],['id'=>$settingInfo['id']]);
}
try {
$data = $this->setParam($info);
$bTemplateModel->edit($data,['template_id'=>$info['template_id'],'source'=>$info['source'],'source_id'=>$info['source_id']]);
//还原头部+底部
$commonData = $this->setCommonParam($info);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>1,'project_id'=>$this->user['project_id']]);
//更新所有界面的other
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$info['type'],'project_id'=>$this->user['project_id']]);
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}else{
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id']]);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
... ...