mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-12 05:22:35 +09:00
Adjust argument priority
This commit is contained in:
parent
358832922e
commit
a6318436c2
2 changed files with 19 additions and 21 deletions
|
|
@ -1201,7 +1201,16 @@ class Context
|
||||||
*/
|
*/
|
||||||
public static function setRequestArguments(array $router_args = [])
|
public static function setRequestArguments(array $router_args = [])
|
||||||
{
|
{
|
||||||
foreach($router_args ?: $_REQUEST as $key => $val)
|
$request_args = $_SERVER['REQUEST_METHOD'] === 'GET' ? $_GET : $_POST;
|
||||||
|
if (count($router_args))
|
||||||
|
{
|
||||||
|
foreach ($router_args as $key => $val)
|
||||||
|
{
|
||||||
|
$request_args[$key] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($request_args as $key => $val)
|
||||||
{
|
{
|
||||||
if($val === '' || isset(self::$_reserved_keys[$key]) || self::get($key))
|
if($val === '' || isset(self::$_reserved_keys[$key]) || self::get($key))
|
||||||
{
|
{
|
||||||
|
|
@ -1210,18 +1219,7 @@ class Context
|
||||||
|
|
||||||
$key = escape($key);
|
$key = escape($key);
|
||||||
$val = self::_filterRequestVar($key, $val);
|
$val = self::_filterRequestVar($key, $val);
|
||||||
$set_to_vars = $router_args ? true : false;
|
self::set($key, $val, true);
|
||||||
|
|
||||||
if($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET[$key]))
|
|
||||||
{
|
|
||||||
$set_to_vars = true;
|
|
||||||
}
|
|
||||||
elseif($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST[$key]))
|
|
||||||
{
|
|
||||||
$set_to_vars = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
self::set($key, $val, $set_to_vars);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set deprecated request parameters.
|
// Set deprecated request parameters.
|
||||||
|
|
@ -1245,7 +1243,7 @@ class Context
|
||||||
|
|
||||||
foreach((array)$params as $key => $val)
|
foreach((array)$params as $key => $val)
|
||||||
{
|
{
|
||||||
if (isset($router_args[$key]))
|
if (isset($request_args[$key]))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1260,7 +1258,7 @@ class Context
|
||||||
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
|
parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
|
||||||
foreach($params as $key => $val)
|
foreach($params as $key => $val)
|
||||||
{
|
{
|
||||||
if (isset($router_args[$key]))
|
if (isset($request_args[$key]))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ class Router
|
||||||
if (preg_match($regexp, $internal_url, $matches))
|
if (preg_match($regexp, $internal_url, $matches))
|
||||||
{
|
{
|
||||||
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
||||||
$allargs = array_merge(['mid' => $prefix, 'act' => $action], $matches, $args);
|
$allargs = array_merge($args, $matches, ['mid' => $prefix, 'act' => $action]);
|
||||||
$result->module = $module_name;
|
$result->module = $module_name;
|
||||||
$result->mid = $prefix;
|
$result->mid = $prefix;
|
||||||
$result->act = $action;
|
$result->act = $action;
|
||||||
|
|
@ -161,7 +161,7 @@ class Router
|
||||||
if (preg_match($regexp, $internal_url, $matches))
|
if (preg_match($regexp, $internal_url, $matches))
|
||||||
{
|
{
|
||||||
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
||||||
$allargs = array_merge(['mid' => $prefix, 'act' => $action[1]], $matches, $args);
|
$allargs = array_merge($args, $matches, ['mid' => $prefix, 'act' => $action[1]]);
|
||||||
$result->module = $action[0];
|
$result->module = $action[0];
|
||||||
$result->mid = $prefix;
|
$result->mid = $prefix;
|
||||||
$result->act = $action[1];
|
$result->act = $action[1];
|
||||||
|
|
@ -174,7 +174,7 @@ class Router
|
||||||
// Try the generic mid/act pattern.
|
// Try the generic mid/act pattern.
|
||||||
if (preg_match('#^[a-zA-Z0-9_]+$#', $internal_url))
|
if (preg_match('#^[a-zA-Z0-9_]+$#', $internal_url))
|
||||||
{
|
{
|
||||||
$allargs = array_merge(['mid' => $prefix, 'act' => $internal_url], $args);
|
$allargs = array_merge($args, ['mid' => $prefix, 'act' => $internal_url]);
|
||||||
$result->mid = $prefix;
|
$result->mid = $prefix;
|
||||||
$result->act = $internal_url;
|
$result->act = $internal_url;
|
||||||
$result->forwarded = true;
|
$result->forwarded = true;
|
||||||
|
|
@ -185,7 +185,7 @@ class Router
|
||||||
// If the module defines a 404 error handler, call it.
|
// If the module defines a 404 error handler, call it.
|
||||||
if ($internal_url && isset($action_info->error_handlers[404]))
|
if ($internal_url && isset($action_info->error_handlers[404]))
|
||||||
{
|
{
|
||||||
$allargs = array_merge(['mid' => $prefix, 'act' => $action_info->error_handlers[404]], $args);
|
$allargs = array_merge($args, ['mid' => $prefix, 'act' => $action_info->error_handlers[404]]);
|
||||||
$result->module = $module_name;
|
$result->module = $module_name;
|
||||||
$result->mid = $prefix;
|
$result->mid = $prefix;
|
||||||
$result->act = $action_info->error_handlers[404];
|
$result->act = $action_info->error_handlers[404];
|
||||||
|
|
@ -205,7 +205,7 @@ class Router
|
||||||
if (preg_match($regexp, $url, $matches))
|
if (preg_match($regexp, $url, $matches))
|
||||||
{
|
{
|
||||||
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
||||||
$allargs = array_merge(['act' => $action[1]], $matches, $args);
|
$allargs = array_merge($args, $matches, ['act' => $action[1]]);
|
||||||
$result->module = $action[0];
|
$result->module = $action[0];
|
||||||
$result->act = $action[1];
|
$result->act = $action[1];
|
||||||
$result->forwarded = true;
|
$result->forwarded = true;
|
||||||
|
|
@ -221,7 +221,7 @@ class Router
|
||||||
if (preg_match($route_info['regexp'], $url, $matches))
|
if (preg_match($route_info['regexp'], $url, $matches))
|
||||||
{
|
{
|
||||||
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
$matches = array_filter($matches, 'is_string', \ARRAY_FILTER_USE_KEY);
|
||||||
$allargs = array_merge($route_info['extra_vars'] ?? [], $matches, $args);
|
$allargs = array_merge($args, $matches, $route_info['extra_vars'] ?? []);
|
||||||
$result->module = $allargs['module'] ?? '';
|
$result->module = $allargs['module'] ?? '';
|
||||||
$result->mid = $allargs['mid'] ?: '';
|
$result->mid = $allargs['mid'] ?: '';
|
||||||
$result->act = $allargs['act'] ?: '';
|
$result->act = $allargs['act'] ?: '';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue