|
...
|
...
|
@@ -10,6 +10,7 @@ use App\Models\News\NewsCategory; |
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
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\BTemplateCommon;
|
|
...
|
...
|
@@ -61,99 +62,144 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 9:44
|
|
|
|
*/
|
|
|
|
public function getTemplate(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
|
|
|
|
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
$template_id = $this->getSettingTemplate($this->param['source'],$this->param['source_id']);//设置的模版id
|
|
|
|
$data = $this->getHtml($template_id,$this->param['source'],$this->param['source_id'],$this->param['is_custom'] ?? 0);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取可视化装修的html
|
|
|
|
* @name :getTemplateHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:47
|
|
|
|
*/
|
|
|
|
public function getHtml($template_id,$source,$source_id,$is_custom){
|
|
|
|
$templateInfo = $this->webTemplateInfo($template_id,$source,$source_id,$is_custom);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$html = $this->isCustomizedPage($source,$source_id);//查看当前页面是否定制
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
$mainInfo = $this->getCommonMain($source,$source_id,$is_custom);//获取中间部分代码
|
|
|
|
}else{
|
|
|
|
$TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
if($templateInfo['type'] == BTemplate::ALL_HTML){//返回整个html代码
|
|
|
|
$type = $this->getCustomizedType($source, $source_id);//定制获取头部底部类型
|
|
|
|
$commonInfo = $this->getCommonPage(0,$this->user['project_id'],$type);//获取定制头部
|
|
|
|
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
}
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
$commonInfo = $this->getCommonPage($source,$source_id,$template_id);//获取头部
|
|
|
|
$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);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据参数获取数据详情
|
|
|
|
* @name :webTemplateInfo
|
|
|
|
* @remark :返回整个html截取代码
|
|
|
|
* @name :handleAllHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:41
|
|
|
|
* @time :2023/12/13 15:39
|
|
|
|
*/
|
|
|
|
public function webTemplateInfo($template_id,$source,$source_id){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
]);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
public function handleAllHtml($commonInfo,$html){
|
|
|
|
if(!empty($commonInfo)){
|
|
|
|
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
|
|
|
|
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
|
|
|
|
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
|
|
|
|
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
|
|
|
|
}
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理首页数据
|
|
|
|
* @name :homeHtml
|
|
|
|
* @remark :页面是否为定制页面获取初始代码
|
|
|
|
* @name :watchProjectIsCustomized
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:36
|
|
|
|
* @time :2023/12/13 10:55
|
|
|
|
*/
|
|
|
|
public function homeHtml($info,$source,$source_id){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//获取模板详情
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$TemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
|
|
|
|
}else{
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$TemplateInfo['html'] = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
public function isCustomizedPage($source,$source_id)
|
|
|
|
{
|
|
|
|
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//是定制界面
|
|
|
|
//TODO::获取初始代码
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$type]);
|
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
}
|
|
|
|
$ATemplateModel = new Template();
|
|
|
|
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']],['name','image']);
|
|
|
|
$TemplateInfo['name'] = $ATemplateInfo['name'];
|
|
|
|
$TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
|
|
|
|
return $customHtmlInfo['main_html'];
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理其他页数据
|
|
|
|
* @name :ProductHtml
|
|
|
|
* @remark :定制界面根据source+source_id获取type类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:40
|
|
|
|
* @time :2023/11/16 11:20
|
|
|
|
*/
|
|
|
|
public function otherHtml($info,$source,$source_id){
|
|
|
|
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
|
|
|
|
if($homeTemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
|
|
public function getCustomizedType($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;}
|
|
|
|
}
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
$mainInfo = $this->getCommonMain($source,$source_id);
|
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_css'];
|
|
|
|
$TemplateInfo['template_id'] = $info['template_id'];
|
|
|
|
}else{
|
|
|
|
$main_html = $TemplateInfo['main_html'];
|
|
|
|
$main_style = $TemplateInfo['main_css'];
|
|
|
|
if($source == BTemplate::SOURCE_BLOG){
|
|
|
|
if($source_id == 0){$type = BTemplate::TYPE_FIVE;}else{$type = BTemplate::TYPE_FOUR;}
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonPage($source,$source_id,$info['template_id']);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $main_style, $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', $main_html, $html);
|
|
|
|
if($source == BTemplate::SOURCE_NEWS){
|
|
|
|
if($source_id == 0){$type = BTemplate::TYPE_SEVEN;}else{$type = BTemplate::TYPE_SIX;}
|
|
|
|
}
|
|
|
|
return $type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前项目设置的模版
|
|
|
|
* @name :getSettingTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:48
|
|
|
|
*/
|
|
|
|
public function getSettingTemplate($source,$source_id){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION) {//定制项目
|
|
|
|
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//是定制界面
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $info['template_id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据参数获取数据详情
|
|
|
|
* @name :webTemplateInfo
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:41
|
|
|
|
*/
|
|
|
|
public function webTemplateInfo($template_id,$source,$source_id,$is_custom = 0){
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'is_custom'=>$is_custom
|
|
|
|
]);
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -164,12 +210,16 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 15:58
|
|
|
|
*/
|
|
|
|
public function getCommonMain($source,$source_id){
|
|
|
|
public function getCommonMain($source,$source_id,$is_custom){
|
|
|
|
$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;}
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM){
|
|
|
|
if($source_id != 0){$type = BTemplate::TYPE_SIX;}else{$type = BTemplate::TYPE_SEVEN;}
|
|
|
|
}else{
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 0) {$type = BTemplate::TYPE_TWO;} else {$type = BTemplate::TYPE_THREE;}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($source_id != 0) {$type = BTemplate::TYPE_FOUR;} else {$type = BTemplate::TYPE_FIVE;}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($source_id != 0) {$type = BTemplate::TYPE_SIX;} else {$type = BTemplate::TYPE_SEVEN;}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {$type = BTemplate::TYPE_EIGHT;}
|
|
|
|
}
|
|
|
|
//查询有没有公共详情模板
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
...
|
...
|
@@ -201,23 +251,23 @@ class BTemplateLogic extends BaseLogic |
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id']
|
|
|
|
];
|
|
|
|
if ($source == 2) {//产品页
|
|
|
|
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 == 3) {//博客页
|
|
|
|
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 == 4) {//新闻页
|
|
|
|
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 == 5) {//聚合页
|
|
|
|
$data['type'] = 8;if ($pageInfo['polymerization'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {//产品页
|
|
|
|
if($source_id != 0){$data['type'] = BTemplate::TYPE_TWO;if ($pageInfo['product_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = BTemplate::TYPE_THREE;if ($pageInfo['product_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {//博客页
|
|
|
|
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_FOUR;if ($pageInfo['blog_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = BTemplate::TYPE_FIVE;if ($pageInfo['blog_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {//新闻页
|
|
|
|
if ($source_id != 0) {$data['type'] = BTemplate::TYPE_SIX;if ($pageInfo['news_details'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}
|
|
|
|
else {$data['type'] = BTemplate::TYPE_SEVEN;if ($pageInfo['news_list'] != 0) {$commonInfo = $commonTemplateModel->read($data);}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {//聚合页
|
|
|
|
$data['type'] = BTemplate::TYPE_EIGHT;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]);
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>BTemplate::TYPE_ONE]);
|
|
|
|
}
|
|
|
|
return $commonInfo;
|
|
|
|
}
|
|
...
|
...
|
@@ -230,86 +280,220 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 11:05
|
|
|
|
*/
|
|
|
|
public function templateSave(){
|
|
|
|
//演示项目,不允许其他号码编辑
|
|
|
|
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($this->param['source'] == 1)){
|
|
|
|
$this->fail('演示项目仅支持演示功能,无法更改首页');
|
|
|
|
}
|
|
|
|
//查询当前模版是否已保存
|
|
|
|
DB::beginTransaction();
|
|
|
|
try {
|
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
|
|
|
|
//字符串截取
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
//保存头部信息
|
|
|
|
$this->saveCommonTemplate($this->param);
|
|
|
|
$param = $this->templateSaveParam($this->param);//组装数据
|
|
|
|
if($info === false){
|
|
|
|
$this->model->add($param);
|
|
|
|
}else{
|
|
|
|
$this->model->edit($param,['id'=>$info['id']]);
|
|
|
|
//演示项目不允许修改
|
|
|
|
$this->showProjectNoEdit($this->param['source']);
|
|
|
|
// DB::beginTransaction();
|
|
|
|
// try {
|
|
|
|
$this->param = $this->handleDefaultString($this->param);//设置默认字符
|
|
|
|
$templateInfo = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],
|
|
|
|
$this->param['source_id'],$this->param['is_custom']);
|
|
|
|
if($templateInfo === false){//执行新增
|
|
|
|
$this->templateAddHtml($this->param['html'], $this->param['source'], $this->param['source_id'],
|
|
|
|
$this->param['template_id'], $this->param['section_list_id'], $this->param['is_custom']);
|
|
|
|
}else{//执行编辑
|
|
|
|
$this->templateEditHtml($this->param['html'],$this->param['source'],$this->param['source_id'],
|
|
|
|
$this->param['template_id'],$this->param['section_list_id'], $this->param['is_custom']);
|
|
|
|
}
|
|
|
|
//写入操作模版记录
|
|
|
|
$this->setTemplateLog($this->param);
|
|
|
|
DB::commit();
|
|
|
|
}catch (\Exception $e){
|
|
|
|
DB::rollBack();
|
|
|
|
$this->fail('系统错误,请联系管理员');
|
|
|
|
}
|
|
|
|
//更新头部信息
|
|
|
|
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id']);
|
|
|
|
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom']);
|
|
|
|
// DB::commit();
|
|
|
|
// }catch (\Exception $e){
|
|
|
|
// DB::rollBack();
|
|
|
|
// $this->fail('系统错误,请联系管理员');
|
|
|
|
// }
|
|
|
|
//通知更新
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id']);
|
|
|
|
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存头部公共数据
|
|
|
|
* @name :saveCommonTemplate
|
|
|
|
* @remark :保存数据时设置默认字符
|
|
|
|
* @name :saveDefaultString
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
* @time :2023/12/15 10:30
|
|
|
|
*/
|
|
|
|
public function saveCommonTemplate($param){
|
|
|
|
$type = $this->getType($param['source'],$param['source_id']);
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
public function handleDefaultString($param){
|
|
|
|
if(!isset($param['template_id'])){
|
|
|
|
$param['template_id'] = 0;
|
|
|
|
}
|
|
|
|
if(!isset($param['is_custom'])){
|
|
|
|
$param['is_custom'] = 0;
|
|
|
|
}
|
|
|
|
if(!isset($param['section_list_id'])){
|
|
|
|
$param['section_list_id'] = '';
|
|
|
|
}
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :可视化添加数据
|
|
|
|
* @name :templateAddHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 10:15
|
|
|
|
*/
|
|
|
|
public function templateAddHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'source'=>$source, 'source_id'=>$source_id,'type'=>BTemplate::PAGE_HTML,
|
|
|
|
'template_id'=>$template, 'project_id'=>$this->user['project_id'],
|
|
|
|
'section_list_id'=>$section_list_id,'is_custom'=>$is_custom,
|
|
|
|
];
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['template_id'];
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $type;
|
|
|
|
$data = $this->handleVisualizationParam($html,$source,$source_id,$data);
|
|
|
|
$this->model->add($data);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :可视化更新html
|
|
|
|
* @name :templateEditHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 10:26
|
|
|
|
*/
|
|
|
|
public function templateEditHtml($html,$source,$source_id,$template,$section_list_id,$is_custom){
|
|
|
|
$condition = [
|
|
|
|
'source'=>$source, 'source_id'=>$source_id,
|
|
|
|
'is_custom'=>$is_custom, 'template_id'=>$template
|
|
|
|
];
|
|
|
|
$data = [
|
|
|
|
'section_list_id'=>$section_list_id
|
|
|
|
];
|
|
|
|
$data = $this->handleVisualizationParam($html,$source,$source_id,$data);
|
|
|
|
$this->model->edit($data,$condition);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理可视化数据
|
|
|
|
* @name :handleProjectParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 10:59
|
|
|
|
*/
|
|
|
|
public function handleVisualizationParam($html,$source, $source_id,$data){
|
|
|
|
if($this->user['is_customized'] == BTemplate::SOURCE_VISUALIZATION){//定制项目
|
|
|
|
$type = $this->getCustomizedType($source, $source_id);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//当前页面是定制界面
|
|
|
|
$data['html'] = $html;
|
|
|
|
$data['type'] = BTemplate::ALL_HTML;
|
|
|
|
}else{
|
|
|
|
$mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
$data['main_html'] = $mainInfo['main_html'];
|
|
|
|
$data['main_css'] = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$mainInfo = $this->handleTemplateHtml($html);
|
|
|
|
$data['main_html'] = $mainInfo['main_html'];
|
|
|
|
$data['main_css'] = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存公共头部底部
|
|
|
|
* @name :saveCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 17:05
|
|
|
|
*/
|
|
|
|
public function saveCommonHtml($html,$source,$source_id,$template_id){
|
|
|
|
$type = $this->getType($source,$source_id,$template_id);//获取头部类型1-9(首页到自定义页面)
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
|
|
|
|
$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{
|
|
|
|
$templateCommonModel->edit($data,['id'=>$info['id']]);
|
|
|
|
$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
|
|
|
|
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$param['template_id']]);
|
|
|
|
return $this->success();
|
|
|
|
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :演示项目不允许修改首页
|
|
|
|
* @name :showProject
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/12 11:27
|
|
|
|
*/
|
|
|
|
public function showProjectNoEdit($source){
|
|
|
|
//演示项目,不允许其他号码编辑
|
|
|
|
if(($this->user['project_id'] == 1) && (!in_array($this->user['mobile'],$this->model->mobile)) && ($source == BTemplate::SOURCE_HOME)){
|
|
|
|
$this->fail('演示项目仅支持演示功能,无法更改首页');
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存时字符串处理
|
|
|
|
* @name :handleCommonParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function handleCommonParam($html){
|
|
|
|
//字符串截取
|
|
|
|
$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');
|
|
|
|
$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,$source_id){
|
|
|
|
public function getType($source,$source_id,$template_id){
|
|
|
|
$type = 1;//首页公共头部底部
|
|
|
|
if($template_id == 0){//保存上传的代码块时,默认为独立头部
|
|
|
|
$this->user['configuration']['is_head'] == 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;}}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($source_id != 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 ($source_id != 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 ($source_id != 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;}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $type;
|
|
...
|
...
|
@@ -322,22 +506,24 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/23 11:16
|
|
|
|
*/
|
|
|
|
public function setTemplateLog($param){
|
|
|
|
public function setOperationRecords($html,$source,$source_id,$template_id,$is_custom,$type = 0){
|
|
|
|
$data = [
|
|
|
|
'template_id'=>$param['template_id'],
|
|
|
|
'template_id'=>$template_id,
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'operator_id'=>$this->user['id'],
|
|
|
|
'text'=>$param['html'],
|
|
|
|
'source'=>$param['source'],
|
|
|
|
'source_id'=>$param['source_id'],
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'main_html'=>$param['main_html'],
|
|
|
|
'main_css'=>$param['main_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'text'=>$html,
|
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>$is_custom,
|
|
|
|
'source'=>$source,
|
|
|
|
'source_id'=>$source_id,
|
|
|
|
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
'head_html' => characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
|
|
|
|
'footer_html' => characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
|
|
|
|
'head_css' => characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
|
|
|
|
'footer_css' => characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
$footer_other = str_replace('<header','',characterTruncation($param['html'],'/<style id="globalsojs-footer">(.*?)<header/s'));
|
|
|
|
$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);
|
|
...
|
...
|
@@ -350,52 +536,30 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/31 16:05
|
|
|
|
*/
|
|
|
|
public function homeOrProduct($source,$source_id = ''){
|
|
|
|
if($source == BTemplate::SOURCE_HOME){
|
|
|
|
$type = 'index';
|
|
|
|
$route = 'index';
|
|
|
|
//路由映射
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
}else{
|
|
|
|
//其他界面通知更新
|
|
|
|
if($source == 2 && $source_id != 0){
|
|
|
|
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;
|
|
|
|
$productModel = new Product();
|
|
|
|
$productInfo = $productModel->read(['id'=>$source_id],['route']);
|
|
|
|
$route = $productInfo['route'];
|
|
|
|
}elseif($source == 3 && $source_id != 0){
|
|
|
|
}elseif($source == BTemplate::SOURCE_BLOG){
|
|
|
|
$type = RouteMap::SOURCE_BLOG;
|
|
|
|
$blogModel = new Blog();
|
|
|
|
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $blogInfo['url'];
|
|
|
|
}elseif($source == 4 && $source_id != 0){
|
|
|
|
}elseif($source == BTemplate::SOURCE_NEWS){
|
|
|
|
$type = RouteMap::SOURCE_NEWS;
|
|
|
|
$newsModel = new News();
|
|
|
|
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $newsInfo['url'];
|
|
|
|
}else{
|
|
|
|
$type = 'all';
|
|
|
|
$route = '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 :templateParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/21 16:30
|
|
|
|
*/
|
|
|
|
public function templateSaveParam($param){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :拼接获取公共头部底部
|
|
|
|
* @name :getHeadFooter
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -419,13 +583,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :字符串处理
|
|
|
|
* @name :StringProcessing
|
|
|
|
* @remark :保存时字符串处理
|
|
|
|
* @name :handleSaveParam
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function stringProcessing($param){
|
|
|
|
public function handleSaveParam($param){
|
|
|
|
//字符串截取
|
|
|
|
$param['head_html'] = characterTruncation($param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
|
|
$param['main_html'] = characterTruncation($param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
...
|
...
|
@@ -433,6 +597,10 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$param['head_css'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/style>/s');
|
|
|
|
$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['type'] = BTemplate::PAGE_HTML;//不显示整个HTML
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -444,7 +612,6 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/7/27 15:08
|
|
|
|
*/
|
|
|
|
public function getModule($type){
|
|
|
|
//获取公共主题头部底部
|
|
|
|
$mainModel = new TemplateTypeMain();
|
|
|
|
$info = $mainModel->read(['type'=>$type]);
|
|
|
|
return $info['main_html'];
|
|
...
|
...
|
@@ -529,7 +696,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$this->param['test_model'] = 2;//未审核模版
|
|
|
|
$this->param['operator_id'] = $this->user['manager_id'] ?? 0;
|
|
|
|
$this->param['html'] = characterTruncation($this->param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
$this->param = $this->handleSaveParam($this->param);
|
|
|
|
$publicTemplateModel = new Template();
|
|
|
|
$rs = $publicTemplateModel->add($this->param);
|
|
|
|
if($rs === false){
|
|
...
|
...
|
@@ -551,20 +718,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
if($commonInfo === false){
|
|
|
|
$this->fail('已装修的项目使用当前功能时,可视化保存首页数据一次,未装修首页请先装修首页');
|
|
|
|
}
|
|
|
|
//判断当前项目是否有设置独立头部的权限
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//有权限时,获取独立头部
|
|
|
|
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$bSettingInfo['template_id'],'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($commonTypeInfo !== false){
|
|
|
|
$commonInfo = $commonTypeInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
|
|
|
|
$commonInfo = $this->getTypeCommonHtml($bSettingInfo['template_id'],$is_custom);
|
|
|
|
//获取设置的默认中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
...
|
...
|
@@ -582,6 +737,31 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据type获取html
|
|
|
|
* @name :getHeaderFooter
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:06
|
|
|
|
*/
|
|
|
|
public function getTypeCommonHtml($template_id,$is_custom){
|
|
|
|
//获取首页公共部分
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
//判断当前项目是否有设置独立头部的权限
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM){
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
//有权限时,获取独立头部
|
|
|
|
$commonTypeInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($commonTypeInfo !== false){
|
|
|
|
$commonInfo = $commonTypeInfo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情模板数据
|
|
|
|
* @name :saveDetail
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -594,6 +774,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
$is_custom = $this->param['is_custom'] ?? 0;//扩展模块详情模版
|
|
|
|
$data = [
|
|
|
|
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
...
|
...
|
@@ -601,37 +782,53 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$data['section_list_id'] = $this->param['section_list_id'];
|
|
|
|
//保存中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type'],'is_custom'=>$is_custom]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $this->param['type'];
|
|
|
|
$data['is_custom'] = $is_custom;
|
|
|
|
$bTemplateMainModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$this->saveDetailCommonHtml($is_custom,$this->param['type'],$bSettingInfo['template_id'],$this->param['html']);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情页模版头部底部
|
|
|
|
* @name :saveDetailCommonHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/15 18:12
|
|
|
|
*/
|
|
|
|
public function saveDetailCommonHtml($is_custom,$type,$template_id,$html){
|
|
|
|
$publicData = [
|
|
|
|
'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'),
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($this->param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/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'),
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($html,"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
];
|
|
|
|
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
if($is_custom == BTemplate::SOURCE_CUSTOM){//扩展模块
|
|
|
|
$this->user['configuration']['is_head'] = BTemplate::SOURCE_NO_CUSTOM;
|
|
|
|
}
|
|
|
|
$templateCommonModel = new BTemplateCommon();
|
|
|
|
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['type'=>$this->param['type'],'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
$templateCommonInfo = $templateCommonModel->read(['type'=>$type,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
if($templateCommonInfo === false){
|
|
|
|
$publicData['type'] = $this->param['type'];
|
|
|
|
$publicData['type'] = $type;
|
|
|
|
$publicData['project_id'] = $this->user['project_id'];
|
|
|
|
$publicData['template_id'] = $bSettingInfo['template_id'];
|
|
|
|
$publicData['template_id'] = $template_id;
|
|
|
|
$templateCommonModel->add($publicData);
|
|
|
|
}else{
|
|
|
|
$templateCommonModel->edit($publicData,['id'=>$templateCommonInfo['id']]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//更新首页头部底部
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$bSettingInfo['template_id']]);
|
|
|
|
$templateCommonModel->edit($publicData,['type'=>1,'project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|