summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorctrlaltca <>2013-01-16 09:03:27 +0000
committerctrlaltca <>2013-01-16 09:03:27 +0000
commit4566740b98ebcc58d36ca095ee20ebacf5567a4e (patch)
tree0341ce9d126ab1052cd40cc929dcf0b353a1c61b
parenta8bb9a32eebc3a62686dd9bf559bf47a8b1c915b (diff)
backported r3253 to trunk/
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/THttpRequest.php2
-rw-r--r--framework/Web/TUrlManager.php30
3 files changed, 28 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index fbebf314..1df4df43 100644
--- a/HISTORY
+++ b/HISTORY
@@ -25,6 +25,7 @@ BUG: Issue #431 - TReCaptcha does not work well with active controls (Gabor)
BUG: Issue #432 - Double slash with URL Tags in www root (ctrlaltca)
EHN: Permit to change the default cipher in TSecurityManager::setEncryption(); changed the default cipher from 3DES to AES256 (ctrlaltca)
+EHN: Added a new UrlFormat for TUrlManager: HiddenPath; works like the 'Path' format, but hides the entryscript.php name (ctrlaltca)
EHN: Use php's hash_hmac() when available in TSecurityManager, and permit the use of all algorithms supported by php (ctrlaltca)
EHN: Use mbstring when available in TSecurityManager to better handle multibyte text (ctrlaltca)
EHN: Updated TinyMCE to 3.5.6 (ctrlaltca)
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index 737bd4fa..133d0f2f 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -1320,6 +1320,7 @@ class TUri extends TComponent
* The following enumerable values are defined:
* - Get: the URL format is like /path/to/index.php?name1=value1&name2=value2...
* - Path: the URL format is like /path/to/index.php/name1,value1/name2,value2...
+ * - HiddenPath: the URL format is like /path/to/name1,value1/name2,value2...
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
@@ -1330,5 +1331,6 @@ class THttpRequestUrlFormat extends TEnumerable
{
const Get='Get';
const Path='Path';
+ const HiddenPath='HiddenPath';
}
diff --git a/framework/Web/TUrlManager.php b/framework/Web/TUrlManager.php
index b5a0a5be..5d96c973 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);