|
...
|
...
|
@@ -12,6 +12,8 @@ namespace App\Services\Html; |
|
|
|
use App\Models\CustomModule\CustomModule;
|
|
|
|
use App\Models\CustomModule\CustomModuleCategory;
|
|
|
|
use App\Models\CustomModule\CustomModuleContent;
|
|
|
|
use App\Models\Project\PageSetting;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
|
|
use App\Models\Template\BTemplateCommon;
|
|
...
|
...
|
@@ -36,20 +38,14 @@ class GeneratePageService |
|
|
|
* @method :post
|
|
|
|
* @time :2024/2/19 16:57
|
|
|
|
*/
|
|
|
|
public function generateHtml($project_id,$route){
|
|
|
|
$this->project_id = $project_id;
|
|
|
|
$this->route = $route;
|
|
|
|
public function generateHtml($projectInfo,$routeInfo){
|
|
|
|
$this->project_id = $projectInfo['id'];
|
|
|
|
$this->route = $routeInfo['route'];
|
|
|
|
ProjectServer::useProject($this->project_id);
|
|
|
|
$routeMapModel = new RouteMap();
|
|
|
|
$routeInfo = $routeMapModel->read(['route'=>$this->param['route']]);
|
|
|
|
if($this->param['route'] != RouteMap::SOURCE_INDEX && $routeInfo['source'] == RouteMap::SOURCE_PAGE){
|
|
|
|
//页面管理单独处理
|
|
|
|
}else{
|
|
|
|
$this->handleParam($routeInfo);
|
|
|
|
return $this->getTemplateHtml();
|
|
|
|
}
|
|
|
|
$this->handleParam($routeInfo);
|
|
|
|
$result = $this->getTemplateHtml($projectInfo);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
return true;
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -125,14 +121,17 @@ class GeneratePageService |
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
*/
|
|
|
|
public function getTemplateHtml(){
|
|
|
|
public function getTemplateHtml($projectInfo){
|
|
|
|
$is_custom = $this->param['is_custom'] ?? 0;//是否为扩展模块
|
|
|
|
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
|
|
|
|
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
|
|
|
|
$template_id = $this->getSettingTemplate($projectInfo,$this->param['source'],$is_list,$is_custom);//设置的模版id
|
|
|
|
if($template_id === false){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
|
|
|
|
if($templateInfo === false){
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
|
|
|
|
$html = $this->customizedReturnHtml($projectInfo,$this->param['source'],$template_id,$is_custom,$is_list);
|
|
|
|
if($html !== false){
|
|
|
|
return $this->success($html);
|
|
|
|
}
|
|
...
|
...
|
@@ -145,10 +144,10 @@ class GeneratePageService |
|
|
|
}
|
|
|
|
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCommonHtml($this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
|
|
|
$commonInfo = $this->getCommonHtml($projectInfo,$this->param['source'],$is_list,$template_id,$is_custom);//获取非定制头部
|
|
|
|
$html = $commonInfo['head_css'].$mainInfo['main_css'].$commonInfo['footer_css'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
|
|
|
|
$html = $this->getHeadFooter($html);
|
|
|
|
$result = ['html'=>$html,'template_id'=>$template_id];
|
|
|
|
$result = ['html'=>$html];
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -181,7 +180,7 @@ class GeneratePageService |
|
|
|
public function webTemplateInfo($source,$source_id,$template_id,$is_custom,$is_list){
|
|
|
|
$templateInfo = $this->model->read([
|
|
|
|
'template_id'=>$template_id, 'source'=>$source,
|
|
|
|
'project_id'=>$this->user['project_id'], 'source_id'=>$source_id,
|
|
|
|
'project_id'=>$this->project_id, 'source_id'=>$source_id,
|
|
|
|
'is_custom'=>$is_custom, 'is_list'=>$is_list
|
|
|
|
]);
|
|
|
|
return $this->success($templateInfo);
|
|
...
|
...
|
@@ -194,29 +193,35 @@ class GeneratePageService |
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/10 13:46
|
|
|
|
*/
|
|
|
|
public function customizedReturnHtml($source,$template_id,$is_custom,$is_list){
|
|
|
|
public function customizedReturnHtml($projectInfo,$source,$template_id,$is_custom,$is_list){
|
|
|
|
//TODO::扩展模块定制单独处理
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('当前扩展模块不存在或已被删除');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//扩展模块定制
|
|
|
|
if($is_list == BTemplate::IS_LIST && $info['list_customized'] == BTemplate::IS_VISUALIZATION){
|
|
|
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
if($html === false){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return $this->success(['html'=>$html]);
|
|
|
|
}
|
|
|
|
if($is_list == BTemplate::IS_DETAIL && $info['detail_customized'] == BTemplate::IS_VISUALIZATION){
|
|
|
|
$html = $this->customModuleCustomizeHtml($source,$is_list,$is_custom);
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
if($html === false){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return $this->success(['html'=>$html]);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
//TODO::默认模块定制
|
|
|
|
$html = $this->isCustomizedPage($source,$is_list,$is_custom);//获取定制页面的html
|
|
|
|
if(!empty($html)){
|
|
|
|
return $this->success(['html'=>$html,'template_id'=>$template_id]);
|
|
|
|
$html = $this->isCustomizedPage($projectInfo,$source,$is_list,$is_custom);//获取定制页面的html
|
|
|
|
if($html !== false){
|
|
|
|
return $this->success(['html'=>$html]);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
...
|
...
|
@@ -233,7 +238,7 @@ class GeneratePageService |
|
|
|
//TODO::获取初始代码
|
|
|
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
|
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
|
|
|
|
if($commonInfo !== false){
|
|
...
|
...
|
@@ -303,17 +308,17 @@ class GeneratePageService |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:55
|
|
|
|
*/
|
|
|
|
public function isCustomizedPage($source,$is_list,$is_custom)
|
|
|
|
public function isCustomizedPage($projectInfo,$source,$is_list,$is_custom)
|
|
|
|
{
|
|
|
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
$page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//是定制界面
|
|
|
|
//TODO::获取初始代码
|
|
|
|
$bTemplateMainModel = new BTemplateMain();
|
|
|
|
$customHtmlInfo = $bTemplateMainModel->read(['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list]);
|
|
|
|
if($customHtmlInfo === false){
|
|
|
|
$this->fail('定制页面,请先上传代码块');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
|
|
|
|
if($commonInfo !== false){
|
|
...
|
...
|
@@ -334,7 +339,7 @@ class GeneratePageService |
|
|
|
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
|
|
|
|
$data = [
|
|
|
|
'template_id' => 0,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'project_id' => $this->project_id,
|
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>$is_custom,
|
|
|
|
'is_list'=>$is_list
|
|
...
|
...
|
@@ -383,9 +388,9 @@ class GeneratePageService |
|
|
|
* @method :post
|
|
|
|
* @time :2023/12/13 10:48
|
|
|
|
*/
|
|
|
|
public function getSettingTemplate($source,$is_list,$is_custom){
|
|
|
|
public function getSettingTemplate($projectInfo,$source,$is_list,$is_custom){
|
|
|
|
$template_id = 0;
|
|
|
|
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
|
|
if($projectInfo['is_customized'] == BTemplate::IS_VISUALIZATION) {//定制项目
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){
|
|
|
|
$customModuleModel = new CustomModule();
|
|
|
|
$info = $customModuleModel->read(['id'=>$source]);
|
|
...
|
...
|
@@ -401,16 +406,16 @@ class GeneratePageService |
|
|
|
}else{
|
|
|
|
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
|
|
|
|
//查看当前页面是否定制,是否开启可视化
|
|
|
|
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
$page_array = (array)$projectInfo['is_visualization']->page_array;//获取所有定制界面
|
|
|
|
if (in_array($type, $page_array)) {//是定制界面
|
|
|
|
return $this->success($template_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->project_id]);
|
|
|
|
if($info === false){
|
|
|
|
$this->fail('请先选择模版');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$template_id = $info['template_id'];
|
|
|
|
return $this->success($template_id);
|
|
...
|
...
|
@@ -423,11 +428,11 @@ class GeneratePageService |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 16:55
|
|
|
|
*/
|
|
|
|
public function getCommonHtml($source,$is_list,$template_id,$is_custom = 0){
|
|
|
|
$type = $this->getType($source,$is_list,$is_custom);
|
|
|
|
public function getCommonHtml($ProjectInfo,$source,$is_list,$template_id,$is_custom = 0,){
|
|
|
|
$type = $this->getType($ProjectInfo,$source,$is_list,$is_custom);
|
|
|
|
$data = [
|
|
|
|
'template_id' => $template_id,
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'project_id' => $this->project_id,
|
|
|
|
'type'=>$type,
|
|
|
|
'is_custom'=>0,
|
|
|
|
];
|
|
...
|
...
|
@@ -440,4 +445,36 @@ class GeneratePageService |
|
|
|
return $this->success($commonInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :(非定制)保存时获取获取设置的类型
|
|
|
|
* @name :getType
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/21 17:29
|
|
|
|
*/
|
|
|
|
public function getType($projectInfo,$source,$is_list,$is_custom = 0){
|
|
|
|
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
|
|
|
|
$is_head = $projectInfo['deploy_build']['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
|
|
|
|
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
//查看页面是否设置自定义头部底部
|
|
|
|
if($is_head != BTemplate::IS_NO_HEADER) {
|
|
|
|
$pageSettingModel = new PageSetting();
|
|
|
|
$pageInfo = $pageSettingModel->read(['project_id' => $projectInfo['id']]);
|
|
|
|
if ($pageInfo === false) {
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
if ($source == BTemplate::SOURCE_PRODUCT) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['product_details'] != 0) {$type = BTemplate::TYPE_PRODUCT_DETAIL;}}
|
|
|
|
else {if ($pageInfo['product_list'] != 0) {$type = BTemplate::TYPE_PRODUCT_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_BLOG) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['blog_details'] != 0) {$type = BTemplate::TYPE_BLOG_DETAIL;}}
|
|
|
|
else {if ($pageInfo['blog_list'] != 0) {$type = BTemplate::TYPE_BLOG_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_NEWS) {if ($is_list != BTemplate::IS_LIST) {if ($pageInfo['news_details'] != 0) {$type = BTemplate::TYPE_NEWS_DETAIL;}}
|
|
|
|
else {if ($pageInfo['news_list'] != 0) {$type = BTemplate::TYPE_NEWS_LIST;}}}
|
|
|
|
if ($source == BTemplate::SOURCE_KEYWORD) {if ($pageInfo['polymerization'] != 0) {$type = BTemplate::TYPE_CUSTOM_PAGE;}}
|
|
|
|
}
|
|
|
|
return $this->success($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|