summaryrefslogtreecommitdiff
path: root/framework/Web/TUrlManager.php
diff options
context:
space:
mode:
authorctrlaltca <>2013-01-16 08:57:12 +0000
committerctrlaltca <>2013-01-16 08:57:12 +0000
commit97395e66b2d930a21ea18498889ddd72e6d77ef2 (patch)
treeb1032feaa7b2901db8742fd641bc349e2979fdf0 /framework/Web/TUrlManager.php
parent33c1798a05c95d98d36842ab0a26b32f642788f5 (diff)
Added a new UrlFormat for TUrlManager: HiddenPath; works like the 'Path' format, but hides the entryscript.php name
Diffstat (limited to 'framework/Web/TUrlManager.php')
-rw-r--r--framework/Web/TUrlManager.php30
1 files changed, 25 insertions, 5 deletions
diff --git a/framework/Web/TUrlManager.php b/framework/Web/TUrlManager.php
index 0e6c78e3..75abdcf1 100644
--- a/framework/Web/TUrlManager.php
+++ b/framework/Web/TUrlManager.php
@@ -44,6 +44,18 @@ class TUrlManager extends TModule
* If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'Path',
* the following format is used instead:
* /entryscript.php/serviceID/serviceParameter/get1,value1/get2,value2...
+ * If {@link THttpRequest::setUrlFormat THttpRequest.UrlFormat} is 'HiddenPath',
+ * then entryscript.php will be hidden and the following format is used instead:
+ * /serviceID/serviceParameter/get1,value1/get2,value2...
+ * In order to use the 'HiddenPath' format you need proper url rewrite configuration;
+ * here's an example for Apache's .htaccess:
+ * <cdde>
+ * Options +FollowSymLinks
+ * RewriteEngine On
+ * RewriteCond %{REQUEST_FILENAME} !-d
+ * RewriteCond %{REQUEST_FILENAME} !-f
+ * RewriteRule ^(.*)$ index.php/$1 [L]
+ * </code>
* @param string service ID
* @param string service parameter
* @param array GET parameters, null if not provided
@@ -87,10 +99,16 @@ class TUrlManager extends TModule
}
}
}
- if($request->getUrlFormat()===THttpRequestUrlFormat::Path)
- return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator()));
- else
- return $request->getApplicationUrl().'?'.$url;
+
+ switch($request->getUrlFormat())
+ {
+ case THttpRequestUrlFormat::Path:
+ return $request->getApplicationUrl().'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator()));
+ case THttpRequestUrlFormat::HiddenPath:
+ return rtrim(dirname($request->getApplicationUrl()), '/').'/'.strtr($url,array($amp=>'/','?'=>'/','='=>$request->getUrlParamSeparator()));
+ default:
+ return $request->getApplicationUrl().'?'.$url;
+ }
}
/**
@@ -110,7 +128,9 @@ class TUrlManager extends TModule
{
$request=$this->getRequest();
$pathInfo=trim($request->getPathInfo(),'/');
- if($request->getUrlFormat()===THttpRequestUrlFormat::Path && $pathInfo!=='')
+ if(($request->getUrlFormat()===THttpRequestUrlFormat::Path ||
+ $request->getUrlFormat()===THttpRequestUrlFormat::HiddenPath) &&
+ $pathInfo!=='')
{
$separator=$request->getUrlParamSeparator();
$paths=explode('/',$pathInfo);