<commit_before><?php
/**
 * TConditional class file.
 *
 * @author <NAME> <<EMAIL>>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2007 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 <NAME> <<EMAIL>>
 * @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);
		}<commit_msg>Fixed object registration.<commit_after><?php
/**
 * TConditional class file.
 *
 * @author <NAME> <<EMAIL>>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2007 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 <NAME> <<EMAIL>>
 * @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);
	}

	/**
	 * Registers an object defined in the template.
	 * This method is overriden so that the objects are actually
	 * registered to the template containing the TConditional control.
	 * @param string name of the object
	 * @param mixed the object to be registered
	 */
	public function registerObject($name,$object)
	{
		$this->getTemplateControl()->registerObject($name,$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);
		}
{'fraction_non_alphanumeric': 0.10901580459770115, 'fraction_numerical': 0.003951149425287357, 'mean_word_length': 4.406796116504855, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5316128', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1508, 'n_words': 538}