|
...
|
...
|
@@ -15,12 +15,15 @@ use App\Models\Project\PageSetting; |
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
use App\Models\Template\BTemplateCom;
|
|
|
|
use App\Models\Template\BTemplateCommon;
|
|
|
|
use App\Models\Template\BTemplateMain;
|
|
|
|
use App\Models\Template\Setting;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Models\Template\BTemplateLog;
|
|
|
|
use App\Models\Template\Template;
|
|
|
|
use App\Models\Template\TemplateReplaceHtml;
|
|
|
|
use App\Models\Template\TemplateReplaceHtmlLog;
|
|
|
|
use App\Models\Template\TemplateTypeMain;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
...
|
...
|
@@ -68,11 +71,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
|
|
|
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
|
|
|
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($templateInfo === false){//todo::无装修数据处理
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
if($html !== false){
|
|
|
|
return $this->success($html);
|
|
|
|
$data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
if($data !== false){
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//非定制初始中间部分
|
|
...
|
...
|
@@ -83,15 +86,87 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
|
|
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
$commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部
|
|
|
|
$html = $commonInfo['head_style'].$mainInfo['main_css'].$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
$result = ['html'=>$html,'template_id'=>$template_id];
|
|
|
|
if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
|
|
|
|
if($templateInfo !== false) {
|
|
|
|
$result['id'] = $templateInfo['id'];
|
|
|
|
$result['updated_at'] = $templateInfo['updated_at'];
|
|
|
|
}
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :非定制获取头部+底部
|
|
|
|
* @name :getTemplateComHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/29 16:53
|
|
|
|
*/
|
|
|
|
public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
|
|
|
|
$condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
|
|
|
|
$headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
|
|
|
|
$bTemplateComModel = new BTemplateCom();
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_OTHER;
|
|
|
|
$condition['source'] = $headComInfo['source'];
|
|
|
|
$otherInfo = $bTemplateComModel->read($condition);
|
|
|
|
if($otherInfo === false){
|
|
|
|
$this->fail('获取失败,请联系管理员');
|
|
|
|
}
|
|
|
|
$footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
|
|
|
|
$data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
|
|
|
|
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :公共头部
|
|
|
|
* @name :HeadComHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/29 17:20
|
|
|
|
*/
|
|
|
|
public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
|
|
|
|
$commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
|
|
|
|
$bTemplateComModel = new BTemplateCom();
|
|
|
|
$condition['source'] = $commonHead;
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_HEAD;
|
|
|
|
$headComInfo = $bTemplateComModel->read($condition);
|
|
|
|
if($headComInfo === false){
|
|
|
|
//取默认公共的
|
|
|
|
$condition['source'] = BTemplate::SOURCE_COM;
|
|
|
|
$headComInfo = $bTemplateComModel->read($condition);
|
|
|
|
if($headComInfo === false){
|
|
|
|
$this->fail('获取失败,请联系管理员');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($headComInfo);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @remark :公共底部
|
|
|
|
* @name :footerComHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/4/29 17:18
|
|
|
|
*/
|
|
|
|
public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
|
|
|
|
$bTemplateComModel = new BTemplateCom();
|
|
|
|
$condition['common_type'] = BTemplate::COMMON_FOOTER;
|
|
|
|
$condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
|
|
|
|
$footerComInfo = $bTemplateComModel->read($condition);
|
|
|
|
if($footerComInfo === false){
|
|
|
|
//取默认首页的
|
|
|
|
$condition['source'] = BTemplate::SOURCE_COM;
|
|
|
|
$footerComInfo = $bTemplateComModel->read($condition);
|
|
|
|
if($footerComInfo === false){
|
|
|
|
$this->fail('获取失败,请联系管理员');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($footerComInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取整个html代码
|
|
|
|
* @name :getCustomizeAllHtml
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -100,11 +175,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
|
|
|
|
$commonInfo = $this->getCustomizeTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部
|
|
|
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
}else{
|
|
|
|
$type = $this->getCustomizedType($this->param['source'],$is_list);
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
|
|
|
$type = $this->getCustomizedType($templateInfo['source'],$is_list);
|
|
|
|
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
|
|
|
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
}
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
|
...
|
...
|
@@ -174,7 +249,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
|
|
|
|
$commonInfo = $this->getCustomizeTemplateComHtml($source,$is_custom,$is_list);//获取定制头部
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
|
|
}
|
|
...
|
...
|
@@ -254,7 +329,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
|
|
|
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
|
|
}
|
|
...
|
...
|
@@ -263,6 +338,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制项目获取头部底部
|
|
|
|
* @name :getCustomizedCommonHtml
|
|
...
|
...
|
@@ -270,49 +346,25 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/29 13:13
|
|
|
|
*/
|
|
|
|
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
|
|
|
|
$data = [
|
|
|
|
'template_id' => 0,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>$is_custom,
|
|
|
|
'is_list'=>$is_list
|
|
|
|
];
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
return $commonTemplateModel->read($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制页面头部类型---根据source获取type类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:20
|
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
|
|
|
|
$data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
|
|
|
|
$param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
|
|
|
|
$commonTemplateModel = new BTemplateCom();
|
|
|
|
$commonList = $commonTemplateModel->list($param);
|
|
|
|
if(!empty($commonList)){
|
|
|
|
foreach ($commonList as $v){
|
|
|
|
if($v['common_type'] == BTemplate::COMMON_HEAD){
|
|
|
|
$data['head_html'] = $v['html'];
|
|
|
|
$data['head_style'] = $v['html_style'];
|
|
|
|
}elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
|
|
|
|
$data['footer_html'] = $v['html'];
|
|
|
|
$data['footer_style'] = $v['html_style'];
|
|
|
|
}else{
|
|
|
|
$data['other'] = $v['html'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -351,38 +403,10 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$template_id = $info['template_id'];
|
|
|
|
return $this->success($template_id);
|
|
|
|
return $this->success($info['template_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据类型获取公共头和底
|
|
|
|
* @name :getCommonPage
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 16:55
|
|
|
|
*/
|
|
|
|
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
|
|
|
|
$type = $this->getType($source,$is_list,$is_custom);
|
|
|
|
$data = [
|
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>0,
|
|
|
|
];
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read($data);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$data['type'] = BTemplate::SOURCE_HOME;
|
|
|
|
$commonInfo = $commonTemplateModel->read($data);
|
|
|
|
}
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存修改后的模版
|
|
|
|
* @name :templateSave
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -409,14 +433,12 @@ class BTemplateLogic extends BaseLogic |
|
|
|
'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
|
|
|
|
'is_list'=>$this->param['is_list']
|
|
|
|
];
|
|
|
|
$data = [
|
|
|
|
'section_list_id'=>$this->param['section_list_id']
|
|
|
|
];
|
|
|
|
$data = ['section_list_id'=>$this->param['section_list_id']];
|
|
|
|
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
|
|
|
|
$this->model->edit($data,$condition);
|
|
|
|
}
|
|
|
|
//更新头部信息
|
|
|
|
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
|
|
|
|
$this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']);
|
|
|
|
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
|
|
//通知更新
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
...
|
...
|
@@ -446,119 +468,70 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/12/15 10:59
|
|
|
|
*/
|
|
|
|
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
|
|
|
|
//TODO::扩展模块定制单独处理
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
}
|
|
|
|
//todo::扩展模块(列表页/详情页)定制
|
|
|
|
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
$data['html'] = $html;
|
|
|
|
$data['type'] = BTemplate::ALL_HTML;
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){
|
|
|
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
if(in_array($type, $page_array)){
|
|
|
|
$data['html'] = $html;
|
|
|
|
$data['type'] = BTemplate::ALL_HTML;
|
|
|
|
}else{
|
|
|
|
//TODO::扩展模块定制单独处理
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
}
|
|
|
|
//todo::扩展模块(列表页/详情页)定制
|
|
|
|
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
$data['html'] = $html;
|
|
|
|
$data['type'] = BTemplate::ALL_HTML;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
$data['main_html'] = $mainInfo['main_html'];
|
|
|
|
$data['main_css'] = $mainInfo['main_css'];
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
$data['main_html'] = $mainInfo['main_html'];
|
|
|
|
$data['main_css'] = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
$data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存公共头部底部
|
|
|
|
* @name :saveCommonHtml
|
|
|
|
* @remark :保存公共部分(头部。底部。连接部分)
|
|
|
|
* @name :saveTemplateCom
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
* @time :2024/4/29 10:32
|
|
|
|
*/
|
|
|
|
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
|
|
|
|
//TODO::定制扩展模块单独处理
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);
|
|
|
|
if($code === false){
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//其他情况
|
|
|
|
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
if($template_id == 0){//定制页面默认为独立头部
|
|
|
|
$type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
|
|
|
|
}
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在
|
|
|
|
public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
|
|
|
|
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
|
|
|
|
$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
|
|
|
|
if($template_id != 0){
|
|
|
|
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :扩展模块定制保存头部处理
|
|
|
|
* @name :saveCustomModuleCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/10 11:33
|
|
|
|
*/
|
|
|
|
public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
}
|
|
|
|
//todo::扩展模块(列表页/详情页)定制
|
|
|
|
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
|
|
|
|
$data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在
|
|
|
|
$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'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
|
|
|
|
'is_custom'=>$is_custom,'is_list'=>$is_list,
|
|
|
|
];
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
$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{
|
|
|
|
$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']]);
|
|
|
|
$param['html'] = $handleInfo['other'];
|
|
|
|
$param['html_style'] = null;
|
|
|
|
$typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
|
|
|
|
}
|
|
|
|
//查看当前数据是否还存在
|
|
|
|
$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{
|
|
|
|
$templateComModel->edit($param,$condition);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -587,55 +560,43 @@ class BTemplateLogic extends BaseLogic |
|
|
|
//字符串截取
|
|
|
|
$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');
|
|
|
|
$param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
$param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($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 :handleSaveParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function handleTemplateHtml($html){
|
|
|
|
//字符串截取
|
|
|
|
$param['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :(非定制)保存时获取获取设置的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @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){
|
|
|
|
return $this->success($source);
|
|
|
|
}
|
|
|
|
$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::SOURCE_KEYWORD;}}
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|