Merge branch 'master-edit-com' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
12 个修改的文件
包含
652 行增加
和
580 行删除
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :BProjectIsComController.php | 4 | + * @name :BProjectComConfigController.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/8/1 14:24 | 7 | * @time :2024/8/1 14:24 |
| @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Bside\Template; | @@ -11,9 +11,9 @@ namespace App\Http\Controllers\Bside\Template; | ||
| 11 | 11 | ||
| 12 | use App\Enums\Common\Code; | 12 | use App\Enums\Common\Code; |
| 13 | use App\Http\Controllers\Bside\BaseController; | 13 | use App\Http\Controllers\Bside\BaseController; |
| 14 | -use App\Http\Logic\Bside\BTemplate\BProjectIsComLogic; | 14 | +use App\Http\Logic\Bside\BTemplate\BProjectComConfigLogic; |
| 15 | 15 | ||
| 16 | -class BProjectIsComController extends BaseController | 16 | +class BProjectComConfigController extends BaseController |
| 17 | { | 17 | { |
| 18 | /** | 18 | /** |
| 19 | * @remark :获取头部底部配置 | 19 | * @remark :获取头部底部配置 |
| @@ -22,7 +22,7 @@ class BProjectIsComController extends BaseController | @@ -22,7 +22,7 @@ class BProjectIsComController extends BaseController | ||
| 22 | * @method :post | 22 | * @method :post |
| 23 | * @time :2024/8/1 15:08 | 23 | * @time :2024/8/1 15:08 |
| 24 | */ | 24 | */ |
| 25 | - public function getIsComConfig(BProjectIsComLogic $logic){ | 25 | + public function getIsComConfig(BProjectComConfigLogic $logic){ |
| 26 | $data = $logic->getIsComConfig(); | 26 | $data = $logic->getIsComConfig(); |
| 27 | $this->response('success',Code::SUCCESS,$data); | 27 | $this->response('success',Code::SUCCESS,$data); |
| 28 | } | 28 | } |
| @@ -34,7 +34,7 @@ class BProjectIsComController extends BaseController | @@ -34,7 +34,7 @@ class BProjectIsComController extends BaseController | ||
| 34 | * @method :post | 34 | * @method :post |
| 35 | * @time :2024/8/1 15:38 | 35 | * @time :2024/8/1 15:38 |
| 36 | */ | 36 | */ |
| 37 | - public function saveComConfig(BProjectIsComLogic $logic){ | 37 | + public function saveComConfig(BProjectComConfigLogic $logic){ |
| 38 | $this->request->validate([ | 38 | $this->request->validate([ |
| 39 | 'data'=>'required', | 39 | 'data'=>'required', |
| 40 | ],[ | 40 | ],[ |
| @@ -13,6 +13,7 @@ use App\Http\Logic\Aside\BaseLogic; | @@ -13,6 +13,7 @@ use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | use App\Models\CustomModule\CustomModule; | 13 | use App\Models\CustomModule\CustomModule; |
| 14 | use App\Models\CustomModule\CustomModuleCategory; | 14 | use App\Models\CustomModule\CustomModuleCategory; |
| 15 | use App\Models\CustomModule\CustomModuleContent; | 15 | use App\Models\CustomModule\CustomModuleContent; |
| 16 | +use App\Models\IsCom\ProjectComConfig; | ||
| 16 | use App\Models\RouteMap\RouteMap; | 17 | use App\Models\RouteMap\RouteMap; |
| 17 | use App\Services\ProjectServer; | 18 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Support\Facades\DB; | 19 | use Illuminate\Support\Facades\DB; |
| @@ -156,6 +157,9 @@ class CustomModuleLogic extends BaseLogic | @@ -156,6 +157,9 @@ class CustomModuleLogic extends BaseLogic | ||
| 156 | $this->fail('当前模块拥有分类不允许删除'); | 157 | $this->fail('当前模块拥有分类不允许删除'); |
| 157 | } | 158 | } |
| 158 | $rs = (new CustomModule())->del($this->param); | 159 | $rs = (new CustomModule())->del($this->param); |
| 160 | + //对应删除项目头部底部配置 | ||
| 161 | + $projectComConfigModel = new ProjectComConfig(); | ||
| 162 | + $projectComConfigModel->del(['source'=>$this->param['id'],'is_custom'=>1]); | ||
| 159 | if($rs === false){ | 163 | if($rs === false){ |
| 160 | $this->fail('系统错误,请联系管理员'); | 164 | $this->fail('系统错误,请联系管理员'); |
| 161 | } | 165 | } |
| @@ -7,7 +7,7 @@ use App\Models\Manage\Manage; | @@ -7,7 +7,7 @@ use App\Models\Manage\Manage; | ||
| 7 | use App\Models\RouteMap\RouteMap; | 7 | use App\Models\RouteMap\RouteMap; |
| 8 | use App\Models\Service\Service as ServiceSettingModel; | 8 | use App\Models\Service\Service as ServiceSettingModel; |
| 9 | use App\Models\Template\BTemplate; | 9 | use App\Models\Template\BTemplate; |
| 10 | -use App\Models\Template\BTemplateCommon; | 10 | +use App\Models\Template\BTemplateCom; |
| 11 | use App\Models\Template\Template; | 11 | use App\Models\Template\Template; |
| 12 | use App\Models\Template\Setting; | 12 | use App\Models\Template\Setting; |
| 13 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| @@ -210,25 +210,34 @@ class ATemplateLogic extends BaseLogic | @@ -210,25 +210,34 @@ class ATemplateLogic extends BaseLogic | ||
| 210 | $templateInfo = $this->model->read(['id'=>$template_id]); | 210 | $templateInfo = $this->model->read(['id'=>$template_id]); |
| 211 | ProjectServer::useProject($project_id); | 211 | ProjectServer::useProject($project_id); |
| 212 | $bTemplateModel = new BTemplate(); | 212 | $bTemplateModel = new BTemplate(); |
| 213 | - $info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]); | 213 | + $info = $bTemplateModel->read(['source'=>BTemplate::SOURCE_HOME,'template_id'=>$template_id]); |
| 214 | if($info === false){ | 214 | if($info === false){ |
| 215 | $data = [ | 215 | $data = [ |
| 216 | - 'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'], | 216 | + 'source'=>BTemplate::SOURCE_HOME, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'], |
| 217 | 'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id, | 217 | 'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id, |
| 218 | ]; | 218 | ]; |
| 219 | $bTemplateModel->add($data); | 219 | $bTemplateModel->add($data); |
| 220 | } | 220 | } |
| 221 | - //保存一次公共头部信息 | ||
| 222 | - $bCommonTemplateModel = new BTemplateCommon(); | ||
| 223 | - $commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]); | ||
| 224 | - if($commonInfo === false){ | ||
| 225 | - $commonData = [ | ||
| 226 | - 'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'], | ||
| 227 | - 'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'], | ||
| 228 | - 'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id, | ||
| 229 | - 'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")) | ||
| 230 | - ]; | ||
| 231 | - $bCommonTemplateModel->add($commonData); | 221 | + //保存一次公共头部+底部+other信息 |
| 222 | + $bComTemplateModel = new BTemplateCom(); | ||
| 223 | + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM]; | ||
| 224 | + $headInfo = $bComTemplateModel->read($condition); | ||
| 225 | + if($headInfo === false){ | ||
| 226 | + $headData = ['html'=>$templateInfo['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id]; | ||
| 227 | + $bComTemplateModel->add(array_merge($condition,$headData)); | ||
| 228 | + } | ||
| 229 | + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_FOOTER,'source'=>BTemplate::SOURCE_COM]; | ||
| 230 | + $footerInfo = $bComTemplateModel->read($condition); | ||
| 231 | + if($footerInfo === false){ | ||
| 232 | + $footerData = ['html'=>$templateInfo['footer_html'], 'html_style'=>$templateInfo['footer_css'], 'project_id'=>$project_id]; | ||
| 233 | + $bComTemplateModel->add(array_merge($condition,$footerData)); | ||
| 234 | + } | ||
| 235 | + $condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_OTHER,'source'=>BTemplate::SOURCE_COM]; | ||
| 236 | + $footerInfo = $bComTemplateModel->read($condition); | ||
| 237 | + if($footerInfo === false){ | ||
| 238 | + $other = str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s")); | ||
| 239 | + $otherData = ['html'=>$other, 'html_style'=>'', 'project_id'=>$project_id]; | ||
| 240 | + $bComTemplateModel->add(array_merge($condition,$otherData)); | ||
| 232 | } | 241 | } |
| 233 | RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id); | 242 | RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id); |
| 234 | DB::disconnect('custom_mysql'); | 243 | DB::disconnect('custom_mysql'); |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :BProjectIsComLogic.php | 4 | + * @name :BProjectComConfigLogic.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/8/1 14:25 | 7 | * @time :2024/8/1 14:25 |
| @@ -11,17 +11,17 @@ namespace App\Http\Logic\Bside\BTemplate; | @@ -11,17 +11,17 @@ namespace App\Http\Logic\Bside\BTemplate; | ||
| 11 | 11 | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | use App\Models\CustomModule\CustomModule; | 13 | use App\Models\CustomModule\CustomModule; |
| 14 | -use App\Models\IsCom\ProjectIsCom; | 14 | +use App\Models\IsCom\ProjectComConfig; |
| 15 | use App\Models\Template\BTemplate; | 15 | use App\Models\Template\BTemplate; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | * @remark :独立头部——底部设置 | 18 | * @remark :独立头部——底部设置 |
| 19 | - * @name :BProjectIsComLogic | 19 | + * @name :BProjectComConfigLogic |
| 20 | * @author :lyh | 20 | * @author :lyh |
| 21 | * @method :post | 21 | * @method :post |
| 22 | * @time :2024/8/1 14:43 | 22 | * @time :2024/8/1 14:43 |
| 23 | */ | 23 | */ |
| 24 | -class BProjectIsComLogic extends BaseLogic | 24 | +class BProjectComConfigLogic extends BaseLogic |
| 25 | { | 25 | { |
| 26 | /** | 26 | /** |
| 27 | * 初始化数据 | 27 | * 初始化数据 |
| @@ -29,7 +29,7 @@ class BProjectIsComLogic extends BaseLogic | @@ -29,7 +29,7 @@ class BProjectIsComLogic extends BaseLogic | ||
| 29 | public function __construct() | 29 | public function __construct() |
| 30 | { | 30 | { |
| 31 | parent::__construct(); | 31 | parent::__construct(); |
| 32 | - $this->model = new ProjectIsCom(); | 32 | + $this->model = new ProjectComConfig(); |
| 33 | $this->param = $this->requestAll; | 33 | $this->param = $this->requestAll; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| @@ -70,7 +70,7 @@ class BProjectIsComLogic extends BaseLogic | @@ -70,7 +70,7 @@ class BProjectIsComLogic extends BaseLogic | ||
| 70 | $is_list = [self::IS_LIST,self::IS_DETAIL]; | 70 | $is_list = [self::IS_LIST,self::IS_DETAIL]; |
| 71 | foreach ($is_list as $isValue){ | 71 | foreach ($is_list as $isValue){ |
| 72 | //查询当前数据是否已保存 | 72 | //查询当前数据是否已保存 |
| 73 | - $info = $this->model->read(['source'=>$pValue,'is_list'=>$isValue,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']); | 73 | + $info = $this->model->read(['source'=>$pValue,'is_list'=>$isValue,'is_custom'=>BTemplate::IS_NO_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']); |
| 74 | if($info !== false){ | 74 | if($info !== false){ |
| 75 | $data[] = $info; | 75 | $data[] = $info; |
| 76 | }else{ | 76 | }else{ |
| @@ -98,7 +98,7 @@ class BProjectIsComLogic extends BaseLogic | @@ -98,7 +98,7 @@ class BProjectIsComLogic extends BaseLogic | ||
| 98 | public function initPageParamData(&$data){ | 98 | public function initPageParamData(&$data){ |
| 99 | $initPageParam = $this->model->initPageParam; | 99 | $initPageParam = $this->model->initPageParam; |
| 100 | foreach($initPageParam as $key => $value){ | 100 | foreach($initPageParam as $key => $value){ |
| 101 | - $info = $this->model->read(['source'=>$value,'is_list'=>self::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM],['name','source','is_list','is_custom','header_status','footer_status']); | 101 | + $info = $this->model->read(['source'=>$value,'is_list'=>self::IS_DETAIL,'is_custom'=>BTemplate::IS_NO_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']); |
| 102 | if($info !== false){ | 102 | if($info !== false){ |
| 103 | $data[] = $info; | 103 | $data[] = $info; |
| 104 | }else{ | 104 | }else{ |
| @@ -10,9 +10,11 @@ | @@ -10,9 +10,11 @@ | ||
| 10 | namespace App\Http\Logic\Bside\BTemplate; | 10 | namespace App\Http\Logic\Bside\BTemplate; |
| 11 | 11 | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | +use App\Models\IsCom\ProjectComConfig; | ||
| 13 | use App\Models\Project\PageSetting; | 14 | use App\Models\Project\PageSetting; |
| 14 | use App\Models\Service\Service as ServiceSettingModel; | 15 | use App\Models\Service\Service as ServiceSettingModel; |
| 15 | use App\Models\Template\BTemplate; | 16 | use App\Models\Template\BTemplate; |
| 17 | +use App\Models\Template\BTemplateCom; | ||
| 16 | use App\Models\Template\BTemplateCommon; | 18 | use App\Models\Template\BTemplateCommon; |
| 17 | use App\Models\Template\BTemplateLog; | 19 | use App\Models\Template\BTemplateLog; |
| 18 | use App\Models\Template\Setting; | 20 | use App\Models\Template\Setting; |
| @@ -64,13 +66,18 @@ class BTemplateLogLogic extends BaseLogic | @@ -64,13 +66,18 @@ class BTemplateLogLogic extends BaseLogic | ||
| 64 | 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']]; | 66 | 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']]; |
| 65 | //TODO::还原头部+底部 | 67 | //TODO::还原头部+底部 |
| 66 | $bTemplateModel->edit(['html'=>$info['text']],$condition); | 68 | $bTemplateModel->edit(['html'=>$info['text']],$condition); |
| 67 | - $commonData = [ | ||
| 68 | - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], | ||
| 69 | - 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css'] | ||
| 70 | - ]; | ||
| 71 | - $type = $this->getCustomizedType($info['source'],$info['is_list']); | ||
| 72 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 73 | - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]); | 69 | + $commonTemplateModel = new BTemplateCom(); |
| 70 | + //还原头部 | ||
| 71 | + $condition = ['template_id'=>$info['template_id'],'source'=>$info['source'], | ||
| 72 | + 'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']]; | ||
| 73 | + $condition['common_type'] = BTemplate::COMMON_HEAD; | ||
| 74 | + $commonTemplateModel->edit(['html'=>$info['head_html'], 'html_style'=>$info['head_css']],$condition); | ||
| 75 | + $condition['common_type'] = BTemplate::COMMON_FOOTER; | ||
| 76 | + $commonTemplateModel->edit(['html'=>$info['footer_html'], 'html_style'=>$info['footer_css']],$condition); | ||
| 77 | + $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 78 | + $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 79 | + $condition['common_type'] = BTemplate::COMMON_OTHER; | ||
| 80 | + $commonTemplateModel->edit(['html'=>$other, 'html_style'=>''],$condition); | ||
| 74 | return $this->success(); | 81 | return $this->success(); |
| 75 | } | 82 | } |
| 76 | 83 | ||
| @@ -99,18 +106,9 @@ class BTemplateLogLogic extends BaseLogic | @@ -99,18 +106,9 @@ class BTemplateLogLogic extends BaseLogic | ||
| 99 | $bTemplateModel->edit($data,$condition); | 106 | $bTemplateModel->edit($data,$condition); |
| 100 | //还原头部+底部 | 107 | //还原头部+底部 |
| 101 | $commonData = [ | 108 | $commonData = [ |
| 102 | - 'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css'] | 109 | + 'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_style'=>$info['footer_css'],'other'=>$info['other'] |
| 103 | ]; | 110 | ]; |
| 104 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 105 | - $type = $this->getType($info['source'],$info['is_list'],$info['is_custom']); | ||
| 106 | - $commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]); | ||
| 107 | - if(!empty($info['other'])){ | ||
| 108 | - $commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]); | ||
| 109 | - }else{ | ||
| 110 | - $footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 111 | - $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 112 | - $commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]); | ||
| 113 | - } | 111 | + $this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']); |
| 114 | }catch (\Exception $e){ | 112 | }catch (\Exception $e){ |
| 115 | $this->fail('系统错误,请联系管理员'); | 113 | $this->fail('系统错误,请联系管理员'); |
| 116 | } | 114 | } |
| @@ -118,36 +116,40 @@ class BTemplateLogLogic extends BaseLogic | @@ -118,36 +116,40 @@ class BTemplateLogLogic extends BaseLogic | ||
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | /** | 118 | /** |
| 121 | - * @remark :定制页面头部类型---根据source获取type类型 | ||
| 122 | - * @name :getType | 119 | + * @remark :保存公共部分(头部。底部。连接部分) |
| 120 | + * @name :saveTemplateCom | ||
| 123 | * @author :lyh | 121 | * @author :lyh |
| 124 | * @method :post | 122 | * @method :post |
| 125 | - * @time :2023/11/16 11:20 | 123 | + * @time :2024/4/29 10:32 |
| 126 | */ | 124 | */ |
| 127 | - public function getCustomizedType($source,$is_list){ | ||
| 128 | - $type = BTemplate::TYPE_HOME; | ||
| 129 | - if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 130 | - if($is_list == BTemplate::IS_LIST){ | ||
| 131 | - $type = BTemplate::TYPE_PRODUCT_LIST; | 125 | + public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){ |
| 126 | + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER]; | ||
| 127 | + $templateComModel = new BTemplateCom(); | ||
| 128 | + foreach ($typeArr as $type){ | ||
| 129 | + if($type == BTemplate::COMMON_HEAD){ | ||
| 130 | + $param['html'] = $handleInfo['head_html']; | ||
| 131 | + $param['html_style'] = $handleInfo['head_style']; | ||
| 132 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部 | ||
| 133 | + }elseif ($type == BTemplate::COMMON_FOOTER){ | ||
| 134 | + $param['html'] = $handleInfo['footer_html']; | ||
| 135 | + $param['html_style'] = $handleInfo['footer_style']; | ||
| 136 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id); | ||
| 132 | }else{ | 137 | }else{ |
| 133 | - $type = BTemplate::TYPE_PRODUCT_DETAIL; | 138 | + $param['html'] = $handleInfo['other']; |
| 139 | + $param['html_style'] = null; | ||
| 140 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id); | ||
| 134 | } | 141 | } |
| 135 | - } | ||
| 136 | - if($source == BTemplate::SOURCE_BLOG){ | ||
| 137 | - if($is_list == BTemplate::IS_LIST){ | ||
| 138 | - $type = BTemplate::TYPE_BLOG_LIST; | ||
| 139 | - }else{ | ||
| 140 | - $type = BTemplate::TYPE_BLOG_DETAIL; | ||
| 141 | - } | ||
| 142 | - } | ||
| 143 | - if($source == BTemplate::SOURCE_NEWS){ | ||
| 144 | - if($is_list == BTemplate::IS_LIST){ | ||
| 145 | - $type = BTemplate::TYPE_NEWS_LIST; | 142 | + //查看当前数据是否还存在 |
| 143 | + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type]; | ||
| 144 | + $info = $templateComModel->read($condition); | ||
| 145 | + if($info === false){ | ||
| 146 | + $data = array_merge($param,$condition); | ||
| 147 | + $templateComModel->add($data); | ||
| 146 | }else{ | 148 | }else{ |
| 147 | - $type = BTemplate::TYPE_NEWS_DETAIL; | 149 | + $templateComModel->edit($param,$condition); |
| 148 | } | 150 | } |
| 149 | } | 151 | } |
| 150 | - return $type; | 152 | + return $this->success(); |
| 151 | } | 153 | } |
| 152 | 154 | ||
| 153 | /** | 155 | /** |
| @@ -157,26 +159,28 @@ class BTemplateLogLogic extends BaseLogic | @@ -157,26 +159,28 @@ class BTemplateLogLogic extends BaseLogic | ||
| 157 | * @method :post | 159 | * @method :post |
| 158 | * @time :2023/10/21 17:29 | 160 | * @time :2023/10/21 17:29 |
| 159 | */ | 161 | */ |
| 160 | - public function getType($source,$is_list,$is_custom = 0){ | ||
| 161 | - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 | 162 | + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){ |
| 163 | + if($template_id == 0){ | ||
| 164 | + return $this->success($source); | ||
| 165 | + } | ||
| 166 | + $type = BTemplate::SOURCE_COM;//公共头部底部 | ||
| 162 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; | 167 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; |
| 163 | - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 | 168 | + if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底 |
| 164 | return $this->success($type); | 169 | return $this->success($type); |
| 165 | } | 170 | } |
| 166 | //查看页面是否设置自定义头部底部 | 171 | //查看页面是否设置自定义头部底部 |
| 167 | - if($is_head != BTemplate::IS_NO_HEADER) { | ||
| 168 | - $pageSettingModel = new PageSetting(); | ||
| 169 | - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 170 | - if ($pageInfo === false) { | ||
| 171 | - return $this->success($type); | ||
| 172 | - } | ||
| 173 | - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}} | ||
| 174 | - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}} | ||
| 175 | - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}} | ||
| 176 | - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}} | ||
| 177 | - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}} | ||
| 178 | - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}} | ||
| 179 | - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}} | 172 | + $comConfigModel = new ProjectComConfig(); |
| 173 | + $configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 174 | + if($configInfo === false){ | ||
| 175 | + return $this->success($type); | ||
| 176 | + } | ||
| 177 | + //头部 | ||
| 178 | + if($commonType == BTemplate::COMMON_HEAD){ | ||
| 179 | + return $this->success($configInfo['header_status'] == 0 ? $type : $source); | ||
| 180 | + } | ||
| 181 | + //底部 | ||
| 182 | + if($commonType == BTemplate::COMMON_FOOTER){ | ||
| 183 | + return $this->success($configInfo['footer_status'] == 0 ? $type : $source); | ||
| 180 | } | 184 | } |
| 181 | return $this->success($type); | 185 | return $this->success($type); |
| 182 | } | 186 | } |
| @@ -6,12 +6,13 @@ use App\Http\Logic\Bside\BaseLogic; | @@ -6,12 +6,13 @@ use App\Http\Logic\Bside\BaseLogic; | ||
| 6 | use App\Models\Blog\BlogCategory; | 6 | use App\Models\Blog\BlogCategory; |
| 7 | use App\Models\CustomModule\CustomModule; | 7 | use App\Models\CustomModule\CustomModule; |
| 8 | use App\Models\CustomModule\CustomModuleCategory; | 8 | use App\Models\CustomModule\CustomModuleCategory; |
| 9 | +use App\Models\IsCom\ProjectComConfig; | ||
| 9 | use App\Models\News\NewsCategory; | 10 | use App\Models\News\NewsCategory; |
| 10 | use App\Models\Product\Category; | 11 | use App\Models\Product\Category; |
| 11 | use App\Models\Project\PageSetting; | 12 | use App\Models\Project\PageSetting; |
| 12 | use App\Models\RouteMap\RouteMap; | 13 | use App\Models\RouteMap\RouteMap; |
| 13 | use App\Models\Service\Service as ServiceSettingModel; | 14 | use App\Models\Service\Service as ServiceSettingModel; |
| 14 | -use App\Models\Template\BTemplateCommon; | 15 | +use App\Models\Template\BTemplateCom; |
| 15 | use App\Models\Template\BTemplateMain; | 16 | use App\Models\Template\BTemplateMain; |
| 16 | use App\Models\Template\Setting; | 17 | use App\Models\Template\Setting; |
| 17 | use App\Models\Template\BTemplate; | 18 | use App\Models\Template\BTemplate; |
| @@ -76,11 +77,11 @@ class BTemplateLogic extends BaseLogic | @@ -76,11 +77,11 @@ class BTemplateLogic extends BaseLogic | ||
| 76 | $is_list = $this->param['is_list'] ?? 0;//是否为列表页 | 77 | $is_list = $this->param['is_list'] ?? 0;//是否为列表页 |
| 77 | $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id | 78 | $template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id |
| 78 | $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); | 79 | $templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list); |
| 79 | - if($templateInfo === false){ | 80 | + if($templateInfo === false){//todo::无装修数据处理 |
| 80 | if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据 | 81 | if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据 |
| 81 | - $html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list); | ||
| 82 | - if($html !== false){ | ||
| 83 | - return $this->success($html); | 82 | + $data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list); |
| 83 | + if($data !== false){ | ||
| 84 | + return $this->success($data); | ||
| 84 | } | 85 | } |
| 85 | } | 86 | } |
| 86 | //非定制初始中间部分 | 87 | //非定制初始中间部分 |
| @@ -91,15 +92,89 @@ class BTemplateLogic extends BaseLogic | @@ -91,15 +92,89 @@ class BTemplateLogic extends BaseLogic | ||
| 91 | } | 92 | } |
| 92 | $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; | 93 | $mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']]; |
| 93 | } | 94 | } |
| 94 | - $commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部 | ||
| 95 | - $html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | 95 | + $commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部 |
| 96 | + $html = $commonInfo['head_style'].$mainInfo['main_css'].$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html']; | ||
| 96 | $html = $this->getHeadFooter($html); | 97 | $html = $this->getHeadFooter($html); |
| 97 | $result = ['html'=>$html,'template_id'=>$template_id]; | 98 | $result = ['html'=>$html,'template_id'=>$template_id]; |
| 98 | - if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];} | 99 | + if($templateInfo !== false) { |
| 100 | + $result['id'] = $templateInfo['id']; | ||
| 101 | + $result['updated_at'] = $templateInfo['updated_at']; | ||
| 102 | + } | ||
| 99 | return $this->success($result); | 103 | return $this->success($result); |
| 100 | } | 104 | } |
| 101 | 105 | ||
| 102 | /** | 106 | /** |
| 107 | + * @remark :非定制获取头部+底部 | ||
| 108 | + * @name :getTemplateComHtml | ||
| 109 | + * @author :lyh | ||
| 110 | + * @method :post | ||
| 111 | + * @time :2024/4/29 16:53 | ||
| 112 | + */ | ||
| 113 | + public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){ | ||
| 114 | + $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; | ||
| 115 | + $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); | ||
| 116 | + $bTemplateComModel = new BTemplateCom(); | ||
| 117 | + $condition['common_type'] = BTemplate::COMMON_OTHER; | ||
| 118 | + $condition['source'] = $headComInfo['source']; | ||
| 119 | + $condition['is_list'] = $headComInfo['is_list']; | ||
| 120 | + $otherInfo = $bTemplateComModel->read($condition); | ||
| 121 | + if($otherInfo === false){ | ||
| 122 | + $this->fail('获取失败,请联系管理员222'); | ||
| 123 | + } | ||
| 124 | + $footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id); | ||
| 125 | + $data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', | ||
| 126 | + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; | ||
| 127 | + return $this->success($data); | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + /** | ||
| 131 | + * @remark :公共头部 | ||
| 132 | + * @name :HeadComHtml | ||
| 133 | + * @author :lyh | ||
| 134 | + * @method :post | ||
| 135 | + * @time :2024/4/29 17:20 | ||
| 136 | + */ | ||
| 137 | + public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){ | ||
| 138 | + $commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id); | ||
| 139 | + $bTemplateComModel = new BTemplateCom(); | ||
| 140 | + $condition['source'] = $commonHead; | ||
| 141 | + $condition['common_type'] = BTemplate::COMMON_HEAD; | ||
| 142 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 143 | + if($headComInfo === false){ | ||
| 144 | + //取默认公共的 | ||
| 145 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 146 | + $condition['is_list'] = BTemplate::IS_DETAIL; | ||
| 147 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 148 | + if($headComInfo === false){ | ||
| 149 | + $this->fail('获取失败,请联系管理员1111'); | ||
| 150 | + } | ||
| 151 | + } | ||
| 152 | + return $this->success($headComInfo); | ||
| 153 | + } | ||
| 154 | + /** | ||
| 155 | + * @remark :公共底部 | ||
| 156 | + * @name :footerComHtml | ||
| 157 | + * @author :lyh | ||
| 158 | + * @method :post | ||
| 159 | + * @time :2024/4/29 17:18 | ||
| 160 | + */ | ||
| 161 | + public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){ | ||
| 162 | + $bTemplateComModel = new BTemplateCom(); | ||
| 163 | + $condition['common_type'] = BTemplate::COMMON_FOOTER; | ||
| 164 | + $condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id); | ||
| 165 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 166 | + if($footerComInfo === false){ | ||
| 167 | + //取默认首页的 | ||
| 168 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 169 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 170 | + if($footerComInfo === false){ | ||
| 171 | + $this->fail('获取失败,请联系管理员'); | ||
| 172 | + } | ||
| 173 | + } | ||
| 174 | + return $this->success($footerComInfo); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + /** | ||
| 103 | * @remark :获取整个html代码 | 178 | * @remark :获取整个html代码 |
| 104 | * @name :getCustomizeAllHtml | 179 | * @name :getCustomizeAllHtml |
| 105 | * @author :lyh | 180 | * @author :lyh |
| @@ -108,11 +183,11 @@ class BTemplateLogic extends BaseLogic | @@ -108,11 +183,11 @@ class BTemplateLogic extends BaseLogic | ||
| 108 | */ | 183 | */ |
| 109 | public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){ | 184 | public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){ |
| 110 | if($is_custom == BTemplate::IS_CUSTOM){ | 185 | if($is_custom == BTemplate::IS_CUSTOM){ |
| 111 | - $commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部 | 186 | + $commonInfo = $this->getCustomizeTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部 |
| 112 | $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | 187 | $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); |
| 113 | }else{ | 188 | }else{ |
| 114 | - $type = $this->getCustomizedType($this->param['source'],$is_list); | ||
| 115 | - $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 | 189 | + $type = $this->getCustomizedType($templateInfo['source'],$is_list); |
| 190 | + $commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部 | ||
| 116 | $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); | 191 | $html = $this->handleAllHtml($commonInfo,$templateInfo['html']); |
| 117 | } | 192 | } |
| 118 | return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); | 193 | return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]); |
| @@ -149,11 +224,12 @@ class BTemplateLogic extends BaseLogic | @@ -149,11 +224,12 @@ class BTemplateLogic extends BaseLogic | ||
| 149 | if($info === false){ | 224 | if($info === false){ |
| 150 | $this->fail('当前扩展模块不存在或已被删除'); | 225 | $this->fail('当前扩展模块不存在或已被删除'); |
| 151 | } | 226 | } |
| 152 | - //扩展模块定制 | 227 | + //扩展模块定制列表 |
| 153 | if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){ | 228 | if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){ |
| 154 | $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); | 229 | $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); |
| 155 | return $this->success(['html'=>$html,'template_id'=>$template_id]); | 230 | return $this->success(['html'=>$html,'template_id'=>$template_id]); |
| 156 | } | 231 | } |
| 232 | + //扩展模块定制详情 | ||
| 157 | if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ | 233 | if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){ |
| 158 | $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); | 234 | $html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom); |
| 159 | return $this->success(['html'=>$html,'template_id'=>$template_id]); | 235 | return $this->success(['html'=>$html,'template_id'=>$template_id]); |
| @@ -182,7 +258,7 @@ class BTemplateLogic extends BaseLogic | @@ -182,7 +258,7 @@ class BTemplateLogic extends BaseLogic | ||
| 182 | if($customHtmlInfo === false){ | 258 | if($customHtmlInfo === false){ |
| 183 | $this->fail('定制页面,请先上传代码块'); | 259 | $this->fail('定制页面,请先上传代码块'); |
| 184 | } | 260 | } |
| 185 | - $commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部 | 261 | + $commonInfo = $this->getCustomizeTemplateComHtml($source,$is_custom,$is_list);//获取定制头部 |
| 186 | if($commonInfo !== false){ | 262 | if($commonInfo !== false){ |
| 187 | $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); | 263 | $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); |
| 188 | } | 264 | } |
| @@ -262,7 +338,7 @@ class BTemplateLogic extends BaseLogic | @@ -262,7 +338,7 @@ class BTemplateLogic extends BaseLogic | ||
| 262 | if($customHtmlInfo === false){ | 338 | if($customHtmlInfo === false){ |
| 263 | $this->fail('定制页面,请先上传代码块'); | 339 | $this->fail('定制页面,请先上传代码块'); |
| 264 | } | 340 | } |
| 265 | - $commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部 | 341 | + $commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部 |
| 266 | if($commonInfo !== false){ | 342 | if($commonInfo !== false){ |
| 267 | $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); | 343 | $customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']); |
| 268 | } | 344 | } |
| @@ -278,49 +354,25 @@ class BTemplateLogic extends BaseLogic | @@ -278,49 +354,25 @@ class BTemplateLogic extends BaseLogic | ||
| 278 | * @method :post | 354 | * @method :post |
| 279 | * @time :2023/12/29 13:13 | 355 | * @time :2023/12/29 13:13 |
| 280 | */ | 356 | */ |
| 281 | - public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){ | ||
| 282 | - $data = [ | ||
| 283 | - 'template_id' => 0, | ||
| 284 | - 'project_id' => $this->user['project_id'], | ||
| 285 | - 'type'=>$type, | ||
| 286 | - 'is_custom'=>$is_custom, | ||
| 287 | - 'is_list'=>$is_list | ||
| 288 | - ]; | ||
| 289 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 290 | - return $commonTemplateModel->read($data); | ||
| 291 | - } | ||
| 292 | - | ||
| 293 | - /** | ||
| 294 | - * @remark :定制页面头部类型---根据source获取type类型 | ||
| 295 | - * @name :getType | ||
| 296 | - * @author :lyh | ||
| 297 | - * @method :post | ||
| 298 | - * @time :2023/11/16 11:20 | ||
| 299 | - */ | ||
| 300 | - public function getCustomizedType($source,$is_list){ | ||
| 301 | - $type = BTemplate::TYPE_HOME; | ||
| 302 | - if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 303 | - if($is_list == BTemplate::IS_LIST){ | ||
| 304 | - $type = BTemplate::TYPE_PRODUCT_LIST; | ||
| 305 | - }else{ | ||
| 306 | - $type = BTemplate::TYPE_PRODUCT_DETAIL; | ||
| 307 | - } | ||
| 308 | - } | ||
| 309 | - if($source == BTemplate::SOURCE_BLOG){ | ||
| 310 | - if($is_list == BTemplate::IS_LIST){ | ||
| 311 | - $type = BTemplate::TYPE_BLOG_LIST; | ||
| 312 | - }else{ | ||
| 313 | - $type = BTemplate::TYPE_BLOG_DETAIL; | ||
| 314 | - } | ||
| 315 | - } | ||
| 316 | - if($source == BTemplate::SOURCE_NEWS){ | ||
| 317 | - if($is_list == BTemplate::IS_LIST){ | ||
| 318 | - $type = BTemplate::TYPE_NEWS_LIST; | ||
| 319 | - }else{ | ||
| 320 | - $type = BTemplate::TYPE_NEWS_DETAIL; | 357 | + public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){ |
| 358 | + $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>'']; | ||
| 359 | + $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]; | ||
| 360 | + $commonTemplateModel = new BTemplateCom(); | ||
| 361 | + $commonList = $commonTemplateModel->list($param); | ||
| 362 | + if(!empty($commonList)){ | ||
| 363 | + foreach ($commonList as $v){ | ||
| 364 | + if($v['common_type'] == BTemplate::COMMON_HEAD){ | ||
| 365 | + $data['head_html'] = $v['html']; | ||
| 366 | + $data['head_style'] = $v['html_style']; | ||
| 367 | + }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){ | ||
| 368 | + $data['footer_html'] = $v['html']; | ||
| 369 | + $data['footer_style'] = $v['html_style']; | ||
| 370 | + }else{ | ||
| 371 | + $data['other'] = $v['html']; | ||
| 372 | + } | ||
| 321 | } | 373 | } |
| 322 | } | 374 | } |
| 323 | - return $type; | 375 | + return $this->success($data); |
| 324 | } | 376 | } |
| 325 | 377 | ||
| 326 | /** | 378 | /** |
| @@ -359,37 +411,9 @@ class BTemplateLogic extends BaseLogic | @@ -359,37 +411,9 @@ class BTemplateLogic extends BaseLogic | ||
| 359 | if($info === false){ | 411 | if($info === false){ |
| 360 | $this->fail('请先选择模版'); | 412 | $this->fail('请先选择模版'); |
| 361 | } | 413 | } |
| 362 | - $template_id = $info['template_id']; | ||
| 363 | - return $this->success($template_id); | ||
| 364 | - } | ||
| 365 | - | ||
| 366 | - /** | ||
| 367 | - * @remark :根据类型获取公共头和底 | ||
| 368 | - * @name :getCommonPage | ||
| 369 | - * @author :lyh | ||
| 370 | - * @method :post | ||
| 371 | - * @time :2023/10/21 16:55 | ||
| 372 | - */ | ||
| 373 | - public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){ | ||
| 374 | - $type = $this->getType($source,$is_list,$is_custom); | ||
| 375 | - $data = [ | ||
| 376 | - 'template_id' => $template_id, | ||
| 377 | - 'project_id' => $this->user['project_id'], | ||
| 378 | - 'type'=>$type, | ||
| 379 | - 'is_custom'=>0, | ||
| 380 | - ]; | ||
| 381 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 382 | - $commonInfo = $commonTemplateModel->read($data); | ||
| 383 | - if($commonInfo === false){ | ||
| 384 | - $data['type'] = BTemplate::SOURCE_HOME; | ||
| 385 | - $commonInfo = $commonTemplateModel->read($data); | ||
| 386 | - } | ||
| 387 | - return $this->success($commonInfo); | 414 | + return $this->success($info['template_id']); |
| 388 | } | 415 | } |
| 389 | 416 | ||
| 390 | - | ||
| 391 | - | ||
| 392 | - | ||
| 393 | /** | 417 | /** |
| 394 | * @remark :保存修改后的模版 | 418 | * @remark :保存修改后的模版 |
| 395 | * @name :templateSave | 419 | * @name :templateSave |
| @@ -417,14 +441,12 @@ class BTemplateLogic extends BaseLogic | @@ -417,14 +441,12 @@ class BTemplateLogic extends BaseLogic | ||
| 417 | 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'], | 441 | 'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'], |
| 418 | 'is_list'=>$this->param['is_list'] | 442 | 'is_list'=>$this->param['is_list'] |
| 419 | ]; | 443 | ]; |
| 420 | - $data = [ | ||
| 421 | - 'section_list_id'=>$this->param['section_list_id'] | ||
| 422 | - ]; | 444 | + $data = ['section_list_id'=>$this->param['section_list_id']]; |
| 423 | $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data); | 445 | $data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data); |
| 424 | $this->model->edit($data,$condition); | 446 | $this->model->edit($data,$condition); |
| 425 | } | 447 | } |
| 426 | //更新头部信息 | 448 | //更新头部信息 |
| 427 | - $this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']); | 449 | + $this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']); |
| 428 | $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']); | 450 | $this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']); |
| 429 | //通知更新 | 451 | //通知更新 |
| 430 | $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); | 452 | $this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']); |
| @@ -454,117 +476,73 @@ class BTemplateLogic extends BaseLogic | @@ -454,117 +476,73 @@ class BTemplateLogic extends BaseLogic | ||
| 454 | * @time :2023/12/15 10:59 | 476 | * @time :2023/12/15 10:59 |
| 455 | */ | 477 | */ |
| 456 | public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){ | 478 | public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){ |
| 457 | - if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目 | ||
| 458 | - //TODO::扩展模块定制单独处理 | ||
| 459 | - if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 460 | - $customModuleModel = new CustomModule(); | ||
| 461 | - $info = $customModuleModel->read(['id'=>$source]); | ||
| 462 | - if($info === false){ | ||
| 463 | - $this->fail('当前扩展模块不存在或已被删除'); | ||
| 464 | - } | ||
| 465 | - //todo::扩展模块(列表页/详情页)定制 | ||
| 466 | - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) { | ||
| 467 | - $data['html'] = $html; | ||
| 468 | - $data['type'] = BTemplate::ALL_HTML; | ||
| 469 | - return $this->success($data); | ||
| 470 | - } | ||
| 471 | - }else{ | 479 | + //TODO::扩展模块定制单独处理 |
| 480 | + if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 481 | + $customModuleModel = new CustomModule(); | ||
| 482 | + $info = $customModuleModel->read(['id'=>$source]); | ||
| 483 | + if($info === false){ | ||
| 484 | + $this->fail('当前扩展模块不存在或已被删除'); | ||
| 485 | + } | ||
| 486 | + //todo::扩展模块(列表页/详情页)定制 | ||
| 487 | + if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) { | ||
| 488 | + $data['html'] = $html; | ||
| 489 | + $data['type'] = BTemplate::ALL_HTML; | ||
| 490 | + return $this->success($data); | ||
| 491 | + } | ||
| 492 | + }else{ | ||
| 493 | + if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){ | ||
| 472 | $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 | 494 | $type = $this->getCustomizedType($source, $is_list);//获取定制界面类型 |
| 473 | - //查看当前页面是否定制,是否开启可视化 | ||
| 474 | $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 | 495 | $page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面 |
| 475 | - if (in_array($type, $page_array)) {//当前页面是定制界面 | 496 | + if(in_array($type, $page_array)){ |
| 476 | $data['html'] = $html; | 497 | $data['html'] = $html; |
| 477 | $data['type'] = BTemplate::ALL_HTML; | 498 | $data['type'] = BTemplate::ALL_HTML; |
| 478 | return $this->success($data); | 499 | return $this->success($data); |
| 479 | } | 500 | } |
| 480 | } | 501 | } |
| 481 | } | 502 | } |
| 482 | - $mainInfo = $this->handleTemplateHtml($html); | ||
| 483 | - $data['main_html'] = $mainInfo['main_html']; | ||
| 484 | - $data['main_css'] = $mainInfo['main_css']; | 503 | + $data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); |
| 504 | + $data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | ||
| 485 | return $this->success($data); | 505 | return $this->success($data); |
| 486 | } | 506 | } |
| 487 | 507 | ||
| 488 | /** | 508 | /** |
| 489 | - * @remark :保存公共头部底部 | ||
| 490 | - * @name :saveCommonHtml | 509 | + * @remark :保存公共部分(头部。底部。连接部分) |
| 510 | + * @name :saveTemplateCom | ||
| 491 | * @author :lyh | 511 | * @author :lyh |
| 492 | * @method :post | 512 | * @method :post |
| 493 | - * @time :2023/12/13 17:05 | 513 | + * @time :2024/4/29 10:32 |
| 494 | */ | 514 | */ |
| 495 | - public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){ | ||
| 496 | - //TODO::定制扩展模块单独处理 | ||
| 497 | - if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 498 | - $code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id); | ||
| 499 | - if($code === false){ | ||
| 500 | - return $this->success(); | ||
| 501 | - } | ||
| 502 | - } | ||
| 503 | - //todo::其他情况 | ||
| 504 | - $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面) | ||
| 505 | - if($template_id == 0){//定制页面默认为独立头部 | ||
| 506 | - $type = $this->getCustomizedType($source,$is_list);//定制默认独立头部 | ||
| 507 | - } | ||
| 508 | - $templateCommonModel = new BTemplateCommon(); | ||
| 509 | - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在 | 515 | + public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){ |
| 516 | + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER]; | ||
| 510 | $handleInfo = $this->handleCommonParam($html); | 517 | $handleInfo = $this->handleCommonParam($html); |
| 511 | - if($commonInfo === false){ | ||
| 512 | - $data = [ | ||
| 513 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 514 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 515 | - 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'], | ||
| 516 | - ]; | ||
| 517 | - $templateCommonModel->add($data); | ||
| 518 | - }else{ | ||
| 519 | - $data = [ | ||
| 520 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 521 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 522 | - ]; | ||
| 523 | - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | ||
| 524 | - } | ||
| 525 | - //更新所有界面的other | ||
| 526 | - if($template_id != 0){ | ||
| 527 | - return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]); | ||
| 528 | - } | ||
| 529 | - } | ||
| 530 | - | ||
| 531 | - /** | ||
| 532 | - * @remark :扩展模块定制保存头部处理 | ||
| 533 | - * @name :saveCustomModuleCommonHtml | ||
| 534 | - * @author :lyh | ||
| 535 | - * @method :post | ||
| 536 | - * @time :2024/1/10 11:33 | ||
| 537 | - */ | ||
| 538 | - public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){ | ||
| 539 | - $customModuleModel = new CustomModule(); | ||
| 540 | - $info = $customModuleModel->read(['id'=>$source]); | ||
| 541 | - if($info === false){ | ||
| 542 | - $this->fail('当前扩展模块不存在或已被删除'); | ||
| 543 | - } | ||
| 544 | - //todo::扩展模块(列表页/详情页)定制 | ||
| 545 | - if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) { | ||
| 546 | - $data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id]; | ||
| 547 | - $templateCommonModel = new BTemplateCommon(); | ||
| 548 | - $commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在 | ||
| 549 | - $handleInfo = $this->handleCommonParam($html); | ||
| 550 | - if($commonInfo === false){ | ||
| 551 | - $data = [ | ||
| 552 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 553 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 554 | - 'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'], | ||
| 555 | - 'is_custom'=>$is_custom,'is_list'=>$is_list, | ||
| 556 | - ]; | ||
| 557 | - $templateCommonModel->add($data); | 518 | + $templateComModel = new BTemplateCom(); |
| 519 | + foreach ($typeArr as $type){ | ||
| 520 | + if($type == BTemplate::COMMON_HEAD){ | ||
| 521 | + $param['html'] = $handleInfo['head_html']; | ||
| 522 | + $param['html_style'] = $handleInfo['head_style']; | ||
| 523 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部 | ||
| 524 | + }elseif ($type == BTemplate::COMMON_FOOTER){ | ||
| 525 | + $param['html'] = $handleInfo['footer_html']; | ||
| 526 | + $param['html_style'] = $handleInfo['footer_style']; | ||
| 527 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id); | ||
| 558 | }else{ | 528 | }else{ |
| 559 | - $data = [ | ||
| 560 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 561 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 562 | - ]; | ||
| 563 | - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | 529 | + $param['html'] = $handleInfo['other']; |
| 530 | + $param['html_style'] = null; | ||
| 531 | + $typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id); | ||
| 532 | + } | ||
| 533 | + $list_is = $is_list; | ||
| 534 | + ($typeSource == 99) ? $list_is = 0 : $list_is; | ||
| 535 | + //查看当前数据是否还存在 | ||
| 536 | + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$list_is,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type]; | ||
| 537 | + $info = $templateComModel->read($condition); | ||
| 538 | + if($info === false){ | ||
| 539 | + $data = array_merge($param,$condition); | ||
| 540 | + $templateComModel->add($data); | ||
| 541 | + }else{ | ||
| 542 | + $templateComModel->edit($param,$condition); | ||
| 564 | } | 543 | } |
| 565 | - return false; | ||
| 566 | } | 544 | } |
| 567 | - return true; | 545 | + return $this->success(); |
| 568 | } | 546 | } |
| 569 | 547 | ||
| 570 | /** | 548 | /** |
| @@ -593,59 +571,46 @@ class BTemplateLogic extends BaseLogic | @@ -593,59 +571,46 @@ class BTemplateLogic extends BaseLogic | ||
| 593 | //字符串截取 | 571 | //字符串截取 |
| 594 | $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); | 572 | $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); |
| 595 | $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); | 573 | $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); |
| 596 | - $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); | ||
| 597 | - $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | 574 | + $param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); |
| 575 | + $param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | ||
| 598 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | 576 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); |
| 599 | $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | 577 | $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); |
| 600 | return $this->success($param); | 578 | return $this->success($param); |
| 601 | } | 579 | } |
| 602 | 580 | ||
| 603 | /** | 581 | /** |
| 604 | - * @remark :保存时字符串处理 | ||
| 605 | - * @name :handleSaveParam | ||
| 606 | - * @author :lyh | ||
| 607 | - * @method :post | ||
| 608 | - * @time :2023/6/29 15:35 | ||
| 609 | - */ | ||
| 610 | - public function handleTemplateHtml($html){ | ||
| 611 | - //字符串截取 | ||
| 612 | - $param['main_html'] = characterTruncationStr($html,"<main","</main>"); | ||
| 613 | - $param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | ||
| 614 | - return $this->success($param); | ||
| 615 | - } | ||
| 616 | - | ||
| 617 | - /** | ||
| 618 | - * @remark :(非定制)保存时获取获取设置的类型 | ||
| 619 | - * @name :getType | 582 | + * @remark :获取类型 |
| 583 | + * @name :getTypes | ||
| 620 | * @author :lyh | 584 | * @author :lyh |
| 621 | * @method :post | 585 | * @method :post |
| 622 | - * @time :2023/10/21 17:29 | 586 | + * @time :2024/8/1 16:01 |
| 623 | */ | 587 | */ |
| 624 | - public function getType($source,$is_list,$is_custom = 0){ | ||
| 625 | - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 | 588 | + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){ |
| 589 | + if($template_id == 0){ | ||
| 590 | + return $this->success($source); | ||
| 591 | + } | ||
| 592 | + $type = BTemplate::SOURCE_COM;//公共头部底部 | ||
| 626 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; | 593 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; |
| 627 | - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 | 594 | + if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底 |
| 628 | return $this->success($type); | 595 | return $this->success($type); |
| 629 | } | 596 | } |
| 630 | //查看页面是否设置自定义头部底部 | 597 | //查看页面是否设置自定义头部底部 |
| 631 | - if($is_head != BTemplate::IS_NO_HEADER) { | ||
| 632 | - $pageSettingModel = new PageSetting(); | ||
| 633 | - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 634 | - if ($pageInfo === false) { | ||
| 635 | - return $this->success($type); | ||
| 636 | - } | ||
| 637 | - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}} | ||
| 638 | - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}} | ||
| 639 | - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}} | ||
| 640 | - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}} | ||
| 641 | - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}} | ||
| 642 | - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}} | ||
| 643 | - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}} | 598 | + $comConfigModel = new ProjectComConfig(); |
| 599 | + $configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 600 | + if($configInfo === false){ | ||
| 601 | + return $this->success($type); | ||
| 602 | + } | ||
| 603 | + //头部 | ||
| 604 | + if($commonType == BTemplate::COMMON_HEAD){ | ||
| 605 | + return $this->success($configInfo['header_status'] == 0 ? $type : $source); | ||
| 606 | + } | ||
| 607 | + //底部 | ||
| 608 | + if($commonType == BTemplate::COMMON_FOOTER){ | ||
| 609 | + return $this->success($configInfo['footer_status'] == 0 ? $type : $source); | ||
| 644 | } | 610 | } |
| 645 | return $this->success($type); | 611 | return $this->success($type); |
| 646 | } | 612 | } |
| 647 | 613 | ||
| 648 | - | ||
| 649 | /** | 614 | /** |
| 650 | * @remark :生成记录 | 615 | * @remark :生成记录 |
| 651 | * @name :setTemplateLog | 616 | * @name :setTemplateLog |
| @@ -946,22 +911,35 @@ class BTemplateLogic extends BaseLogic | @@ -946,22 +911,35 @@ class BTemplateLogic extends BaseLogic | ||
| 946 | } | 911 | } |
| 947 | 912 | ||
| 948 | /** | 913 | /** |
| 949 | - * @remark :设置模版 | ||
| 950 | - * @name :setCustomTemplate | 914 | + * @remark :定制页面头部类型---根据source获取type类型 |
| 915 | + * @name :getType | ||
| 951 | * @author :lyh | 916 | * @author :lyh |
| 952 | * @method :post | 917 | * @method :post |
| 953 | - * @time :2024/5/24 15:55 | 918 | + * @time :2023/11/16 11:20 |
| 954 | */ | 919 | */ |
| 955 | - public function setCustomTemplate(){ | ||
| 956 | - $templateModel = new Template(); | ||
| 957 | - $templateInfo = $templateModel->read(['id'=>$this->param['template_id']],['id','main_html','main_css']); | ||
| 958 | - if($templateInfo === false){ | ||
| 959 | - $this->fail('未获取到模版数据'); | 920 | + public function getCustomizedType($source,$is_list){ |
| 921 | + $type = BTemplate::TYPE_HOME; | ||
| 922 | + if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 923 | + if($is_list == BTemplate::IS_LIST){ | ||
| 924 | + $type = BTemplate::TYPE_PRODUCT_LIST; | ||
| 925 | + }else{ | ||
| 926 | + $type = BTemplate::TYPE_PRODUCT_DETAIL; | ||
| 927 | + } | ||
| 960 | } | 928 | } |
| 961 | - if(empty($templateInfo['main_html']) || empty($templateInfo['main_css'])){ | ||
| 962 | - $this->fail('当前模版替换数据错误'); | 929 | + if($source == BTemplate::SOURCE_BLOG){ |
| 930 | + if($is_list == BTemplate::IS_LIST){ | ||
| 931 | + $type = BTemplate::TYPE_BLOG_LIST; | ||
| 932 | + }else{ | ||
| 933 | + $type = BTemplate::TYPE_BLOG_DETAIL; | ||
| 934 | + } | ||
| 963 | } | 935 | } |
| 964 | - $this->model->edit(['html'=>$templateInfo['main_html'],'html_style'=>$templateInfo['main_css']],['id'=>$this->param['id']]); | ||
| 965 | - return $this->success(); | 936 | + if($source == BTemplate::SOURCE_NEWS){ |
| 937 | + if($is_list == BTemplate::IS_LIST){ | ||
| 938 | + $type = BTemplate::TYPE_NEWS_LIST; | ||
| 939 | + }else{ | ||
| 940 | + $type = BTemplate::TYPE_NEWS_DETAIL; | ||
| 941 | + } | ||
| 942 | + } | ||
| 943 | + return $type; | ||
| 966 | } | 944 | } |
| 967 | } | 945 | } |
| @@ -3,11 +3,12 @@ | @@ -3,11 +3,12 @@ | ||
| 3 | namespace App\Http\Logic\Bside\BTemplate; | 3 | namespace App\Http\Logic\Bside\BTemplate; |
| 4 | 4 | ||
| 5 | use App\Http\Logic\Bside\BaseLogic; | 5 | use App\Http\Logic\Bside\BaseLogic; |
| 6 | +use App\Models\IsCom\ProjectComConfig; | ||
| 6 | use App\Models\Project\PageSetting; | 7 | use App\Models\Project\PageSetting; |
| 7 | use App\Models\RouteMap\RouteMap; | 8 | use App\Models\RouteMap\RouteMap; |
| 8 | use App\Models\Service\Service as ServiceSettingModel; | 9 | use App\Models\Service\Service as ServiceSettingModel; |
| 9 | use App\Models\Template\BCustomTemplate; | 10 | use App\Models\Template\BCustomTemplate; |
| 10 | -use App\Models\Template\BTemplateCommon; | 11 | +use App\Models\Template\BTemplateCom; |
| 11 | use App\Models\Template\BTemplateLog; | 12 | use App\Models\Template\BTemplateLog; |
| 12 | use App\Models\Template\BTemplateMain; | 13 | use App\Models\Template\BTemplateMain; |
| 13 | use App\Models\Template\Setting; | 14 | use App\Models\Template\Setting; |
| @@ -50,13 +51,81 @@ class CustomTemplateLogic extends BaseLogic | @@ -50,13 +51,81 @@ class CustomTemplateLogic extends BaseLogic | ||
| 50 | $this->fail('当前数据不存在'); | 51 | $this->fail('当前数据不存在'); |
| 51 | } | 52 | } |
| 52 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ | 53 | if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){ |
| 53 | - $html = $this->getBodyHeaderFooter($info['html'],$info['html_style']); | 54 | + $html = $this->getTemplateComHtml($info['html'],$info['html_style']); |
| 54 | $info['html'] = $this->getHeadFooter($html); | 55 | $info['html'] = $this->getHeadFooter($html); |
| 55 | } | 56 | } |
| 56 | return $this->success($info); | 57 | return $this->success($info); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| 59 | /** | 60 | /** |
| 61 | + * @remark :非定制获取头部+底部 | ||
| 62 | + * @name :getTemplateComHtml | ||
| 63 | + * @author :lyh | ||
| 64 | + * @method :post | ||
| 65 | + * @time :2024/4/29 16:53 | ||
| 66 | + */ | ||
| 67 | + public function getTemplateComHtml($html,$html_style){ | ||
| 68 | + $headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]); | ||
| 69 | + $bTemplateComModel = new BTemplateCom(); | ||
| 70 | + $condition['common_type'] = BTemplate::COMMON_OTHER; | ||
| 71 | + $condition['source'] = $headComInfo['source']; | ||
| 72 | + $otherInfo = $bTemplateComModel->read($condition); | ||
| 73 | + if($otherInfo === false){ | ||
| 74 | + $this->fail('获取失败,请联系管理员'); | ||
| 75 | + } | ||
| 76 | + $footerComInfo = $this->getFooterComHtml(); | ||
| 77 | + $commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', | ||
| 78 | + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; | ||
| 79 | + $html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html']; | ||
| 80 | + return $this->success($html); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * @remark :公共头部 | ||
| 85 | + * @name :HeadComHtml | ||
| 86 | + * @author :lyh | ||
| 87 | + * @method :post | ||
| 88 | + * @time :2024/4/29 17:20 | ||
| 89 | + */ | ||
| 90 | + public function getHeadComHtml($condition){ | ||
| 91 | + $bTemplateComModel = new BTemplateCom(); | ||
| 92 | + $condition['source'] = $this->getType(); | ||
| 93 | + $condition['common_type'] = BTemplate::COMMON_HEAD; | ||
| 94 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 95 | + if($headComInfo === false){ | ||
| 96 | + //取默认公共的 | ||
| 97 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 98 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 99 | + if($headComInfo === false){ | ||
| 100 | + $this->fail('获取失败,请联系管理员'); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + return $this->success($headComInfo); | ||
| 104 | + } | ||
| 105 | + /** | ||
| 106 | + * @remark :公共底部 | ||
| 107 | + * @name :footerComHtml | ||
| 108 | + * @author :lyh | ||
| 109 | + * @method :post | ||
| 110 | + * @time :2024/4/29 17:18 | ||
| 111 | + */ | ||
| 112 | + public function getFooterComHtml(){ | ||
| 113 | + $bTemplateComModel = new BTemplateCom(); | ||
| 114 | + $condition['common_type'] = BTemplate::COMMON_FOOTER; | ||
| 115 | + $condition['source'] = $this->getType(BTemplate::COMMON_FOOTER); | ||
| 116 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 117 | + if($footerComInfo === false){ | ||
| 118 | + //取默认首页的 | ||
| 119 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 120 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 121 | + if($footerComInfo === false){ | ||
| 122 | + $this->fail('获取失败,请联系管理员'); | ||
| 123 | + } | ||
| 124 | + } | ||
| 125 | + return $this->success($footerComInfo); | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 60 | * @remark :保存自定义界面 | 129 | * @remark :保存自定义界面 |
| 61 | * @name :customTemplateSave | 130 | * @name :customTemplateSave |
| 62 | * @author :lyh | 131 | * @author :lyh |
| @@ -126,11 +195,13 @@ class CustomTemplateLogic extends BaseLogic | @@ -126,11 +195,13 @@ class CustomTemplateLogic extends BaseLogic | ||
| 126 | if($bSettingInfo === false){ | 195 | if($bSettingInfo === false){ |
| 127 | $this->fail('请先选择模版'); | 196 | $this->fail('请先选择模版'); |
| 128 | } | 197 | } |
| 198 | + | ||
| 199 | + $handleInfo = $this->handleResultParam($html); | ||
| 129 | if(!isset($this->param['template_status'])){//代表直接替换模版 不更新头部底部 | 200 | if(!isset($this->param['template_status'])){//代表直接替换模版 不更新头部底部 |
| 130 | - $this->saveCommonTemplate($html,$bSettingInfo['template_id']); | 201 | + $this->saveTemplateCom($handleInfo,$bSettingInfo['template_id']); |
| 131 | } | 202 | } |
| 132 | - $this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'); | ||
| 133 | - $this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'); | 203 | + $this->param['html'] = $handleInfo['main_html']; |
| 204 | + $this->param['html_style'] = $handleInfo['main_style']; | ||
| 134 | } | 205 | } |
| 135 | $rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]); | 206 | $rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]); |
| 136 | if($rs === false){ | 207 | if($rs === false){ |
| @@ -151,6 +222,7 @@ class CustomTemplateLogic extends BaseLogic | @@ -151,6 +222,7 @@ class CustomTemplateLogic extends BaseLogic | ||
| 151 | * @time :2023/8/23 11:16 | 222 | * @time :2023/8/23 11:16 |
| 152 | */ | 223 | */ |
| 153 | public function setTemplateLog($template_id,$html,$source_id){ | 224 | public function setTemplateLog($template_id,$html,$source_id){ |
| 225 | + $handleInfo = $this->handleResultParam($html); | ||
| 154 | $data = [ | 226 | $data = [ |
| 155 | 'template_id'=>$template_id, | 227 | 'template_id'=>$template_id, |
| 156 | 'project_id'=>$this->user['project_id'], | 228 | 'project_id'=>$this->user['project_id'], |
| @@ -158,71 +230,109 @@ class CustomTemplateLogic extends BaseLogic | @@ -158,71 +230,109 @@ class CustomTemplateLogic extends BaseLogic | ||
| 158 | 'text'=>$html, | 230 | 'text'=>$html, |
| 159 | 'source'=>9, | 231 | 'source'=>9, |
| 160 | 'source_id'=>$source_id, | 232 | 'source_id'=>$source_id, |
| 161 | - 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | ||
| 162 | - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | ||
| 163 | - 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | ||
| 164 | - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | ||
| 165 | - 'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'), | ||
| 166 | - 'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | 233 | + 'head_html'=>$handleInfo['head_html'], |
| 234 | + 'head_css'=>$handleInfo['head_style'], | ||
| 235 | + 'footer_html'=>$handleInfo['footer_html'], | ||
| 236 | + 'footer_css'=>$handleInfo['footer_style'], | ||
| 237 | + 'main_html' => $handleInfo['main_html'], | ||
| 238 | + 'main_css' => $handleInfo['main_style'], | ||
| 239 | + 'other'=>$handleInfo['other'] | ||
| 167 | ]; | 240 | ]; |
| 168 | - $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | ||
| 169 | - $data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | ||
| 170 | $bTemplateLogModel = new BTemplateLog(); | 241 | $bTemplateLogModel = new BTemplateLog(); |
| 171 | return $bTemplateLogModel->add($data); | 242 | return $bTemplateLogModel->add($data); |
| 172 | } | 243 | } |
| 173 | 244 | ||
| 174 | /** | 245 | /** |
| 175 | - * @remark :保存头部公共数据 | ||
| 176 | - * @name :saveCommonTemplate | 246 | + * @remark :截取数据返回 |
| 247 | + * @name :handleResultParam | ||
| 177 | * @author :lyh | 248 | * @author :lyh |
| 178 | * @method :post | 249 | * @method :post |
| 179 | - * @time :2023/10/13 14:27 | 250 | + * @time :2024/5/6 14:14 |
| 180 | */ | 251 | */ |
| 181 | - public function saveCommonTemplate($html,$template_id){ | ||
| 182 | - $type = $this->getType(); | ||
| 183 | - $templateCommonModel = new BTemplateCommon(); | ||
| 184 | - $info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]); | ||
| 185 | - $data = [ | 252 | + public function handleResultParam($html){ |
| 253 | + $handleInfo = [ | ||
| 186 | 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), | 254 | 'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'), |
| 187 | - 'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), | 255 | + 'head_style'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'), |
| 188 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), | 256 | 'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'), |
| 189 | - 'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), | 257 | + 'footer_style'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'), |
| 258 | + 'main_html' => characterTruncationStr($html,"<main","</main>"), | ||
| 259 | + 'main_style' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'), | ||
| 190 | ]; | 260 | ]; |
| 191 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | 261 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); |
| 192 | $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | 262 | $other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); |
| 193 | - if($info === false){ | ||
| 194 | - $data['template_id'] = $template_id; | ||
| 195 | - $data['project_id'] = $this->user['project_id']; | ||
| 196 | - $data['type'] = $type; | ||
| 197 | - $templateCommonModel->add($data); | ||
| 198 | - }else{ | ||
| 199 | - $templateCommonModel->edit($data,['id'=>$info['id']]); | 263 | + $handleInfo['other'] = $other; |
| 264 | + return $this->success($handleInfo); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + /** | ||
| 268 | + * @remark :保存公共部分(头部。底部。连接部分) | ||
| 269 | + * @name :saveTemplateCom | ||
| 270 | + * @author :lyh | ||
| 271 | + * @method :post | ||
| 272 | + * @time :2024/4/29 10:32 | ||
| 273 | + */ | ||
| 274 | + public function saveTemplateCom($handleInfo,$template_id){ | ||
| 275 | + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER]; | ||
| 276 | + $templateComModel = new BTemplateCom(); | ||
| 277 | + foreach ($typeArr as $type){ | ||
| 278 | + if($type == BTemplate::COMMON_HEAD){ | ||
| 279 | + $param['html'] = $handleInfo['head_html']; | ||
| 280 | + $param['html_style'] = $handleInfo['head_style']; | ||
| 281 | + $typeSource = $this->getType($type);//头部是否为独立头部 | ||
| 282 | + }elseif ($type == BTemplate::COMMON_FOOTER){ | ||
| 283 | + $param['html'] = $handleInfo['footer_html']; | ||
| 284 | + $param['html_style'] = $handleInfo['footer_style']; | ||
| 285 | + $typeSource = $this->getType($type); | ||
| 286 | + }else{ | ||
| 287 | + $param['html'] = $handleInfo['other']; | ||
| 288 | + $param['html_style'] = null; | ||
| 289 | + $type == BTemplate::COMMON_HEAD; | ||
| 290 | + $typeSource = $this->getType($type); | ||
| 291 | + } | ||
| 292 | + //查看当前数据是否还存在 | ||
| 293 | + $condition = ['template_id'=>$template_id,'source'=>$typeSource,'common_type'=>$type]; | ||
| 294 | + $info = $templateComModel->read($condition); | ||
| 295 | + if($info === false){ | ||
| 296 | + $data = array_merge($param,$condition); | ||
| 297 | + $rs = $templateComModel->add($data); | ||
| 298 | + }else{ | ||
| 299 | + $rs = $templateComModel->edit($param,$condition); | ||
| 300 | + } | ||
| 301 | + if($rs === false){ | ||
| 302 | + $this->fail('保存错误,请联系管理员'); | ||
| 303 | + } | ||
| 200 | } | 304 | } |
| 201 | - //更新所有界面的other | ||
| 202 | - $templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]); | ||
| 203 | return $this->success(); | 305 | return $this->success(); |
| 204 | } | 306 | } |
| 205 | 307 | ||
| 206 | /** | 308 | /** |
| 207 | - * @remark :获取设置的类型 | 309 | + * @remark :(非定制)保存时获取获取设置的类型 |
| 208 | * @name :getType | 310 | * @name :getType |
| 209 | * @author :lyh | 311 | * @author :lyh |
| 210 | * @method :post | 312 | * @method :post |
| 211 | * @time :2023/10/21 17:29 | 313 | * @time :2023/10/21 17:29 |
| 212 | */ | 314 | */ |
| 213 | - public function getType(){ | ||
| 214 | - $type = 1;//首页公共头部底部 | 315 | + public function getType($commonType = BTemplate::COMMON_HEAD){ |
| 316 | + $type = BTemplate::SOURCE_COM;//公共头部底部 | ||
| 317 | + $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; | ||
| 318 | + if($is_head == BTemplate::IS_NO_HEADER){ | ||
| 319 | + return $this->success($type); | ||
| 320 | + } | ||
| 215 | //查看页面是否设置自定义头部底部 | 321 | //查看页面是否设置自定义头部底部 |
| 216 | - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 217 | - $pageSettingModel = new PageSetting(); | ||
| 218 | - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 219 | - if ($pageInfo !== false) { | ||
| 220 | - if ($pageInfo['page_list'] != 0) { | ||
| 221 | - $type = 9; | ||
| 222 | - } | ||
| 223 | - } | 322 | + $comConfigModel = new ProjectComConfig(); |
| 323 | + $configInfo = $comConfigModel->read(['source'=>9,'is_list'=>0,'is_custom'=>0]); | ||
| 324 | + if ($configInfo === false) { | ||
| 325 | + return $this->success($type); | ||
| 224 | } | 326 | } |
| 225 | - return $type; | 327 | + //头部 |
| 328 | + if($commonType == BTemplate::COMMON_HEAD){ | ||
| 329 | + return $this->success($configInfo['header_status'] == 0 ? $type : 9); | ||
| 330 | + } | ||
| 331 | + //底部 | ||
| 332 | + if($commonType == BTemplate::COMMON_FOOTER){ | ||
| 333 | + return $this->success($configInfo['footer_status'] == 0 ? $type : 9); | ||
| 334 | + } | ||
| 335 | + return $this->success($type); | ||
| 226 | } | 336 | } |
| 227 | 337 | ||
| 228 | /** | 338 | /** |
| @@ -290,59 +400,6 @@ class CustomTemplateLogic extends BaseLogic | @@ -290,59 +400,6 @@ class CustomTemplateLogic extends BaseLogic | ||
| 290 | } | 400 | } |
| 291 | 401 | ||
| 292 | /** | 402 | /** |
| 293 | - * @remark :获取body的详情 | ||
| 294 | - * @name :getBodyHeaderFooter | ||
| 295 | - * @author :lyh | ||
| 296 | - * @method :post | ||
| 297 | - * @time :2023/7/21 18:08 | ||
| 298 | - */ | ||
| 299 | - public function getBodyHeaderFooter($preg_html,$html_style){ | ||
| 300 | - if(empty($preg_html)){ | ||
| 301 | - $preg_html = "<main></main>"; | ||
| 302 | - $html_style = "<style id='globalsojs-styles'></style>"; | ||
| 303 | - } | ||
| 304 | - //获取设置的默认模版 | ||
| 305 | - $bSettingModel = new Setting(); | ||
| 306 | - $info = $bSettingModel->read(['project_id'=>$this->user['project_id']]); | ||
| 307 | - if($info === false){ | ||
| 308 | - $this->fail('请先设置模版'); | ||
| 309 | - } | ||
| 310 | - //获取type类型 | ||
| 311 | - $commonInfo = $this->getCommonPage($info['template_id']); | ||
| 312 | - $html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other']. | ||
| 313 | - $commonInfo['head_html'].$preg_html.$commonInfo['footer_html']; | ||
| 314 | - return $this->success($html); | ||
| 315 | - } | ||
| 316 | - | ||
| 317 | - /** | ||
| 318 | - * @remark :根据类型获取公共头和底 | ||
| 319 | - * @name :getCommonPage | ||
| 320 | - * @author :lyh | ||
| 321 | - * @method :post | ||
| 322 | - * @time :2023/10/21 16:55 | ||
| 323 | - */ | ||
| 324 | - public function getCommonPage($template_id){ | ||
| 325 | - if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) { | ||
| 326 | - //查看页面是否设置自定义头部底部 | ||
| 327 | - $pageSettingModel = new PageSetting(); | ||
| 328 | - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 329 | - if ($pageInfo !== false) { | ||
| 330 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 331 | - if ($pageInfo['page_list'] != 0) { | ||
| 332 | - //使用独立头和底 | ||
| 333 | - $commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]); | ||
| 334 | - } | ||
| 335 | - } | ||
| 336 | - } | ||
| 337 | - if(!isset($commonInfo) || $commonInfo === false){ | ||
| 338 | - //获取首页公共的头部和底部 | ||
| 339 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 340 | - $commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]); | ||
| 341 | - } | ||
| 342 | - return $commonInfo; | ||
| 343 | - } | ||
| 344 | - | ||
| 345 | - /** | ||
| 346 | * @remark :拼接获取公共头部底部 | 403 | * @remark :拼接获取公共头部底部 |
| 347 | * @name :getHeadFooter | 404 | * @name :getHeadFooter |
| 348 | * @author :lyh | 405 | * @author :lyh |
| @@ -423,27 +480,37 @@ class CustomTemplateLogic extends BaseLogic | @@ -423,27 +480,37 @@ class CustomTemplateLogic extends BaseLogic | ||
| 423 | * @name :copyCustomTemplateInfo | 480 | * @name :copyCustomTemplateInfo |
| 424 | * @author :lyh | 481 | * @author :lyh |
| 425 | * @method :post | 482 | * @method :post |
| 426 | - * @time :2024/5/24 14:47 | 483 | + * @time :2024/4/28 16:16 |
| 427 | */ | 484 | */ |
| 428 | public function copyCustomTemplateInfo(){ | 485 | public function copyCustomTemplateInfo(){ |
| 429 | $info = $this->model->read(['id'=>$this->param['id']]); | 486 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 430 | - if($info === false){ | ||
| 431 | - $this->fail('当前数据不存在'); | ||
| 432 | - } | ||
| 433 | - $param = [ | ||
| 434 | - 'name'=>$info['name'].'-copy', | ||
| 435 | - 'status'=>$info['status'], | ||
| 436 | - 'url'=>$info['url'].'-copy', | ||
| 437 | - 'html'=>$info['html'], | ||
| 438 | - 'html_style'=>$info['html_style'], | ||
| 439 | - 'project_id'=>$info['project_id'], | ||
| 440 | - 'is_visualization'=>$info['is_visualization'], | ||
| 441 | - 'six_read'=>$info['six_read'], | ||
| 442 | - 'is_upgrade'=>$info['is_upgrade'], | 487 | + $param = $this->setCustomTemplateParams($info); |
| 488 | + $save_id = $this->model->insertGetId($param); | ||
| 489 | + $route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']); | ||
| 490 | + $this->model->edit(['route'=>$route],['id'=>$save_id]); | ||
| 491 | + return $this->success(['id'=>$save_id]); | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + /** | ||
| 495 | + * @remark :组装数据 | ||
| 496 | + * @name :setCustomTemplateParams | ||
| 497 | + * @author :lyh | ||
| 498 | + * @method :post | ||
| 499 | + * @time :2024/4/28 16:18 | ||
| 500 | + */ | ||
| 501 | + public function setCustomTemplateParams($info) | ||
| 502 | + { | ||
| 503 | + return [ | ||
| 504 | + 'name' => $info['name'] . '-copy', | ||
| 505 | + 'status' => $info['status'], | ||
| 506 | + 'url' => $info['url'], | ||
| 507 | + 'html' => $info['html'], | ||
| 508 | + 'html_style' => $info['html_style'], | ||
| 509 | + 'project_id' => $info['project_id'], | ||
| 510 | + 'section_list_id' => $info['section_list_id'], | ||
| 511 | + 'is_visualization' => $info['is_visualization'], | ||
| 512 | + 'created_at' => date('Y-m-d H:i:s'), | ||
| 513 | + 'updated_at' => date('Y-m-d H:i:s'), | ||
| 443 | ]; | 514 | ]; |
| 444 | - $id = $this->model->addReturnId($param); | ||
| 445 | - $route = RouteMap::setRoute($param['url'],RouteMap::SOURCE_PAGE,$id,$param['project_id']); | ||
| 446 | - $this->model->edit(['url'=>$route],['id'=>$id]); | ||
| 447 | - return $this->success(['id'=>$id]); | ||
| 448 | } | 515 | } |
| 449 | } | 516 | } |
| @@ -10,11 +10,12 @@ | @@ -10,11 +10,12 @@ | ||
| 10 | namespace App\Http\Logic\Bside\BTemplate; | 10 | namespace App\Http\Logic\Bside\BTemplate; |
| 11 | 11 | ||
| 12 | use App\Http\Logic\Bside\BaseLogic; | 12 | use App\Http\Logic\Bside\BaseLogic; |
| 13 | +use App\Models\IsCom\ProjectComConfig; | ||
| 13 | use App\Models\Project\PageSetting; | 14 | use App\Models\Project\PageSetting; |
| 14 | use App\Models\RouteMap\RouteMap; | 15 | use App\Models\RouteMap\RouteMap; |
| 15 | use App\Models\Service\Service as ServiceSettingModel; | 16 | use App\Models\Service\Service as ServiceSettingModel; |
| 16 | use App\Models\Template\BTemplate; | 17 | use App\Models\Template\BTemplate; |
| 17 | -use App\Models\Template\BTemplateCommon; | 18 | +use App\Models\Template\BTemplateCom; |
| 18 | use App\Models\Template\BTemplateMain; | 19 | use App\Models\Template\BTemplateMain; |
| 19 | use App\Models\Template\Setting; | 20 | use App\Models\Template\Setting; |
| 20 | use App\Models\Template\TemplateTypeMain; | 21 | use App\Models\Template\TemplateTypeMain; |
| @@ -51,14 +52,83 @@ class InitHtmlLogic extends BaseLogic | @@ -51,14 +52,83 @@ class InitHtmlLogic extends BaseLogic | ||
| 51 | $data['id'] = $mainInfo['id']; | 52 | $data['id'] = $mainInfo['id']; |
| 52 | $data['updated_at'] = $mainInfo['updated_at']; | 53 | $data['updated_at'] = $mainInfo['updated_at']; |
| 53 | } | 54 | } |
| 54 | - $commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部 | ||
| 55 | - $html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | 55 | + $commonInfo = $this->getTemplateComHtml($this->param['type'],$is_list,$is_custom,$template_id); //获取头部 |
| 56 | + $html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html']; | ||
| 56 | $html = $this->getHeadFooter($html);//组装数据 | 57 | $html = $this->getHeadFooter($html);//组装数据 |
| 57 | $data['html'] = $html; | 58 | $data['html'] = $html; |
| 58 | return $this->success($data); | 59 | return $this->success($data); |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | /** | 62 | /** |
| 63 | + * @remark :非定制获取头部+底部 | ||
| 64 | + * @name :getTemplateComHtml | ||
| 65 | + * @author :lyh | ||
| 66 | + * @method :post | ||
| 67 | + * @time :2024/4/29 16:53 | ||
| 68 | + */ | ||
| 69 | + public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){ | ||
| 70 | + $condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id]; | ||
| 71 | + $headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id); | ||
| 72 | + $bTemplateComModel = new BTemplateCom(); | ||
| 73 | + $condition['common_type'] = BTemplate::COMMON_OTHER; | ||
| 74 | + $condition['source'] = $headComInfo['source']; | ||
| 75 | + $otherInfo = $bTemplateComModel->read($condition); | ||
| 76 | + if($otherInfo === false){ | ||
| 77 | + $this->fail('获取失败,请联系管理员'); | ||
| 78 | + } | ||
| 79 | + $footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id); | ||
| 80 | + $data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '', | ||
| 81 | + 'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? '']; | ||
| 82 | + return $this->success($data); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * @remark :公共头部 | ||
| 87 | + * @name :HeadComHtml | ||
| 88 | + * @author :lyh | ||
| 89 | + * @method :post | ||
| 90 | + * @time :2024/4/29 17:20 | ||
| 91 | + */ | ||
| 92 | + public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){ | ||
| 93 | + $commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id); | ||
| 94 | + $bTemplateComModel = new BTemplateCom(); | ||
| 95 | + $condition['source'] = $commonHead; | ||
| 96 | + $condition['common_type'] = BTemplate::COMMON_HEAD; | ||
| 97 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 98 | + if($headComInfo === false){ | ||
| 99 | + //取默认公共的 | ||
| 100 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 101 | + $headComInfo = $bTemplateComModel->read($condition); | ||
| 102 | + if($headComInfo === false){ | ||
| 103 | + $this->fail('获取失败,请联系管理员'); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + return $this->success($headComInfo); | ||
| 107 | + } | ||
| 108 | + /** | ||
| 109 | + * @remark :公共底部 | ||
| 110 | + * @name :footerComHtml | ||
| 111 | + * @author :lyh | ||
| 112 | + * @method :post | ||
| 113 | + * @time :2024/4/29 17:18 | ||
| 114 | + */ | ||
| 115 | + public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){ | ||
| 116 | + $bTemplateComModel = new BTemplateCom(); | ||
| 117 | + $condition['common_type'] = BTemplate::COMMON_FOOTER; | ||
| 118 | + $condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id); | ||
| 119 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 120 | + if($footerComInfo === false){ | ||
| 121 | + //取默认首页的 | ||
| 122 | + $condition['source'] = BTemplate::SOURCE_COM; | ||
| 123 | + $footerComInfo = $bTemplateComModel->read($condition); | ||
| 124 | + if($footerComInfo === false){ | ||
| 125 | + $this->fail('获取失败,请联系管理员'); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + return $this->success($footerComInfo); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + /** | ||
| 62 | * @remark :拼接获取公共头部底部 | 132 | * @remark :拼接获取公共头部底部 |
| 63 | * @name :getHeadFooter | 133 | * @name :getHeadFooter |
| 64 | * @author :lyh | 134 | * @author :lyh |
| @@ -116,96 +186,82 @@ class InitHtmlLogic extends BaseLogic | @@ -116,96 +186,82 @@ class InitHtmlLogic extends BaseLogic | ||
| 116 | ]; | 186 | ]; |
| 117 | $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); | 187 | $bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]); |
| 118 | } | 188 | } |
| 119 | - $this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom); | 189 | + $this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom); |
| 120 | $route = RouteMap::getRoute('all',0,$this->user['project_id']); | 190 | $route = RouteMap::getRoute('all',0,$this->user['project_id']); |
| 121 | $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); | 191 | $this->curlDelRoute(['route'=>$route,'new_route'=>$route]); |
| 122 | return $this->success(); | 192 | return $this->success(); |
| 123 | } | 193 | } |
| 124 | 194 | ||
| 125 | /** | 195 | /** |
| 126 | - * @remark :保存公共头部底部 | ||
| 127 | - * @name :saveCommonHtml | 196 | + * @remark :保存公共部分(头部。底部。连接部分) |
| 197 | + * @name :saveTemplateCom | ||
| 128 | * @author :lyh | 198 | * @author :lyh |
| 129 | * @method :post | 199 | * @method :post |
| 130 | - * @time :2023/12/13 17:05 | 200 | + * @time :2024/4/29 10:32 |
| 131 | */ | 201 | */ |
| 132 | - public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){ | ||
| 133 | - $type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面) | ||
| 134 | - $templateCommonModel = new BTemplateCommon(); | ||
| 135 | - $commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在 | 202 | + public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){ |
| 203 | + $typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER]; | ||
| 136 | $handleInfo = $this->handleCommonParam($html); | 204 | $handleInfo = $this->handleCommonParam($html); |
| 137 | - if($commonInfo === false){ | ||
| 138 | - $data = [ | ||
| 139 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 140 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 141 | - 'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'], | ||
| 142 | - ]; | ||
| 143 | - $templateCommonModel->add($data); | ||
| 144 | - }else{ | ||
| 145 | - $data = [ | ||
| 146 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'], | ||
| 147 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 148 | - ]; | ||
| 149 | - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | ||
| 150 | - } | ||
| 151 | - //更新所有界面的other | ||
| 152 | - return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]); | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - /** | ||
| 156 | - * @remark :根据类型获取公共头和底 | ||
| 157 | - * @name :getCommonPage | ||
| 158 | - * @author :lyh | ||
| 159 | - * @method :post | ||
| 160 | - * @time :2023/10/21 16:55 | ||
| 161 | - */ | ||
| 162 | - public function getCommonHtml($source,$is_list,$template_id,$is_custom){ | ||
| 163 | - $type = $this->getType($source,$is_list,$is_custom); | ||
| 164 | - $data = [ | ||
| 165 | - 'template_id' => $template_id, | ||
| 166 | - 'project_id' => $this->user['project_id'], | ||
| 167 | - 'type'=>$type | ||
| 168 | - ]; | ||
| 169 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 170 | - $commonInfo = $commonTemplateModel->read($data); | ||
| 171 | - if($commonInfo === false){ | ||
| 172 | - $data['type'] = BTemplate::SOURCE_HOME; | ||
| 173 | - $commonInfo = $commonTemplateModel->read($data); | 205 | + $templateComModel = new BTemplateCom(); |
| 206 | + foreach ($typeArr as $type){ | ||
| 207 | + if($type == BTemplate::COMMON_HEAD){ | ||
| 208 | + $param['html'] = $handleInfo['head_html']; | ||
| 209 | + $param['html_style'] = $handleInfo['head_style']; | ||
| 210 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部 | ||
| 211 | + }elseif ($type == BTemplate::COMMON_FOOTER){ | ||
| 212 | + $param['html'] = $handleInfo['footer_html']; | ||
| 213 | + $param['html_style'] = $handleInfo['footer_style']; | ||
| 214 | + $typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id); | ||
| 215 | + }else{ | ||
| 216 | + $param['html'] = $handleInfo['other']; | ||
| 217 | + $param['html_style'] = null; | ||
| 218 | + $typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id); | ||
| 219 | + } | ||
| 220 | + //查看当前数据是否还存在 | ||
| 221 | + $condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type]; | ||
| 222 | + $info = $templateComModel->read($condition); | ||
| 223 | + if($info === false){ | ||
| 224 | + $data = array_merge($param,$condition); | ||
| 225 | + $templateComModel->add($data); | ||
| 226 | + }else{ | ||
| 227 | + $templateComModel->edit($param,$condition); | ||
| 228 | + } | ||
| 174 | } | 229 | } |
| 175 | - return $this->success($commonInfo); | 230 | + return $this->success(); |
| 176 | } | 231 | } |
| 177 | 232 | ||
| 178 | /** | 233 | /** |
| 179 | - * @remark :保存时获取获取设置的类型 | 234 | + * @remark :(非定制)保存时获取获取设置的类型 |
| 180 | * @name :getType | 235 | * @name :getType |
| 181 | * @author :lyh | 236 | * @author :lyh |
| 182 | * @method :post | 237 | * @method :post |
| 183 | * @time :2023/10/21 17:29 | 238 | * @time :2023/10/21 17:29 |
| 184 | */ | 239 | */ |
| 185 | - public function getType($source,$is_list,$is_custom = 0){ | ||
| 186 | - $type = BTemplate::SOURCE_HOME;//首页公共头部底部 | 240 | + public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){ |
| 241 | + if($template_id == 0){ | ||
| 242 | + return $this->success($source); | ||
| 243 | + } | ||
| 244 | + $type = BTemplate::SOURCE_COM;//公共头部底部 | ||
| 187 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; | 245 | $is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER; |
| 188 | - if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部 | 246 | + if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底 |
| 189 | return $this->success($type); | 247 | return $this->success($type); |
| 190 | } | 248 | } |
| 191 | //查看页面是否设置自定义头部底部 | 249 | //查看页面是否设置自定义头部底部 |
| 192 | - if($is_head != BTemplate::IS_NO_HEADER) { | ||
| 193 | - $pageSettingModel = new PageSetting(); | ||
| 194 | - $pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]); | ||
| 195 | - if ($pageInfo === false) { | ||
| 196 | - return $this->success($type); | ||
| 197 | - } | ||
| 198 | - if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}} | ||
| 199 | - else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}} | ||
| 200 | - if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}} | ||
| 201 | - else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}} | ||
| 202 | - if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}} | ||
| 203 | - else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}} | ||
| 204 | - if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}} | 250 | + $comConfigModel = new ProjectComConfig(); |
| 251 | + $configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]); | ||
| 252 | + if($configInfo === false){ | ||
| 253 | + return $this->success($type); | ||
| 254 | + } | ||
| 255 | + //头部 | ||
| 256 | + if($commonType == BTemplate::COMMON_HEAD){ | ||
| 257 | + return $this->success($configInfo['header_status'] == 0 ? $type : $source); | ||
| 258 | + } | ||
| 259 | + //底部 | ||
| 260 | + if($commonType == BTemplate::COMMON_FOOTER){ | ||
| 261 | + return $this->success($configInfo['footer_status'] == 0 ? $type : $source); | ||
| 205 | } | 262 | } |
| 206 | return $this->success($type); | 263 | return $this->success($type); |
| 207 | } | 264 | } |
| 208 | - | ||
| 209 | /** | 265 | /** |
| 210 | * @remark :保存时字符串处理 | 266 | * @remark :保存时字符串处理 |
| 211 | * @name :handleCommonParam | 267 | * @name :handleCommonParam |
| @@ -217,8 +273,8 @@ class InitHtmlLogic extends BaseLogic | @@ -217,8 +273,8 @@ class InitHtmlLogic extends BaseLogic | ||
| 217 | //字符串截取 | 273 | //字符串截取 |
| 218 | $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); | 274 | $param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'); |
| 219 | $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); | 275 | $param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'); |
| 220 | - $param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); | ||
| 221 | - $param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | 276 | + $param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'); |
| 277 | + $param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'); | ||
| 222 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); | 278 | $footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s')); |
| 223 | $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); | 279 | $param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other); |
| 224 | return $this->success($param); | 280 | return $this->success($param); |
| @@ -271,24 +327,42 @@ class InitHtmlLogic extends BaseLogic | @@ -271,24 +327,42 @@ class InitHtmlLogic extends BaseLogic | ||
| 271 | if($info === false){ | 327 | if($info === false){ |
| 272 | $html = ''; | 328 | $html = ''; |
| 273 | }else{ | 329 | }else{ |
| 274 | - //扩展模块获取头部 | ||
| 275 | - if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 276 | - $type = $this->param['type']; | ||
| 277 | - }else{ | ||
| 278 | - $type = $this->getCustomizedType($this->param['type'],$is_list); | ||
| 279 | - } | ||
| 280 | - $commonTemplateModel = new BTemplateCommon(); | ||
| 281 | - $commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]); | ||
| 282 | - if($commonInfo !== false){ | ||
| 283 | - $info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']); | ||
| 284 | - } | ||
| 285 | - $html = $info['main_html']; | 330 | + $commonInfo = $this->getCustomizeTemplateComHtml($this->param['type'],$is_custom,$is_list); |
| 331 | + $html = $this->handleAllHtml($commonInfo,$info['main_html']); | ||
| 286 | } | 332 | } |
| 287 | //更新头部底部 | 333 | //更新头部底部 |
| 288 | return $this->success(['html'=>$html]); | 334 | return $this->success(['html'=>$html]); |
| 289 | } | 335 | } |
| 290 | 336 | ||
| 291 | /** | 337 | /** |
| 338 | + * @remark :定制获取头部底部 | ||
| 339 | + * @name :getCustomizedCommonHtml | ||
| 340 | + * @author :lyh | ||
| 341 | + * @method :post | ||
| 342 | + * @time :2023/12/29 13:13 | ||
| 343 | + */ | ||
| 344 | + public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){ | ||
| 345 | + $data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>'']; | ||
| 346 | + $param = ['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]; | ||
| 347 | + $commonTemplateModel = new BTemplateCom(); | ||
| 348 | + $commonList = $commonTemplateModel->list($param); | ||
| 349 | + if(!empty($commonList)){ | ||
| 350 | + foreach ($commonList as $v){ | ||
| 351 | + if($v['common_type'] == BTemplate::COMMON_HEAD){ | ||
| 352 | + $data['head_html'] = $v['html']; | ||
| 353 | + $data['head_style'] = $v['html_style']; | ||
| 354 | + }elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){ | ||
| 355 | + $data['footer_html'] = $v['html']; | ||
| 356 | + $data['footer_style'] = $v['html_style']; | ||
| 357 | + }else{ | ||
| 358 | + $data['other'] = $v['html']; | ||
| 359 | + } | ||
| 360 | + } | ||
| 361 | + } | ||
| 362 | + return $this->success($data); | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + /** | ||
| 292 | * @remark :返回整个html截取代码 | 366 | * @remark :返回整个html截取代码 |
| 293 | * @name :handleAllHtml | 367 | * @name :handleAllHtml |
| 294 | * @author :lyh | 368 | * @author :lyh |
| @@ -331,7 +405,7 @@ class InitHtmlLogic extends BaseLogic | @@ -331,7 +405,7 @@ class InitHtmlLogic extends BaseLogic | ||
| 331 | $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); | 405 | $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); |
| 332 | } | 406 | } |
| 333 | //更新头部底部 | 407 | //更新头部底部 |
| 334 | - $this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom); | 408 | + $this->saveTemplateCom($this->param['html'],0,$this->param['type'],$is_list,$is_custom); |
| 335 | }catch (\Exception $exception){ | 409 | }catch (\Exception $exception){ |
| 336 | $this->fail('保存失败,请联系开发人员'); | 410 | $this->fail('保存失败,请联系开发人员'); |
| 337 | } | 411 | } |
| @@ -339,73 +413,6 @@ class InitHtmlLogic extends BaseLogic | @@ -339,73 +413,6 @@ class InitHtmlLogic extends BaseLogic | ||
| 339 | } | 413 | } |
| 340 | 414 | ||
| 341 | /** | 415 | /** |
| 342 | - * @remark :定制代码更新头部信息 | ||
| 343 | - * @name :saveCustomizeCommon | ||
| 344 | - * @author :lyh | ||
| 345 | - * @method :post | ||
| 346 | - * @time :2024/1/6 10:29 | ||
| 347 | - */ | ||
| 348 | - public function saveCustomizeCommon($html,$source,$is_list,$is_custom){ | ||
| 349 | - if($is_custom == BTemplate::IS_CUSTOM){ | ||
| 350 | - $type = $source; | ||
| 351 | - }else{ | ||
| 352 | - $type = $this->getCustomizedType($source,$is_list); | ||
| 353 | - } | ||
| 354 | - $templateCommonModel = new BTemplateCommon(); | ||
| 355 | - $commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在 | ||
| 356 | - $handleInfo = $this->handleCommonParam($html); | ||
| 357 | - if($commonInfo === false){ | ||
| 358 | - $data = [ | ||
| 359 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'], | ||
| 360 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 361 | - 'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'], | ||
| 362 | - 'is_custom'=>$is_custom,'is_list'=>$is_list | ||
| 363 | - ]; | ||
| 364 | - $templateCommonModel->add($data); | ||
| 365 | - }else{ | ||
| 366 | - $data = [ | ||
| 367 | - 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'], | ||
| 368 | - 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'], | ||
| 369 | - ]; | ||
| 370 | - $templateCommonModel->edit($data,['id'=>$commonInfo['id']]); | ||
| 371 | - } | ||
| 372 | - return $this->success(); | ||
| 373 | - } | ||
| 374 | - | ||
| 375 | - /** | ||
| 376 | - * @remark :定制页面头部类型---根据source获取type类型 | ||
| 377 | - * @name :getType | ||
| 378 | - * @author :lyh | ||
| 379 | - * @method :post | ||
| 380 | - * @time :2023/11/16 11:20 | ||
| 381 | - */ | ||
| 382 | - public function getCustomizedType($source,$is_list){ | ||
| 383 | - $type = BTemplate::TYPE_HOME; | ||
| 384 | - if($source == BTemplate::SOURCE_PRODUCT){ | ||
| 385 | - if($is_list == BTemplate::IS_LIST){ | ||
| 386 | - $type = BTemplate::TYPE_PRODUCT_LIST; | ||
| 387 | - }else{ | ||
| 388 | - $type = BTemplate::TYPE_PRODUCT_DETAIL; | ||
| 389 | - } | ||
| 390 | - } | ||
| 391 | - if($source == BTemplate::SOURCE_BLOG){ | ||
| 392 | - if($is_list == BTemplate::IS_LIST){ | ||
| 393 | - $type = BTemplate::TYPE_BLOG_LIST; | ||
| 394 | - }else{ | ||
| 395 | - $type = BTemplate::TYPE_BLOG_DETAIL; | ||
| 396 | - } | ||
| 397 | - } | ||
| 398 | - if($source == BTemplate::SOURCE_NEWS){ | ||
| 399 | - if($is_list == BTemplate::IS_LIST){ | ||
| 400 | - $type = BTemplate::TYPE_NEWS_LIST; | ||
| 401 | - }else{ | ||
| 402 | - $type = BTemplate::TYPE_NEWS_DETAIL; | ||
| 403 | - } | ||
| 404 | - } | ||
| 405 | - return $type; | ||
| 406 | - } | ||
| 407 | - | ||
| 408 | - /** | ||
| 409 | * @remark :前端获取设置模块(侧边栏) | 416 | * @remark :前端获取设置模块(侧边栏) |
| 410 | * @name :getInitModuleMain | 417 | * @name :getInitModuleMain |
| 411 | * @author :lyh | 418 | * @author :lyh |
| 1 | <?php | 1 | <?php |
| 2 | /** | 2 | /** |
| 3 | * @remark : | 3 | * @remark : |
| 4 | - * @name :ProjectIsCom.php | 4 | + * @name :ProjectComConfig.php |
| 5 | * @author :lyh | 5 | * @author :lyh |
| 6 | * @method :post | 6 | * @method :post |
| 7 | * @time :2024/8/1 11:50 | 7 | * @time :2024/8/1 11:50 |
| @@ -16,14 +16,16 @@ use App\Models\Template\Template; | @@ -16,14 +16,16 @@ use App\Models\Template\Template; | ||
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | * @remark :是否为独立头部+底部 | 18 | * @remark :是否为独立头部+底部 |
| 19 | - * @name :ProjectIsCom | 19 | + * @name :ProjectComConfig |
| 20 | * @author :lyh | 20 | * @author :lyh |
| 21 | * @method :post | 21 | * @method :post |
| 22 | * @time :2024/8/1 11:51 | 22 | * @time :2024/8/1 11:51 |
| 23 | */ | 23 | */ |
| 24 | -class ProjectIsCom extends Base | 24 | +class ProjectComConfig extends Base |
| 25 | { | 25 | { |
| 26 | protected $table = 'gl_project_com_config'; | 26 | protected $table = 'gl_project_com_config'; |
| 27 | + //连接数据库 | ||
| 28 | + protected $connection = 'custom_mysql'; | ||
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| 29 | * @name :(包含详情页+列表页) | 31 | * @name :(包含详情页+列表页) |
| @@ -24,7 +24,7 @@ class BTemplate extends Base | @@ -24,7 +24,7 @@ class BTemplate extends Base | ||
| 24 | const SOURCE_NEWS = 4;//新闻详情页 | 24 | const SOURCE_NEWS = 4;//新闻详情页 |
| 25 | const SOURCE_KEYWORD = 5;//聚合页 | 25 | const SOURCE_KEYWORD = 5;//聚合页 |
| 26 | 26 | ||
| 27 | - const SOURCE_PAGE = 6;//单页面 | 27 | + const SOURCE_PAGE = 9;//单页面 |
| 28 | const SOURCE_CUSTOM = 7;//自定义模块 | 28 | const SOURCE_CUSTOM = 7;//自定义模块 |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| @@ -556,8 +556,8 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -556,8 +556,8 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 556 | }); | 556 | }); |
| 557 | //设置公共头部+底部配置 | 557 | //设置公共头部+底部配置 |
| 558 | Route::prefix('com_config')->group(function () { | 558 | Route::prefix('com_config')->group(function () { |
| 559 | - Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectIsComController::class, 'getIsComConfig'])->name('com_config_getIsComConfig'); | ||
| 560 | - Route::any('/saveComConfig', [\App\Http\Controllers\Bside\Template\BProjectIsComController::class, 'saveComConfig'])->name('com_config_getIsComConfig'); | 559 | + Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'getIsComConfig'])->name('com_config_getIsComConfig'); |
| 560 | + Route::any('/saveComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'saveComConfig'])->name('com_config_getIsComConfig'); | ||
| 561 | 561 | ||
| 562 | }); | 562 | }); |
| 563 | }); | 563 | }); |
-
请 注册 或 登录 后发表评论