diff options
Diffstat (limited to 'framework/Web/UI/TControl.php')
-rw-r--r-- | framework/Web/UI/TControl.php | 618 |
1 files changed, 1 insertions, 617 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index e5e6fa18..e32fb371 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1749,620 +1749,4 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable } } } -} - - -/** - * TControlCollection class - * - * TControlCollection implements a collection that enables - * controls to maintain a list of their child controls. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -class TControlCollection extends TList -{ - /** - * the control that owns this collection. - * @var TControl - */ - private $_o; - - /** - * Constructor. - * @param TControl the control that owns this collection. - * @param boolean whether the list is read-only - */ - public function __construct(TControl $owner,$readOnly=false) - { - $this->_o=$owner; - parent::__construct(null,$readOnly); - } - - /** - * @return TControl the control that owns this collection. - */ - protected function getOwner() - { - return $this->_o; - } - - /** - * Inserts an item at the specified position. - * This overrides the parent implementation by performing additional - * operations for each newly added child control. - * @param integer the speicified position. - * @param mixed new item - * @throws TInvalidDataTypeException if the item to be inserted is neither a string nor a TControl. - */ - public function insertAt($index,$item) - { - if($item instanceof TControl) - { - parent::insertAt($index,$item); - $this->_o->addedControl($item); - } - else if(is_string($item) || ($item instanceof IRenderable)) - parent::insertAt($index,$item); - else - throw new TInvalidDataTypeException('controlcollection_control_required'); - } - - /** - * Removes an item at the specified position. - * This overrides the parent implementation by performing additional - * cleanup work when removing a child control. - * @param integer the index of the item to be removed. - * @return mixed the removed item. - */ - public function removeAt($index) - { - $item=parent::removeAt($index); - if($item instanceof TControl) - $this->_o->removedControl($item); - return $item; - } - - /** - * Overrides the parent implementation by invoking {@link TControl::clearNamingContainer} - */ - public function clear() - { - parent::clear(); - if($this->_o instanceof INamingContainer) - $this->_o->clearNamingContainer(); - } -} - -/** - * TEmptyControlCollection class - * - * TEmptyControlCollection implements an empty control list that prohibits adding - * controls to it. This is useful for controls that do not allow child controls. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -class TEmptyControlCollection extends TControlCollection -{ - /** - * Constructor. - * @param TControl the control that owns this collection. - */ - public function __construct(TControl $owner) - { - parent::__construct($owner,true); - } - - /** - * Inserts an item at the specified position. - * This overrides the parent implementation by ignoring new addition. - * @param integer the speicified position. - * @param mixed new item - */ - public function insertAt($index,$item) - { - if(!is_string($item)) // string is possible if property tag is used. we simply ignore it in this case - parent::insertAt($index,$item); // this will generate an exception in parent implementation - } -} - -/** - * INamingContainer interface. - * INamingContainer marks a control as a naming container. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface INamingContainer -{ -} - -/** - * IPostBackEventHandler interface - * - * If a control wants to respond to postback event, it must implement this interface. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IPostBackEventHandler -{ - /** - * Raises postback event. - * The implementation of this function should raise appropriate event(s) (e.g. OnClick, OnCommand) - * indicating the component is responsible for the postback event. - * @param string the parameter associated with the postback event - */ - public function raisePostBackEvent($param); -} - -/** - * IPostBackDataHandler interface - * - * If a control wants to load post data, it must implement this interface. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IPostBackDataHandler -{ - /** - * Loads user input data. - * The implementation of this function can use $values[$key] to get the user input - * data that are meant for the particular control. - * @param string the key that can be used to retrieve data from the input data collection - * @param array the input data collection - * @return boolean whether the data of the control has been changed - */ - public function loadPostData($key,$values); - /** - * Raises postdata changed event. - * The implementation of this function should raise appropriate event(s) (e.g. OnTextChanged) - * indicating the control data is changed. - */ - public function raisePostDataChangedEvent(); - /** - * @return boolean whether postback causes the data change. Defaults to false for non-postback state. - */ - public function getDataChanged(); -} - - -/** - * IValidator interface - * - * If a control wants to validate user input, it must implement this interface. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IValidator -{ - /** - * Validates certain data. - * The implementation of this function should validate certain data - * (e.g. data entered into TTextBox control). - * @return boolean whether the data passes the validation - */ - public function validate(); - /** - * @return boolean whether the previous {@link validate()} is successful. - */ - public function getIsValid(); - /** - * @param boolean whether the validator validates successfully - */ - public function setIsValid($value); - /** - * @return string error message during last validate - */ - public function getErrorMessage(); - /** - * @param string error message for the validation - */ - public function setErrorMessage($value); -} - - -/** - * IValidatable interface - * - * If a control wants to be validated by a validator, it must implement this interface. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IValidatable -{ - /** - * @return mixed the value of the property to be validated. - */ - public function getValidationPropertyValue(); - /** - * @return boolean wether this control's validators validated successfully (must default to true) - */ - public function getIsValid(); - /** - * @return boolean wether this control's validators validated successfully - */ - public function setIsValid($value); -} - -/** - * IBroadcastEventReceiver interface - * - * If a control wants to check broadcast event, it must implement this interface. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IBroadcastEventReceiver -{ - /** - * Handles broadcast event. - * This method is invoked automatically when an event is broadcasted. - * Within this method, you may check the event name given in - * the event parameter to determine whether you should respond to - * this event. - * @param TControl sender of the event - * @param TBroadCastEventParameter event parameter - */ - public function broadcastEventReceived($sender,$param); -} - -/** - * ITheme interface. - * - * This interface must be implemented by theme. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface ITheme -{ - /** - * Applies this theme to the specified control. - * @param TControl the control to be applied with this theme - */ - public function applySkin($control); -} - -/** - * ITemplate interface - * - * ITemplate specifies the interface for classes encapsulating - * parsed template structures. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface ITemplate -{ - /** - * Instantiates the template. - * Content in the template will be instantiated as components and text strings - * and passed to the specified parent control. - * @param TControl the parent control - */ - public function instantiateIn($parent); -} - -/** - * IButtonControl interface - * - * IButtonControl specifies the common properties and events that must - * be implemented by a button control, such as {@link TButton}, {@link TLinkButton}, - * {@link TImageButton}. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -interface IButtonControl -{ - /** - * @return string caption of the button - */ - public function getText(); - - /** - * @param string caption of the button - */ - public function setText($value); - - /** - * @return boolean whether postback event trigger by this button will cause input validation - */ - public function getCausesValidation(); - - /** - * @param boolean whether postback event trigger by this button will cause input validation - */ - public function setCausesValidation($value); - - /** - * @return string the command name associated with the {@link onCommand OnCommand} event. - */ - public function getCommandName(); - - /** - * @param string the command name associated with the {@link onCommand OnCommand} event. - */ - public function setCommandName($value); - - /** - * @return string the parameter associated with the {@link onCommand OnCommand} event - */ - public function getCommandParameter(); - - /** - * @param string the parameter associated with the {@link onCommand OnCommand} event. - */ - public function setCommandParameter($value); - - /** - * @return string the group of validators which the button causes validation upon postback - */ - public function getValidationGroup(); - - /** - * @param string the group of validators which the button causes validation upon postback - */ - public function setValidationGroup($value); - - /** - * Raises <b>OnClick</b> event. - * @param TEventParameter event parameter to be passed to the event handlers - */ - public function onClick($param); - - /** - * Raises <b>OnCommand</b> event. - * @param TCommandEventParameter event parameter to be passed to the event handlers - */ - public function onCommand($param); - - /** - * @param boolean set by a panel to register this button as the default button for the panel. - */ - public function setIsDefaultButton($value); - - /** - * @return boolean true if this button is registered as a default button for a panel. - */ - public function getIsDefaultButton(); -} - -/** - * ISurroundable interface - * - * Identifies controls that may create an additional surrounding tag. The id of the - * tag can be obtained with {@link getSurroundingTagID}. - * - * @package System.Web.UI - * @since 3.1.2 - */ -interface ISurroundable -{ - /** - * @return string the id of the embedding tag of the control or the control's clientID if not surrounded - */ - public function getSurroundingTagID(); -} - -/** - * TBroadcastEventParameter class - * - * TBroadcastEventParameter encapsulates the parameter data for - * events that are broadcasted. The name of of the event is specified via - * {@link setName Name} property while the event parameter is via - * {@link setParameter Parameter} property. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -class TBroadcastEventParameter extends TEventParameter -{ - private $_name; - private $_param; - - /** - * Constructor. - * @param string name of the broadcast event - * @param mixed parameter of the broadcast event - */ - public function __construct($name='',$parameter=null) - { - $this->_name=$name; - $this->_param=$parameter; - } - - /** - * @return string name of the broadcast event - */ - public function getName() - { - return $this->_name; - } - - /** - * @param string name of the broadcast event - */ - public function setName($value) - { - $this->_name=$value; - } - - /** - * @return mixed parameter of the broadcast event - */ - public function getParameter() - { - return $this->_param; - } - - /** - * @param mixed parameter of the broadcast event - */ - public function setParameter($value) - { - $this->_param=$value; - } -} - -/** - * TCommandEventParameter class - * - * TCommandEventParameter encapsulates the parameter data for <b>Command</b> - * event of button controls. You can access the name of the command via - * {@link getCommandName CommandName} property, and the parameter carried - * with the command via {@link getCommandParameter CommandParameter} property. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -class TCommandEventParameter extends TEventParameter -{ - private $_name; - private $_param; - - /** - * Constructor. - * @param string name of the command - * @param string parameter of the command - */ - public function __construct($name='',$parameter='') - { - $this->_name=$name; - $this->_param=$parameter; - } - - /** - * @return string name of the command - */ - public function getCommandName() - { - return $this->_name; - } - - /** - * @return string parameter of the command - */ - public function getCommandParameter() - { - return $this->_param; - } -} - - -/** - * TCompositeLiteral class - * - * TCompositeLiteral is used internally by {@link TTemplate} for representing - * consecutive static strings, expressions and statements. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @package System.Web.UI - * @since 3.0 - */ -class TCompositeLiteral extends TComponent implements IRenderable, IBindable -{ - const TYPE_EXPRESSION=0; - const TYPE_STATEMENTS=1; - const TYPE_DATABINDING=2; - private $_container=null; - private $_items=array(); - private $_expressions=array(); - private $_statements=array(); - private $_bindings=array(); - - /** - * Constructor. - * @param array list of items to be represented by TCompositeLiteral - */ - public function __construct($items) - { - $this->_items=array(); - $this->_expressions=array(); - $this->_statements=array(); - foreach($items as $id=>$item) - { - if(is_array($item)) - { - if($item[0]===self::TYPE_EXPRESSION) - $this->_expressions[$id]=$item[1]; - else if($item[0]===self::TYPE_STATEMENTS) - $this->_statements[$id]=$item[1]; - else if($item[0]===self::TYPE_DATABINDING) - $this->_bindings[$id]=$item[1]; - $this->_items[$id]=''; - } - else - $this->_items[$id]=$item; - } - } - - /** - * @return TComponent container of this component. It serves as the evaluation context of expressions and statements. - */ - public function getContainer() - { - return $this->_container; - } - - /** - * @param TComponent container of this component. It serves as the evaluation context of expressions and statements. - */ - public function setContainer(TComponent $value) - { - $this->_container=$value; - } - - /** - * Evaluates the expressions and/or statements in the component. - */ - public function evaluateDynamicContent() - { - $context=$this->_container===null?$this:$this->_container; - foreach($this->_expressions as $id=>$expression) - $this->_items[$id]=$context->evaluateExpression($expression); - foreach($this->_statements as $id=>$statement) - $this->_items[$id]=$context->evaluateStatements($statement); - } - - /** - * Performs databindings. - * This method is required by {@link IBindable} - */ - public function dataBind() - { - $context=$this->_container===null?$this:$this->_container; - foreach($this->_bindings as $id=>$binding) - $this->_items[$id]=$context->evaluateExpression($binding); - } - - /** - * Renders the content stored in this component. - * This method is required by {@link IRenderable} - * @param ITextWriter - */ - public function render($writer) - { - $writer->write(implode('',$this->_items)); - } -} - +}
\ No newline at end of file |