From b706f2f6ab1c249e21b4f1bdab42592f3085d51c Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sat, 13 Jun 2020 00:27:23 +0900 Subject: [PATCH] Add support for the generic mid/act URL pattern --- common/framework/router.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/framework/router.php b/common/framework/router.php index 7d931b0cb..f0bfe6e31 100644 --- a/common/framework/router.php +++ b/common/framework/router.php @@ -82,11 +82,14 @@ class Router $prefix = $matches[1]; $internal_url = $matches[2] ?? ''; - // Get the list of routes defined by the module. + // Find the module associated with this prefix. $module_info = \ModuleModel::getModuleInfoByMid($prefix); if ($module_info && $module_info->module) { + // Get module actions. $action_info = \ModuleModel::getModuleActionXml($module_info->module); + + // Try the list of routes defined by the module. foreach ($action_info->route->{$method} as $regexp => $action) { if (preg_match($regexp, $internal_url, $matches)) @@ -96,6 +99,13 @@ class Router return $allargs; } } + + // Try the generic mid/act pattern. + if (preg_match('#^[a-zA-Z0-9_]+$#', $internal_url) && isset($action_info->action->{$internal_url}) && !$action_info->action->{$internal_url}->route) + { + $allargs = array_merge(['mid' => $prefix, 'act' => $internal_url], $args); + return $allargs; + } } }