summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-03-23 12:11:49 +0000
committerxue <>2006-03-23 12:11:49 +0000
commit502ef5c173b2ca1220725d9814022102ea5dd749 (patch)
tree490639c4d0e84b6142653c48911480a88f34fe05
parent4cb6d6bd3c22c18bdbe7dea29e0de9c77ebfe025 (diff)
Added a new parameter to constructUrl() for encoding GET parameters.
-rw-r--r--framework/Web/Services/TPageService.php5
-rw-r--r--framework/Web/THttpRequest.php15
2 files changed, 15 insertions, 5 deletions
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index 8d3ccca3..022c1286 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -452,11 +452,12 @@ class TPageService extends TService
* @param string page path
* @param array list of GET parameters, null if no GET parameters required
* @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 for the page and GET parameters
*/
- public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=false)
+ public function constructUrl($pagePath,$getParams=null,$encodeAmpersand=false,$encodeGetItems=true)
{
- return $this->getRequest()->constructUrl($this->_id,$pagePath,$getParams,$encodeAmpersand);
+ return $this->getRequest()->constructUrl($this->_id,$pagePath,$getParams,$encodeAmpersand,$encodeGetItems);
}
}
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index d3a8480a..2fd02d1d 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -436,16 +436,25 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar
* @param string service parameter
* @param array GET parameters, null if not needed
* @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
*/
- public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false)
+ public function constructUrl($serviceID,$serviceParam,$getItems=null,$encodeAmpersand=false,$encodeGetItems=true)
{
$url=$serviceID.'='.$serviceParam;
$amp=$encodeAmpersand?'&amp;':'&';
if(is_array($getItems) || $getItems instanceof Traversable)
{
- foreach($getItems as $name=>$value)
- $url.=$amp.urlencode($name).'='.urlencode($value);
+ if($encodeGetItems)
+ {
+ foreach($getItems as $name=>$value)
+ $url.=$amp.urlencode($name).'='.urlencode($value);
+ }
+ else
+ {
+ foreach($getItems as $name=>$value)
+ $url.=$amp.$name.'='.$value;
+ }
}
if($this->getUrlFormat()==='Path')
{