|
...
|
...
|
@@ -29,14 +29,14 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 9:34
|
|
|
|
*/
|
|
|
|
public function publicTemplateLists($map,$order = 'created_at',$filed = ['*']){
|
|
|
|
public function publicTemplateLists($map,$order = 'created_at',$filed = ['id','name','image','created_at']){
|
|
|
|
$templateModel = new Template();
|
|
|
|
$lists = $templateModel->list($map,$order,$filed);
|
|
|
|
return $this->success($lists);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前选择的模板
|
|
|
|
* @remark :获取当前选择使用的模板
|
|
|
|
* @name :getModuleTemplate
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
...
|
...
|
@@ -47,8 +47,13 @@ class BTemplateLogic extends BaseLogic |
|
|
|
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
$TemplateInfo = [];
|
|
|
|
if($info !== false){
|
|
|
|
//查看当前模板是否已编辑保存
|
|
|
|
$TemplateInfo = $this->model->read(['template_id'=>$info['template_id'],'project_id'=>$this->user['project_id']]);
|
|
|
|
//查看当前模板是否已编辑保存web_template
|
|
|
|
$TemplateInfo = $this->model->read([
|
|
|
|
'template_id'=>$info['template_id'],
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
]);
|
|
|
|
if($TemplateInfo === false){
|
|
|
|
//获取模板详情
|
|
|
|
$ATemplateModel = new Template();
|
|
...
|
...
|
@@ -91,22 +96,44 @@ class BTemplateLogic extends BaseLogic |
|
|
|
* @time :2023/6/29 11:05
|
|
|
|
*/
|
|
|
|
public function templateSave(){
|
|
|
|
//字符串截取
|
|
|
|
$this->param['head_html'] = characterTruncation($this->param['html'],'<header>','</header>');
|
|
|
|
$this->param['main_html'] = characterTruncation($this->param['html'],'<main>','</main>');
|
|
|
|
$this->param['footer_html'] = characterTruncation($this->param['html'],'<footer>','</footer>');
|
|
|
|
$this->param['head_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-header">','</style>');
|
|
|
|
$this->param['main_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-style">','</style>');
|
|
|
|
$this->param['footer_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-footer">','</style>');
|
|
|
|
if(isset($this->param['id']) && !empty($this->param['id'])){
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
|
|
|
|
}else{
|
|
|
|
//查询当前模版是否已保存
|
|
|
|
$info = $this->model->read(
|
|
|
|
[
|
|
|
|
'project_id'=>$this->user['project_id'],
|
|
|
|
'source'=>$this->param['source'],
|
|
|
|
'source_id'=>$this->param['source_id'],
|
|
|
|
'template_id'=>$this->param['template_id'],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
if($info === false){
|
|
|
|
//字符串截取
|
|
|
|
$this->StringProcessing();
|
|
|
|
$this->param['project_id'] = $this->user['project_id'];
|
|
|
|
$rs = $this->model->add($this->param);
|
|
|
|
}else{
|
|
|
|
$this->StringProcessing();
|
|
|
|
$rs = $this->model->edit($this->param,['id'=>$info['id']]);
|
|
|
|
}
|
|
|
|
if($rs === false){
|
|
|
|
$this->fail('error');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :字符串处理
|
|
|
|
* @name :StringProcessing
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/29 15:35
|
|
|
|
*/
|
|
|
|
public function StringProcessing(){
|
|
|
|
//字符串截取
|
|
|
|
$this->param['head_html'] = characterTruncation($this->param['html'],'/<header\b[^>]*>(.*?)<\/header>/s');
|
|
|
|
$this->param['main_html'] = characterTruncation($this->param['html'],'/<main\b[^>]*>(.*?)<\/main>/s');
|
|
|
|
$this->param['footer_html'] = characterTruncation($this->param['html'],'/<footer\b[^>]*>(.*?)<\/footer>/s');
|
|
|
|
$this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/s');
|
|
|
|
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-styles">(.*?)<\/style>/s');
|
|
|
|
$this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/s');
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|