summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY1
-rw-r--r--framework/Web/THttpRequest.php19
2 files changed, 19 insertions, 1 deletions
diff --git a/HISTORY b/HISTORY
index dbfd8106..638bd9d8 100644
--- a/HISTORY
+++ b/HISTORY
@@ -11,6 +11,7 @@ ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName p
ENH: Ticket#277 - Added TControl.CustomData property (Qiang)
ENH: Ticket#287 - TControl::broadcastEvent() may raise events now (Qiang)
ENH: Ticket#292 - Added THttpRequest::parseUrl() so that it is easier to be extended (Qiang)
+ENH: Better URL 'Path' format (Qiang)
NEW: Added TStyleSheet (Wei)
Version 3.0.2 July 2, 2006
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]='';
}