|
...
|
...
|
@@ -79,466 +79,4 @@ class VisualizationLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制页面支持可视化装修获取html
|
|
|
|
* @name :getHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/15 11:30
|
|
|
|
*/
|
|
|
|
public function getHtml(){
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);//获取类型
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取定制界面
|
|
|
|
//查看当前类型是否是定制界面
|
|
|
|
if(in_array($type,$page_array)){//是定制界面
|
|
|
|
return $this->getVisualizationHtml($type);
|
|
|
|
}else{//非定制界面
|
|
|
|
return $this->getTemplateHtml();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制界面获取html
|
|
|
|
* @name :getVisualizationHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 11:47
|
|
|
|
*/
|
|
|
|
public function getVisualizationHtml($type){
|
|
|
|
|
|
|
|
if(in_array($type,[1,3,5,7])){//单页
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前定制单页是否有代码块
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->fail('请先上传定制代码块');
|
|
|
|
}
|
|
|
|
return ['html'=>$templateInfo['html']];
|
|
|
|
}else{//模块页
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id']);//查看当前页面是否可视化
|
|
|
|
if($templateInfo === false){//获取代码块
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$this->fail('请先上传定制代码块');
|
|
|
|
}
|
|
|
|
return ['html'=>$mainInfo['main_html']];
|
|
|
|
}
|
|
|
|
//替换为公共头部和底部
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$headerFooterHtml = $templateCommonModel->read(['template_id'=>0,'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$html = $templateInfo['html'];
|
|
|
|
if($headerFooterHtml !== false){
|
|
|
|
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $headerFooterHtml['head_html'], $html);
|
|
|
|
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $headerFooterHtml['footer_html'], $html);
|
|
|
|
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $headerFooterHtml['head_css'], $html);
|
|
|
|
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $headerFooterHtml['footer_css'], $html);
|
|
|
|
}
|
|
|
|
return ['html'=>$html];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :非定制项目获取html
|
|
|
|
* @name :getTemplateHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 11:44
|
|
|
|
*/
|
|
|
|
public function getTemplateHtml(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$settingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($settingInfo === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$templateInfo = $this->getWebTemplate($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);//查看当前页面是否可视化
|
|
|
|
if($templateInfo === false){
|
|
|
|
//根据类型在获取中间部分
|
|
|
|
$mainData = $this->getCommonMain($this->param['source'],$this->param['source_id']);
|
|
|
|
}else{
|
|
|
|
$mainData = [
|
|
|
|
'main_html'=>$templateInfo['main_html'],
|
|
|
|
'main_css'=>$templateInfo['main_css']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
//获取公共头部底部
|
|
|
|
$commonInfo = $this->getCommonPage($this->param['source'],$this->param['source_id'],$settingInfo['template_id']);
|
|
|
|
//拼接数据
|
|
|
|
$html = $commonInfo['head_css'].$mainData['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$mainData['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$settingInfo['template_id']]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :拼接获取公共头部底部
|
|
|
|
* @name :getHeadFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/21 17:22
|
|
|
|
*/
|
|
|
|
public function getHeadFooter($html){
|
|
|
|
//获取公共主题头部底部
|
|
|
|
$serviceSettingModel = new ServiceSettingModel();
|
|
|
|
$list = $serviceSettingModel->list(['type'=>2],'created_at');
|
|
|
|
//拼接html
|
|
|
|
foreach ($list as $v){
|
|
|
|
if($v['key'] == 'head'){
|
|
|
|
$html = $v['values'].$html;
|
|
|
|
}
|
|
|
|
if($v['key'] == 'footer'){
|
|
|
|
$html = $html.$v['values'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取可视化装修记录
|
|
|
|
* @name :getWebTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:21
|
|
|
|
*/
|
|
|
|
public function getWebTemplate($source,$source_id,$template_id = 0){
|
|
|
|
//查询可视化是否第一次保存
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$param = [
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'template_id'=>$template_id
|
|
|
|
];
|
|
|
|
return $bTemplateModel->read($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制界面根据source+source_id获取type类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/16 11:20
|
|
|
|
*/
|
|
|
|
public function getType($source,$source_id){
|
|
|
|
$type = BTemplate::TYPE_ONE;
|
|
|
|
if($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
if($source_id == 0){$type = BTemplate::TYPE_THREE;}else{$type = BTemplate::TYPE_TWO;}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
|
|
|
|
}
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :非定制获取设置头部底部的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getSaveType($source,$source_id){
|
|
|
|
$type = 1;//首页公共头部底部
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo !== false) {
|
|
|
|
if ($source == 2) {if ($source_id != 0) {if ($pageInfo['product_details'] != 0) {$type = 2;}} else {if ($pageInfo['product_list'] != 0) {$type = 3;}}}
|
|
|
|
if ($source == 3) {if ($source_id != 0) {if ($pageInfo['blog_details'] != 0) {$type = 4;}} else {if ($pageInfo['blog_list'] != 0) {$type = 5;}}}
|
|
|
|
if ($source == 4) {if ($source_id != 0) {if ($pageInfo['news_details'] != 0) {$type = 6;}} else {if ($pageInfo['news_list'] != 0) {$type = 7;}}}
|
|
|
|
if ($source == 5) {if ($pageInfo['polymerization'] != 0) {$type = 8;}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存定制项目可视化
|
|
|
|
* @name :saveHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/15 11:47
|
|
|
|
*/
|
|
|
|
public function saveHtml(){
|
|
|
|
if(!isset($this->user['is_visualization']->page_array)){
|
|
|
|
$this->fail('当前为定制项目,请先选择定制界面');
|
|
|
|
}
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;
|
|
|
|
$type = $this->getType($this->param['source'],$this->param['source_id']);
|
|
|
|
try {
|
|
|
|
if(in_array($type,$page_array)){//定制页面
|
|
|
|
$this->saveVisualizationHtml($type);
|
|
|
|
}else{
|
|
|
|
if(!isset($this->param['is_custom'])){
|
|
|
|
$this->param['is_custom'] = 0;
|
|
|
|
}
|
|
|
|
$this->saveTemplateHtml($this->param);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存定制界面
|
|
|
|
* @name :saveVisualizationHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 15:42
|
|
|
|
*/
|
|
|
|
public function saveVisualizationHtml($type){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$this->param['source'], 'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'], 'template_id'=>0
|
|
|
|
]);
|
|
|
|
try {
|
|
|
|
//更新头部底部
|
|
|
|
$this->visualizationSaveHeaderFooter($type);
|
|
|
|
if($templateInfo === false){
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$this->param['template_id'] = 0;
|
|
|
|
$bTemplateModel->add($this->param);
|
|
|
|
}else{
|
|
|
|
$param['html'] = $this->param['html'];
|
|
|
|
$bTemplateModel->edit($param,['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'template_id'=>0]);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :定制界面保存头部底部
|
|
|
|
* @name :visualizationSaveHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/6 10:41
|
|
|
|
*/
|
|
|
|
public function visualizationSaveHeaderFooter($type){
|
|
|
|
//更新头部底部代码
|
|
|
|
$header_footer = [
|
|
|
|
'head_html'=>characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'head_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html'=>characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>0,'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
if($info === false){
|
|
|
|
$header_footer['template_id'] = 0;
|
|
|
|
$header_footer['project_id'] = $this->user['project_id'];
|
|
|
|
$header_footer['type'] = $type;
|
|
|
|
$templateCommonModel->add($header_footer);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($header_footer,['template_id'=>0,'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :非定制界面保存数据
|
|
|
|
* @name :saveTemplateHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/5 15:44
|
|
|
|
*/
|
|
|
|
public function saveTemplateHtml($param){
|
|
|
|
$bTemplateModel = new BTemplate();
|
|
|
|
$templateInfo = $bTemplateModel->read([
|
|
|
|
'source'=>$param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$param['source_id'],
|
|
|
|
'template_id'=>$param['template_id'],
|
|
|
|
'is_custom'=>$param['is_custom']
|
|
|
|
]);
|
|
|
|
$this->param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$this->param['main_css'] = characterTruncation($param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s');
|
|
|
|
//保存头部
|
|
|
|
if($param['is_custom'] == BTemplate::SOURCE_NO_CUSTOM){//非扩展模块才可以保存头底
|
|
|
|
$this->saveCommonTemplate($param['html'],$param['source'],$param['source_id'],$param['template_id']);
|
|
|
|
}
|
|
|
|
if($templateInfo === false){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
$bTemplateModel->add($param);
|
|
|
|
}else{
|
|
|
|
$bTemplateModel->edit($param,['source'=>$param['source'],'source_id'=>$param['source_id'],'is_custom'=>$param['is_custom']]);
|
|
|
|
}
|
|
|
|
$this->setTemplateLog($param['template_id'],$param['html'],$param['source'],$param['source_id'],$param['is_custom']);
|
|
|
|
$this->homeOrProduct($param['source'],$param['source_id'],$param['is_custom']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :通知首页更新
|
|
|
|
* @name :IsHome
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/31 16:05
|
|
|
|
*/
|
|
|
|
public function homeOrProduct($source,$source_id = '',$is_custom = 0){
|
|
|
|
if($is_custom == 0){
|
|
|
|
if($source == BTemplate::SOURCE_HOME){
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
$type = RouteMap::SOURCE_INDEX;
|
|
|
|
}elseif($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
$type = RouteMap::SOURCE_PRODUCT;
|
|
|
|
}elseif($source == BTemplate::SOURCE_BLOG){
|
|
|
|
$type = RouteMap::SOURCE_BLOG;
|
|
|
|
}elseif($source == BTemplate::SOURCE_NEWS){
|
|
|
|
$type = RouteMap::SOURCE_NEWS;
|
|
|
|
}else{
|
|
|
|
$type = 'all';
|
|
|
|
}
|
|
|
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
$type = RouteMap::SOURCE_MODULE;
|
|
|
|
$route = RouteMap::getRoute($type,$source_id,$this->user['project_id']);
|
|
|
|
}
|
|
|
|
$this->addUpdateNotify($type,$route);
|
|
|
|
return $this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :生成记录
|
|
|
|
* @name :setTemplateLog
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/23 11:16
|
|
|
|
*/
|
|
|
|
public function setTemplateLog($template_id,$html,$source,$source_id,$is_custom){
|
|
|
|
$data = [
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'operator_id'=>$this->user['id'],
|
|
|
|
'text'=>$html,
|
|
|
|
'source'=>$source,
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
'is_custom'=>$is_custom
|
|
|
|
];
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
|
|
|
$bTemplateLogModel = new BTemplateLog();
|
|
|
|
return $bTemplateLogModel->add($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存头部公共数据
|
|
|
|
* @name :saveCommonTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($html,$source,$source_id,$template_id){
|
|
|
|
$type = $this->getSaveType($source,$source_id);
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$data = [
|
|
|
|
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $template_id;
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $type;
|
|
|
|
$templateCommonModel->add($data);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
//更新所有界面的other
|
|
|
|
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取中间公共部分
|
|
|
|
* @name :getCommonMain
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 15:58
|
|
|
|
*/
|
|
|
|
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;}
|
|
|
|
//查询有没有公共详情模板
|
|
|
|
$mainInfo = $this->model->read(['type'=>$type]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['main_html'] = $this->getModule($type);
|
|
|
|
$data['main_css'] = "<style id='globalsojs-styles'></style>";
|
|
|
|
}else{
|
|
|
|
$data['main_html'] = $mainInfo['main_html'];
|
|
|
|
$data['main_css'] = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :默认产品模块
|
|
|
|
* @name :getProductModule
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/27 15:08
|
|
|
|
*/
|
|
|
|
public function getModule($type){
|
|
|
|
//获取公共主题头部底部
|
|
|
|
$mainModel = new TemplateTypeMain();
|
|
|
|
$info = $mainModel->read(['type'=>$type]);
|
|
|
|
return $info['main_html'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据类型获取公共头和底
|
|
|
|
* @name :getCommonPage
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 16:55
|
|
|
|
*/
|
|
|
|
public function getCommonPage($source,$source_id,$template_id){
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
|
|
|
|
if ($pageInfo != false) {
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$data = [
|
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id']
|
|
|
|
];
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
|
|
|
|
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 == BTemplate::SOURCE_BLOG) {//博客页
|
|
|
|
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 == BTemplate::SOURCE_NEWS) {//新闻页
|
|
|
|
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 == BTemplate::SOURCE_KEYWORD) {//聚合页
|
|
|
|
$data['type'] = 8;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]);
|
|
|
|
}
|
|
|
|
return $commonInfo;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|