From c72a6d328f37bb6b5eaa5c7eeab6c06a1936255a Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 21 Jul 2006 15:05:29 +0000 Subject: Fixed #292. --- HISTORY | 1 + framework/Web/THttpRequest.php | 41 ++++++++++++++++++++++++++++++++--- framework/Web/UI/TTemplateControl.php | 1 - 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/HISTORY b/HISTORY index e32f7185..6c5f0f33 100644 --- a/HISTORY +++ b/HISTORY @@ -9,6 +9,7 @@ ENH: Ticket#225 - TRadioButton::getRadioButtonsInGroup() added (Wei) ENH: Ticket#223 - Use TRequiredFieldValidator for TRadioButtons with GroupName property (Wei) 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) NEW: Added TStyleSheet (Wei) Version 3.0.2 July 2, 2006 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) { @@ -523,6 +525,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. diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php index 0595a9e5..c7364d4b 100644 --- a/framework/Web/UI/TTemplateControl.php +++ b/framework/Web/UI/TTemplateControl.php @@ -119,7 +119,6 @@ class TTemplateControl extends TCompositeControl { Prado::trace("Loading template ".get_class($this),'System.Web.UI.TTemplateControl'); $template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this)); - self::$_template[get_class($this)]=$template; return $template; } -- cgit v1.2.3