summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TConditional.php
diff options
context:
space:
mode:
authorctrlaltca <>2012-07-12 11:21:01 +0000
committerctrlaltca <>2012-07-12 11:21:01 +0000
commit903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch)
treee08bf04f0823650a231227ac3499121270172a23 /framework/Web/UI/WebControls/TConditional.php
parent3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff)
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'framework/Web/UI/WebControls/TConditional.php')
-rw-r--r--framework/Web/UI/WebControls/TConditional.php284
1 files changed, 142 insertions, 142 deletions
diff --git a/framework/Web/UI/WebControls/TConditional.php b/framework/Web/UI/WebControls/TConditional.php
index d04324f0..28af2305 100644
--- a/framework/Web/UI/WebControls/TConditional.php
+++ b/framework/Web/UI/WebControls/TConditional.php
@@ -1,143 +1,143 @@
-<?php
-/**
- * TConditional class file.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @link http://www.pradosoft.com/
+<?php
+/**
+ * TConditional class file.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @link http://www.pradosoft.com/
* @copyright Copyright &copy; 2005-2012 PradoSoft
- * @license http://www.pradosoft.com/license/
- * @version $Id$
- * @package System.Web.UI.WebControls
- */
-
-/**
- * TConditional class.
- *
- * TConditional displays appropriate content based on the evaluation result
- * of a PHP expression specified via {@link setCondition Condition}.
- * If the result is true, it instantiates the template {@link getTrueTemplate TrueTemplate};
- * otherwise, the template {@link getFalseTemplate FalseTemplate} is instantiated.
- * The PHP expression is evaluated right before {@link onInit} stage of the control lifecycle.
- *
- * Since {@link setCondition Condition} is evaluated at a very early stage, it is recommended
- * you set {@link setCondition Condition} in template and the expression should not refer to
- * objects that are available on or after {@link onInit} lifecycle.
- *
- * A typical usage of TConditional is shown as following:
- * <code>
- * <com:TConditional Condition="$this->User->IsGuest">
- * <prop:TrueTemplate>
- * <a href="path/to/login">Login</a>
- * </prop:TrueTemplate>
- * <prop:FalseTemplate>
- * <a href="path/to/logout">Logout</a>
- * </prop:FalseTemplate>
- * </com:TConditional>
- * </code>
- *
- * TConditional is very light. It instantiates either {@link getTrueTemplate TrueTemplate}
- * or {@link getFalseTemplate FalseTemplate}, but never both. And the condition is evaluated only once.
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id$
- * @package System.Web.UI.WebControls
- * @since 3.1.1
- */
-class TConditional extends TControl
-{
- private $_condition='true';
- private $_trueTemplate;
- private $_falseTemplate;
- private $_creatingChildren=false;
-
- /**
- * Processes an object that is created during parsing template.
- * This method overrides the parent implementation by removing
- * all contents enclosed in the template tag.
- * @param string|TComponent text string or component parsed and instantiated in template
- * @see createdOnTemplate
- */
- public function addParsedObject($object)
- {
- if($this->_creatingChildren)
- parent::addParsedObject($object);
- }
-
- /**
- * Creates child controls.
- * This method overrides the parent implementation. It evaluates {@link getCondition Condition}
- * and instantiate the corresponding template.
- */
- public function createChildControls()
- {
- $this->_creatingChildren=true;
- $result=true;
- try
- {
- $result=$this->getTemplateControl()->evaluateExpression($this->_condition);
- }
- catch(Exception $e)
- {
- throw new TInvalidDataValueException('conditional_condition_invalid',$this->_condition,$e->getMessage());
- }
- if($result)
- {
- if($this->_trueTemplate)
- $this->_trueTemplate->instantiateIn($this->getTemplateControl(),$this);
- }
- else if($this->_falseTemplate)
- $this->_falseTemplate->instantiateIn($this->getTemplateControl(),$this);
- $this->_creatingChildren=false;
- }
-
- /**
- * @return string the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate.
- */
- public function getCondition()
- {
- return $this->_condition;
- }
-
- /**
- * Sets the PHP expression to be evaluated for conditionally displaying content.
- * The context of the expression is the template control containing TConditional.
- * @param string the PHP expression used for determining which template to use.
- */
- public function setCondition($value)
- {
- $this->_condition=TPropertyValue::ensureString($value);
- }
-
- /**
- * @return ITemplate the template applied when {@link getCondition Condition} is true.
- */
- public function getTrueTemplate()
- {
- return $this->_trueTemplate;
- }
-
- /**
- * @param ITemplate the template applied when {@link getCondition Condition} is true.
- */
- public function setTrueTemplate(ITemplate $value)
- {
- $this->_trueTemplate=$value;
- }
-
- /**
- * @return ITemplate the template applied when {@link getCondition Condition} is false.
- */
- public function getFalseTemplate()
- {
- return $this->_falseTemplate;
- }
-
- /**
- * @param ITemplate the template applied when {@link getCondition Condition} is false.
- */
- public function setFalseTemplate(ITemplate $value)
- {
- $this->_falseTemplate=$value;
- }
-}
-
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Web.UI.WebControls
+ */
+
+/**
+ * TConditional class.
+ *
+ * TConditional displays appropriate content based on the evaluation result
+ * of a PHP expression specified via {@link setCondition Condition}.
+ * If the result is true, it instantiates the template {@link getTrueTemplate TrueTemplate};
+ * otherwise, the template {@link getFalseTemplate FalseTemplate} is instantiated.
+ * The PHP expression is evaluated right before {@link onInit} stage of the control lifecycle.
+ *
+ * Since {@link setCondition Condition} is evaluated at a very early stage, it is recommended
+ * you set {@link setCondition Condition} in template and the expression should not refer to
+ * objects that are available on or after {@link onInit} lifecycle.
+ *
+ * A typical usage of TConditional is shown as following:
+ * <code>
+ * <com:TConditional Condition="$this->User->IsGuest">
+ * <prop:TrueTemplate>
+ * <a href="path/to/login">Login</a>
+ * </prop:TrueTemplate>
+ * <prop:FalseTemplate>
+ * <a href="path/to/logout">Logout</a>
+ * </prop:FalseTemplate>
+ * </com:TConditional>
+ * </code>
+ *
+ * TConditional is very light. It instantiates either {@link getTrueTemplate TrueTemplate}
+ * or {@link getFalseTemplate FalseTemplate}, but never both. And the condition is evaluated only once.
+ *
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ * @version $Id$
+ * @package System.Web.UI.WebControls
+ * @since 3.1.1
+ */
+class TConditional extends TControl
+{
+ private $_condition='true';
+ private $_trueTemplate;
+ private $_falseTemplate;
+ private $_creatingChildren=false;
+
+ /**
+ * Processes an object that is created during parsing template.
+ * This method overrides the parent implementation by removing
+ * all contents enclosed in the template tag.
+ * @param string|TComponent text string or component parsed and instantiated in template
+ * @see createdOnTemplate
+ */
+ public function addParsedObject($object)
+ {
+ if($this->_creatingChildren)
+ parent::addParsedObject($object);
+ }
+
+ /**
+ * Creates child controls.
+ * This method overrides the parent implementation. It evaluates {@link getCondition Condition}
+ * and instantiate the corresponding template.
+ */
+ public function createChildControls()
+ {
+ $this->_creatingChildren=true;
+ $result=true;
+ try
+ {
+ $result=$this->getTemplateControl()->evaluateExpression($this->_condition);
+ }
+ catch(Exception $e)
+ {
+ throw new TInvalidDataValueException('conditional_condition_invalid',$this->_condition,$e->getMessage());
+ }
+ if($result)
+ {
+ if($this->_trueTemplate)
+ $this->_trueTemplate->instantiateIn($this->getTemplateControl(),$this);
+ }
+ else if($this->_falseTemplate)
+ $this->_falseTemplate->instantiateIn($this->getTemplateControl(),$this);
+ $this->_creatingChildren=false;
+ }
+
+ /**
+ * @return string the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate.
+ */
+ public function getCondition()
+ {
+ return $this->_condition;
+ }
+
+ /**
+ * Sets the PHP expression to be evaluated for conditionally displaying content.
+ * The context of the expression is the template control containing TConditional.
+ * @param string the PHP expression used for determining which template to use.
+ */
+ public function setCondition($value)
+ {
+ $this->_condition=TPropertyValue::ensureString($value);
+ }
+
+ /**
+ * @return ITemplate the template applied when {@link getCondition Condition} is true.
+ */
+ public function getTrueTemplate()
+ {
+ return $this->_trueTemplate;
+ }
+
+ /**
+ * @param ITemplate the template applied when {@link getCondition Condition} is true.
+ */
+ public function setTrueTemplate(ITemplate $value)
+ {
+ $this->_trueTemplate=$value;
+ }
+
+ /**
+ * @return ITemplate the template applied when {@link getCondition Condition} is false.
+ */
+ public function getFalseTemplate()
+ {
+ return $this->_falseTemplate;
+ }
+
+ /**
+ * @param ITemplate the template applied when {@link getCondition Condition} is false.
+ */
+ public function setFalseTemplate(ITemplate $value)
+ {
+ $this->_falseTemplate=$value;
+ }
+}
+