summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorChristophe.Boulain <>2009-07-15 09:01:05 +0000
committerChristophe.Boulain <>2009-07-15 09:01:05 +0000
commit3ba065922fadd3dfc9e60014690e139a5568f8a9 (patch)
tree232f99f1a77b64def015fce4445bf572773f93ca /framework/Web
parentf1c27f46100582a1e52a27b616bf468e849068e7 (diff)
Merging latests 3.1 changes into trunk
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js2
-rw-r--r--framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js2
-rw-r--r--framework/Web/THttpResponse.php44
-rw-r--r--framework/Web/UI/ActiveControls/TActivePageAdapter.php4
-rw-r--r--framework/Web/UI/TPage.php31
5 files changed, 61 insertions, 22 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
index 5402c4e7..56395d44 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js
@@ -110,6 +110,8 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete,
if(options.AutoPostBack)
this.onInit(options);
+
+ Prado.Registry.set(options.ID, this);
},
doCallback : function(event, options)
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
index 51e3f489..052a18b0 100644
--- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
+++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js
@@ -18,6 +18,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend(
Prado.WebUI.TInPlaceTextBox.register(this);
this.createEditorInput();
this.initializeListeners();
+
+ Prado.Registry.set(options.ID, this);
},
/**
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index e3373855..3222f22f 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -43,7 +43,7 @@ Prado::using('System.Web.THttpResponseAdapter');
* or {@link TGlobalization::setCharset() TGlobalization.Charset} is set.
*
* Since 3.1.2, HTTP status code can be set with the {@link setStatusCode StatusCode} property.
- *
+ *
* Note: Some HTTP Status codes can require additional header or body information. So, if you use {@link setStatusCode StatusCode}
* in your application, be sure to add theses informations.
* E.g : to make an http authentication :
@@ -53,12 +53,12 @@ Prado::using('System.Web.THttpResponseAdapter');
* $response=$this->getResponse();
* $response->setStatusCode(401);
* $response->appendHeader('WWW-Authenticate: Basic realm="Test"');
- * }
+ * }
* </code>
- *
+ *
* This event handler will sent the 401 status code (Unauthorized) to the browser, with the WWW-Authenticate header field. This
* will force the browser to ask for a username and a password.
- *
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id$
* @package System.Web
@@ -70,10 +70,10 @@ class THttpResponse extends TModule implements ITextWriter
* @var The differents defined status code by RFC 2616 {@link http://www.faqs.org/rfcs/rfc2616}
*/
private static $HTTP_STATUS_CODES = array(
- 100 => 'Continue', 101 => 'Switching Protocols',
- 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
- 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect',
- 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
+ 100 => 'Continue', 101 => 'Switching Protocols',
+ 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
+ 300 => 'Multiple Choices', 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', 307 => 'Temporary Redirect',
+ 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Time-out', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Large', 415 => 'Unsupported Media Type', 416 => 'Requested range not satisfiable', 417 => 'Expectation Failed',
500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'HTTP Version not supported'
);
@@ -259,7 +259,7 @@ class THttpResponse extends TModule implements ITextWriter
* Set the HTTP status code for the response.
* The code and its reason will be sent to client using the currently requested http protocol version (see {@link THttpRequest::getHttpProtocolVersion})
* Keep in mind that HTTP/1.0 clients might not understand all status codes from HTTP/1.1
- *
+ *
* @param integer HTTP status code
* @param string HTTP status reason, defaults to standard HTTP reasons
*/
@@ -315,13 +315,17 @@ class THttpResponse extends TModule implements ITextWriter
* @param string content to be set. If null, the content will be read from the server file pointed to by $fileName.
* @param string mime type of the content.
* @param array list of headers to be sent. Each array element represents a header string (e.g. 'Content-Type: text/plain').
+ * @param boolean force download of file, even if browser able to display inline. Defaults to 'true'.
+ * @param string force a specific file name on client side. Defaults to 'null' means auto-detect.
+ * @param integer size of file or content in bytes if already known. Defaults to 'null' means auto-detect.
* @throws TInvalidDataValueException if the file cannot be found
*/
- public function writeFile($fileName,$content=null,$mimeType=null,$headers=null)
+ public function writeFile($fileName,$content=null,$mimeType=null,$headers=null,$forceDownload=true,$clientFileName=null,$fileSize=null)
{
static $defaultMimeTypes=array(
'css'=>'text/css',
'gif'=>'image/gif',
+ 'png'=>'image/png',
'jpg'=>'image/jpeg',
'jpeg'=>'image/jpeg',
'htm'=>'text/html',
@@ -343,7 +347,15 @@ class THttpResponse extends TModule implements ITextWriter
$mimeType=$defaultMimeTypes[$ext];
}
}
- $fn=basename($fileName);
+
+ if($clientFileName===null)
+ $clientFileName=basename($fileName);
+ else
+ $clientFileName=basename($clientFileName);
+
+ if($fileSize===null || $fileSize < 0)
+ $fileSize = ($content===null?filesize($fileName):strlen($content));
+
$this->sendHttpHeader();
if(is_array($headers))
{
@@ -357,8 +369,8 @@ class THttpResponse extends TModule implements ITextWriter
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
}
header("Content-type: $mimeType");
- header('Content-Length: '.($content===null?filesize($fileName):strlen($content)));
- header("Content-Disposition: attachment; filename=\"$fn\"");
+ header('Content-Length: '.$fileSize);
+ header("Content-Disposition: " . ($forceDownload ? 'attachment' : 'inline') . "; filename=\"$clientFileName\"");
header('Content-Transfer-Encoding: binary');
if($content===null)
readfile($fileName);
@@ -388,7 +400,7 @@ class THttpResponse extends TModule implements ITextWriter
* You can set the set {@link setStatusCode StatusCode} to a value between 300 and 399 before
* calling this function to change the type of redirection.
* If not specified, StatusCode will be 302 (Found) by default
- *
+ *
* @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.
*/
@@ -403,7 +415,7 @@ class THttpResponse extends TModule implements ITextWriter
header('Location: '.str_replace('&amp;','&',$url), true, $this->_status);
else
header('Location: '.str_replace('&amp;','&',$url));
-
+
exit();
}
@@ -440,7 +452,7 @@ class THttpResponse extends TModule implements ITextWriter
if($this->_bufferOutput)
ob_flush();
}
-
+
/**
* Send the HTTP header with the status code (defaults to 200) and status reason (defaults to OK)
*/
diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
index 90eed970..b91da695 100644
--- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php
+++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php
@@ -316,13 +316,13 @@ class TCallbackErrorHandler extends TErrorHandler
{
$response = $this->getApplication()->getResponse();
$trace = TJavaScript::jsonEncode($this->getExceptionStackTrace($exception));
- $response->appendHeader('HTTP/1.0 500 Internal Error');
+ $response->setStatusCode(500, 'Internal Server Error');
$response->appendHeader(TActivePageAdapter::CALLBACK_ERROR_HEADER.': '.$trace);
}
else
{
error_log("Error happened while processing an existing error:\n".$exception->__toString());
- header('HTTP/1.0 500 Internal Error');
+ header('HTTP/1.0 500 Internal Server Error', true, 500);
}
$this->getApplication()->getResponse()->flush();
}
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 12433715..6f7e533d 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -134,6 +134,11 @@ class TPage extends TTemplateControl
*/
private $_enableStateEncryption=false;
/**
+ * @var boolean whether page state should be compressed
+ * @since 3.1.6
+ */
+ private $_enableStateCompression=true;
+ /**
* @var string page state persister class name
*/
private $_statePersisterClass='System.Web.UI.TPageStatePersister';
@@ -283,7 +288,7 @@ class TPage extends TTemplateControl
$this->setAdapter(new TActivePageAdapter($this));
// Decode Callback postData from UTF-8 to current Charset
- if (($g=$this->getApplication()->getGlobalization(false))!==null &&
+ if (($g=$this->getApplication()->getGlobalization(false))!==null &&
strtoupper($enc=$g->getCharset())!='UTF-8')
foreach ($this->_postData as $k=>$v)
$this->_postData[$k]=iconv('UTF-8',$enc.'//IGNORE',$v);
@@ -1124,6 +1129,24 @@ class TPage extends TTemplateControl
}
/**
+ * @return boolean whether page state should be compressed. Defaults to true.
+ * @since 3.1.6
+ */
+ public function getEnableStateCompression()
+ {
+ return $this->_enableStateCompression;
+ }
+
+ /**
+ * @param boolean whether page state should be compressed.
+ * @since 3.1.6
+ */
+ public function setEnableStateCompression($value)
+ {
+ $this->_enableStateCompression=TPropertyValue::ensureBoolean($value);
+ }
+
+ /**
* @return string the requested page path for this page
*/
public function getPagePath()
@@ -1234,7 +1257,7 @@ class TPageStateFormatter
$str=$sm->hashData(Prado::serialize($data));
else
$str=Prado::serialize($data);
- if(extension_loaded('zlib'))
+ if($page->getEnableStateCompression() && extension_loaded('zlib'))
$str=gzcompress($str);
if($page->getEnableStateEncryption())
$str=$sm->encrypt($str);
@@ -1256,7 +1279,7 @@ class TPageStateFormatter
$sm=$page->getApplication()->getSecurityManager();
if($page->getEnableStateEncryption())
$str=$sm->decrypt($str);
- if(extension_loaded('zlib'))
+ if($page->getEnableStateCompression() && extension_loaded('zlib'))
$str=@gzuncompress($str);
if($page->getEnableStateValidation())
{
@@ -1270,4 +1293,4 @@ class TPageStateFormatter
}
}
-?>
+?> \ No newline at end of file