use anonymous function
This commit is contained in:
parent
870bcb024b
commit
a374e6d918
24
_public.php
24
_public.php
@ -14,32 +14,23 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->url->register('alias', '', '^(.*)$', ['urlAlias','alias']);
|
dcCore::app()->url->register('alias', '', '^(.*)$', function ($args) {
|
||||||
|
|
||||||
class urlAlias extends dcUrlHandlers
|
|
||||||
{
|
|
||||||
public static function alias($args)
|
|
||||||
{
|
|
||||||
$o = new dcAliases();
|
$o = new dcAliases();
|
||||||
$aliases = $o->getAliases();
|
$aliases = $o->getAliases();
|
||||||
|
$part = $args;
|
||||||
|
|
||||||
foreach ($aliases as $v) {
|
foreach ($aliases as $v) {
|
||||||
if (@preg_match('#^/.*/$#', $v['alias_url']) && @preg_match($v['alias_url'], $args)) {
|
if (@preg_match('#^/.*/$#', $v['alias_url']) && @preg_match($v['alias_url'], $args)) {
|
||||||
self::callAliasHandler(preg_replace($v['alias_url'], $v['alias_destination'], $args));
|
$part = preg_replace($v['alias_url'], $v['alias_destination'], $args);
|
||||||
|
|
||||||
return;
|
break;
|
||||||
} elseif ($v['alias_url'] == $args) {
|
} elseif ($v['alias_url'] == $args) {
|
||||||
self::callAliasHandler($v['alias_destination']);
|
$part = $v['alias_destination'];
|
||||||
|
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self::callAliasHandler($args);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function callAliasHandler($part)
|
|
||||||
{
|
|
||||||
dcCore::app()->url->unregister('alias');
|
dcCore::app()->url->unregister('alias');
|
||||||
dcCore::app()->url->getArgs($part, $type, $args);
|
dcCore::app()->url->getArgs($part, $type, $args);
|
||||||
|
|
||||||
@ -48,5 +39,4 @@ class urlAlias extends dcUrlHandlers
|
|||||||
} else {
|
} else {
|
||||||
dcCore::app()->url->callHandler($type, $args);
|
dcCore::app()->url->callHandler($type, $args);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user