|
...
|
...
|
@@ -73,20 +73,23 @@ class BTemplateLogic extends BaseLogic |
|
|
|
'is_custom'=>$is_custom, 'is_list'=>$is_list
|
|
|
|
]);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$html = $this->isCustomizedPage($this->param['source'],$is_list);//获取定制页面的html
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
if(!empty($html)){
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$mainInfo = $this->getMAinHtml($this->param['source'],$is_custom,$is_list);//获取中间部分代码
|
|
|
|
}else{
|
|
|
|
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
|
|
|
|
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,0);//获取定制头部
|
|
|
|
$type = $this->getCustomizedType($this->param['source'],$is_list);
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
|
|
|
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
|
|
|
|
}
|
|
|
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id);//获取定制头部
|
|
|
|
$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'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
...
|
...
|
@@ -128,8 +131,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/7/27 15:08
|
|
|
|
*/
|
|
|
|
public function getInitModule($type,$is_custom,$is_list){
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM) {
|
|
|
|
$type = BTemplate::TYPE_CUSTOM;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM) {
|
|
|
|
$type = BTemplate::SOURCE_CUSTOM;
|
|
|
|
}
|
|
|
|
$mainModel = new TemplateTypeMain();
|
|
|
|
$info = $mainModel->read(['type'=>$type,'is_list'=>$is_list]);
|
|
...
|
...
|
@@ -172,7 +175,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonHtml($type,$is_list,0);//获取定制头部
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($type);//获取定制头部
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
|
|
|
|
}
|
|
...
|
...
|
@@ -182,33 +185,50 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据source获取type类型
|
|
|
|
* @remark :定制项目获取头部底部
|
|
|
|
* @name :getCustomizedCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/29 13:13
|
|
|
|
*/
|
|
|
|
public function getCustomizedCommonHtml($type){
|
|
|
|
$data = [
|
|
|
|
'template_id' => 0,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type'=>$type
|
|
|
|
];
|
|
|
|
$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_ONE;
|
|
|
|
$type = BTemplate::TYPE_HOME;
|
|
|
|
if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_THREE;
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_TWO;
|
|
|
|
$type = BTemplate::TYPE_PRODUCT_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_FIVE;
|
|
|
|
$type = BTemplate::TYPE_BLOG_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_FOUR;
|
|
|
|
$type = BTemplate::TYPE_BLOG_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($is_list == BTemplate::IS_LIST){
|
|
|
|
$type = BTemplate::TYPE_SEVEN;
|
|
|
|
$type = BTemplate::TYPE_NEWS_LIST;
|
|
|
|
}else{
|
|
|
|
$type = BTemplate::TYPE_SIX;
|
|
|
|
$type = BTemplate::TYPE_NEWS_DETAIL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
...
|
...
|
@@ -223,7 +243,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function getSettingTemplate($source,$is_list){
|
|
|
|
$template_id = 0;
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
|
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
...
|
...
|
@@ -247,8 +267,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 16:55
|
|
|
|
*/
|
|
|
|
public function getCommonHtml($source,$is_list,$template_id){
|
|
|
|
$type = $this->getType($source,$is_list,$template_id);
|
|
|
|
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'],
|
|
...
|
...
|
@@ -306,7 +326,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$this->model->edit($data,$condition);
|
|
|
|
}
|
|
|
|
//更新头部信息
|
|
|
|
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id']);
|
|
|
|
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$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->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
|
|
...
|
...
|
@@ -336,7 +356,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/12/15 10:59
|
|
|
|
*/
|
|
|
|
public function handleVisualizationParam($html,$source, $is_list,$data){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
|
|
|
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
...
|
...
|
@@ -364,8 +384,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
*/
|
|
|
|
public function saveCommonHtml($html,$source,$is_list,$template_id){
|
|
|
|
$type = $this->getType($source,$is_list,$template_id);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
|
|
|
|
$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]);//查看当前头部是否存在
|
|
|
|
$handleInfo = $this->handleCommonParam($html);
|
|
...
|
...
|
@@ -440,11 +463,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($source,$is_list,$template_id){
|
|
|
|
public function getType($source,$is_list,$is_custom = 0){
|
|
|
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
|
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
|
|
|
$is_head == BTemplate::IS_HEADER;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if($is_head != BTemplate::IS_NO_HEADER) {
|
|
...
|
...
|
@@ -453,17 +476,18 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if ($pageInfo === false) {
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list == 0) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_TWO;}}
|
|
|
|
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_THREE;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list == 0) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_FOUR;}}
|
|
|
|
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_FIVE;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list == 0) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_SIX;}}
|
|
|
|
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_SEVEN;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_EIGHT;}}
|
|
|
|
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;}}
|
|
|
|
}
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :生成记录
|
|
|
|
* @name :setTemplateLog
|
|
...
|
...
|
@@ -581,7 +605,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
$param['footer_css'] = characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s');
|
|
|
|
if(!isset($param['is_custom'])){
|
|
|
|
$param['is_custom'] = BTemplate::SOURCE_NO_CUSTOM;
|
|
|
|
$param['is_custom'] = BTemplate::IS_NO_CUSTOM;
|
|
|
|
}
|
|
|
|
$param['type'] = BTemplate::PAGE_HTML;//不显示整个HTML
|
|
|
|
return $this->success($param);
|
...
|
...
|
|