|
...
|
...
|
@@ -3,17 +3,22 @@ |
|
|
|
namespace App\Http\Logic\Bside\BTemplate;
|
|
|
|
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Blog\BlogCategory;
|
|
|
|
use App\Models\News\News;
|
|
|
|
use App\Models\News\NewsCategory;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\PageSetting;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Service\Service as ServiceSettingModel;
|
|
|
|
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\TemplateTypeMain;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use mysql_xdevapi\Exception;
|
|
...
|
...
|
@@ -61,12 +66,10 @@ class BTemplateLogic extends BaseLogic |
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
}
|
|
|
|
$TemplateInfo = [];
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_HOME){//首页
|
|
|
|
$TemplateInfo = $this->homeHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}
|
|
|
|
if($this->param['source'] == $this->model::SOURCE_PRODUCT){//产品页
|
|
|
|
$TemplateInfo = $this->productHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}else{
|
|
|
|
$TemplateInfo = $this->otherHtml($info,$this->param['source'],$this->param['source_id']);
|
|
|
|
}
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
...
|
...
|
@@ -105,7 +108,7 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$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']]);
|
|
|
|
$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'];
|
|
...
|
...
|
@@ -120,13 +123,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :处理产品页数据
|
|
|
|
* @remark :处理其他页数据
|
|
|
|
* @name :ProductHtml
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/25 16:40
|
|
|
|
*/
|
|
|
|
public function productHtml($info,$source,$source_id){
|
|
|
|
public function otherHtml($info,$source,$source_id){
|
|
|
|
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
|
|
|
|
if($homeTemplateInfo === false){
|
|
|
|
$this->fail('请先装修首页');
|
|
...
|
...
|
@@ -134,33 +137,93 @@ class BTemplateLogic extends BaseLogic |
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->webTemplateInfo($info['template_id'],$source,$source_id);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css']."<style id='globalsojs-styles'></style>".$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html']."<main>{$this->getProductModule()}</main>".$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', "<style id='globalsojs-styles'></style>", $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
|
|
|
|
}
|
|
|
|
$mainInfo = $this->getCommonMain($source,$source_id);
|
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_css'];
|
|
|
|
$TemplateInfo['template_id'] = $info['template_id'];
|
|
|
|
}else{
|
|
|
|
//兼容老数据
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
if($commonInfo !== false){
|
|
|
|
$html = $commonInfo['head_css'].$TemplateInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$TemplateInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
}else{
|
|
|
|
$html = preg_replace('/<style id="globalsojs-styles">(.*?)<\/style>/s', $TemplateInfo['main_css'], $homeTemplateInfo['html']);
|
|
|
|
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s',$TemplateInfo['main_html'] , $html);
|
|
|
|
}
|
|
|
|
$main_html = $TemplateInfo['main_html'];
|
|
|
|
$main_style = $TemplateInfo['main_css'];
|
|
|
|
}
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
$TemplateInfo['html'] = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($TemplateInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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;}
|
|
|
|
//查询有没有公共详情模板
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'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 :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 == 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(!isset($commonInfo) || $commonInfo === false){
|
|
|
|
$commonTemplateModel = new BTemplateCommon();
|
|
|
|
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
|
|
|
|
}
|
|
|
|
return $commonInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :设置模板
|
|
|
|
* @name :setTemplate
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -203,12 +266,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$info = $this->webTemplateInfo($this->param['template_id'],$this->param['source'],$this->param['source_id']);
|
|
|
|
//字符串截取
|
|
|
|
$this->param = $this->stringProcessing($this->param);
|
|
|
|
//保存头部信息
|
|
|
|
$this->saveCommonTemplate($this->param);
|
|
|
|
$this->param = $this->templateSaveParam($this->param);//组装数据
|
|
|
|
$param = $this->templateSaveParam($this->param);//组装数据
|
|
|
|
if($info === false){
|
|
|
|
$this->model->add($this->param);
|
|
|
|
$this->model->add($param);
|
|
|
|
}else{
|
|
|
|
$this->model->edit($this->param,['id'=>$info['id']]);
|
|
|
|
$this->model->edit($param,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
//写入操作模版记录
|
|
|
|
$this->setTemplateLog($this->param);
|
|
...
|
...
|
@@ -230,27 +294,53 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/10/13 14:27
|
|
|
|
*/
|
|
|
|
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']]);
|
|
|
|
// @file_put_contents(storage_path('logs/lyh_error.log'), var_export($param['html'], true) . PHP_EOL, FILE_APPEND);
|
|
|
|
$info = $templateCommonModel->read(['template_id'=>$param['template_id'],'project_id'=>$this->user['project_id'],'type'=>$type]);
|
|
|
|
$data = [
|
|
|
|
'head_html'=>$param['head_html'],
|
|
|
|
'head_css'=>$param['head_css'],
|
|
|
|
'footer_html'=>$param['footer_html'],
|
|
|
|
'footer_css'=>$param['footer_css'],
|
|
|
|
'other'=>str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")),
|
|
|
|
];
|
|
|
|
$other = str_replace('<header','',characterTruncation($param['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
|
|
|
|
if($info === false){
|
|
|
|
$data['template_id'] = $param['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']]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取设置的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($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 :setTemplateLog
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -289,13 +379,30 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$route = '';
|
|
|
|
//路由映射
|
|
|
|
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $this->user['project_id']);
|
|
|
|
}elseif($source == BTemplate::SOURCE_PRODUCT){
|
|
|
|
$type = RouteMap::SOURCE_PRODUCT;
|
|
|
|
$productModel = new Product();
|
|
|
|
$info = $productModel->read(['id'=>$source_id]);
|
|
|
|
$route = $info['route'];
|
|
|
|
}else{
|
|
|
|
//其他界面通知更新
|
|
|
|
if($source == 2 && $source_id != 0){
|
|
|
|
$type = RouteMap::SOURCE_PRODUCT;
|
|
|
|
$productModel = new Product();
|
|
|
|
$productInfo = $productModel->read(['id'=>$source_id],['route']);
|
|
|
|
$route = $productInfo['route'];
|
|
|
|
}elseif($source == 3 && $source_id != 0){
|
|
|
|
$type = RouteMap::SOURCE_BLOG;
|
|
|
|
$blogModel = new Blog();
|
|
|
|
$blogInfo = $blogModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $blogInfo['url'];
|
|
|
|
}elseif($source == 4 && $source_id != 0){
|
|
|
|
$type = RouteMap::SOURCE_NEWS;
|
|
|
|
$newsModel = new News();
|
|
|
|
$newsInfo = $newsModel->read(['id'=>$source_id],['url']);
|
|
|
|
$route = $newsInfo['url'];
|
|
|
|
}else{
|
|
|
|
$type = 0;
|
|
|
|
$route = 'all';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>$type, 'route'=>$route]);
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -307,11 +414,8 @@ class BTemplateLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function templateSaveParam($param){
|
|
|
|
$param['project_id'] = $this->user['project_id'];
|
|
|
|
if($param['source'] == 1){//首页
|
|
|
|
$param['html'] = characterTruncation($param['html'],'/<style id="globalsojs-header">(.*?)<\/footer>/s');
|
|
|
|
}else{
|
|
|
|
$param['html'] = $param['main_html'];
|
|
|
|
}
|
|
|
|
$param['html'] = $param['main_html'];
|
|
|
|
unset($param['head_html'],$param['head_css'],$param['footer_html'],$param['footer_css']);
|
|
|
|
return $this->success($param);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -363,11 +467,11 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/27 15:08
|
|
|
|
*/
|
|
|
|
public function getProductModule(){
|
|
|
|
public function getModule($type){
|
|
|
|
//获取公共主题头部底部
|
|
|
|
$serviceSettingModel = new ServiceSettingModel();
|
|
|
|
$info = $serviceSettingModel->read(['type'=>$serviceSettingModel::TYPE_PRODUCT]);
|
|
|
|
return $info['values'];
|
|
|
|
$mainModel = new TemplateTypeMain();
|
|
|
|
$info = $mainModel->read(['type'=>$type]);
|
|
|
|
return $info['main_html'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -425,19 +529,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$newCategory = NewsCategory::where($map)->get();
|
|
|
|
$blogCategory = BlogCategory::where($map)->get();
|
|
|
|
if (!empty($productCategory)){
|
|
|
|
foreach ($productCategory as $item){
|
|
|
|
$data["products"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($productCategory as $item){$data["products"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
if (!empty($newCategory)){
|
|
|
|
foreach ($newCategory as $item){
|
|
|
|
$data["news"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($newCategory as $item){$data["news"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
if (!empty($blogCategory)){
|
|
|
|
foreach ($blogCategory as $item){
|
|
|
|
$data["blogs"]["category"][] =$item;
|
|
|
|
}
|
|
|
|
foreach ($blogCategory as $item){$data["blogs"]["category"][] =$item;}
|
|
|
|
}
|
|
|
|
//返回
|
|
|
|
return $this->success($data);
|
|
...
|
...
|
@@ -461,4 +559,101 @@ class BTemplateLogic extends BaseLogic |
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取详情模板详情
|
|
|
|
* @name :getDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 11:29
|
|
|
|
*/
|
|
|
|
public function getDetail(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//获取设置的默认中间部分
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$mainInfo = $bTemplateMainModel->read(['project_id'=>$this->user['project_id'],'type'=>$this->param['type']]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$main_html = $this->getModule($this->param['type']);
|
|
|
|
$main_style = "<style id='globalsojs-styles'></style>";
|
|
|
|
}else{
|
|
|
|
$main_html = $mainInfo['main_html'];
|
|
|
|
$main_style = $mainInfo['main_css'];
|
|
|
|
}
|
|
|
|
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].
|
|
|
|
$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);//组装数据
|
|
|
|
return $this->success($html);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存详情模板数据
|
|
|
|
* @name :saveDetail
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/24 11:53
|
|
|
|
*/
|
|
|
|
public function saveDetail(){
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$bSettingInfo = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($bSettingInfo === false){
|
|
|
|
$this->fail('请先设置模板');
|
|
|
|
}
|
|
|
|
$data = [
|
|
|
|
'main_html'=>characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s'),
|
|
|
|
'main_css'=>characterTruncation($this->param['html'],'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
|
|
|
|
];
|
|
|
|
$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']]);
|
|
|
|
if($mainInfo === false){
|
|
|
|
$data['project_id'] = $this->user['project_id'];
|
|
|
|
$data['type'] = $this->param['type'];
|
|
|
|
$bTemplateMainModel->add($data);
|
|
|
|
}else{
|
|
|
|
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
|
|
|
|
}
|
|
|
|
$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")),
|
|
|
|
];
|
|
|
|
//查看当前模板是否有独立头部,有独立头部,更新独立头部,无独立头部,更新公共头部
|
|
|
|
$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']]);
|
|
|
|
if($templateCommonInfo === false){
|
|
|
|
$publicData['type'] = $this->param['type'];
|
|
|
|
$publicData['project_id'] = $this->user['project_id'];
|
|
|
|
$publicData['template_id'] = $bSettingInfo['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']]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|