summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TTextBox.php
diff options
context:
space:
mode:
authorxue <>2006-01-14 00:19:18 +0000
committerxue <>2006-01-14 00:19:18 +0000
commitf16aa6762984e4d555a1cf93692db0a69fa2ab38 (patch)
tree5a460a73acb869cc58ecb1277118b2e039e0fd1b /framework/Web/UI/WebControls/TTextBox.php
parentf0737c5b52373f262a4c8cfd25d4e1bb6ff33aee (diff)
Added TBaseDataList control. Updated class tree. Modified TTextBox about SafeHtml support. Modified TTextBox demo accordingly.
Diffstat (limited to 'framework/Web/UI/WebControls/TTextBox.php')
-rw-r--r--framework/Web/UI/WebControls/TTextBox.php56
1 files changed, 33 insertions, 23 deletions
diff --git a/framework/Web/UI/WebControls/TTextBox.php b/framework/Web/UI/WebControls/TTextBox.php
index dae0ccf8..4eb42313 100644
--- a/framework/Web/UI/WebControls/TTextBox.php
+++ b/framework/Web/UI/WebControls/TTextBox.php
@@ -10,8 +10,6 @@
* @package System.Web.UI.WebControls
*/
-Prado::using('System.3rdParty.SafeHtml.TSafeHtmlParser');
-
/**
* TTextBox class
*
@@ -56,8 +54,14 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
* @var array list of auto complete types
*/
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;
+ /**
+ * @var mixed safe text parser
+ */
+ private static $_safeTextParser=null;
+ /**
+ * @var string safe textbox content with javascript stripped off
+ */
+ private $_safeText;
/**
* @return string tag name of the textbox
@@ -94,7 +98,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
if($textMode==='SingleLine')
{
$writer->addAttribute('type','text');
- if(($text=$this->getRawText())!=='')
+ if(($text=$this->getText())!=='')
$writer->addAttribute('value',$text);
if(($act=$this->getAutoCompleteType())!=='None')
{
@@ -173,7 +177,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
public function loadPostData($key,$values)
{
$value=$values[$key];
- if(!$this->getReadOnly() && $this->getRawText()!==$value)
+ if(!$this->getReadOnly() && $this->getText()!==$value)
{
$this->setText($value);
return true;
@@ -230,7 +234,7 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
protected function renderContents($writer)
{
if($this->getTextMode()==='MultiLine')
- $writer->write(THttpUtility::htmlEncode($this->getRawText()));
+ $writer->write(THttpUtility::htmlEncode($this->getText()));
}
/**
@@ -362,35 +366,41 @@ class TTextBox extends TWebControl implements IPostBackDataHandler, IValidatable
}
/**
- * @return string the unmodified text content of the TTextBox control.
+ * @return string the text content of the TTextBox control.
*/
- public function getRawText()
+ public function getText()
{
return $this->getViewState('Text','');
}
/**
- * @return string safe text content.
+ * Sets the text content of the TTextBox control.
+ * @param string the text content
*/
- public function getText()
+ public function setText($value)
{
- $text = $this->getRawText();
- if(is_null($this->_safeContent))
- {
- $renderer = new TSafeHtmlParser();
- $this->_safeContent = $renderer->parse($text);
- }
- return $this->_safeContent;
+ $this->setViewState('Text',$value,'');
+ $this->_safeText = null;
}
/**
- * Sets the text content of the TTextBox control.
- * @param string the text content
+ * @return string safe text content with javascript stripped off
*/
- public function setText($value)
+ public function getSafeText()
{
- $this->setViewState('Text',$value,'');
- $this->_safeContent = null;
+ if($this->_safeText===null)
+ $this->_safeText=$this->getSafeTextParser()->parse($this->getText());
+ return $this->_safeText;
+ }
+
+ /**
+ * @return mixed safe text parser
+ */
+ protected function getSafeTextParser()
+ {
+ if(!self::$_safeTextParser)
+ self::$_safeTextParser=Prado::createComponent('System.3rdParty.SafeHtml.TSafeHtmlParser');
+ return self::$_safeTextParser;
}
/**