mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
Support short URLs for module
This commit is contained in:
parent
f8a47bbabb
commit
4a433fa536
1 changed files with 25 additions and 13 deletions
|
|
@ -305,13 +305,22 @@ class Router
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove $mid and $act from arguments and work with the remainder.
|
// Remove $mid and $act from arguments and work with the remainder.
|
||||||
$args2 = $args; unset($args2['mid'], $args2['act']);
|
$args2 = $args; unset($args2['module'], $args2['mid'], $args2['act']);
|
||||||
|
|
||||||
// If $mid exists, try routes defined in the module.
|
// If $mid exists, try routes defined in the module.
|
||||||
if ($rewrite_level >= 2 && isset($args['mid']))
|
if ($rewrite_level >= 2 && (isset($args['mid']) || isset($args['module'])))
|
||||||
{
|
{
|
||||||
// Get module action info.
|
// Get module action info.
|
||||||
$action_info = self::_getActionInfoByPrefix($args['mid'], $module_name = '');
|
if (isset($args['mid']))
|
||||||
|
{
|
||||||
|
$action_info = self::_getActionInfoByPrefix($args['mid']);
|
||||||
|
$prefix_type = 'mid';
|
||||||
|
}
|
||||||
|
elseif (isset($args['module']))
|
||||||
|
{
|
||||||
|
$action_info = self::_getActionInfoByModule($args['module']);
|
||||||
|
$prefix_type = 'module';
|
||||||
|
}
|
||||||
|
|
||||||
// If there is no $act, use the default action.
|
// If there is no $act, use the default action.
|
||||||
$act = isset($args['act']) ? $args['act'] : $action_info->default_index_act;
|
$act = isset($args['act']) ? $args['act'] : $action_info->default_index_act;
|
||||||
|
|
@ -323,26 +332,29 @@ class Router
|
||||||
$result = self::_getBestMatchingRoute($action->route, $args2);
|
$result = self::_getBestMatchingRoute($action->route, $args2);
|
||||||
if ($result !== false)
|
if ($result !== false)
|
||||||
{
|
{
|
||||||
self::$_route_cache[$keys_string] = '$mid/' . $result . '$act:delete';
|
self::$_route_cache[$keys_string] = '$' . $prefix_type . '/' . $result . '$act:delete';
|
||||||
return $args['mid'] . '/' . self::_insertRouteVars($result, $args2);
|
return $args[$prefix_type] . '/' . self::_insertRouteVars($result, $args2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check other modules for $act.
|
// Check other modules for $act.
|
||||||
$forwarded_routes = self::_getForwardedRoutes('internal');
|
if ($prefix_type === 'mid')
|
||||||
if (isset($forwarded_routes['reverse'][$act]))
|
|
||||||
{
|
{
|
||||||
$result = self::_getBestMatchingRoute($forwarded_routes['reverse'][$act], $args2);
|
$forwarded_routes = self::_getForwardedRoutes('internal');
|
||||||
if ($result !== false)
|
if (isset($forwarded_routes['reverse'][$act]))
|
||||||
{
|
{
|
||||||
self::$_route_cache[$keys_string] = '$mid/' . $result . '$act:delete';
|
$result = self::_getBestMatchingRoute($forwarded_routes['reverse'][$act], $args2);
|
||||||
return $args['mid'] . '/' . self::_insertRouteVars($result, $args2);
|
if ($result !== false)
|
||||||
|
{
|
||||||
|
self::$_route_cache[$keys_string] = '$' . $prefix_type . '/' . $result . '$act:delete';
|
||||||
|
return $args[$prefix_type] . '/' . self::_insertRouteVars($result, $args2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try the generic mid/act pattern.
|
// Try the generic mid/act pattern.
|
||||||
self::$_route_cache[$keys_string] = '$mid/$act';
|
self::$_route_cache[$keys_string] = '$' . $prefix_type . '/$act';
|
||||||
return $args['mid'] . '/' . $args['act'] . (count($args2) ? ('?' . http_build_query($args2)) : '');
|
return $args[$prefix_type] . '/' . $args['act'] . (count($args2) ? ('?' . http_build_query($args2)) : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try registered global routes.
|
// Try registered global routes.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue