作者 lyh

gx

... ... @@ -81,22 +81,55 @@ class Demo extends Command
$settingInfo = $settingModel->read(['project_id'=>$project_id]);
if($settingInfo !== false){
$templateCommonModel = new BTemplateCommon();
$commonList = $templateCommonModel->list(['template_id'=>$settingModel['template_id']]);
$commonList = $templateCommonModel->list(['id'=>1,'template_id'=>$settingModel['template_id'],'is_custom'=>0]);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['type'] == 1){//首页头部底部
//保存一次公共头+底
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$headData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>BTemplate::COMMON_HEAD,
'template_id'=>$v['template_id'],
'html'=>$v['head_html'],
'html_style'=>$v['head_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($headData);
}elseif ($type == BTemplate::COMMON_FOOTER){
$footerData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>BTemplate::COMMON_FOOTER,
'template_id'=>$v['template_id'],
'html'=>$v['footer_html'],
'html_style'=>$v['footer_css'],
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($footerData);
}elseif ($type == BTemplate::COMMON_OTHER){
$otherData = [
'project_id'=>$v['project_id'],
'source'=>$v['type'] == 1 ? 99 : $v['type'],
'common_type'=>BTemplate::COMMON_OTHER,
'template_id'=>$v['template_id'],
'html'=>$v['other'],
'html_style'=>null,
'is_custom'=>$v['is_custom'],
'is_list'=>$v['is_list']
];
$templateComModel = new BTemplateCom();
$templateComModel->add($otherData);
}
//保存一次公共头部+底部+other信息
$bComTemplateModel = new BTemplateCom();
$param = ['template_id'=>$settingModel['template_id'],'common_type'=>BTemplate::COMMON_HEAD,'source'=>BTemplate::SOURCE_COM];
if($headInfo === false){
$headData = ['html'=>$settingModel['template_id']['head_html'], 'html_style'=>$templateInfo['head_css'], 'project_id'=>$project_id];
$bComTemplateModel->add(array_merge($condition,$headData));
}
}
}
}
return true;
}
}
... ...