From 3f803219e784b53f363b5ef25b3be00fd310fb1c Mon Sep 17 00:00:00 2001
From: xue <>
Date: Tue, 24 Jan 2006 23:21:08 +0000
Subject: Modified THttpRequest and THttpSession so that they can be used like
 an array. Items properties are removed as a result.

---
 framework/Web/THttpRequest.php | 66 +++++++++++++++++++++++++++---------------
 1 file changed, 43 insertions(+), 23 deletions(-)

(limited to 'framework/Web/THttpRequest.php')

diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php
index d397cc56..2a3a35aa 100644
--- a/framework/Web/THttpRequest.php
+++ b/framework/Web/THttpRequest.php
@@ -16,7 +16,27 @@
  * THttpRequest provides storage and access scheme for user request sent via HTTP.
  * It also encapsulates a uniform way to parse and construct URLs.
  *
- * To retrieve user POST and GET variables, use {@link getItems()} method.
+ * User post data can be retrieved from THttpRequest by using it like an associative array.
+ * For example, to test if a user supplies a variable named 'param1', you can use,
+ * <code>
+ *   if(isset($request['param1'])) ...
+ *   // equivalent to:
+ *   // if($request->contains('param1')) ...
+ * </code>
+ * To get the value of 'param1', use,
+ * <code>
+ *   $value=$request['param1'];
+ *   // equivalent to:
+ *   //   $value=$request->itemAt('param1');
+ * </code>
+ * To traverse the user post data, use
+ * <code>
+ *   foreach($request as $name=>$value) ...
+ * </code>
+ * Note, POST and GET variables are merged together in THttpRequest.
+ * If a variable name appears in both POST and GET data, then POST data
+ * takes precedence.
+ *
  * To construct a URL that can be recognized by Prado, use {@link constructUrl()}.
  * THttpRequest also provides the cookies sent by the user, user information such
  * as his browser capabilities, accepted languages, etc.
@@ -29,7 +49,7 @@
  * @package System.Web
  * @since 3.0
  */
-class THttpRequest extends TModule
+class THttpRequest extends TMap implements IModule
 {
 	/**
 	 * GET variable name to store service information
@@ -59,13 +79,29 @@ class THttpRequest extends TModule
 	 * @var string path info of URL
 	 */
 	private $_pathInfo;
-	/**
-	 * @var TMap list of input variables (including GET and POST)
-	 */
-	private $_items;
 
 	private $_services;
 	private $_requestResolved=false;
+	/**
+	 * @var string module id
+	 */
+	private $_id;
+
+	/**
+	 * @return string id of this module
+	 */
+	public function getID()
+	{
+		return $this->_id;
+	}
+
+	/**
+	 * @param string id of this module
+	 */
+	public function setID($value)
+	{
+		$this->_id=$value;
+	}
 
 	/**
 	 * Initializes the module.
@@ -104,7 +140,7 @@ class THttpRequest extends TModule
 				$_COOKIE=$this->stripSlashes($_COOKIE);
 		}
 
-		$this->_items=new TMap(array_merge($_POST,$_GET));
+		$this->copyfrom(array_merge($_GET,$_POST));
 
 		$this->_initialized=true;
 		$this->getApplication()->setRequest($this);
@@ -279,22 +315,6 @@ class THttpRequest extends TModule
 		return Prado::getUserLanguages();
 	}
 
-	/**
-	 * @return TMap list of input variables, include GET, POST
-	 */
-	public function getItems()
-	{
-		return $this->_items;
-	}
-
-	/**
-	 * @return TMap list of input variables, include GET, POST
-	 */	
-	public function getParameters()
-	{
-		return $this->_items;
-	}
-
 	/**
 	 * @return THttpCookieCollection list of cookies to be sent
 	 */
-- 
cgit v1.2.3