diff options
Diffstat (limited to 'framework/Web/THttpRequest.php')
-rw-r--r-- | framework/Web/THttpRequest.php | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index b908db53..6cd11113 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -181,7 +181,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar $getVariables[$path]='';
}
}
- $this->_items=array_merge($getVariables,array_merge($_GET,$_POST));
+ $this->_items=array_merge($this->parseUrl(),$_POST);
}
else
$this->_items=array_merge($_GET,$_POST);
@@ -293,7 +293,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar {
return ($this->getIsSecureConnection() ? "https://" : "http://") . $_SERVER ['HTTP_HOST'];
}
-
+
/**
* @return string entry script URL (w/o host part)
*/
@@ -309,7 +309,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar {
return $this->getBaseUrl() . $this->getApplicationUrl();
}
-
+
/**
* @return string application entry script file path (processed w/ realpath())
*/
@@ -465,6 +465,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar /**
* Constructs a URL that is recognizable by Prado.
* You may override this method to provide your own way of URL formatting.
+ * 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&...
* @param string service ID
@@ -473,6 +474,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar * @param boolean whether to encode the ampersand in URL, defaults to false.
* @param boolean whether to encode the GET parameters (their names and values), defaults to true.
* @return string URL
+ * @see parseUrl
*/
public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false,$encodeGetItems=true)
{
@@ -524,6 +526,39 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar }
/**
+ * Parses the request URL and returns an array of input parameters (including GET variables).
+ * @return array list of input parameters, indexed by parameter names
+ */
+ protected function parseUrl()
+ {
+ if($this->_pathInfo!=='')
+ {
+ $paths=explode('/',$this->_pathInfo);
+ $getVariables=$_GET;
+ foreach($paths as $path)
+ {
+ if(($path=trim($path))!=='')
+ {
+ if(($pos=strpos($path,','))!==false)
+ {
+ $name=substr($path,0,$pos);
+ $value=substr($path,$pos+1);
+ if(($pos=strpos($name,'[]'))!==false)
+ $getVariables[substr($name,0,$pos)][]=$value;
+ else
+ $getVariables[$name]=$value;
+ }
+ else
+ $getVariables[$path]='';
+ }
+ }
+ return $getVariables;
+ }
+ else
+ return $_GET;
+ }
+
+ /**
* Resolves the requested servie.
* This method implements a URL-based service resolution.
* A URL in the format of /index.php?sp=serviceID.serviceParameter
|