This class defines the common interface and features of a control in an XHTML form. It importantly adds the ability to assign events and actions to a control, effectively creating an event driven model for a web application.
An event is an effect on the control that represents user interaction (e.g. clicking, changing text). Not all controls support all events, although they do all support the FC_EVENT_UPDATE event.
An action is a callback routine that is associated with a specific control event. This routine is triggered if the event is detected. In this way, for example, some code can be called whenever an input image is clicked.
Definition at line 261 of file controls.php.
Public Member Functions | |
ControlElement ($name, $control_name=null) | |
The ControlElement constructor. | |
getId () | |
Get the unique ID. | |
setId ($id) | |
Set the unique ID. | |
isSimpleControl () | |
Check whether this is a simple control. | |
submitsMultipleValues () | |
Check whether this control submits multiple values. | |
display () | |
Check whether this control should be displayed. | |
setDisplay ($display) | |
Decide whether this control should be displayed. | |
disabled () | |
Check whether this control is disabled. | |
setDisabled ($disabled) | |
Decide whether this control should be disabled. | |
updated () | |
Check whether the control has been updated. | |
setUpdated ($updated) | |
Decide whether the control is to be marked as being updated. | |
checkControlName ($name) | |
Check a control name. | |
getControlName () | |
Get the control's name. | |
setControlName ($name) | |
Set the control's name. | |
getValue () | |
Get the control's value. | |
setValue ($value) | |
Set the control's value. | |
addAction ($event, $name, $callback) | |
Add an action. | |
setActionTriggered ($name, $state) | |
Decide whether an action should be flagged as having been triggered. | |
actionTriggered ($name) | |
Check whether an action has been triggered. | |
& | getAction ($name) |
Get an action callback. | |
getEvent ($name) | |
Get the event(s) associated with a specific action. | |
getActionNames ($event=0) | |
Get the action names, optionally associated with a particular event. | |
getActions ($event=0) | |
Get the control actions, optionally associated with a particular event. | |
actionExists ($name) | |
Check whether an action exists. | |
triggerAction ($name) | |
Trigger an action. | |
removeAction ($name) | |
Remove an action. | |
triggerActions () | |
Trigger all actions associated with the control. | |
addEvent ($event) | |
Adds an event to the control. | |
eventHasOccurred ($event) | |
Check whether an event has occurred. | |
setEventHasOccurred ($event, $state) | |
Decide whether an event has occurred. | |
supportedEvents () | |
Get the events supported by the control. | |
isValidEvent ($event) | |
Check whether the control supports an event. | |
resetEvents () | |
Reset the status of the control's events. | |
_processPOSTED ($post) | |
Process a HTTPD POSTed value. | |
__wakeup () | |
Initialise control after unserialisation. | |
__sleep () | |
Prepare object for serialisation. | |
Public Attributes | |
$actions | |
A list of actions. | |
$events | |
A list of supported events. | |
$display | |
A flag stating whether the control should be displayed. |
|
The ControlElement constructor.
Definition at line 275 of file controls.php. References FC_EVENT_UPDATE, and gen_control_name(). |
|
Prepare object for serialisation. This method is automatically called just before the object is serialised to carry out clean-up operations. See the PHP documentation at http://www.php.net/manual/en/language.oop.magic-functions.php for more information.
Reimplemented from XHTMLElement. Reimplemented in EnhancedImageInput, Option, CheckedInput, and SelectElement. Definition at line 786 of file controls.php. |
|
Initialise control after unserialisation. Checks for a POST variable corresponding to this control and processes it if found.
Reimplemented from XHTMLElement. Reimplemented in FileInput, and SelectElement. Definition at line 769 of file controls.php. |
|
Process a HTTPD POSTed value. The POSTed value is processed and set as the value of the current control.
Reimplemented in ClickedInput, SingleOption, MultipleOption, RadioInput, and CheckboxInput. Definition at line 749 of file controls.php. |
|
Check whether an action exists.
Definition at line 585 of file controls.php. |
|
Check whether an action has been triggered.
Definition at line 496 of file controls.php. |
|
Add an action. Associate a callback routine with an event and a unique action name.
Definition at line 463 of file controls.php. |
|
Adds an event to the control. If the event is not supported by the control, an error is raised.
Definition at line 651 of file controls.php. |
|
Check a control name. Triggers an error if the control name is not valid.
Definition at line 404 of file controls.php. References is_valid_control_name(). |
|
Check whether this control is disabled.
Definition at line 359 of file controls.php. |
|
Check whether this control should be displayed.
Definition at line 337 of file controls.php. |
|
Check whether an event has occurred.
Reimplemented in SelectElement. Definition at line 663 of file controls.php. |
|
Get an action callback.
Definition at line 508 of file controls.php. |
|
Get the action names, optionally associated with a particular event. All action names registered with the control are returned unless a bitwise combination of FC_EVENT_* constants is passed as an argument in which case only those actions which support that event are returned.
Definition at line 541 of file controls.php. |
|
Get the control actions, optionally associated with a particular event. All actions registered with the control are returned unless a bitwise combination of FC_EVENT_* constants is passed as an argument in which case only those actions which support that event are returned.
Definition at line 568 of file controls.php. References $actions. |
|
Get the control's name.
Reimplemented in Option. Definition at line 414 of file controls.php. |
|
Get the event(s) associated with a specific action. If the action is associated with multiple events, the returned value can be checked with the bitwise operator to see what events it supports.
Definition at line 523 of file controls.php. |
|
Get the unique ID.
Definition at line 297 of file controls.php. |
|
Get the control's value. An interface for retrieving a control's value. This should be overridden in a subclass to return a value.
Reimplemented in TextArea, ValueInput, ImageInput, Option, FileInput, and SelectElement. Definition at line 436 of file controls.php. |
|
Check whether this is a simple control. A simple control is a control that does not contain other controls.
Reimplemented in SelectElement. Definition at line 317 of file controls.php. |
|
Check whether the control supports an event.
Definition at line 710 of file controls.php. |
|
Remove an action. Removes an action from the control.
Definition at line 623 of file controls.php. |
|
Reset the status of the control's events. All events are set as not having occurred, and all actions are set as not having been triggered.
Definition at line 721 of file controls.php. References $events. |
|
Decide whether an action should be flagged as having been triggered.
Definition at line 483 of file controls.php. |
|
Set the control's name.
Reimplemented in Option, and SelectElement. Definition at line 424 of file controls.php. |
|
Decide whether this control should be disabled.
Reimplemented in HiddenInput, and EnhancedImageInput. Definition at line 369 of file controls.php. |
|
Decide whether this control should be displayed.
Definition at line 347 of file controls.php. References $display. |
|
Decide whether an event has occurred.
Definition at line 674 of file controls.php. |
|
Set the unique ID.
Reimplemented in SelectElement. Definition at line 306 of file controls.php. |
|
Decide whether the control is to be marked as being updated. Determines whether the control should be flagged as having experienced a FC_EVENT_UPDATE event.
Definition at line 390 of file controls.php. References FC_EVENT_UPDATE. |
|
Set the control's value. This sets the control's value and flags the control has having been updated.
Reimplemented in TextArea, ValueInput, ImageInput, Option, and FileInput. Definition at line 446 of file controls.php. |
|
Check whether this control submits multiple values. A control that submits multiple values is a control such as a checkbox or multiple select.
Reimplemented in ImageInput, MultipleOption, CheckboxInput, SelectElement, and MultipleSelect. Definition at line 328 of file controls.php. |
|
Get the events supported by the control.
Definition at line 692 of file controls.php. References $events. |
|
Trigger an action. The callback routine associated with a particular action is executed if the event associated with the action has occurred.
Definition at line 598 of file controls.php. |
|
Trigger all actions associated with the control. ControlElement::triggerAction() is called for each of the control's actions.
Reimplemented in SelectElement. Definition at line 634 of file controls.php. |
|
Check whether the control has been updated. Checks whether the FC_EVENT_UPDATE event has occurred.
Definition at line 379 of file controls.php. References FC_EVENT_UPDATE. |
|
A list of actions.
Definition at line 264 of file controls.php. Referenced by getActions(). |
|
A flag stating whether the control should be displayed.
Definition at line 268 of file controls.php. Referenced by setDisplay(). |
|
A list of supported events.
Definition at line 266 of file controls.php. Referenced by resetEvents(), and supportedEvents(). |