diff options
| -rw-r--r-- | demos/controls/protected/pages/HomePage.tpl | 6 | ||||
| -rw-r--r-- | framework/Exceptions/messages.txt | 6 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TExpression.php | 24 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TLabel.php | 18 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TLiteral.php | 44 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TPlaceHolder.php | 10 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TStatements.php | 27 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TStyle.php | 5 | ||||
| -rw-r--r-- | framework/Web/UI/WebControls/TWebControl.php | 5 | 
9 files changed, 91 insertions, 54 deletions
| diff --git a/demos/controls/protected/pages/HomePage.tpl b/demos/controls/protected/pages/HomePage.tpl index 66fd9e71..9c9ef716 100644 --- a/demos/controls/protected/pages/HomePage.tpl +++ b/demos/controls/protected/pages/HomePage.tpl @@ -2,11 +2,11 @@  <com:TContent id="header" >
  <com:TForm>
  <h1>Welcome! <%=$this->User->Name %></h1>
 -<com:TLiteral Text="literal" />
 +<com:TLiteral Text="<literal>" Encode="true"/>
  <com:TTextBox Text="textbox" />
 -<com:TLabel Text="label" /><br/>
 +<com:TLabel Text="test" AssociatedControlID="checkbox"/><br/>
  <com:System.Web.UI.WebControls.TButton text="Toggle Button" ForeColor="red" Font.size="18" Click="testClick" /> (requires membership)<br/>
 -<com:TCheckBox Text="Checkbox" /><br/>
 +<com:TCheckBox Text="Checkbox" ID="checkbox"/><br/>
  <com:TImage ImageUrl=<%~/fungii_logo.gif %> />
  <com:TImageButton ImageUrl=<%~/fungii_logo.gif %> /><br/>
  <com:THyperLink Text="Visit a 'classless' page" NavigateUrl="?sp=page.plain" /> |
 diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt index abb6c0dd..eb385ead 100644 --- a/framework/Exceptions/messages.txt +++ b/framework/Exceptions/messages.txt @@ -133,4 +133,8 @@ control_stylesheet_applied				= StyleSheet skin has already been applied to %s.  control_id_nonunique					= %s.ID '%s' is not unique among all controls under the same naming container.
  webcontrol_accesskey_invalid			= %s.AccessKey '%s' is invalid. It must be a single character only.
 -webcontrol_style_invalid				= %s.Style must take string value only.
\ No newline at end of file +webcontrol_style_invalid				= %s.Style must take string value only.
 +
 +label_associatedcontrol_invalid			= TLabel.AssociatedControl '%s' cannot be found.
 +
 +literal_body_forbidden					= TLiteral controls do not allow body contents.
