diff options
author | xue <> | 2006-07-21 16:08:10 +0000 |
---|---|---|
committer | xue <> | 2006-07-21 16:08:10 +0000 |
commit | aff2407a4507713453deb274837ab2bbf39303b2 (patch) | |
tree | 4ea91137a434d7de3629d8c191660d1fb1f7278d /framework/Web/THttpRequest.php | |
parent | b0744e3ffc412d4f8f706f8e75242509798bf21d (diff) |
Better URL 'Path' format
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r-- | framework/Web/THttpRequest.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index dbe410f4..323a4b7c 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -448,6 +448,8 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar * If you do so, you may also need to override {@link parseUrl} so that the URL can be properly parsed.
* The URL is constructed as the following format:
* /entryscript.php?serviceID=serviceParameter&get1=value1&...
+ * If {@link setUrlFormat UrlFormat} is 'Path', the following format is used instead:
+ * /entryscript.php/serviceID/serviceParameter/get1,value1/get2,value2...
* @param string service ID
* @param string service parameter
* @param array GET parameters, null if not needed
@@ -458,7 +460,10 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */
public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false,$encodeGetItems=true)
{
- $url=$serviceID.'='.$serviceParam;
+ if($this->getUrlFormat()==='Path')
+ $url=$serviceID.'/'.$serviceParam;
+ else
+ $url=$serviceID.'='.$serviceParam;
$amp=$encodeAmpersand?'&':'&';
if(is_array($getItems) || $getItems instanceof Traversable)
{
@@ -507,7 +512,10 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar /**
* Parses the request URL and returns an array of input parameters (including GET variables).
+ * This method is invoked when the URL format is 'Path'.
+ * You may override this method to support customized URL format.
* @return array list of input parameters, indexed by parameter names
+ * @see constructUrl
*/
protected function parseUrl()
{
@@ -515,6 +523,8 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar {
$paths=explode('/',$this->_pathInfo);
$getVariables=$_GET;
+ $index=0;
+ $serviceID=null;
foreach($paths as $path)
{
if(($path=trim($path))!=='')
@@ -528,6 +538,13 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar else
$getVariables[$name]=$value;
}
+ else if($index===0)
+ {
+ $serviceID=$path;
+ $getVariables[$serviceID]='';
+ }
+ else if($index===1 && $serviceID!==null)
+ $getVariables[$serviceID]=$path;
else
$getVariables[$path]='';
}
|