Class TConditional

Description

TConditional class.

TConditional displays appropriate content based on the evaluation result of a PHP expression specified via Condition. If the result is true, it instantiates the template TrueTemplate; otherwise, the template FalseTemplate is instantiated. The PHP expression is evaluated right before onInit stage of the control lifecycle.

Since Condition is evaluated at a very early stage, it is recommended you set Condition in template and the expression should not refer to objects that are available on or after onInit lifecycle.

A typical usage of TConditional is shown as following:

  1. <com:TConditional Condition="$this->User->IsGuest">
  2. <prop:TrueTemplate>
  3. <a href="path/to/login">Login</a>
  4. </prop:TrueTemplate>
  5. <prop:FalseTemplate>
  6. <a href="path/to/logout">Logout</a>
  7. </prop:FalseTemplate>
  8. </com:TConditional>

TConditional is very light. It instantiates either TrueTemplate or FalseTemplate, but never both. And the condition is evaluated only once.

  • since: 3.1.1
  • version: $Id: TConditional.php 2273 2007-09-29 21:10:55Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

Located in /Web/UI/WebControls/TConditional.php (line 46)

TComponent
   |
   --TApplicationComponent
      |
      --TControl
         |
         --TConditional
Method Summary
void addParsedObject (string|TComponent $object)
string getCondition ()
void registerObject (string $name, mixed $object)
void setCondition (string $value)
void setFalseTemplate (ITemplate $value)
void setTrueTemplate (ITemplate $value)
Methods
addParsedObject (line 60)

Processes an object that is created during parsing template.

This method overrides the parent implementation by removing all contents enclosed in the template tag.

void addParsedObject (string|TComponent $object)
  • string|TComponent $object: text string or component parsed and instantiated in template

Redefinition of:
TControl::addParsedObject()
Adds the object instantiated on a template to the child control collection.
createChildControls (line 83)

Creates child controls.

This method overrides the parent implementation. It evaluates Condition and instantiate the corresponding template.

  • access: public
void createChildControls ()

Redefinition of:
TControl::createChildControls()
Creates child controls.
getCondition (line 108)
  • return: the PHP expression used for determining which template to use. Defaults to 'true', meaning using TrueTemplate.
  • access: public
string getCondition ()
getFalseTemplate (line 142)
  • return: the template applied when Condition is false.
  • access: public
ITemplate getFalseTemplate ()
getTrueTemplate (line 126)
  • return: the template applied when Condition is true.
  • access: public
ITemplate getTrueTemplate ()
registerObject (line 73)

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.

  • access: public
void registerObject (string $name, mixed $object)
  • string $name: name of the object
  • mixed $object: the object to be registered

Redefinition of:
TControl::registerObject()
Registers an object by a name.
setCondition (line 118)

Sets the PHP expression to be evaluated for conditionally displaying content.

The context of the expression is the template control containing TConditional.

  • access: public
void setCondition (string $value)
  • string $value: the PHP expression used for determining which template to use.
setFalseTemplate (line 150)
  • access: public
void setFalseTemplate (ITemplate $value)
setTrueTemplate (line 134)
  • access: public
void setTrueTemplate (ITemplate $value)

Inherited Methods

Inherited From TControl

TControl::__construct()
TControl::addedControl()
TControl::addParsedObject()
TControl::addToPostDataLoader()
TControl::applyStyleSheetSkin()
TControl::autoBindProperty()
TControl::autoDataBindProperties()
TControl::bindProperty()
TControl::broadcastEvent()
TControl::bubbleEvent()
TControl::clearChildState()
TControl::clearControlState()
TControl::clearNamingContainer()
TControl::clearViewState()
TControl::convertUniqueIdToClientId()
TControl::createChildControls()
TControl::createControlCollection()
TControl::dataBind()
TControl::dataBindChildren()
TControl::dataBindProperties()
TControl::ensureChildControls()
TControl::findControl()
TControl::findControlsByID()
TControl::findControlsByType()
TControl::focus()
TControl::getAdapter()
TControl::getAllowChildControls()
TControl::getAttribute()
TControl::getAttributes()
TControl::getChildControlsCreated()
TControl::getClientID()
TControl::getControls()
TControl::getControlStage()
TControl::getControlState()
TControl::getCustomData()
TControl::getEnabled()
TControl::getEnableTheming()
TControl::getEnableViewState()
TControl::getHasAdapter()
TControl::getHasAttributes()
TControl::getHasChildInitialized()
TControl::getHasControls()
TControl::getHasInitialized()
TControl::getHasLoaded()
TControl::getHasLoadedPostData()
TControl::getHasPreRendered()
TControl::getID()
TControl::getNamingContainer()
TControl::getPage()
TControl::getParent()
TControl::getRegisteredObject()
TControl::getSkinID()
TControl::getSourceTemplateControl()
TControl::getTemplateControl()
TControl::getUniqueID()
TControl::getViewState()
TControl::getVisible()
TControl::hasAttribute()
TControl::initRecursive()
TControl::isDescendentOf()
TControl::isObjectRegistered()
TControl::loadRecursive()
TControl::loadState()
TControl::loadStateRecursive()
TControl::onDataBinding()
TControl::onInit()
TControl::onLoad()
TControl::onPreRender()
TControl::onUnload()
TControl::preRenderRecursive()
TControl::raiseBubbleEvent()
TControl::registerObject()
TControl::removeAttribute()
TControl::removedControl()
TControl::render()
TControl::renderChildren()
TControl::renderControl()
TControl::saveState()
TControl::saveStateRecursive()
TControl::setAdapter()
TControl::setAttribute()
TControl::setChildControlsCreated()
TControl::setControlStage()
TControl::setControlState()
TControl::setCustomData()
TControl::setEnabled()
TControl::setEnableTheming()
TControl::setEnableViewState()
TControl::setID()
TControl::setPage()
TControl::setSkinID()
TControl::setTemplateControl()
TControl::setViewState()
TControl::setVisible()
TControl::trackViewState()
TControl::traverseChildControls()
TControl::unbindProperty()
TControl::unloadRecursive()
TControl::unregisterObject()
TControl::__get()

Inherited From TApplicationComponent

TApplicationComponent::getApplication()
TApplicationComponent::getRequest()
TApplicationComponent::getResponse()
TApplicationComponent::getService()
TApplicationComponent::getSession()
TApplicationComponent::getUser()
TApplicationComponent::publishAsset()
TApplicationComponent::publishFilePath()

Inherited From TComponent

TComponent::addParsedObject()
TComponent::attachEventHandler()
TComponent::canGetProperty()
TComponent::canSetProperty()
TComponent::createdOnTemplate()
TComponent::detachEventHandler()
TComponent::evaluateExpression()
TComponent::evaluateStatements()
TComponent::getEventHandlers()
TComponent::getSubProperty()
TComponent::hasEvent()
TComponent::hasEventHandler()
TComponent::hasProperty()
TComponent::raiseEvent()
TComponent::setSubProperty()
TComponent::__get()
TComponent::__set()
Class Constants

Documentation generated on Sun, 30 Sep 2007 19:14:53 -0400 by phpDocumentor 1.3.0RC4