From 52ae5aef521fa7d800e09206342eb9ac17043cd8 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 13 Jan 2006 12:57:54 +0000 Subject: --- framework/3rdParty/readme.html | 11 +++++-- framework/Web/UI/WebControls/TTextBox.php | 29 ++++++++++++++--- tests/FunctionalTests/protected/application.xml | 1 - tests/FunctionalTests/protected/pages/Home.page | 35 ++------------------- .../protected/pages/I18N/BasicI18N.page | 36 ++-------------------- .../pages/Validation/RequiredFieldValidator.page | 7 +++-- .../pages/Validation/RequiredFieldValidator.php | 5 +-- 7 files changed, 46 insertions(+), 78 deletions(-) diff --git a/framework/3rdParty/readme.html b/framework/3rdParty/readme.html index e48eba45..b84425f2 100644 --- a/framework/3rdParty/readme.html +++ b/framework/3rdParty/readme.html @@ -19,8 +19,8 @@ projects.
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index e37b98b8..dae0ccf8 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -10,6 +10,8 @@
* @package System.Web.UI.WebControls
*/
+Prado::using('System.3rdParty.SafeHtml.TSafeHtmlParser');
+
/**
* TTextBox class
*
@@ -55,6 +57,8 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
*/
private static $_autoCompleteTypes=array('BusinessCity','BusinessCountryRegion','BusinessFax','BusinessPhone','BusinessState','BusinessStreetAddress','BusinessUrl','BusinessZipCode','Cellular','Company','Department','Disabled','DisplayName','Email','FirstName','Gender','HomeCity','HomeCountryRegion','HomeFax','Homepage','HomePhone','HomeState','HomeStreetAddress','HomeZipCode','JobTitle','LastName','MiddleName','None','Notes','Office','Pager','Search');
+ protected $_safeContent;
+
/**
* @return string tag name of the textbox
*/
@@ -90,7 +94,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
if($textMode==='SingleLine')
{
$writer->addAttribute('type','text');
- if(($text=$this->getText())!=='')
+ if(($text=$this->getRawText())!=='')
$writer->addAttribute('value',$text);
if(($act=$this->getAutoCompleteType())!=='None')
{
@@ -169,7 +173,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
public function loadPostData($key,$values)
{
$value=$values[$key];
- if(!$this->getReadOnly() && $this->getText()!==$value)
+ if(!$this->getReadOnly() && $this->getRawText()!==$value)
{
$this->setText($value);
return true;
@@ -226,7 +230,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
protected function renderContents($writer)
{
if($this->getTextMode()==='MultiLine')
- $writer->write(THttpUtility::htmlEncode($this->getText()));
+ $writer->write(THttpUtility::htmlEncode($this->getRawText()));
}
/**
@@ -358,13 +362,27 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
/**
- * @return string the text content of the TTextBox control.
+ * @return string the unmodified text content of the TTextBox control.
*/
- public function getText()
+ public function getRawText()
{
return $this->getViewState('Text','');
}
+ /**
+ * @return string safe text content.
+ */
+ public function getText()
+ {
+ $text = $this->getRawText();
+ if(is_null($this->_safeContent))
+ {
+ $renderer = new TSafeHtmlParser();
+ $this->_safeContent = $renderer->parse($text);
+ }
+ return $this->_safeContent;
+ }
+
/**
* Sets the text content of the TTextBox control.
* @param string the text content
@@ -372,6 +390,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
public function setText($value)
{
$this->setViewState('Text',$value,'');
+ $this->_safeContent = null;
}
/**
diff --git a/tests/FunctionalTests/protected/application.xml b/tests/FunctionalTests/protected/application.xml
index ca946653..53e73457 100644
--- a/tests/FunctionalTests/protected/application.xml
+++ b/tests/FunctionalTests/protected/application.xml
@@ -13,7 +13,6 @@
- -
- - - -
-