|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Models\File\Image;
|
|
|
|
use App\Models\File\File as FileModel;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
...
|
...
|
@@ -851,7 +852,7 @@ function getCustomRouteMap($module_route,$route = '') |
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/10 14:29
|
|
|
|
*/
|
|
|
|
function getRouteMap($source,$source_id,$is_upgrade = 0){
|
|
|
|
function getRouteMap($source,$source_id,$is_upgrade = 0, $returnModel = false){
|
|
|
|
$route = '';
|
|
|
|
$routeMapModel = new RouteMap();
|
|
|
|
$info = $routeMapModel->read(['source'=>$source,'source_id'=>$source_id]);
|
|
...
|
...
|
@@ -878,6 +879,9 @@ function getRouteMap($source,$source_id,$is_upgrade = 0){ |
|
|
|
$route = $info['route'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($returnModel){
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -1237,4 +1241,115 @@ function getDomain($url) { |
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 解析url的 route
|
|
|
|
* @param $pathInfo
|
|
|
|
* @return string
|
|
|
|
* @author zbj
|
|
|
|
* @date 2025/5/24
|
|
|
|
*/
|
|
|
|
function analysisRoute($pathInfo)
|
|
|
|
{
|
|
|
|
$language = '';
|
|
|
|
$router = "";
|
|
|
|
$page = null;
|
|
|
|
|
|
|
|
$pathArr = explode("/", $pathInfo);
|
|
|
|
$pathArr = array_filter($pathArr);
|
|
|
|
$first = array_shift($pathArr);
|
|
|
|
$last = array_pop($pathArr);
|
|
|
|
$other = implode("/", $pathArr);
|
|
|
|
|
|
|
|
$first = $first == "zh-ct" ? "zh-TW" : $first;
|
|
|
|
$tlsLang = array_keys(Translate::$tls_list);
|
|
|
|
if (in_array($first, $tlsLang)) {
|
|
|
|
$language = $first;
|
|
|
|
$first = '';
|
|
|
|
}
|
|
|
|
$lastIsRoute = RouteMap::select("id")->where("route", $last)->first();
|
|
|
|
if (is_numeric($last) && empty($lastIsRoute)) {
|
|
|
|
$page = $last;
|
|
|
|
$last = '';
|
|
|
|
}
|
|
|
|
$router_array = compact('first', 'other', 'last');
|
|
|
|
$router_array = array_filter($router_array);
|
|
|
|
|
|
|
|
//解析路由5.0 + 6.0
|
|
|
|
$keyword = new \App\Models\Product\Keyword();
|
|
|
|
$topSearchRoute = $keyword->product_keyword_route;
|
|
|
|
if (isset($router_array['first'])) {
|
|
|
|
if (isset($router_array['other'])) {
|
|
|
|
if ($router_array['other'] == "page") {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
} else {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) >= 1) {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isset($router_array['last'])) {
|
|
|
|
if (in_array($router_array['first'], $topSearchRoute)) {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
$page = (int)$router_array['last'];
|
|
|
|
} else {
|
|
|
|
$router = $router_array['last'];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$router = $router_array['first'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isset($router_array['last'])) {
|
|
|
|
if ($router_array['last'] != "page") {
|
|
|
|
if (isset($router_array['other']) && in_array($router_array['other'], $topSearchRoute)) {
|
|
|
|
$router = $router_array['other'];
|
|
|
|
$page = (int)$router_array['last'];
|
|
|
|
} else {
|
|
|
|
$router = $router_array['last'];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) == 1) {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
} else {
|
|
|
|
$router = $otherArr[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!empty($router_array)) {
|
|
|
|
$otherArr = explode("/", $router_array['other']);
|
|
|
|
$otherArr = array_filter($otherArr);
|
|
|
|
if (count($otherArr) == 3) {
|
|
|
|
$router = $otherArr[1];
|
|
|
|
} else {
|
|
|
|
$router = $otherArr[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//路由算法处理,路由只有一级,route_map表中route(规定),不考虑小语种
|
|
|
|
//新增考虑小语种,判断是否小语种访问,有页面不说,当nginx 404页面之后进程序,生成当前小语种页面
|
|
|
|
$lang = $language;
|
|
|
|
if ($page == null) {
|
|
|
|
if ($router != null) {
|
|
|
|
if ($lang != null) {
|
|
|
|
$tlsLang = array_keys(Translate::$tls_list);
|
|
|
|
$isLang = in_array($lang, $tlsLang);
|
|
|
|
if (!$isLang) {
|
|
|
|
$router = $lang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$tlsLang = array_keys(Translate::$tls_list);
|
|
|
|
$isLang = in_array($lang, $tlsLang);
|
|
|
|
if (!$isLang) {
|
|
|
|
$router = $lang;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $router;
|
|
|
|
} |
...
|
...
|
|