\ No newline at end of file diff --git a/framework/Web/UI/WebControls/TExpression.php b/framework/Web/UI/WebControls/TExpression.php index 9168f178..eb1151b0 100644 --- a/framework/Web/UI/WebControls/TExpression.php +++ b/framework/Web/UI/WebControls/TExpression.php @@ -3,9 +3,9 @@   * TExpression class file
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 - * @link http://www.xisc.com/
 - * @copyright Copyright © 2004-2005, Qiang Xue
 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
   */
 @@ -14,12 +14,12 @@   * TExpression class
   *
   * TExpression evaluates a PHP expression and renders the result.
 - * The expression is evaluated during rendering stage. You can set
 - * it via the property <b>Expression</b>. You should also specify
 - * the context object by <b>Context</b> property which is used as
 - * the object in which the expression is evaluated. If the <b>Context</b>
 - * property is not set, the TExpression component itself will be
 - * assumed as the context.
 + * The expression is evaluated during the rendering stage. The expression being
 + * evaluated can be set via the property {@link setExpression Expression}.
 + * The context of the expression evaluated is the TExpression object itself.
 + *
 + * Note, since TExpression allows evaluation of arbitrary PHP expression,
 + * make sure {@link setExpression Expression} does not come directly from user input.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
   * @version $Revision: $  $Date: $
 @@ -28,6 +28,9 @@   */
  class TExpression extends TControl
  {
 +	/**
 +	 * @var string PHP expression to be evaluated
 +	 */
  	private $_e='';
  	/**
 @@ -39,8 +42,7 @@ class TExpression extends TControl  	}
  	/**
 -	 * Sets the expression of the TExpression
 -	 * @param string the expression to be set
 +	 * @param string the expression to be evaluated
  	 */
  	public function setExpression($value)
  	{
 diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php index 15148732..f80ad758 100644 --- a/framework/Web/UI/WebControls/TLabel.php +++ b/framework/Web/UI/WebControls/TLabel.php @@ -3,9 +3,9 @@   * TLabel class file.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 - * @link http://www.xisc.com/
 - * @copyright Copyright © 2004-2005, Qiang Xue
 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
   */
 @@ -14,14 +14,14 @@   * TLabel class
   *
   * TLabel represents a label control that displays text on a Web pagge.
 - * Use <b>Text</b> property to set the text to be displayed.
 + * Use {@link setText Text} property to set the text to be displayed.
   * TLabel will render the contents enclosed within its component tag
 - * if <b>Text</b> is empty.
 + * if {@link setText Text} is empty.
   * To use TLabel as a form label, associate it with a control by setting the
 - * <b>AssociateControlID</b> property. The associated control must be locatable
 - * within the label's naming container.
 + * {@link setAssociateControlID AssociateControlID} property.
 + * The associated control must be locatable within the label's naming container.
   *
 - * Note, <b>Text</b> will NOT be encoded for rendering.
 + * Note, {@link setText Text} will NOT be encoded for rendering.
   * Make usre it does not contain dangerous characters that you want to avoid.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 @@ -51,7 +51,7 @@ class TLabel extends TWebControl  			if($control=$this->findControl($aid))
  				$writer->addAttribute('for',$control->getClientID());
  			else
 -				throw new TInvalidDataValueException('control_not_found',$aid);
 +				throw new TInvalidDataValueException('label_associatedcontrol_invalid',$aid);
  		}
  		parent::addAttributesToRender($writer);
  	}
 diff --git a/framework/Web/UI/WebControls/TLiteral.php b/framework/Web/UI/WebControls/TLiteral.php index 459552f7..cda144dd 100644 --- a/framework/Web/UI/WebControls/TLiteral.php +++ b/framework/Web/UI/WebControls/TLiteral.php @@ -3,9 +3,9 @@   * TLiteral class file
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 - * @link http://www.xisc.com/
 - * @copyright Copyright © 2004-2005, Qiang Xue
 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
   */
 @@ -13,18 +13,15 @@  /**
   * TLiteral class
   *
 - * TLiteral reserves a location on the Web page to display static text or body content.
 - * The TLiteral control is similar to the TLabel control, except the TLiteral
 - * control does not allow you to apply a style to the displayed text.
 + * TLiteral displays a static text on the Web page.
 + * TLiteral is similar to the TLabel control, except that the TLiteral
 + * control does not allow child controls and do not have style properties (e.g. BackColor, Font, etc.)
   * You can programmatically control the text displayed in the control by setting
 - * the <b>Text</b> property. If the <b>Text</b> property is empty, the content
 - * enclosed within the TLiteral control will be displayed. This is very useful
 - * for reserving a location on a page because you can add text and controls
 - * as children of TLiteral control and they will be rendered at the place.
 + * the {@link setText Text} property. The text displayed may be HTML-encoded
 + * if the {@link setEncode Encode} property is set true (defaults to false).
   *
 - * Note, <b>Text</b> is not HTML encoded before it is displayed in the TLiteral component.
 - * If the values for the component come from user input, be sure to validate the values
 - * to help prevent security vulnerabilities.
 + * Note, if {@link setEncode Encode} is false, make sure {@link setText Text}
 + * does not contain unwanted characters that may bring security vulnerabilities.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
   * @version $Revision: $  $Date: $
 @@ -34,6 +31,17 @@  class TLiteral extends TControl
  {
  	/**
 +	 * Processes an object that is created during parsing template.
 +	 * This method overrides the parent implementation by forbidding any child controls.
 +	 * @param string|TComponent text string or component parsed and instantiated in template
 +	 */
 +	public function addParsedObject($object)
 +	{
 +		if($object instanceof TComponent)
 +			throw new TConfigurationException('literal_body_forbidden');
 +	}
 +
 +	/**
  	 * @return string the static text of the TLiteral
  	 */
  	public function getText()
 @@ -50,18 +58,24 @@ class TLiteral extends TControl  		$this->setViewState('Text',$value,'');
  	}
 +	/**
 +	 * @return boolean whether the rendered text should be HTML-encoded. Defaults to false.
 +	 */
  	public function getEncode()
  	{
  		return $this->getViewState('Encode',false);
  	}
 +	/**
 +	 * @param boolean  whether the rendered text should be HTML-encoded.
 +	 */
  	public function setEncode($value)
  	{
 -		$this->setViewState('Encode',$value,false);
 +		$this->setViewState('Encode',TPropertyValue::ensureBoolean($value),false);
  	}
  	/**
 -	 * Renders the evaluation result of the statements.
 +	 * Renders the literal control.
  	 * @param THtmlWriter the writer used for the rendering purpose
  	 */
  	protected function render($writer)
 diff --git a/framework/Web/UI/WebControls/TPlaceHolder.php b/framework/Web/UI/WebControls/TPlaceHolder.php index 9149e180..91979a26 100644 --- a/framework/Web/UI/WebControls/TPlaceHolder.php +++ b/framework/Web/UI/WebControls/TPlaceHolder.php @@ -3,9 +3,9 @@   * TPlaceHolder class file
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 - * @link http://www.xisc.com/
 - * @copyright Copyright © 2004-2005, Qiang Xue
 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
   */
 @@ -13,6 +13,10 @@  /**
   * TPlaceHolder class
   *
 + * TPlaceHolder reserves a place on a template, where static texts or controls
 + * may be inserted. You may add or remove texts or child controls of TPlaceHolder
 + * by manipulating the {@link TControl::getControls Controls} property.
 + *
   * @author Qiang Xue <qiang.xue@gmail.com>
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
 diff --git a/framework/Web/UI/WebControls/TStatements.php b/framework/Web/UI/WebControls/TStatements.php index 5c1ffe1e..0474acf1 100644 --- a/framework/Web/UI/WebControls/TStatements.php +++ b/framework/Web/UI/WebControls/TStatements.php @@ -3,9 +3,9 @@   * TStatements class file
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
 - * @link http://www.xisc.com/
 - * @copyright Copyright © 2004-2005, Qiang Xue
 - * @license http://www.opensource.org/licenses/bsd-license.php BSD License
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
   * @version $Revision: $  $Date: $
   * @package System.Web.UI.WebControls
   */
 @@ -13,13 +13,14 @@  /**
   * TStatements class
   *
 - * TStatements executes a set of PHP statements and renders the display
 - * generated by the statements. The execution happens during rendering stage.
 - * You can set the statements via the property <b>Statements</b>.
 - * You should also specify the context object by <b>Context</b> property
 - * which is used as the object in which the statements is evaluated.
 - * If the <b>Context</b> property is not set, the TStatements component
 - * itself will be assumed as the context.
 + * TStatements executes one or several PHP statements and renders the display
 + * generated during the execution. The execution happens during the rendering stage.
 + * The PHP statements being executed can be set via the property
 + * {@link setStatements Statements}. The context of the statemenets executed
 + * is the TStatements object itself.
 + *
 + * Note, since TStatements allows execution of arbitrary PHP statements,
 + * make sure {@link setStatements Statements} does not come directly from user input.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
   * @version $Revision: $  $Date: $
 @@ -28,6 +29,9 @@   */
  class TStatements extends TControl
  {
 +	/**
 +	 * @var string PHP statements
 +	 */
  	private $_s='';
  	/**
 @@ -39,8 +43,7 @@ class TStatements extends TControl  	}
  	/**
 -	 * Sets the statements of the TStatements
 -	 * @param string the statements to be set
 +	 * @param string the PHP statements to be executed
  	 */
  	public function setStatements($value)
  	{
 diff --git a/framework/Web/UI/WebControls/TStyle.php b/framework/Web/UI/WebControls/TStyle.php index 8a046ff1..bb1d733a 100644 --- a/framework/Web/UI/WebControls/TStyle.php +++ b/framework/Web/UI/WebControls/TStyle.php @@ -11,6 +11,11 @@   */
  /**
 + * Includes TFont definition
 + */
 +Prado::using('System.Web.UI.WebControls.TFont');
 +
 +/**
   * TStyle class
   *
   * TStyle encapsulates the CSS style applied to a control.
 diff --git a/framework/Web/UI/WebControls/TWebControl.php b/framework/Web/UI/WebControls/TWebControl.php index b54f0e71..33f35c72 100644 --- a/framework/Web/UI/WebControls/TWebControl.php +++ b/framework/Web/UI/WebControls/TWebControl.php @@ -11,6 +11,11 @@   */
  /**
 + * Includes TStyle definition
 + */
 +Prado::using('System.Web.UI.WebControls.TStyle');
 +
 +/**
   * TWebControl class
   *
   * TWebControl is the base class for controls that share a common set
 | 
