作者 lyh

gx

... ... @@ -6,7 +6,6 @@ use App\Http\Logic\Aside\BaseLogic;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\Template;
use App\Models\Template\Setting;
... ... @@ -204,34 +203,25 @@ class ATemplateLogic extends BaseLogic
$templateInfo = $this->model->read(['id'=>$template_id]);
ProjectServer::useProject($project_id);
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>BTemplate::SOURCE_HOME,'template_id'=>$template_id]);
$info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]);
if($info === false){
$data = [
'source'=>BTemplate::SOURCE_HOME, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id
'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'main_css'=>$templateInfo['main_css'], 'project_id'=>$project_id,
];
$bTemplateModel->add($data);
}
//保存一次公共头部+底部+other信息
$bComTemplateModel = new BTemplateCom();
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];
$headInfo = $bComTemplateModel->read($condition);
if($headInfo === false){
$headData = ['html'=>$templateInfo['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$headData));
}
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_FOOTER,'source'=>BTemplate::SOURCE_COM];
$footerInfo = $bComTemplateModel->read($condition);
if($footerInfo === false){
$footerData = ['html'=>$templateInfo['footer_html'], 'html_style'=>$templateInfo['footer_css'], 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$footerData));
}
$condition = ['template_id'=>$template_id,'common_type'=>BTemplate::COMMON_OTHER,'source'=>BTemplate::SOURCE_COM];
$footerInfo = $bComTemplateModel->read($condition);
if($footerInfo === false){
$other = str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"));
$otherData = ['html'=>$other, 'html_style'=>'', 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$otherData));
//保存一次公共头部信息
$bCommonTemplateModel = new BTemplateCommon();
$commonInfo = $bCommonTemplateModel->read(['template_id'=>$template_id,'type'=>1]);
if($commonInfo === false){
$commonData = [
'type'=>1, 'template_id'=>$template_id, 'head_html'=>$templateInfo['head_html'],
'head_css'=>$templateInfo['head_css'], 'footer_html'=>$templateInfo['footer_html'],
'footer_css'=>$templateInfo['footer_css'],'project_id'=>$project_id,
'other'=>str_replace('<header','',characterTruncation($templateInfo['html'],"/<link id=\"google-fonts-link\"(.*?)<header/s"))
];
$bCommonTemplateModel->add($commonData);
}
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id);
DB::disconnect('custom_mysql');
... ...