作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

正在显示 44 个修改的文件 包含 1219 行增加600 行删除
... ... @@ -187,6 +187,7 @@ class SyncProject extends Command
'lead_name' => $param['principal_name'],
'mobile' => $param['principal_mobile'],
'mysql_id'=>Project::MYSQL_ID,
'serve_id'=>9,
'qq' => $param['customer_qq'],
'channel' => Channel::getProjectChannel($param['company_id'], $param['username_sales']),
'requirement' => $param['remark'],
... ...
<?php
namespace App\Console\Commands\RankData;
use App\Helper\Arr;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Console\Command;
class updateAiProjects extends Command
{
protected $signature = 'updateAiProjects';
protected $description = '更新AI站点域名数据';
public function handle()
{
$api_url = 'https://demosite5.globalso.com/api/domain';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
$file_path = public_path('ai_domains.txt');
file_put_contents($file_path, json_encode($data['data']));
}
} catch (\Exception | GuzzleException $e) {
errorLog('AI站点项目获取失败', [], $e);
return false;
}
}
}
... ...
... ... @@ -90,7 +90,7 @@ class RecommendedSuppliers extends Command
];
$res = http_post($url,json_encode($param));
echo date('Y-m-d H:i:s') . json_encode($res) . PHP_EOL;
if(!empty($res) && $res['code'] == 200 && !empty($res['data'])){
if(!empty($res) && isset($res['code']) && $res['code'] == 200 && !empty($res['data'])){
//保存多条数据
$saveData = [
'project_id'=>$project_id,
... ... @@ -115,8 +115,6 @@ class RecommendedSuppliers extends Command
* @time :2024/7/1 18:07
*/
public function getKeywords($project_id){
$keywordModel = new Keyword();
$keywordModel->
$info = Keyword::inRandomOrder()->first();
$keywordInfo = $this->getPurchaser($info->title,$project_id);
if($keywordInfo !== false){
... ...
... ... @@ -79,9 +79,9 @@ class SyncSubmitTaskDistribution extends Command
foreach ($list as $task) {
$data[] = [
'type' => $task->type,
'data' => json_encode($task->data),
'created_at' => $task['created_at'],
'updated_at' => $task['updated_at'],
'data' => $task->data,
'created_at' => $task->created_at,
'updated_at' => $task->updated_at,
];
}
$data && SyncSubmitTaskModel::insert($data);
... ...
... ... @@ -8,8 +8,11 @@
namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Models\Blog\Blog;
use App\Models\Com\KeywordVideoTask;
use App\Models\Com\KeywordVideoTaskLog;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\Devops\ServerConfig;
use App\Models\Devops\Servers;
use App\Models\Devops\ServersIp;
... ... @@ -23,6 +26,8 @@ use App\Models\Project\DeployOptimize;
use App\Models\Project\MinorLanguages;
use App\Models\Project\Project;
use App\Models\Purchaser\PurchaserInfo;
use App\Models\RouteMap\RouteMap;
use App\Models\Template\BTemplateCom;
use App\Services\AmazonS3Service;
use App\Services\ProjectServer;
use App\Utils\EncryptUtils;
... ... @@ -48,7 +53,17 @@ class Demo extends Command
protected $description = 'demo';
public function handle(){
$this->synchronizationFile('/upload/m/file/2024-07/tongli-haiyuan-keywords.pdf');
$projectModel = new Project();
$list = $projectModel->list(['type'=>['!=',0],'delete_status'=>0]);
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
$templateComModel = new BTemplateCom();
$templateComModel->edit(['source'=>3,'is_list'=>1],['source'=>5,'is_list'=>0,'is_custom'=>0]);
$templateComModel->edit(['source'=>4,'is_list'=>1],['source'=>7,'is_list'=>0,'is_custom'=>0]);
DB::disconnect('custom_mysql');
}
}
public function synchronizationFile($path_name){
... ...
... ... @@ -77,6 +77,28 @@ class HeaderFooter extends Command
$commonList = $templateCommonModel->list(['template_id'=>['in',[$settingInfo['template_id'],0]]]);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['is_custom'] == 0){
if($v['type'] == 3){
$v['type'] = 2;
$v['is_list'] = 1;
}
if($v['type'] == 4){
$v['type'] = 3;
$v['is_list'] = 0;
}
if($v['type'] == 5){
$v['type'] = 3;
$v['is_list'] = 1;
}
if($v['type'] == 6){
$v['type'] = 4;
$v['is_list'] = 0;
}
if($v['type'] == 7){
$v['type'] = 4;
$v['is_list'] = 1;
}
}
$typeArr = [1, 2, 3];
foreach ($typeArr as $type){
if($type == 1){
... ...
... ... @@ -11,6 +11,7 @@ namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Helper\Translate;
use App\Models\Blog\Blog;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\Product\CategoryRelated;
use App\Models\Product\Keyword;
... ... @@ -54,13 +55,14 @@ class UpdateRoute extends Command
*/
public function handle(){
$projectModel = new Project();
$list = $projectModel->list(['id'=>['in',[664]]]);
$list = $projectModel->list(['id'=>['in',[802]]]);
$data = [];
foreach ($list as $v){
echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
ProjectServer::useProject($v['id']);
// $this->getProduct();
$this->setProductKeyword();
// $this->getBlog();
DB::disconnect('custom_mysql');
}
echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
... ... @@ -386,4 +388,14 @@ class UpdateRoute extends Command
}
return true;
}
public function getBlog(){
$blogModel = new Blog();
$lists = $blogModel->list();
foreach ($lists as $v){
$route = RouteMap::setRoute($v['name'], RouteMap::SOURCE_BLOG, $v['id'], 1462);
$blogModel->edit(['url'=>$route],['id'=>$v['id']]);
}
return true;
}
}
... ...
... ... @@ -40,6 +40,9 @@ class Kernel extends ConsoleKernel
$schedule->command('delete_template_log')->monthlyOn(15, '00:01')->withoutOverlapping();
// 每日推送已完成视频任务项目生成对应界面
$schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1);
//更新AI站点数据
$schedule->command('updateAiProjects')->everyFourHours()->withoutOverlapping(1);
}
/**
... ...
... ... @@ -531,24 +531,12 @@ class OptimizationReportController extends BaseController
*/
public function getAiProjects($domain = null)
{
$key = 'ai_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'https://demosite5.globalso.com/api/domain';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('AI站点项目获取失败', [], $e);
return false;
}
}
$file_path = public_path('ai_domains.txt');
$data = file_get_contents($file_path);
$data = json_decode($data, true);
if ($domain !== null) {
$domain = parse_url($domain);
$data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first();
$data = collect($data)->where('bind_domain', $domain['host'] ?? $domain['path'])->first();
return $data ?: [];
}
return $data;
... ...
... ... @@ -14,6 +14,7 @@ use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Devops\ServersLogic;
use App\Models\Devops\Servers as ServersModel;
use App\Models\Devops\ServersIp;
use App\Models\Project\Project;
class ServersController extends BaseController
{
... ... @@ -46,6 +47,18 @@ class ServersController extends BaseController
if(isset($this->map['server_name']) && !empty($this->map['server_name'])){
$this->map['server_name'] = ['like','%'.$this->map['server_name'].'%'];
}
if(isset($this->map['project_name']) && !empty($this->map['project_name'])){
$projectModel = new Project();
$projectInfo = $projectModel->read(['title'=>['like','%'.$this->map['project_name'].'%']],['id','serve_id']);
if($projectInfo !== false){
$serversIpModel = new ServersIp();
$ipInfo = $serversIpModel->read(['id'=>$projectInfo['serve_id']],['servers_id']);
if($ipInfo !== false){
$this->map['id'] = $ipInfo['servers_id'];
}
}
unset($this->map['project_name']);
}
$serversModel = new ServersModel();
$data = $serversModel->lists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$data);
... ...
... ... @@ -39,7 +39,7 @@ class ServersIpController extends BaseController
}
$serversIpModel = new ServersIpModel();
$this->map['status'] = 0;
$data = $serversIpModel->list($this->map);
$data = $serversIpModel->list($this->map,'total',['*'],'asc');
foreach ($data as $k => $v){
$v['is_optional'] = 0;//是否可选择
if($v['total'] >= $info['ip_total']){
... ...
... ... @@ -174,6 +174,7 @@ class OptimizeController extends BaseController
'gl_project.is_translate AS is_translate',
'gl_project.is_translate_tag AS is_translate_tag',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.site_status AS site_status',
'gl_project_online_check.id AS online_check_id',
'gl_project_online_check.question AS question',
'gl_project_online_check.go_question AS go_question',
... ... @@ -220,6 +221,9 @@ class OptimizeController extends BaseController
if(isset($this->map['title']) && !empty($this->map['title'])){
$query = $query->where('gl_project.title','like','%'.$this->map['title'].'%');
}
if(isset($this->map['site_status'])){
$query = $query->where('gl_project.site_status',$this->map['site_status']);
}
if(isset($this->map['ai_video']) && !empty($this->map['ai_video'])){
$query = $query->where('gl_project_deploy_optimize.ai_video',$this->map['ai_video']);
}
... ...
... ... @@ -48,7 +48,6 @@ class CNoticeController extends BaseController
$url = $request->input('url', []);
$language = $request->input('language', []);
$is_sitemap = intval($request->input('is_sitemap', 0));
//获取项目所在服务器
$project_model = new Project();
$project_info = $project_model->read(['id'=>$project_id],['serve_id']);
... ... @@ -106,8 +105,10 @@ class CNoticeController extends BaseController
'is_sitemap' => $is_sitemap
];
http_post($c_url, json_encode($param));
// $shell = 'curl -X POST ' . escapeshellarg($c_url) . ' -H "Content-Type: application/json"' .
// ' -d ' . escapeshellarg(json_encode($param)) . ' > /dev/null 2>&1 &';
// shell_exec($shell);
}
$this->response('更新中请稍后, 更新完成将会发送站内信通知更新结果!');
}
... ...
... ... @@ -278,4 +278,5 @@ class BaseController extends Controller
];
return http_post($c_url, json_encode($param));
}
}
... ...
... ... @@ -69,6 +69,9 @@ class BlogController extends BaseController
}
});
}
if(isset($this->map['operator_id'])){
$query = $query->where('operator_id',$this->map['operator_id']);
}
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
... ...
... ... @@ -32,8 +32,7 @@ class CustomModuleExtentController extends BaseController
'module_id.required' => 'module_id不能为空',
]);
$this->map['project_id'] = $this->user['project_id'];
$filed = ['id','title','status','type','operator_id','project_id','module_id','created_at','updated_at'];
$lists = $customModuleExtend->list($this->map,$this->order,$filed);
$lists = $customModuleExtend->list($this->map,$this->order,['id','title','key','status','type','operator_id','project_id','module_id','created_at','updated_at']);
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -73,6 +73,9 @@ class NewsController extends BaseController
}
});
}
if(isset($this->map['operator_id'])){
$query = $query->where('operator_id',$this->map['operator_id']);
}
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
... ...
... ... @@ -165,6 +165,9 @@ class ProductController extends BaseController
if(isset($this->map['status'])){
$query = $query->where('status',$this->map['status']);
}
if(isset($this->map['created_uid'])){
$query = $query->where('created_uid',$this->map['created_uid']);
}
if(!empty($this->param['start_at']) && !empty($this->param['end_at'])){
$query->where('created_at', '>=' ,$this->param['start_at'].' 00:00:00')->where('created_at', '<=' ,$this->param['end_at'].' 59:59:59');
}
... ... @@ -625,4 +628,21 @@ class ProductController extends BaseController
$data = $logic->getSearchCategoryList();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :清空所有的产品+关键词关联
* @name :delProductKeyword
* @author :lyh
* @method :post
* @time :2024/8/5 15:47
*/
public function delProductKeyword(ProductLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不为空',
]);
$logic->delProductKeyword();
$this->response('success');
}
}
... ...
... ... @@ -27,4 +27,5 @@ class LanguageController extends BaseController
$lists = $webLanguageModel->list();
$this->response('success',Code::SUCCESS,$lists);
}
}
... ...
<?php
/**
* @remark :
* @name :LanguageTxtController.php
* @author :lyh
* @method :post
* @time :2024/8/6 14:40
*/
namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Models\WebSetting\LanguageTxt;
class LanguageTxtController extends BaseController
{
/**
* @remark :获取文本信息
* @name :getLanguageTxt
* @author :lyh
* @method :post
* @time :2024/8/5 17:29
*/
public function getLanguageTxt(){
$languageTxtModel = new LanguageTxt();
$data = $languageTxtModel->list();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存用户配置
* @name :saveLanguageTxt
* @author :lyh
* @method :post
* @time :2024/8/6 14:41
*/
public function saveLanguageTxt(){
$this->request->validate([
'name'=>'required',
'en_name'=>'required',
],[
'name.required' => 'name不能为空',
'en_name'=>'自定义名称en_name不为空',
]);
$languageTxtModel = new LanguageTxt();
$id = $languageTxtModel->addReturnId($this->param);
$this->response('success',Code::SUCCESS,['id'=>$id]);
}
/**
* @remark :删除数据
* @name :delLanguageTxt
* @author :lyh
* @method :post
* @time :2024/8/6 14:48
*/
public function delLanguageTxt(){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'name不能为空',
]);
$languageTxtModel = new LanguageTxt();
$languageTxtModel->del(['id'=>['in',$this->param['id']]]);
$this->response('success');
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
use App\Models\WebSetting\LanguageTxt;
/**
* @name:项目配置多语言设置
... ... @@ -84,7 +85,6 @@ class ProjectCountryController extends BaseController
],[
'language_id.required' => 'language_id不能为空'
]);
$info = $projectCountryLogic->country_custom_info();
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -60,9 +60,9 @@ class TranslateController extends BaseController
'language_id.required' => 'language_id不能为空',
]);
$this->map['type'] = 1;
$data = $translate->list($this->map);
$data = $translate->formatQuery($this->map)->with('translate_data')->get()->toArray();
foreach ($data as $k=>$v){
$v['data'] = json_decode($v['data']);
$v['data'] = json_decode($v['translate_data']['data'],JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
$data[$k] = $v;
}
$this->response('success',Code::SUCCESS,$data);
... ...
<?php
/**
* @remark :
* @name :BProjectComConfigController.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:24
*/
namespace App\Http\Controllers\Bside\Template;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\BTemplate\BProjectComConfigLogic;
class BProjectComConfigController extends BaseController
{
/**
* @remark :获取头部底部配置
* @name :getIsComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 15:08
*/
public function getIsComConfig(BProjectComConfigLogic $logic){
$data = $logic->getIsComConfig();
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :保存配置
* @name :saveComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 15:38
*/
public function saveComConfig(BProjectComConfigLogic $logic){
$this->request->validate([
'data'=>'required',
],[
'data.required' => 'data不能为空',
]);
$logic->saveComConfig();
$this->response('success');
}
}
... ...
... ... @@ -31,6 +31,23 @@ class BTemplateController extends BaseController
}
/**
* @remark :获取数据详情
* @name :templateInfo
* @author :lyh
* @method :post
* @time :2024/7/31 14:27
*/
public function publicInfo(BTemplateLogic $BTemplateLogic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$info = $BTemplateLogic->getPublicTemplateInfo();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取用户模版id
* @name :getUserTemplate
* @author :lyh
... ...
... ... @@ -74,7 +74,7 @@ class BTemplateLogController extends BaseController
$this->response('请先选择模版',Code::SYSTEM_ERROR);
}
$this->map = ['source'=>$this->param['source'],'source_id'=>$this->param['source_id'],'is_custom'=>$is_custom,'template_id'=>$settingInfo['template_id']];
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','created_at','updated_at']);
$lists = $bTemplateLog->lists($this->map,$this->page,$this->row,$this->order,['id','template_id','operator_id','source','source_id','created_at','updated_at']);
if(!empty($lists['list'])){
$templateModel = new Template();
$userModel = new User();
... ...
... ... @@ -109,4 +109,17 @@ class UserController extends BaseController
$userLogic->user_del();
$this->response('success');
}
/**
* @remark :获取当前项目的所有管理员
* @name :getUserLists
* @author :lyh
* @method :post
* @time :2024/8/6 9:40
*/
public function getUserLists(){
$userModel = new UserModel();
$list = $userModel->list(['project_id'=>$this->user['project_id']]);
$this->response('success',Code::SUCCESS,$list);
}
}
... ...
... ... @@ -13,6 +13,7 @@ use App\Http\Logic\Aside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\CustomModule\CustomModuleContent;
use App\Models\IsCom\ProjectComConfig;
use App\Models\RouteMap\RouteMap;
use App\Services\ProjectServer;
use Illuminate\Support\Facades\DB;
... ... @@ -93,9 +94,11 @@ class CustomModuleLogic extends BaseLogic
'name'=>$this->param['route'],
'module_id'=>$id,
'project_id'=>$this->param['project_id'],
'route'=>RouteMap::setRoute($this->param['route'],RouteMap::SOURCE_MODULE_CATE,$id,$this->param['project_id'])
'route'=>$this->param['route']
];
$customModuleCateModel->add($data);
$cateId = $customModuleCateModel->addReturnId($data);
$route = RouteMap::setRoute($this->param['route'],RouteMap::SOURCE_MODULE_CATE,$cateId,$this->param['project_id']);
$customModuleCateModel->edit(['route'=>$route],['id'=>$cateId]);
}
return $this->success();
}
... ... @@ -154,6 +157,9 @@ class CustomModuleLogic extends BaseLogic
$this->fail('当前模块拥有分类不允许删除');
}
$rs = (new CustomModule())->del($this->param);
//对应删除项目头部底部配置
$projectComConfigModel = new ProjectComConfig();
$projectComConfigModel->del(['source'=>$this->param['id'],'is_custom'=>1]);
if($rs === false){
$this->fail('系统错误,请联系管理员');
}
... ...
... ... @@ -7,7 +7,7 @@ use App\Models\Manage\Manage;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\Template;
use App\Models\Template\Setting;
use App\Services\ProjectServer;
... ... @@ -210,25 +210,34 @@ class ATemplateLogic extends BaseLogic
$templateInfo = $this->model->read(['id'=>$template_id]);
ProjectServer::useProject($project_id);
$bTemplateModel = new BTemplate();
$info = $bTemplateModel->read(['source'=>1,'template_id'=>$template_id]);
$info = $bTemplateModel->read(['source'=>BTemplate::SOURCE_HOME,'template_id'=>$template_id]);
if($info === false){
$data = [
'source'=>1, 'source_id'=>0, 'template_id'=>$template_id, 'main_html'=>$templateInfo['main_html'],
'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,
];
$bTemplateModel->add($data);
}
//保存一次公共头部信息
$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);
//保存一次公共头部+底部+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));
}
RouteMap::setRoute('index', RouteMap::SOURCE_PAGE, 0, $project_id);
DB::disconnect('custom_mysql');
... ...
<?php
/**
* @remark :
* @name :BProjectComConfigLogic.php
* @author :lyh
* @method :post
* @time :2024/8/1 14:25
*/
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\CustomModule\CustomModule;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Template\BTemplate;
/**
* @remark :独立头部——底部设置
* @name :BProjectComConfigLogic
* @author :lyh
* @method :post
* @time :2024/8/1 14:43
*/
class BProjectComConfigLogic extends BaseLogic
{
/**
* 初始化数据
*/
public function __construct()
{
parent::__construct();
$this->model = new ProjectComConfig();
$this->param = $this->requestAll;
}
const PUB_STATUS = 0;//公共
const PRO_STATUS = 1;//獨立
const IS_LIST = 1;
const IS_DETAIL = 0;
const IS_NO_CUSTOM = 0;
const IS_CUSTOM = 1;//扩展模块
/**
* @remark :获取初始数据
* @name :getIsComSetting
* @author :lyh
* @method :post
* @time :2024/8/1 15:02
*/
public function getIsComConfig(){
$data = [];
$data = $this->initParamData($data);
$data = $this->initPageParamData($data);
$data = $this->initCustomData($data);
return $this->success($data);
}
/**
* @remark :(独立头底)初始数据
* @name :initializedData
* @author :lyh
* @method :post
* @time :2024/8/1 11:52
*/
public function initParamData(&$data){
//默认模块
$initParam = $this->model->initParam;
foreach ($initParam as $pKey => $pValue){
$is_list = [self::IS_LIST,self::IS_DETAIL];
foreach ($is_list as $isValue){
//查询当前数据是否已保存
$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']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$pKey.($isValue == 0 ? '详情' : '列表'),
'source'=>$pValue,
'is_list'=>$isValue,
'is_custom'=>self::IS_NO_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
}
return $this->success($data);
}
/**
* @remark :单页面初始化
* @name :initPageParamData
* @author :lyh
* @method :post
* @time :2024/8/1 14:37
*/
public function initPageParamData(&$data){
$initPageParam = $this->model->initPageParam;
foreach($initPageParam as $key => $value){
$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']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$key,
'source'=>$value,
'is_list'=>self::IS_DETAIL,
'is_custom'=>self::IS_NO_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
return $this->success($data);
}
/**
* @remark :获取扩展模块初始数据
* @name :initCustomData
* @author :lyh
* @method :post
* @time :2024/8/1 14:42
*/
public function initCustomData(&$data){
$customModel = new CustomModule();
$customList = $customModel->list(['status'=>0]);
$is_list = [self::IS_LIST,self::IS_DETAIL];
foreach($customList as $value){
foreach ($is_list as $isValue){
$info = $this->model->read(['source'=>$value['id'],'is_list'=>$isValue,'is_custom'=>BTemplate::IS_CUSTOM],['id','name','source','is_list','is_custom','header_status','footer_status']);
if($info !== false){
$data[] = $info;
}else{
$data[] = [
'name'=>$value['name'].($isValue == self::IS_DETAIL ? '详情' : '列表'),
'source'=>$value['id'],
'is_list'=>$isValue,
'is_custom'=>self::IS_CUSTOM,
'header_status'=>self::PUB_STATUS,
'footer_status'=>self::PUB_STATUS,
];
}
}
}
return $this->success($data);
}
/**
* @remark :保存配置
* @name :saveComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 15:41
*/
public function saveComConfig(){
$data = $this->param['data'];
foreach ($data as $k => $v){
if(isset($v['id']) && !empty($v['id'])){
$id = $v['id'];
unset($v['id']);
$this->model->edit($v,['id'=>$id]);
}else{
//查询当前数据是否存在
$this->model->add($v);
}
}
return $this->success();
}
}
... ...
... ... @@ -10,9 +10,11 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
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\BTemplateLog;
use App\Models\Template\Setting;
... ... @@ -64,13 +66,18 @@ class BTemplateLogLogic extends BaseLogic
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom']];
//TODO::还原头部+底部
$bTemplateModel->edit(['html'=>$info['text']],$condition);
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'],
'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
];
$type = $this->getCustomizedType($info['source'],$info['is_list']);
$commonTemplateModel = new BTemplateCommon();
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
$commonTemplateModel = new BTemplateCom();
//还原头部
$condition = ['template_id'=>$info['template_id'],'source'=>$info['source'],
'is_list'=>$info['is_list'],'is_custom'=>$info['is_custom'],'project_id'=>$this->user['project_id']];
$condition['common_type'] = BTemplate::COMMON_HEAD;
$commonTemplateModel->edit(['html'=>$info['head_html'], 'html_style'=>$info['head_css']],$condition);
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$commonTemplateModel->edit(['html'=>$info['footer_html'], 'html_style'=>$info['footer_css']],$condition);
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$condition['common_type'] = BTemplate::COMMON_OTHER;
$commonTemplateModel->edit(['html'=>$other, 'html_style'=>''],$condition);
return $this->success();
}
... ... @@ -99,18 +106,9 @@ class BTemplateLogLogic extends BaseLogic
$bTemplateModel->edit($data,$condition);
//还原头部+底部
$commonData = [
'head_html'=>$info['head_html'], 'head_css'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_css'=>$info['footer_css']
'head_html'=>$info['head_html'], 'head_style'=>$info['head_css'], 'footer_html'=>$info['footer_html'], 'footer_style'=>$info['footer_css'],'other'=>$info['other']
];
$commonTemplateModel = new BTemplateCommon();
$type = $this->getType($info['source'],$info['is_list'],$info['is_custom']);
$commonTemplateModel->edit($commonData,['template_id'=>$info['template_id'],'type'=>$type,'project_id'=>$this->user['project_id']]);
if(!empty($info['other'])){
$commonTemplateModel->edit(['other'=>$info['other']],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$info['type']]);
}else{
$footer_other = str_replace('<header','',characterTruncation($info['text'],'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$commonTemplateModel->edit(['other'=>$other],['project_id'=>$this->user['project_id'],'template_id'=>$info['template_id'],'type'=>$type]);
}
$this->saveTemplateCom($commonData,$info['template_id'],$info['source'],$info['is_list'],$info['is_custom']);
}catch (\Exception $e){
$this->fail('系统错误,请联系管理员');
}
... ... @@ -118,36 +116,40 @@ class BTemplateLogLogic extends BaseLogic
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
* @time :2024/4/29 10:32
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
public function saveTemplateCom($handleInfo,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
$templateComModel->edit($param,$condition);
}
}
return $type;
return $this->success();
}
/**
... ... @@ -157,26 +159,28 @@ class BTemplateLogLogic extends BaseLogic
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === 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;}}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
... ...
... ... @@ -6,12 +6,13 @@ use App\Http\Logic\Bside\BaseLogic;
use App\Models\Blog\BlogCategory;
use App\Models\CustomModule\CustomModule;
use App\Models\CustomModule\CustomModuleCategory;
use App\Models\IsCom\ProjectComConfig;
use App\Models\News\NewsCategory;
use App\Models\Product\Category;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\BTemplate;
... ... @@ -52,6 +53,19 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :获取模版详情
* @name :getPublicTemplateInfo
* @author :lyh
* @method :post
* @time :2024/7/31 14:31
*/
public function getPublicTemplateInfo(){
$templateModel = new Template();
$info = $templateModel->read($this->param);
return $this->success($info);
}
/**
* @remark :获取可视化html
* @name :getTemplateHtml
* @author :lyh
... ... @@ -63,11 +77,11 @@ class BTemplateLogic extends BaseLogic
$is_list = $this->param['is_list'] ?? 0;//是否为列表页
$template_id = $this->getSettingTemplate($this->param['source'],$is_list,$is_custom);//设置的模版id
$templateInfo = $this->webTemplateInfo($this->param['source'],$this->param['source_id'],$template_id,$is_custom,$is_list);
if($templateInfo === false){
if($templateInfo === false){//todo::无装修数据处理
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//处理定制页面初始数据
$html = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($html !== false){
return $this->success($html);
$data = $this->customizedReturnHtml($this->param['source'],$template_id,$is_custom,$is_list);
if($data !== false){
return $this->success($data);
}
}
//非定制初始中间部分
... ... @@ -78,15 +92,83 @@ class BTemplateLogic extends BaseLogic
}
$mainInfo = ['main_html'=>$templateInfo['main_html'], 'main_css'=>$templateInfo['main_css']];
}
$commonInfo = $this->getCommonHtml($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'];
$commonInfo = $this->getTemplateComHtml($this->param['source'],$is_list,$is_custom,$template_id);//获取非定制头部
$html = $commonInfo['head_style'].$mainInfo['main_css'].$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$mainInfo['main_html'].$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);
$result = ['html'=>$html,'template_id'=>$template_id];
if($templateInfo !== false) {$result['id'] = $templateInfo['id'];$result['updated_at'] = $templateInfo['updated_at'];}
if($templateInfo !== false) {
$result['id'] = $templateInfo['id'];
$result['updated_at'] = $templateInfo['updated_at'];
}
return $this->success($result);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
$condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>'','is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
$headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
$bTemplateComModel = new BTemplateCom();
$otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员222');
}
$footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
$data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
return $this->success($data);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
$commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $commonHead;
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员111');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :获取整个html代码
* @name :getCustomizeAllHtml
* @author :lyh
... ... @@ -95,11 +177,11 @@ class BTemplateLogic extends BaseLogic
*/
public function getCustomizeAllHtml($templateInfo,$template_id,$is_custom,$is_list){
if($is_custom == BTemplate::IS_CUSTOM){
$commonInfo = $this->getCustomizedCommonHtml($this->param['source'],$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($templateInfo['source'],$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}else{
$type = $this->getCustomizedType($this->param['source'],$is_list);
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$type = $this->getCustomizedType($templateInfo['source'],$is_list);
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
$html = $this->handleAllHtml($commonInfo,$templateInfo['html']);
}
return $this->success(['html'=>$html,'template_id'=>$template_id,'id'=>$templateInfo['id'],'updated_at'=>$templateInfo['updated_at']]);
... ... @@ -136,11 +218,12 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//扩展模块定制
//扩展模块定制列表
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($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]);
... ... @@ -169,7 +252,7 @@ class BTemplateLogic extends BaseLogic
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($source,$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($source,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ... @@ -221,11 +304,11 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/13 15:39
*/
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
if(!empty($commonInfo['head_html']) && !empty($commonInfo['footer_html'])){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_style'] ?? '', $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_style'] ?? '', $html);
}
return $html;
}
... ... @@ -249,7 +332,7 @@ class BTemplateLogic extends BaseLogic
if($customHtmlInfo === false){
$this->fail('定制页面,请先上传代码块');
}
$commonInfo = $this->getCustomizedCommonHtml($type,$is_custom,$is_list);//获取定制头部
$commonInfo = $this->getCustomizeTemplateComHtml($type,$is_custom,$is_list);//获取定制头部
if($commonInfo !== false){
$customHtmlInfo['main_html'] = $this->handleAllHtml($commonInfo,$customHtmlInfo['main_html']);
}
... ... @@ -265,49 +348,25 @@ class BTemplateLogic extends BaseLogic
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizedCommonHtml($type,$is_custom = 0,$is_list = 0){
$data = [
'template_id' => 0,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>$is_custom,
'is_list'=>$is_list
];
$commonTemplateModel = new BTemplateCommon();
return $commonTemplateModel->read($data);
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
$data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
$param = ['template_id'=>$template_id,'source'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
$commonTemplateModel = new BTemplateCom();
$commonList = $commonTemplateModel->list($param);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['common_type'] == BTemplate::COMMON_HEAD){
$data['head_html'] = $v['html'];
$data['head_style'] = $v['html_style'];
}elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
$data['footer_html'] = $v['html'];
$data['footer_style'] = $v['html_style'];
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
$data['other'] = $v['html'];
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
return $this->success($data);
}
/**
... ... @@ -346,38 +405,10 @@ class BTemplateLogic extends BaseLogic
if($info === false){
$this->fail('请先选择模版');
}
$template_id = $info['template_id'];
return $this->success($template_id);
return $this->success($info['template_id']);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @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);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type,
'is_custom'=>0,
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
}
return $this->success($commonInfo);
}
/**
* @remark :保存修改后的模版
* @name :templateSave
* @author :lyh
... ... @@ -404,14 +435,12 @@ class BTemplateLogic extends BaseLogic
'is_custom'=>$this->param['is_custom'], 'template_id'=>$this->param['template_id'],
'is_list'=>$this->param['is_list']
];
$data = [
'section_list_id'=>$this->param['section_list_id']
];
$data = ['section_list_id'=>$this->param['section_list_id']];
$data = $this->handleVisualizationParam($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['is_custom'],$data);
$this->model->edit($data,$condition);
}
//更新头部信息
$this->saveCommonHtml($this->param['html'],$this->param['source'],$this->param['is_list'],$this->param['template_id'],$this->param['is_custom']);
$this->saveTemplateCom($this->param['html'],$this->param['template_id'],$this->param['source'],$this->param['is_list'],$this->param['is_custom']);
$this->setOperationRecords($this->param['html'],$this->param['source'],$this->param['source_id'],$this->param['template_id'],$this->param['is_custom'],$this->param['is_list']);
//通知更新
$this->homeOrProduct($this->param['source'],$this->param['source_id'],$this->param['is_custom'],$this->param['is_list']);
... ... @@ -441,7 +470,6 @@ class BTemplateLogic extends BaseLogic
* @time :2023/12/15 10:59
*/
public function handleVisualizationParam($html,$source, $is_list,$is_custom,$data){
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){//定制项目
//TODO::扩展模块定制单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$customModuleModel = new CustomModule();
... ... @@ -456,102 +484,60 @@ class BTemplateLogic extends BaseLogic
return $this->success($data);
}
}else{
if($this->user['is_customized'] == BTemplate::IS_VISUALIZATION){
$type = $this->getCustomizedType($source, $is_list);//获取定制界面类型
//查看当前页面是否定制,是否开启可视化
$page_array = (array)$this->user['is_visualization']->page_array;//获取所有定制界面
if (in_array($type, $page_array)) {//当前页面是定制界面
if(in_array($type, $page_array)){
$data['html'] = $html;
$data['type'] = BTemplate::ALL_HTML;
return $this->success($data);
}
}
}
$mainInfo = $this->handleTemplateHtml($html);
$data['main_html'] = $mainInfo['main_html'];
$data['main_css'] = $mainInfo['main_css'];
$data['main_html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$data['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($data);
}
/**
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/12/13 17:05
* @time :2024/4/29 10:32
*/
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
//TODO::定制扩展模块单独处理
if($is_custom == BTemplate::IS_CUSTOM){
$code = $this->saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id);
if($code === false){
return $this->success();
}
}
//todo::其他情况
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
if($template_id == 0){//定制页面默认为独立头部
$type = $this->getCustomizedType($source,$is_list);//定制默认独立头部
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type,'is_custom'=>0]);//查看当前头部是否存在
public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
}
//更新所有界面的other
if($template_id != 0){
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
if($typeSource == 99){
$is_custom = $is_list = 0;
}
}
/**
* @remark :扩展模块定制保存头部处理
* @name :saveCustomModuleCommonHtml
* @author :lyh
* @method :post
* @time :2024/1/10 11:33
*/
public function saveCustomModuleCommonHtml($html,$source,$is_custom,$is_list,$template_id){
$customModuleModel = new CustomModule();
$info = $customModuleModel->read(['id'=>$source]);
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$this->fail('当前扩展模块不存在或已被删除');
}
//todo::扩展模块(列表页/详情页)定制
if($info['list_customized'] == BTemplate::IS_VISUALIZATION || $info['detail_customized'] == BTemplate::IS_VISUALIZATION) {
$data = ['type'=>$source,'is_custom'=>$is_custom,'is_list'=>$is_list,'template_id'=>$template_id];
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read($data);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$source,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list,
];
$templateCommonModel->add($data);
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
$templateComModel->edit($param,$condition);
}
return false;
}
return true;
return $this->success();
}
/**
... ... @@ -580,59 +566,46 @@ class BTemplateLogic extends BaseLogic
//字符串截取
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
return $this->success($param);
}
/**
* @remark :保存时字符串处理
* @name :handleSaveParam
* @remark :获取类型
* @name :getTypes
* @author :lyh
* @method :post
* @time :2023/6/29 15:35
* @time :2024/8/1 16:01
*/
public function handleTemplateHtml($html){
//字符串截取
$param['main_html'] = characterTruncationStr($html,"<main","</main>");
$param['main_css'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
return $this->success($param);
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
/**
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === 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;}}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
/**
* @remark :生成记录
* @name :setTemplateLog
... ... @@ -933,22 +906,35 @@ class BTemplateLogic extends BaseLogic
}
/**
* @remark :设置模版
* @name :setCustomTemplate
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2024/5/24 15:55
* @time :2023/11/16 11:20
*/
public function setCustomTemplate(){
$templateModel = new Template();
$templateInfo = $templateModel->read(['id'=>$this->param['template_id']],['id','main_html','main_css']);
if($templateInfo === false){
$this->fail('未获取到模版数据');
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
if(empty($templateInfo['main_html']) || empty($templateInfo['main_css'])){
$this->fail('当前模版替换数据错误');
}
$this->model->edit(['html'=>$templateInfo['main_html'],'html_style'=>$templateInfo['main_css']],['id'=>$this->param['id']]);
return $this->success();
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
}
... ...
... ... @@ -3,11 +3,12 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BCustomTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateLog;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
... ... @@ -30,7 +31,7 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/6/29 15:46
*/
public function customTemplateLists($map,$page,$row,$order = 'created_at'){
$filed = ['id','name','status','url','title','keywords','description','project_id','is_upgrade','six_read','is_visualization','created_at','updated_at'];
$filed = ['id','name','status','url','operator_id','title','keywords','description','project_id','is_upgrade','six_read','is_visualization','created_at','updated_at'];
$map['deleted_status'] = 0;
$map['project_id'] = $this->user['project_id'];
$lists = $this->model->lists($map,$page,$row,$order,$filed);
... ... @@ -50,13 +51,85 @@ class CustomTemplateLogic extends BaseLogic
$this->fail('当前数据不存在');
}
if($info['is_visualization'] == 0 || $info['is_visualization'] == 1){
$html = $this->getBodyHeaderFooter($info['html'],$info['html_style']);
$html = $this->getTemplateComHtml($info['html'],$info['html_style']);
$info['html'] = $this->getHeadFooter($html);
}
return $this->success($info);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($html,$html_style){
if(empty($html)){
$html = "<main></main>";
$html_style = "<style id='globalsojs-styles'></style>";
}
$headComInfo = $this->getHeadComHtml(['common_type'=>BTemplate::COMMON_HEAD]);
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_OTHER;
$condition['source'] = $headComInfo['source'];
$otherInfo = $bTemplateComModel->read($condition);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员');
}
$footerComInfo = $this->getFooterComHtml();
$commonInfo = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
$html = $commonInfo['head_style'].$html_style.$commonInfo['footer_style'].$commonInfo['other']. $commonInfo['head_html'].$html.$commonInfo['footer_html'];
return $this->success($html);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition){
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $this->getType();
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$condition['source'] = BTemplate::SOURCE_COM;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml(){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType(BTemplate::COMMON_FOOTER);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$condition['source'] = BTemplate::SOURCE_COM;
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :保存自定义界面
* @name :customTemplateSave
* @author :lyh
... ... @@ -64,13 +137,7 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/6/29 16:21
*/
public function customTemplateSave(){
$this->param['url'] = str_replace_url($this->param['url']);
if(($this->project['deploy_build']['is_search'] == 0) && ($this->param['url'] == 'search')){
$this->fail('请先开启搜索页可视化');
}
if(($this->project['deploy_build']['is_keyword'] == 0) && ($this->param['url'] == 'keyword')){
$this->fail('请先开启聚合页可视化');
}
$this->param = $this->handleSaveParam();;
if(isset($this->param['id']) && !empty($this->param['id'])){
$id = $this->param['id'];
$is_upgrade = $this->param['is_upgrade'] ?? 0;//1:5.0数据 0:6.0
... ... @@ -82,6 +149,7 @@ class CustomTemplateLogic extends BaseLogic
}
}
$this->editCustomRoute($this->param['url']);
unset($this->param['html'],$this->param['html_style']);
$this->model->edit($this->param,['id'=>$id]);
}else{
if($this->param['url'] == $this->model::NOT_FOUND_PAGE_URL){
... ... @@ -107,6 +175,25 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :参数验证
* @name :handleSaveParam
* @author :lyh
* @method :post
* @time :2024/8/6 16:52
*/
public function handleSaveParam(){
$this->param['url'] = str_replace_url($this->param['url']);
$this->param['operator_id'] = $this->user['id'];
if(($this->project['deploy_build']['is_search'] == 0) && ($this->param['url'] == 'search')){
$this->fail('请先开启搜索页可视化');
}
if(($this->project['deploy_build']['is_keyword'] == 0) && ($this->param['url'] == 'keyword')){
$this->fail('请先开启聚合页可视化');
}
return $this->success($this->param);
}
/**
* @remark :可视化保存html
* @name :saveHtml
* @author :lyh
... ... @@ -126,9 +213,13 @@ class CustomTemplateLogic extends BaseLogic
if($bSettingInfo === false){
$this->fail('请先选择模版');
}
$this->saveCommonTemplate($html,$bSettingInfo['template_id']);
$this->param['html'] = characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s');
$this->param['html_style'] = characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s');
$handleInfo = $this->handleResultParam($html);
if(!isset($this->param['template_status'])){//代表直接替换模版 不更新头部底部
$this->saveTemplateCom($handleInfo,$bSettingInfo['template_id']);
}
$this->param['html'] = $handleInfo['main_html'];
$this->param['html_style'] = $handleInfo['main_style'];
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id'],'project_id'=>$this->user['project_id']]);
if($rs === false){
... ... @@ -149,6 +240,7 @@ class CustomTemplateLogic extends BaseLogic
* @time :2023/8/23 11:16
*/
public function setTemplateLog($template_id,$html,$source_id){
$handleInfo = $this->handleResultParam($html);
$data = [
'template_id'=>$template_id,
'project_id'=>$this->user['project_id'],
... ... @@ -156,71 +248,109 @@ class CustomTemplateLogic extends BaseLogic
'text'=>$html,
'source'=>9,
'source_id'=>$source_id,
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncation($html,'/<main\b[^>]*>(.*?)<\/main>/s'),
'main_css' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
'head_html'=>$handleInfo['head_html'],
'head_css'=>$handleInfo['head_style'],
'footer_html'=>$handleInfo['footer_html'],
'footer_css'=>$handleInfo['footer_style'],
'main_html' => $handleInfo['main_html'],
'main_css' => $handleInfo['main_style'],
'other'=>$handleInfo['other']
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$data['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$bTemplateLogModel = new BTemplateLog();
return $bTemplateLogModel->add($data);
}
/**
* @remark :保存头部公共数据
* @name :saveCommonTemplate
* @remark :截取数据返回
* @name :handleResultParam
* @author :lyh
* @method :post
* @time :2023/10/13 14:27
* @time :2024/5/6 14:14
*/
public function saveCommonTemplate($html,$template_id){
$type = $this->getType();
$templateCommonModel = new BTemplateCommon();
$info = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);
$data = [
public function handleResultParam($html){
$handleInfo = [
'head_html'=>characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s'),
'head_css'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'head_style'=>characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s'),
'footer_html'=>characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s'),
'footer_css'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'footer_style'=>characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s'),
'main_html' => characterTruncationStr($html,"<main","</main>"),
'main_style' => characterTruncation($html,'/<style id="globalsojs-styles">(.*?)<\/style>/s'),
];
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$other = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
$handleInfo['other'] = $other;
return $this->success($handleInfo);
}
/**
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2024/4/29 10:32
*/
public function saveTemplateCom($handleInfo,$template_id){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($type);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($type);
}else{
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$type == BTemplate::COMMON_HEAD;
$typeSource = $this->getType($type);
}
//查看当前数据是否还存在
$condition = ['template_id'=>$template_id,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data['template_id'] = $template_id;
$data['project_id'] = $this->user['project_id'];
$data['type'] = $type;
$templateCommonModel->add($data);
$data = array_merge($param,$condition);
$rs = $templateComModel->add($data);
}else{
$templateCommonModel->edit($data,['id'=>$info['id']]);
$rs = $templateComModel->edit($param,$condition);
}
if($rs === false){
$this->fail('保存错误,请联系管理员');
}
}
//更新所有界面的other
$templateCommonModel->edit(['other'=>$other],['project_id'=>$this->user['project_id']]);
return $this->success();
}
/**
* @remark :获取设置的类型
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType(){
$type = 1;//首页公共头部底部
public function getType($commonType = BTemplate::COMMON_HEAD){
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_head == BTemplate::IS_NO_HEADER){
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
if ($pageInfo['page_list'] != 0) {
$type = 9;
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>9,'is_list'=>0,'is_custom'=>0]);
if ($configInfo === false) {
return $this->success($type);
}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : 9);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : 9);
}
return $type;
return $this->success($type);
}
/**
... ... @@ -288,59 +418,6 @@ class CustomTemplateLogic extends BaseLogic
}
/**
* @remark :获取body的详情
* @name :getBodyHeaderFooter
* @author :lyh
* @method :post
* @time :2023/7/21 18:08
*/
public function getBodyHeaderFooter($preg_html,$html_style){
if(empty($preg_html)){
$preg_html = "<main></main>";
$html_style = "<style id='globalsojs-styles'></style>";
}
//获取设置的默认模版
$bSettingModel = new Setting();
$info = $bSettingModel->read(['project_id'=>$this->user['project_id']]);
if($info === false){
$this->fail('请先设置模版');
}
//获取type类型
$commonInfo = $this->getCommonPage($info['template_id']);
$html = $commonInfo['head_css'].$html_style.$commonInfo['footer_css'].$commonInfo['other'].
$commonInfo['head_html'].$preg_html.$commonInfo['footer_html'];
return $this->success($html);
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonPage($template_id){
if(isset($this->user['configuration']['is_head']) && ($this->user['configuration']['is_head'] != 0)) {
//查看页面是否设置自定义头部底部
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo !== false) {
$commonTemplateModel = new BTemplateCommon();
if ($pageInfo['page_list'] != 0) {
//使用独立头和底
$commonInfo = $commonTemplateModel->read(['template_id' => $template_id, 'project_id' => $this->user['project_id'], 'type' => 9]);
}
}
}
if(!isset($commonInfo) || $commonInfo === false){
//获取首页公共的头部和底部
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>1]);
}
return $commonInfo;
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ... @@ -421,27 +498,37 @@ class CustomTemplateLogic extends BaseLogic
* @name :copyCustomTemplateInfo
* @author :lyh
* @method :post
* @time :2024/5/24 14:47
* @time :2024/4/28 16:16
*/
public function copyCustomTemplateInfo(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在');
$param = $this->setCustomTemplateParams($info);
$save_id = $this->model->insertGetId($param);
$route = RouteMap::setRoute($param['url'], RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
$this->model->edit(['route'=>$route],['id'=>$save_id]);
return $this->success(['id'=>$save_id]);
}
$param = [
'name'=>$info['name'].'-copy',
'status'=>$info['status'],
'url'=>$info['url'].'-copy',
'html'=>$info['html'],
'html_style'=>$info['html_style'],
'project_id'=>$info['project_id'],
'is_visualization'=>$info['is_visualization'],
'six_read'=>$info['six_read'],
'is_upgrade'=>$info['is_upgrade'],
/**
* @remark :组装数据
* @name :setCustomTemplateParams
* @author :lyh
* @method :post
* @time :2024/4/28 16:18
*/
public function setCustomTemplateParams($info)
{
return [
'name' => $info['name'] . '-copy',
'status' => $info['status'],
'url' => $info['url'],
'html' => $info['html'],
'html_style' => $info['html_style'],
'project_id' => $info['project_id'],
'section_list_id' => $info['section_list_id'],
'is_visualization' => $info['is_visualization'],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
];
$id = $this->model->addReturnId($param);
$route = RouteMap::setRoute($param['url'],RouteMap::SOURCE_PAGE,$id,$param['project_id']);
$this->model->edit(['url'=>$route],['id'=>$id]);
return $this->success(['id'=>$id]);
}
}
... ...
... ... @@ -10,11 +10,12 @@
namespace App\Http\Logic\Bside\BTemplate;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\IsCom\ProjectComConfig;
use App\Models\Project\PageSetting;
use App\Models\RouteMap\RouteMap;
use App\Models\Service\Service as ServiceSettingModel;
use App\Models\Template\BTemplate;
use App\Models\Template\BTemplateCommon;
use App\Models\Template\BTemplateCom;
use App\Models\Template\BTemplateMain;
use App\Models\Template\Setting;
use App\Models\Template\TemplateTypeMain;
... ... @@ -51,14 +52,79 @@ class InitHtmlLogic extends BaseLogic
$data['id'] = $mainInfo['id'];
$data['updated_at'] = $mainInfo['updated_at'];
}
$commonInfo = $this->getCommonHtml($this->param['type'],$is_list,$template_id,$is_custom); //获取头部
$html = $commonInfo['head_css'].$main_style.$commonInfo['footer_css'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$commonInfo = $this->getTemplateComHtml($this->param['type'],$is_list,$is_custom,$template_id); //获取头部
$html = $commonInfo['head_style'].$main_style.$commonInfo['footer_style'].$commonInfo['other'].$commonInfo['head_html'].$main_html.$commonInfo['footer_html'];
$html = $this->getHeadFooter($html);//组装数据
$data['html'] = $html;
return $this->success($data);
}
/**
* @remark :非定制获取头部+底部
* @name :getTemplateComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 16:53
*/
public function getTemplateComHtml($source,$is_list,$is_custom,$template_id){
$condition = ['common_type'=>BTemplate::COMMON_HEAD,'source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom,'template_id'=>$template_id];
$headComInfo = $this->getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id);
$bTemplateComModel = new BTemplateCom();
$otherInfo = $bTemplateComModel->read(['source'=>$headComInfo['source'],'common_type'=>BTemplate::COMMON_OTHER,'is_list'=>$headComInfo['is_list'],'is_custom'=>$headComInfo['is_custom']]);
if($otherInfo === false){
$this->fail('获取失败,请联系管理员');
}
$footerComInfo = $this->getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id);
$data = ['head_html'=>$headComInfo['html'] ?? '', 'head_style'=>$headComInfo['html_style'] ?? '', 'other'=>$otherInfo['html'] ?? '',
'footer_html'=>$footerComInfo['html'] ?? '','footer_style'=>$footerComInfo['html_style'] ?? ''];
return $this->success($data);
}
/**
* @remark :公共头部
* @name :HeadComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:20
*/
public function getHeadComHtml($condition,$source,$is_list,$is_custom,$template_id){
$commonHead = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
$bTemplateComModel = new BTemplateCom();
$condition['source'] = $commonHead;
$condition['common_type'] = BTemplate::COMMON_HEAD;
$headComInfo = $bTemplateComModel->read($condition);
if($headComInfo === false){
//取默认公共的
$headComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_HEAD]);
if($headComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($headComInfo);
}
/**
* @remark :公共底部
* @name :footerComHtml
* @author :lyh
* @method :post
* @time :2024/4/29 17:18
*/
public function getFooterComHtml($condition,$source,$is_list,$is_custom,$template_id){
$bTemplateComModel = new BTemplateCom();
$condition['common_type'] = BTemplate::COMMON_FOOTER;
$condition['source'] = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_FOOTER,$template_id);
$footerComInfo = $bTemplateComModel->read($condition);
if($footerComInfo === false){
//取默认首页的
$footerComInfo = $bTemplateComModel->read(['source'=>BTemplate::SOURCE_COM,'common_type'=>BTemplate::COMMON_FOOTER]);
if($footerComInfo === false){
$this->fail('获取失败,请联系管理员');
}
}
return $this->success($footerComInfo);
}
/**
* @remark :拼接获取公共头部底部
* @name :getHeadFooter
* @author :lyh
... ... @@ -116,96 +182,85 @@ class InitHtmlLogic extends BaseLogic
];
$bTemplateMainModel->edit($data,['id'=>$mainInfo['id']]);
}
$this->saveCommonHtml($this->param['html'],$this->param['type'],$is_list,$template_id,$is_custom);
$this->saveTemplateCom($this->param['html'],$template_id,$this->param['type'],$is_list,$is_custom);
$route = RouteMap::getRoute('all',0,$this->user['project_id']);
$this->curlDelRoute(['route'=>$route,'new_route'=>$route]);
return $this->success();
}
/**
* @remark :保存公共头部底部
* @name :saveCommonHtml
* @remark :保存公共部分(头部。底部。连接部分)
* @name :saveTemplateCom
* @author :lyh
* @method :post
* @time :2023/12/13 17:05
* @time :2024/4/29 10:32
*/
public function saveCommonHtml($html,$source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);//获取头部类型1-9(首页到自定义页面)
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>$template_id,'project_id'=>$this->user['project_id'],'type'=>$type]);//查看当前头部是否存在
public function saveTemplateCom($html,$template_id,$source,$is_list,$is_custom){
$typeArr = [BTemplate::COMMON_HEAD, BTemplate::COMMON_FOOTER, BTemplate::COMMON_OTHER];
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>$template_id, 'project_id'=>$this->user['project_id'],
];
$templateCommonModel->add($data);
$templateComModel = new BTemplateCom();
foreach ($typeArr as $type){
if($type == BTemplate::COMMON_HEAD){
$param['html'] = $handleInfo['head_html'];
$param['html_style'] = $handleInfo['head_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);//头部是否为独立头部
}elseif ($type == BTemplate::COMMON_FOOTER){
$param['html'] = $handleInfo['footer_html'];
$param['html_style'] = $handleInfo['footer_style'];
$typeSource = $this->getType($source,$is_list,$is_custom,$type,$template_id);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],'other'=>$handleInfo['other'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
$param['html'] = $handleInfo['other'];
$param['html_style'] = null;
$typeSource = $this->getType($source,$is_list,$is_custom,BTemplate::COMMON_HEAD,$template_id);
}
//更新所有界面的other
return $templateCommonModel->edit(['other'=>$handleInfo['other']],['project_id'=>$this->user['project_id'],'template_id'=>$template_id]);
if($typeSource == 99){
$is_custom = $is_list = 0;
}
/**
* @remark :根据类型获取公共头和底
* @name :getCommonPage
* @author :lyh
* @method :post
* @time :2023/10/21 16:55
*/
public function getCommonHtml($source,$is_list,$template_id,$is_custom){
$type = $this->getType($source,$is_list,$is_custom);
$data = [
'template_id' => $template_id,
'project_id' => $this->user['project_id'],
'type'=>$type
];
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read($data);
if($commonInfo === false){
$data['type'] = BTemplate::SOURCE_HOME;
$commonInfo = $commonTemplateModel->read($data);
//查看当前数据是否还存在
$condition = ['project_id'=>$this->user['project_id'],'template_id'=>$template_id,'is_list'=>$is_list,'is_custom'=>$is_custom,'source'=>$typeSource,'common_type'=>$type];
$info = $templateComModel->read($condition);
if($info === false){
$data = array_merge($param,$condition);
$templateComModel->add($data);
}else{
$templateComModel->edit($param,$condition);
}
return $this->success($commonInfo);
}
return $this->success();
}
/**
* @remark :保存时获取获取设置的类型
* @remark :(非定制)保存时获取获取设置的类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/10/21 17:29
*/
public function getType($source,$is_list,$is_custom = 0){
$type = BTemplate::SOURCE_HOME;//首页公共头部底部
public function getType($source,$is_list,$is_custom = BTemplate::IS_NO_CUSTOM,$commonType = BTemplate::COMMON_HEAD,$template_id = 0){
if($template_id == 0){
return $this->success($source);
}
$type = BTemplate::SOURCE_COM;//公共头部底部
$is_head = $this->user['configuration']['is_head'] ?? BTemplate::IS_NO_HEADER;
if($is_custom == BTemplate::IS_CUSTOM){//拓展模块为首页头部
if($is_head == BTemplate::IS_NO_HEADER){//拓展模块为公共头+底
return $this->success($type);
}
//查看页面是否设置自定义头部底部
if($is_head != BTemplate::IS_NO_HEADER) {
$pageSettingModel = new PageSetting();
$pageInfo = $pageSettingModel->read(['project_id' => $this->user['project_id']]);
if ($pageInfo === false) {
$comConfigModel = new ProjectComConfig();
$configInfo = $comConfigModel->read(['source'=>$source,'is_list'=>$is_list,'is_custom'=>$is_custom]);
if($configInfo === 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;}}
//头部
if($commonType == BTemplate::COMMON_HEAD){
return $this->success($configInfo['header_status'] == 0 ? $type : $source);
}
//底部
if($commonType == BTemplate::COMMON_FOOTER){
return $this->success($configInfo['footer_status'] == 0 ? $type : $source);
}
return $this->success($type);
}
/**
* @remark :保存时字符串处理
* @name :handleCommonParam
... ... @@ -217,8 +272,8 @@ class InitHtmlLogic extends BaseLogic
//字符串截取
$param['head_html'] = characterTruncation($html,'/<header\b[^>]*>(.*?)<\/header>/s');
$param['footer_html'] = characterTruncation($html,'/<footer\b[^>]*>(.*?)<\/footer>/s');
$param['head_css'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_css'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$param['head_style'] = characterTruncation($html,'/<style id="globalsojs-header">(.*?)<\/style>/s');
$param['footer_style'] = characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<\/style>/s');
$footer_other = str_replace('<header','',characterTruncation($html,'/<style id="globalsojs-footer">(.*?)<header/s'));
$param['other'] = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', '', $footer_other);
return $this->success($param);
... ... @@ -271,21 +326,39 @@ class InitHtmlLogic extends BaseLogic
if($info === false){
$html = '';
}else{
//扩展模块获取头部
if($is_custom == BTemplate::IS_CUSTOM){
$type = $this->param['type'];
$commonInfo = $this->getCustomizeTemplateComHtml($this->param['type'],$is_custom,$is_list);
$html = $this->handleAllHtml($commonInfo,$info['main_html']);
}
//更新头部底部
return $this->success(['html'=>$html]);
}
/**
* @remark :定制获取头部底部
* @name :getCustomizedCommonHtml
* @author :lyh
* @method :post
* @time :2023/12/29 13:13
*/
public function getCustomizeTemplateComHtml($type,$is_custom,$is_list,$template_id = 0){
$data = ['head_html'=>'','head_style'=>'','footer_html'=>'','footer_style'=>'','other'=>''];
$param = ['template_id'=>$template_id,'source'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list];
$commonTemplateModel = new BTemplateCom();
$commonList = $commonTemplateModel->list($param);
if(!empty($commonList)){
foreach ($commonList as $v){
if($v['common_type'] == BTemplate::COMMON_HEAD){
$data['head_html'] = $v['html'];
$data['head_style'] = $v['html_style'];
}elseif ($v['common_type'] == BTemplate::COMMON_FOOTER){
$data['footer_html'] = $v['html'];
$data['footer_style'] = $v['html_style'];
}else{
$type = $this->getCustomizedType($this->param['type'],$is_list);
$data['other'] = $v['html'];
}
$commonTemplateModel = new BTemplateCommon();
$commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);
if($commonInfo !== false){
$info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
}
$html = $info['main_html'];
}
//更新头部底部
return $this->success(['html'=>$html]);
return $this->success($data);
}
/**
... ... @@ -296,11 +369,11 @@ class InitHtmlLogic extends BaseLogic
* @time :2023/12/13 15:39
*/
public function handleAllHtml($commonInfo,$html){
if(!empty($commonInfo)){
if(!empty($commonInfo['head_html']) && !empty($commonInfo['footer_html'])){
$html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
$html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
$html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_style'] ?? '', $html);
$html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_style'] ?? '', $html);
}
return $html;
}
... ... @@ -331,7 +404,7 @@ class InitHtmlLogic extends BaseLogic
$bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
}
//更新头部底部
$this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list,$is_custom);
$this->saveTemplateCom($this->param['html'],0,$this->param['type'],$is_list,$is_custom);
}catch (\Exception $exception){
$this->fail('保存失败,请联系开发人员');
}
... ... @@ -339,73 +412,6 @@ class InitHtmlLogic extends BaseLogic
}
/**
* @remark :定制代码更新头部信息
* @name :saveCustomizeCommon
* @author :lyh
* @method :post
* @time :2024/1/6 10:29
*/
public function saveCustomizeCommon($html,$source,$is_list,$is_custom){
if($is_custom == BTemplate::IS_CUSTOM){
$type = $source;
}else{
$type = $this->getCustomizedType($source,$is_list);
}
$templateCommonModel = new BTemplateCommon();
$commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type,'is_custom'=>$is_custom,'is_list'=>$is_list]);//查看当前头部是否存在
$handleInfo = $this->handleCommonParam($html);
if($commonInfo === false){
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
'is_custom'=>$is_custom,'is_list'=>$is_list
];
$templateCommonModel->add($data);
}else{
$data = [
'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
];
$templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
}
return $this->success();
}
/**
* @remark :定制页面头部类型---根据source获取type类型
* @name :getType
* @author :lyh
* @method :post
* @time :2023/11/16 11:20
*/
public function getCustomizedType($source,$is_list){
$type = BTemplate::TYPE_HOME;
if($source == BTemplate::SOURCE_PRODUCT){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_PRODUCT_LIST;
}else{
$type = BTemplate::TYPE_PRODUCT_DETAIL;
}
}
if($source == BTemplate::SOURCE_BLOG){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_BLOG_LIST;
}else{
$type = BTemplate::TYPE_BLOG_DETAIL;
}
}
if($source == BTemplate::SOURCE_NEWS){
if($is_list == BTemplate::IS_LIST){
$type = BTemplate::TYPE_NEWS_LIST;
}else{
$type = BTemplate::TYPE_NEWS_DETAIL;
}
}
return $type;
}
/**
* @remark :前端获取设置模块(侧边栏)
* @name :getInitModuleMain
* @author :lyh
... ...
... ... @@ -170,11 +170,11 @@ class BlogLogic extends BaseLogic
* @time :2023/6/13 11:30
*/
public function paramProcessing($param){
$param['operator_id'] = $this->user['id'];
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
}
if(isset($param['category_id']) && !empty($param['category_id'])){
... ... @@ -193,8 +193,11 @@ class BlogLogic extends BaseLogic
* @time :2023/10/20 9:02
*/
public function getCategory($category){
if(empty($category)){
return '';
}
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
return !empty(trim(trim($str,','),',')) ? ','.trim(trim($str,','),',').',' : '';
}
/**
... ...
... ... @@ -240,10 +240,8 @@ class CustomModuleContentLogic extends BaseLogic
{
//生成一条删除路由记录
$info = $this->model->read(['id' => $id], ['id', 'route']);
if ($info['route'] != $route) {
$this->addUpdateNotify(RouteMap::SOURCE_MODULE,$route);
$this->curlDelRoute(['route'=>$info['route'],'new_route'=>$route]);
}
return true;
}
... ...
... ... @@ -183,6 +183,7 @@ class NewsLogic extends BaseLogic
*/
public function paramProcessing($param)
{
$param['operator_id'] = $this->user['id'];
if(isset($param['image'])){
$param['image'] = str_replace_url($param['image'] ?? '');
}
... ... @@ -193,7 +194,6 @@ class NewsLogic extends BaseLogic
$param['operator_id'] = $this->user['id'];
}else{
$param['create_id'] = $this->user['id'];
$param['operator_id'] = $this->user['id'];
$param['project_id'] = $this->user['project_id'];
}
if(isset($param['category_id']) && !empty($param['category_id'])){
... ... @@ -213,7 +213,7 @@ class NewsLogic extends BaseLogic
*/
public function getCategory($category){
$str = implode(',',$category);
return !empty(trim(trim($str,','),',')) ? ','.$str.',' : '';
return !empty(trim(trim($str,','),',')) ? ','.trim(trim($str,','),',').',' : '';
}
/**
... ...
... ... @@ -921,4 +921,16 @@ class ProductLogic extends BaseLogic
}
return $this->success($data);
}
/**
* @remark :删除数据
* @name :delProductKeyword
* @author :lyh
* @method :post
* @time :2024/8/5 15:49
*/
public function delProductKeyword(){
$this->model->edit(['keyword_id'=>null],['id'=>$this->param['id']]);
return $this->success(['id'=>$this->param['id']]);
}
}
... ...
... ... @@ -307,29 +307,18 @@ class RankDataLogic extends BaseLogic
/**
* 获取AI站点项目
*
* @author zbj
* @date 2023/5/12
*/
public function getAiProjects($domain = null)
{
$key = 'ai_projects_list';
$data = Cache::get($key);
if (!$data) {
$api_url = 'https://demosite5.globalso.com/api/domain';
try {
$data = HttpUtils::get($api_url, []);
if ($data) {
$data = Arr::s2a($data);
Cache::put($key, $data, 4 * 3600);
}
} catch (\Exception | GuzzleException $e) {
errorLog('AI站点项目获取失败', [], $e);
return false;
}
}
$file_path = public_path('ai_domains.txt');
$data = file_get_contents($file_path);
$data = json_decode($data, true);
if ($domain !== null) {
$domain = parse_url($domain);
$data = collect($data['data'])->where('bind_domain', $domain['host'] ?? $domain['path'])->first();
$data = collect($data)->where('bind_domain', $domain['host'] ?? $domain['path'])->first();
return $data ?: [];
}
return $data;
... ...
... ... @@ -188,6 +188,7 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
$info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
$info['is_inquiry_country'] = $project['is_inquiry_country'];
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
... ... @@ -293,6 +294,7 @@ class UserLoginLogic
$info['is_visualization'] = json_decode($project['is_visualization']);
}
$info['is_visualization_authority'] = $project['deploy_build']['is_visualization_authority'];
$info['is_inquiry_country'] = $project['is_inquiry_country'];
//是否开通AMP
$is_amp = 0;
if(!empty($project['deploy_optimize']['domain'])){
... ...
<?php
/**
* @remark :
* @name :ProjectComConfig.php
* @author :lyh
* @method :post
* @time :2024/8/1 11:50
*/
namespace App\Models\IsCom;
use App\Models\Base;
use App\Models\Project\Project;
use App\Models\Template\BTemplate;
use App\Models\Template\Template;
/**
* @remark :是否为独立头部+底部
* @name :ProjectComConfig
* @author :lyh
* @method :post
* @time :2024/8/1 11:51
*/
class ProjectComConfig extends Base
{
protected $table = 'gl_project_com_config';
//连接数据库
protected $connection = 'custom_mysql';
/**
* @name :(包含详情页+列表页)
* @var array
*/
public $initParam = [
'产品'=>BTemplate::SOURCE_PRODUCT,
'博客'=>BTemplate::SOURCE_BLOG,
'新闻'=>BTemplate::SOURCE_NEWS,
];
/**
* @name : 单一界面
* @var array
*/
public $initPageParam = [
'首页'=>BTemplate::SOURCE_HOME,
'单页面'=>BTemplate::SOURCE_PAGE,
];
}
... ...
... ... @@ -23,6 +23,8 @@ class BTemplate extends Base
const SOURCE_NEWS = 4;//新闻详情页
const SOURCE_KEYWORD = 5;//聚合页
const SOURCE_PAGE = 9;//单页面
const SOURCE_CUSTOM = 7;//自定义模块
/**
... ... @@ -34,8 +36,8 @@ class BTemplate extends Base
* 公共头部底部连接部分
*/
const COMMON_HEAD = 1;//公共头部
const COMMON_FOOTER = 2;//公共头部
const COMMON_OTHER = 3;//公共头部
const COMMON_FOOTER = 2;//公共底部
const COMMON_OTHER = 3;//公共other
/**
* 独立头部类型
*/
... ...
<?php
/**
* @remark :
* @name :LanguageTxtController.php
* @author :lyh
* @method :post
* @time :2024/8/5 17:36
*/
namespace App\Models\WebSetting;
use App\Models\Base;
class LanguageTxt extends Base
{
protected $table = 'gl_language_txt';
//连接数据库
protected $connection = 'custom_mysql';
}
... ...
此 diff 太大无法显示。
... ... @@ -44,7 +44,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\User\UserController::class, 'info'])->name('user_info');
Route::any('/role_list', [\App\Http\Controllers\Bside\User\UserController::class, 'role_list'])->name('user_role_list');
Route::any('/del', [\App\Http\Controllers\Bside\User\UserController::class, 'del'])->name('user_del');
Route::any('/getUserLists', [\App\Http\Controllers\Bside\User\UserController::class, 'getUserLists'])->name('user_getUserLists');
});
//项目独立头部和底部设置
Route::prefix('pageSetting')->group(function () {
... ... @@ -256,6 +256,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\Product\ProductController::class, 'batchSetCategory'])->name('product_batchSetCategory');
Route::any('/sendAiProduct', [\App\Http\Controllers\Bside\Product\ProductController::class, 'sendAiProduct'])->name('product_sendAiProduct');
Route::any('/getSearchCategoryList', [\App\Http\Controllers\Bside\Product\ProductController::class, 'getSearchCategoryList'])->name('product_getSearchCategoryList');
Route::any('/delProductKeyword', [\App\Http\Controllers\Bside\Product\ProductController::class, 'delProductKeyword'])->name('product_delProductKeyword');
//产品分类
Route::get('category', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'index'])->name('product_category');
Route::get('category/info', [\App\Http\Controllers\Bside\Product\CategoryController::class, 'info'])->name('product_category_info');
... ... @@ -356,6 +357,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('template')->group(function () {
//获取所有公共主题模版
Route::any('/publicTemplateLists', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'publicTemplateLists'])->name('template_publicTemplateLists');
Route::any('/publicInfo', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'publicInfo'])->name('template_publicInfo');
//获取选中的主题模版
Route::any('/getPublicTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getPublicTemplate'])->name('template_getPublicTemplate');
Route::any('/getTemplate', [\App\Http\Controllers\Bside\Template\BTemplateController::class, 'getTemplate'])->name('template_getTemplate');
... ... @@ -553,6 +555,17 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/save', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'save'])->name('template_label_save');
Route::any('/del', [\App\Http\Controllers\Bside\Template\BTemplateLabelController::class, 'del'])->name('template_label_del');
});
//设置公共头部+底部配置
Route::prefix('com_config')->group(function () {
Route::any('/getIsComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'getIsComConfig'])->name('com_config_getIsComConfig');
Route::any('/saveComConfig', [\App\Http\Controllers\Bside\Template\BProjectComConfigController::class, 'saveComConfig'])->name('com_config_getIsComConfig');
});
//自定义小语种文本信息
Route::prefix('language_txt')->group(function () {
Route::any('/getLanguageTxt', [\App\Http\Controllers\Bside\Setting\LanguageTxtController::class, 'getLanguageTxt'])->name('language_txt_getLanguageTxt');
Route::any('/saveLanguageTxt', [\App\Http\Controllers\Bside\Setting\LanguageTxtController::class, 'saveLanguageTxt'])->name('language_txt_saveLanguageTxt');
Route::any('/delLanguageTxt', [\App\Http\Controllers\Bside\Setting\LanguageTxtController::class, 'delLanguageTxt'])->name('language_txt_delLanguageTxt');
});
});
//无需登录验证的路由组
Route::group([], function () {
... ...