|
...
|
...
|
@@ -13,6 +13,7 @@ use App\Http\Logic\Bside\BaseLogic; |
|
|
|
use App\Models\Project\PageSetting;
|
|
|
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Models\Template\BTemplateCom;
|
|
|
|
use App\Models\Template\BTemplateCommon;
|
|
|
|
use App\Models\Template\BTemplateLog;
|
|
|
|
use App\Models\Template\Setting;
|
|
...
|
...
|
@@ -64,13 +65,18 @@ class BTemplateLogLogic extends BaseLogic |
|
|
|
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
|
|
|
|
//TODO::还原头部+底部
|
|
|
|
$bTemplateModel->edit(['html'=>$info['text']],$condition);
|
|
|
|
$commonData = [
|
|
|
|
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],
|
|
|
|
'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
|
|
|
|
];
|
|
|
|
$type = $this->getCustomizedType($info['source'],$info['is_list']);
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
|
|
|
|
$commonTemplateModel = new BTemplateCom();
|
|
|
|
//还原头部
|
|
|
|
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],
|
|
|
|
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']];
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_HEAD;
|
|
|
|
$commonTemplateModel->edit(['html'=>$info['head_html'], 'html_style'=>$info['head_css']],$condition);
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_FOOTER;
|
|
|
|
$commonTemplateModel->edit(['html'=>$info['footer_html'], 'html_style'=>$info['footer_css']],$condition);
|
|
|
|
$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);
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_OTHER;
|
|
|
|
$commonTemplateModel->edit(['html'=>$other, 'html_style'=>''],$condition);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -99,18 +105,9 @@ class BTemplateLogLogic extends BaseLogic |
|
|
|
$bTemplateModel->edit($data,$condition);
|
|
|
|
//还原头部+底部
|
|
|
|
$commonData = [
|
|
|
|
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
|
|
|
|
'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_style'=>$info['footer_css'],'other'=>$info['other']
|
|
|
|
];
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);
|
|
|
|
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$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'],'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'],'type'=>$type]);
|
|
|
|
}
|
|
|
|
$this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
...
|
...
|
@@ -118,36 +115,40 @@ class BTemplateLogLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
* @name :getType
|
|
|
|
* @remark :保存公共部分(头部。底部。连接部分)
|
|
|
|
* @name :saveTemplateCom
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:20
|
|
|
|
* @time :2024/4/29 10:32
|
|
|
|
*/
|
|
|
|
public function getCustomizedType($source,$is_list){
|
|
|
|
$type = BTemplate::TYPE_HOME;
|
|
|
|
if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){
|
|
|
|
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
|
|
|
|
$templateComModel = new BTemplateCom();
|
|
|
|
foreach ($typeArr as $type){
|
|
|
|
if($type == BTemplate::COMMON_HEAD){
|
|
|
|
$param['html'] = $handleInfo['head_html'];
|
|
|
|
$param['html_style'] = $handleInfo['head_style'];
|
|
|
|
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
|
|
|
|
}elseif ($type == BTemplate::COMMON_FOOTER){
|
|
|
|
$param['html'] = $handleInfo['footer_html'];
|
|
|
|
$param['html_style'] = $handleInfo['footer_style'];
|
|
|
|
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
$param['html'] = $handleInfo['other'];
|
|
|
|
$param['html_style'] = null;
|
|
|
|
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
//查看当前数据是否还存在
|
|
|
|
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
|
|
|
|
$info = $templateComModel->read($condition);
|
|
|
|
if($info === false){
|
|
|
|
$data = array_merge($param,$condition);
|
|
|
|
$templateComModel->add($data);
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
$templateComModel->edit($param,$condition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -157,27 +158,30 @@ class BTemplateLogLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($source,$is_list,$is_custom = 0){
|
|
|
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$CommonType = BTemplate::COMMON_HEAD,$template_id = 0){
|
|
|
|
if($template_id == 0){//定制全为独立头部和底部
|
|
|
|
$type = $source;
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
$type = BTemplate::SOURCE_COM;//公共头部底部
|
|
|
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM || $is_head == BTemplate::IS_NO_HEADER){//拓展模块为首页头部
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo === false) {
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id'],'type'=>$CommonType]);
|
|
|
|
if ($pageInfo === false) {
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_HOME){if ($pageInfo['home'] != 0){$type = BTemplate::SOURCE_HOME;}}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}
|
|
|
|
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::SOURCE_PRODUCT;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::SOURCE_BLOG;}}
|
|
|
|
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::SOURCE_BLOG;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::SOURCE_NEWS;}}
|
|
|
|
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::SOURCE_NEWS;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|