From c843c768a6b48da104e242e86f23b621c8fff005 Mon Sep 17 00:00:00 2001 From: pzinovkin Date: Wed, 17 Dec 2008 09:04:40 +0000 Subject: [PATCH] rewrite base processing & storing route name after dispatching git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@28 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/Router.class.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/classes/Router.class.php b/classes/Router.class.php index 5ad0638..9aba3b6 100644 --- a/classes/Router.class.php +++ b/classes/Router.class.php @@ -18,6 +18,7 @@ final class Router static protected $rewrite_base = ''; static protected $decorator = DEFAULT_DECORATOR; + static protected $route_name = ''; /** @@ -55,18 +56,17 @@ final class Router */ function proccess($path) { - if ($trim = self::getRewriteBase()) { - if (substr($path, 0 , strlen($trim)) == $trim) { - $path = substr($path, strlen($trim)); - } + if(self::getRewriteBase()){ + $path = trim(ltrim($path, self::getRewriteBase()), '/'); } - + $path = explode('/', $path); foreach($this->routes as $name => $route) { if ($route->match($path)) { $route->action .= ACTION_POSTFIX; Env::setParams($route->params); + self::$route_name = $name; return $route; } } @@ -87,6 +87,11 @@ final class Router { self::$decorator = $decorator.DECORATOR_POSTFIX; } + + static public function getRouteName() + { + return self::$route_name; + } } /**