mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Improve parsing of route definitions and deleted vars
This commit is contained in:
parent
bb3d1f08a1
commit
a814b4e334
3 changed files with 28 additions and 16 deletions
|
|
@ -18,6 +18,7 @@ class ModuleActionParser
|
|||
'hex' => '[0-9a-f]+',
|
||||
'word' => '[a-zA-Z0-9_]+',
|
||||
'any' => '[^/]+',
|
||||
'delete' => '[^/]+',
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -194,7 +195,7 @@ class ModuleActionParser
|
|||
}
|
||||
else
|
||||
{
|
||||
$var_type = ends_with('_srl', $match[1]) ? 'number' : 'any';
|
||||
$var_type = ends_with('_srl', $match[1]) ? 'int' : 'any';
|
||||
$var_pattern = self::$_shortcuts[$var_type];
|
||||
}
|
||||
$named_group = '(?P<' . $match[1] . '>' . $var_pattern . ')';
|
||||
|
|
@ -207,7 +208,9 @@ class ModuleActionParser
|
|||
|
||||
// Return the regexp and variable list.
|
||||
$result = new \stdClass;
|
||||
$result->route = preg_replace($var_regexp, '\\$$1', $route['route']);
|
||||
$result->route = preg_replace_callback($var_regexp, function($match) {
|
||||
return '$' . ((isset($match[2]) && $match[2] === 'delete') ? ($match[1] . ':' . $match[2]) : $match[1]);
|
||||
}, $route['route']);
|
||||
$result->priority = $route['priority'] ?: 0;
|
||||
$result->regexp = $regexp;
|
||||
$result->vars = $vars;
|
||||
|
|
|
|||
|
|
@ -120,7 +120,6 @@ class Router
|
|||
// Separate the prefix and the internal part of the URL.
|
||||
$prefix = $matches[1];
|
||||
$internal_url = $matches[2] ?? '';
|
||||
|
||||
// Find the module associated with this prefix.
|
||||
$action_info = self::_getActionInfoByPrefix($prefix);
|
||||
if ($action_info)
|
||||
|
|
@ -372,7 +371,7 @@ class Router
|
|||
$matched_arguments = array_intersect_key($route_vars['vars'], $vars);
|
||||
if (count($matched_arguments) === count($route_vars['vars']))
|
||||
{
|
||||
$reordered_routes[$route] = $route_vars['priority'] ?: count($matched_arguments);
|
||||
$reordered_routes[$route] = ($route_vars['priority'] * 1000) + count($matched_arguments);
|
||||
}
|
||||
}
|
||||
if (!count($reordered_routes))
|
||||
|
|
|
|||
|
|
@ -57,25 +57,35 @@
|
|||
</grants>
|
||||
<actions>
|
||||
<action name="dispBoardContent" type="view" permission="list" standalone="false" index="true">
|
||||
<route route="$document_srl:int" priority="51" />
|
||||
<route route="$document_srl:int/page/$page:int" priority="52" />
|
||||
<route route="category/$category:int/search/$search_target:word/$search_keyword:any" priority="41" />
|
||||
<route route="category/$category:int/search/$search_target:word/$search_keyword:any/page/$page:int" priority="42" />
|
||||
<route route="search/$search_target:word/$search_keyword:any" priority="31" />
|
||||
<route route="search/$search_target:word/$search_keyword:any/page/$page:int" priority="32" />
|
||||
<route route="category/$category:int" priority="21" />
|
||||
<route route="category/$category:int/page/$page:int" priority="22" />
|
||||
<route route="$document_srl:int" priority="100" />
|
||||
<route route="$document_srl:int/comment/$comment_srl:int" priority="100" />
|
||||
<route route="$document_srl:int/page/$page:int" priority="100" />
|
||||
<route route="category/$category:int/search/$search_target:word/$search_keyword:any" priority="60" />
|
||||
<route route="category/$category:int/search/$search_target:word/$search_keyword:any/page/$page:int" priority="60" />
|
||||
<route route="search/$search_target:word/$search_keyword:any" priority="50" />
|
||||
<route route="search/$search_target:word/$search_keyword:any/page/$page:int" priority="50" />
|
||||
<route route="category/$category:int" priority="40" />
|
||||
<route route="category/$category:int/page/$page:int" priority="40" />
|
||||
<route route="page/$page:int" priority="10" />
|
||||
</action>
|
||||
<action name="dispBoardWrite" type="view" permission="write_document" standalone="false" meta-noindex="true">
|
||||
<route route="write" />
|
||||
<route route="$document_srl:int/edit" />
|
||||
<route route="$document_srl/edit" />
|
||||
</action>
|
||||
<action name="dispBoardDelete" type="view" permission="write_document" standalone="false" meta-noindex="true" route="$document_srl/delete" />
|
||||
<action name="dispBoardWriteComment" type="view" permission="write_comment" standalone="false" meta-noindex="true" route="$document_srl/comment" />
|
||||
<action name="dispBoardReplyComment" type="view" permission="write_comment" standalone="false" meta-noindex="true" route="comment/$comment_srl/reply"/>
|
||||
<action name="dispBoardModifyComment" type="view" permission="write_comment" standalone="false" meta-noindex="true" route="comment/$comment_srl/edit" />
|
||||
<action name="dispBoardDeleteComment" type="view" permission="write_comment" standalone="false" meta-noindex="true" route="comment/$comment_srl/delete" />
|
||||
<action name="dispBoardReplyComment" type="view" permission="write_comment" standalone="false" meta-noindex="true">
|
||||
<route route="comment/$comment_srl/reply" />
|
||||
<route route="comment/$comment_srl/reply$document_srl:delete" />
|
||||
</action>
|
||||
<action name="dispBoardModifyComment" type="view" permission="write_comment" standalone="false" meta-noindex="true">
|
||||
<route route="comment/$comment_srl/edit" />
|
||||
<route route="comment/$comment_srl/edit$document_srl:delete" />
|
||||
</action>
|
||||
<action name="dispBoardDeleteComment" type="view" permission="write_comment" standalone="false" meta-noindex="true">
|
||||
<route route="comment/$comment_srl/delete" />
|
||||
<route route="comment/$comment_srl/delete$document_srl:delete" />
|
||||
</action>
|
||||
<action name="dispBoardDeleteTrackback" type="view" permission="list,view" standalone="false" meta-noindex="true" />
|
||||
<action name="dispBoardContentList" type="view" permission="list" standalone="false" />
|
||||
<action name="dispBoardContentView" type="view" permission="view" standalone="false" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue