From cb1021da880b5200fdfe87e43d96a86de811e482 Mon Sep 17 00:00:00 2001
From: xue <>
Date: Mon, 19 Jun 2006 12:37:59 +0000
Subject: Fixed #244, #245.
---
HISTORY | 2 ++
.../protected/pages/Advanced/Collections.page | 12 ++++++------
framework/Web/THttpRequest.php | 18 +++++++++++++++++-
framework/Web/THttpResponse.php | 5 ++++-
4 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/HISTORY b/HISTORY
index 7e0ee535..784ce572 100644
--- a/HISTORY
+++ b/HISTORY
@@ -3,6 +3,8 @@ Version 3.0.2 July 2, 2006
BUG: Ticket#182 - List and validator controls cause problem in child classes (Qiang)
BUG: Ticket#191 - Duplicated postbacks occur when using TButton with validators (Qiang)
BUG: Ticket#213 - PRADO Requirements Checker charset error (Qiang)
+BUG: Ticket#244 - redirect() needs absolute URL (Qiang)
+BUG: Ticket#245 - getIsSecureConnection() is not working correctly (Qiang)
CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang)
CHG: Postback enabled control will always disable default client-side browser action. (Qiang)
CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang)
diff --git a/demos/quickstart/protected/pages/Advanced/Collections.page b/demos/quickstart/protected/pages/Advanced/Collections.page
index 181dc556..7fc3443d 100644
--- a/demos/quickstart/protected/pages/Advanced/Collections.page
+++ b/demos/quickstart/protected/pages/Advanced/Collections.page
@@ -1,6 +1,6 @@
Collection is a basic data structure in programming. In traditional PHP programming, array is used widely to represent collection data structure. A PHP array is a mix of cardinal-indxed array and hash table.
Collections
+Collections
A TList object represents a cardinal-indexed array, i.e., an array (object) with the index 0, 1, 2, ...
@@ -42,7 +42,7 @@ In addition, TList implements a few commonly used convenient methods foAs aforementioned, many PRADO component properties are based on TList or TList-derived collection classes. These properties all share the above usages.
@@ -62,7 +62,7 @@ foreach($control->Controls as $childControl) ... Another example is the Items property, available in list controls, TRepeater, TDataList and TDataGrid. In these controls, the ancestor class of Items is TList. -Often, we want to extend TList to perform additional operations for each addition or removal of an item. The only methods that the child class needs to override are insertAt() and removeAt(). For example, to ensure the list only contains items that are of TControl type, we can override insertAt() as follows,
@@ -77,7 +77,7 @@ public function insertAt($index,$item) -A TMap object represents a hash table (or we say string-indexed array).
@@ -107,7 +107,7 @@ The following methods are provided by TMap for convenience,TAttributeCollection is a special class extending from TMap. It is mainly used by the Attributes property of TControl.
diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index 4e04ecca..b908db53 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -259,7 +259,7 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar */ public function getIsSecureConnection() { - return !empty($_SERVER['HTTPS']); + return isset($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'],'off'); } /** @@ -286,6 +286,14 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar return $this->_requestUri; } + /** + * @return string schema and hostname of the requested URL + */ + public function getBaseUrl() + { + return ($this->getIsSecureConnection() ? "https://" : "http://") . $_SERVER ['HTTP_HOST']; + } + /** * @return string entry script URL (w/o host part) */ @@ -294,6 +302,14 @@ class THttpRequest extends TApplicationComponent implements IteratorAggregate,Ar return $_SERVER['SCRIPT_NAME']; } + /** + * @return string entry script URL (w/ host part) + */ + public function getAbsoluteApplicationUrl() + { + return $this->getBaseUrl() . $this->getApplicationUrl(); + } + /** * @return string application entry script file path (processed w/ realpath()) */ diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index 5a3ff99d..f455f48d 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -274,12 +274,15 @@ class THttpResponse extends TModule implements ITextWriter /** * Redirects the browser to the specified URL. * The current application will be terminated after this method is invoked. - * @param string URL to be redirected to + * @param string URL to be redirected to. If the URL is a relative one, the base URL of + * the current request will be inserted at the beginning. */ public function redirect($url) { if(!$this->getApplication()->getRequestCompleted()) $this->getApplication()->onEndRequest(); + if($url[0]==='/') + $url=$this->getRequest()->getBaseUrl().$url; header('Location:'.$url); exit(); } -- cgit v1.2.3