TKComponent Class Reference
[Core Classes]

Base class for all toolkit components and containers. More...

Inheritance diagram for TKComponent:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 __call ($name, $args)
 Implements dynamic function calls for, e.g., setXxx().
 __clone ()
 Clones this component and subcomponents for reuse.
 __construct ()
 Constructor.
__get ($fldName)
 Allows simpler syntax for getting properties.
 __isset ($fldName)
 Determines whether property or event exists.
 __set ($fldName, $value)
 Allows simpler syntax for setting properties and events.
 __toString ()
 Converts object to a string suitable for debugging purposes.
 append ($fldName, $value, $pre=false)
 Appends a value to a property.
 appendMany ($fields)
 Performs multiple append operations at once.
 eventExists ($eventName)
 Gets whether an event exists on this object.
 exists ($fld)
 Returns whether a property exists.
get ($fldName)
 Retrieves a given property.
 getId ()
 Retrieves the object's unique ID.
 getProperties ($values=false)
 Returns a list of all the properties this object has.
 getTheme ()
 Retrieves the currently active theme for this object.
 getThemeClass ()
 Retrieves the current theme class for this object.
 render ()
 Converts this component (and any children) to HTML.
 set ($fldName, $value)
 Sets a property.
 setAction ($eventName, $action)
 Associates an action with an event.
 setId ($id)
 Sets a new ID for the object.
 setMany ($fields)
 Calls set() many times.
 setTheme ($theme)
 Sets the toolkit theme for this object.
 setThemeClass ($class)
 Sets the theme class for this object.

Public Attributes

const EVENT_DIRECT
 Event is direct (regular JavaScript event).
const EVENT_INDIRECT
 Event is indirect (triggered by another TK event).
const PROP_ARRAY
 Property is an array.
const PROP_BOOLEAN
 Property is a boolean.
const PROP_CLASS
 Property is a class array (flat list of classes).
const PROP_NUMERIC
 Property is numeric (integer or float).
const PROP_OBJECT
 Property is an object.
const PROP_STRING
 Property is a string.
const PROP_STYLE
 Property is a style array (associative array of CSS style => value elements).

Protected Member Functions

 addEvent ($eventName, $eventType=self::EVENT_DIRECT, $eventExtra=array())
 Adds an event to this object.
 addExtraCSS ($slot, $css)
 Add extra CSS to page.
 addExtraJS ($slot, $js)
 Add extra JavaScript to page.
 addProperty ($propName, $type)
 Adds a property to this object.
 enableTranslateFields ($bEnable)
 Enable or disable automatic translation of class, style and event properties.
 getAllEventJS ()
 Retrieves all inline JavaScript for a component.
 mergeClasses ($names, $extra=array())
 Retranslates multiple class properties into one string.
 mergeStyles ($names, $extra=array())
 Retranslates multiple style properties into one string.
 onClone ()
 Called by __clone() to perform additional cloning-related operations.
 removeEvent ($eventName)
 Removes an event already defined for this object.
 removePropChangeListener ($prop)
 Removes an already registered property change listener.
 removeProperty ($propName)
 Removes an existing property.
 renderComponent ($class, $style, $events, $id)
 Called when rendering; should be overridden by descendent components.
 setPropChangeListener ($prop, $fn)
 Adds a callback to be called when property changes.
 translateClass ($name, $extra=array())
 Retranslates a class property into a HTML string.
 translateFields ($extraClasses=array(), $extraStyles=array())
 Translates class, style and event properties to HTML strings.
 translateStyle ($name, $extra=array())
 Retranslates a style property into a HTML string.

Static Protected Member Functions

static convertChild ($child)
 Converts XML child with TK tag to TK component.
static convertStdAttributes ($obj, $attrs)
 Converts XML attributes into properties (called from your createFromXML method).
static convertStdEvents ($obj, $node)
 Converts XML event tags into toolkit events/actions (called from your createFromXML method).

Private Attributes

 $bTranslateFields
 If true, render() pre-translates class/style properties (see enableTranslateFields()).
 $directEvents
 JavaScript events and actions array.
 $eventExtra
 Additional information about events (to keep other arrays cleaner).
 $hasActions
 If true, object has actions associated with events and needs to generate JS.
 $html
 Already-rendered HTML (produced by render()).
 $id
 Component ID (used in the id attribute in the HTML).
 $indirectEvents
 Indirect/custom events and actions array.
 $parent
 Parent component, or null if component has no parent.
 $properties
 Component properties array and their values.
 $propListeners
 Maps property names to callbacks that monitor property changes.
 $propTypes
 Maps property names to type information about property.
 $theme
 TKTheme (or derivative) associated with this component.
 $themeClass
 Theme class (see Themes).

Static Private Attributes

static $NULL_VALUE
 This is only needed because nulls need to be able to be returned by reference.


Detailed Description

Base class for all toolkit components and containers.

This class is an abstract class and thus cannot be instantiated. It provides most of the functionality used by components and containers, and also some functionality for making the toolkit work with PageRender2.

Properties:
  • class array: CSS class(es) to be used for this object
  • style array: CSS styles in attribute => value pairs to be used for this object
  • alt string: ALT tag text for this object

Events:
  • onclick: JavaScript onclick event
  • ondblclick: JavaScript ondblclick event
  • onmousedown: JavaScript onmousedown event
  • onmouseout: JavaScript onmouseout event
  • onmouseover: JavaScript onmouseover event
  • onmouseup: JavaScript onmouseup event
  • onkeydown: JavaScript onkeydown event
  • onkeypress: JavaScript onkeypress event
  • onkeyup: JavaScript onkeyup event

Definition at line 29 of file TKComponent.php5.


Constructor & Destructor Documentation

TKComponent::__construct (  ) 

Constructor.

For internal use only.

This method needs no arguments. It should be called by derived classes before doing anything else since this constructor initializes many mechanisms for the component.

Reimplemented from SObject.

Reimplemented in TKBorderPanel, TKHBox, TKNullBox, TKScrollPane, TKTree, TKVBox, and TKContainer.

Definition at line 112 of file TKComponent.php5.

References Toolkit::addObject(), addProperty(), Toolkit::getDefaultTheme(), and Toolkit::getNextId().


Member Function Documentation

TKComponent::__call ( name,
args 
)

Implements dynamic function calls for, e.g., setXxx().

This method allows you to call, e.g., setStyle(...) instead of set('style', ...). See the main documentation for this class for more on the dynamic functions.

This method implements setXxx(), getXxx(), appendXxx() and existsXxx() corresponding to set(), get(), append(), exists().

Parameters:
$name [string]: name of method
$args [array]: arguments to method
Returns:
[mixed]: whatever needs to be returned by set(), get(), append() or exists()

Reimplemented in TKContainer.

Definition at line 266 of file TKComponent.php5.

References SObject::setError().

TKComponent::__clone (  ) 

Clones this component and subcomponents for reuse.

Once a component has been rendered, it is not safe to re-use the HTML generated because it may contain unique IDs, events, etc. This method attempts to clone this component so that it can be reused with its configuration. It is NOT safe for use at the moment because of many sticky details in properly cloning components and espcially containers.

Reimplemented in TKContainer.

Definition at line 323 of file TKComponent.php5.

References onClone().

& TKComponent::__get ( fldName  ) 

Allows simpler syntax for getting properties.

This method allows you to say

 $oc = $component->outer_class;
instead of
 $oc = $component->get('outer_class');

The same rules apply for getting via this mechanism as for using the get() method or the dynamic function calls (e.g., getStyle()). If the property given is "html", then render() is called and the HTML for this component is returned.

Parameters:
$fldName [string]: name of parameter
Returns:
[mixed]: value of property

Definition at line 180 of file TKComponent.php5.

References $html, and render().

TKComponent::__isset ( fldName  ) 

Determines whether property or event exists.

This method first checks to see if an event by the given name exists, otherwise it checks to see if the property by the given name exists. Don't give events and properties the same names to prevent problems with this mechanism.

Parameters:
$fldName [string]: name of property or event whose existence to check
Returns:
[boolean]: whether property or event exists on this object

Definition at line 233 of file TKComponent.php5.

References eventExists().

TKComponent::__set ( fldName,
value 
)

Allows simpler syntax for setting properties and events.

This method allows you to say

 $component->outer_class = array('whatever');
instead of
 $component->set('outer_class', array('whatever'));

The same rules apply for setting via this mechanism as for using the set() method or the dynamic function calls (e.g., setStyle()). The benefit of this mechanism, though, is that it detects whether the field to set is actually an event, and if so, calls setAction() instead of set().

Parameters:
$fldName [string]: name of parameter or event
$value [mixed]: new value for parameter or event
Returns:
[boolean]: success or failure

Definition at line 216 of file TKComponent.php5.

References eventExists(), and setAction().

TKComponent::__toString (  ) 

Converts object to a string suitable for debugging purposes.

All this really does is print out the type of component and its ID. Child classes may (and should) override this method to provide more interesting information.

Returns:
[string]: short debugging string

Definition at line 248 of file TKComponent.php5.

References getId().

TKComponent::addEvent ( eventName,
eventType = self::EVENT_DIRECT,
eventExtra = array() 
) [protected]

Adds an event to this object.

For internal use only.

By adding an event, users of the class can attach actions to that event. Events come in two types: direct and indirect. Direct events are generated by the webbrowser and need no special trigger. Indirect events are generated by toolkit actions. The actions that generate indirect events should be automatically created and attached by the class that defines the indirect event. The user of the class should never be required to generate indirect events.

Parameters:
$eventName [string]: name of event (e.g. 'onfoo')
$eventType [int]: type of event (EVENT_DIRECT or EVENT_INDIRECT)
$eventExtra [array]: additional information about the event, as needed by some actions
Returns:
[boolean] success

Definition at line 1046 of file TKComponent.php5.

References $eventExtra.

Referenced by TKRadioButton::__construct(), TKFormElement::__construct(), TKForm::__construct(), TKCheckBox::__construct(), TKPopup::__construct(), and TKSelect::addOption().

TKComponent::addExtraCSS ( slot,
css 
) [protected]

Add extra CSS to page.

For internal use only.

Parameters:
$slot [string]: unique key to identify block of CSS
$css [string]: CSS to add

Definition at line 807 of file TKComponent.php5.

References Toolkit::globalAddExtraCSS().

TKComponent::addExtraJS ( slot,
js 
) [protected]

Add extra JavaScript to page.

For internal use only.

Parameters:
$slot [string]: unique key to identify block of JavaScript
$js [string]: JavaScript to add

Definition at line 796 of file TKComponent.php5.

References Toolkit::globalAddExtraJS().

Referenced by TKTree::renderContainer().

TKComponent::addProperty ( propName,
type 
) [protected]

Adds a property to this object.

For internal use only.

Properties must be added before they can be used. Subclasses of TKComponent, which define their own new properties must call this method in the constructor before using those new properties. Properties have one of five types: numeric, string, boolean, object and array. If TKComponent::$ENABLE_PROP_TYPE_CHECKING is set to true (the default), then these types will be checked when setting and appending to properties.

Parameters:
$propName [string]: name of property
$type [int]: type of property (PROP_NUMERIC, PROP_STRING, PROP_BOOLEAN, PROP_OBJECT, PROP_ARRAY)
Returns:
[boolean] success

Definition at line 931 of file TKComponent.php5.

Referenced by __construct(), TKTextArea::__construct(), TKSelect::__construct(), TKRadioButton::__construct(), TKFormTable::__construct(), TKFormLabel::__construct(), TKFormInput::__construct(), TKFormElement::__construct(), TKForm::__construct(), TKCheckBox::__construct(), TKTree::__construct(), TKTable::__construct(), TKPopup::__construct(), TKNullBox::__construct(), TKList::__construct(), TKHBox::__construct(), TKClosePopup::__construct(), TKBorderPanel::__construct(), TKPagedView::__construct(), TKLabel::__construct(), TKIconButton::__construct(), TKHTML::__construct(), TKButton::__construct(), and TKAbstractButton::__construct().

TKComponent::append ( fldName,
value,
pre = false 
)

Appends a value to a property.

Appending means different things for different types. For numeric types, appending simply adds the two values together. This does not always make sense, so be careful when appending numeric types. Strings are concatenated. Arrays are more complicated. If the value to be appended is an array, then it is array_merge'd with the current value. If the value is not an array, then it is array_push'ed onto the end of the current value. Objects and booleans cannot be appended and an error message will be displayed.

If the $pre parameter is true, then values are prepended to the existing value. For strings, the concatenation order is reversed. Numeric values are added the same as with a false $pre. Arrays are merged or pushed onto at the opposite end, as expected.

Parameters:
$fldName [string]: name of property
$value [mixed]: value to be appended to property
$pre [boolean]: if true, value is prepended, rather than appended
Returns:
[TKComponent] current object

Definition at line 501 of file TKComponent.php5.

References SObject::setError().

Referenced by appendMany(), and TKTree::onAdd().

TKComponent::appendMany ( fields  ) 

Performs multiple append operations at once.

Pass in an array of property => value pairs and each pair will result in a call to append(). Note that you cannot affect the $pre flag of append().

Parameters:
$fields [array]: array of property => value pairs
Returns:
[TKComponent] current object

Definition at line 562 of file TKComponent.php5.

References append().

static TKComponent::convertChild ( child  )  [static, protected]

Converts XML child with TK tag to TK component.

For internal use only.

This function takes care of creating a toolkit component based on an XML tag that starts with 'TK'. Call it from within your class's createFromXML() method.

Parameters:
$child [XML]: XML to convert
Returns:
[TKComponent]: child object

Definition at line 893 of file TKComponent.php5.

static TKComponent::convertStdAttributes ( obj,
attrs 
) [static, protected]

Converts XML attributes into properties (called from your createFromXML method).

For internal use only.

The special XML attributes 'id', 'theme' and 'theme_class' are handled appropriately. All other attributes are treated as names of properties and assigned accordingly. If you do not want to have the attributes treated in such a fashion, remove them from the attrs array before passing it in to this method.

Parameters:
$obj [TKComponent]: newly created component
$attrs [array]: XML attributes associated with component's tag in TKHTML

Definition at line 823 of file TKComponent.php5.

References $theme, and exists().

static TKComponent::convertStdEvents ( obj,
node 
) [static, protected]

Converts XML event tags into toolkit events/actions (called from your createFromXML method).

For internal use only.

Gathers all event tags and creates the associated actions and then associates them with the specified events.

Parameters:
$obj [TKComponent]: newly created TK object from XML
$node [array]: XML tree representing TK object

Definition at line 870 of file TKComponent.php5.

TKComponent::enableTranslateFields ( bEnable  )  [protected]

Enable or disable automatic translation of class, style and event properties.

For internal use only.

Normally, before renderComponent() is called translateFields() is called to convert class and style properties to strings suitable for embedding into HTML and also generates JavaScript to be embedded into HTML as well. If this is not desirable because the component either doesn't need to make use of these fields, or because it will do its own translation, then the component can disable automatical translation by calling this method with 'false'.

Parameters:
$bEnable [boolean]: whether to enable or disable automatic translation of fields

Definition at line 913 of file TKComponent.php5.

TKComponent::eventExists ( eventName  ) 

Gets whether an event exists on this object.

Parameters:
$eventName [string]: name of event to check for
Returns:
[boolean] whether event exists on this object

Definition at line 681 of file TKComponent.php5.

Referenced by __isset(), __set(), and setAction().

TKComponent::exists ( fld  ) 

Returns whether a property exists.

Parameters:
$fld [string]: name of property to check existence for
Returns:
[boolean] whether that property exists

Definition at line 575 of file TKComponent.php5.

Referenced by convertStdAttributes().

& TKComponent::get ( fldName  ) 

Retrieves a given property.

You can also use $obj->prop instead of $obj->get('prop'). Additionally, there is $obj->getProp().

Parameters:
$fldName [string]: name of property to retrieve
Returns:
[mixed] value of property or null if no such property exists

Definition at line 346 of file TKComponent.php5.

References SObject::setError().

TKComponent::getAllEventJS (  )  [protected]

Retrieves all inline JavaScript for a component.

For internal use only.

Call this method from your renderComponent() method to generate all the JavaScript events and actions. The returned string can be placed directly in an HTML tag.

Returns:
[string] JavaScript attributes for embedding in HTML tag

Definition at line 1108 of file TKComponent.php5.

Referenced by translateFields().

TKComponent::getId (  ) 

TKComponent::getProperties ( values = false  ) 

Returns a list of all the properties this object has.

Returns:
[array] list of property names

Definition at line 584 of file TKComponent.php5.

TKComponent::getTheme (  ) 

Retrieves the currently active theme for this object.

Returns:
[TKTheme] the current them object for this class

Definition at line 609 of file TKComponent.php5.

TKComponent::getThemeClass (  ) 

Retrieves the current theme class for this object.

Returns:
[string] theme class name

Definition at line 631 of file TKComponent.php5.

TKComponent::mergeClasses ( names,
extra = array() 
) [protected]

Retranslates multiple class properties into one string.

For internal use only.

This will take a list of class properties, without the '_class' suffix and add any additional literal classes and then generate the standard ' class="foo bar"' string. You can use this method to modify the given class attributes in your renderComponent() or renderContainer() method. The alternative is to disable pre-translation with TKComponent::enableTranslateFields().

Parameters:
$names [array]: list of class properties without '_class'
$extra [array]: flat list of additional classes to put in the final string
Returns:
[string]: style string and described above

Definition at line 1174 of file TKComponent.php5.

References Toolkit::classToString().

TKComponent::mergeStyles ( names,
extra = array() 
) [protected]

Retranslates multiple style properties into one string.

For internal use only.

This will take a list of style properties, without the '_style' suffix and add any addition literal styles and then generate the standard ' style="foo:xxx; bar:yyy"' string. You can use this method to modify the given style attributes in your renderComponent() or renderContainer() method. The alternative is to disable pre-translation with TKComponent::enableTranslateFields().

Parameters:
$names [array]: list of style properties without '_style'
$extra [array]: associative array of additional styles to put in the final string; if any styles provided in this extra array conflict with those in the properties, the ones in the properties are overriden.
Returns:
[string]: style string and described above

Definition at line 1198 of file TKComponent.php5.

References Toolkit::styleToString().

TKComponent::onClone (  )  [protected]

Called by __clone() to perform additional cloning-related operations.

For internal use only.

If cloning requires additional work to be done for your component, you should override this method and have it do whatever additional work it needs to be done. This method is called at the end of the clone process, so you can assume properties, events, etc. have already been cloned as best the default __clone() method can do.

Definition at line 776 of file TKComponent.php5.

Referenced by __clone().

TKComponent::removeEvent ( eventName  )  [protected]

Removes an event already defined for this object.

For internal use only.

In general, this only needs to be called to remove events valid for the parent class, but not for this class. You should never need to remove large numbers of events. If that is the case, then it is better to rethink your class's parentage.

Parameters:
$eventName [string]: name of event to remove
Returns:
[boolean] success

Definition at line 1084 of file TKComponent.php5.

TKComponent::removePropChangeListener ( prop  )  [protected]

Removes an already registered property change listener.

For internal use only.

If there was a previously registered property change listener, it is better to use setPropChangeListener() to restore it, than this function which will set the listener to null.

Parameters:
$prop [string]: name of property to remove listener for
Returns:
[boolean]: success

Definition at line 1021 of file TKComponent.php5.

References SObject::setWarning().

TKComponent::removeProperty ( propName  )  [protected]

Removes an existing property.

For internal use only.

Only call this function if a parent class's property does not make sense for the subclass. In general, however, you might want to rethink which class is the parent class if you end up using a large number of removeProperty() calls in your constructor.

Parameters:
$propName [string]: name of property to remove
Returns:
[boolean] success

Definition at line 975 of file TKComponent.php5.

Referenced by TKHTML::__construct().

TKComponent::render (  ) 

Converts this component (and any children) to HTML.

This will only actually generate the HTML once. If render() has been called before, this will only return the results of the previous render operation.

Returns:
[string] HTML from rendering, or false if there was an error rendering

Reimplemented in TKCSERDClassicReview, TKSDRResourceResultMetadata, and TKSDRResourceResultSet.

Definition at line 693 of file TKComponent.php5.

References $id, renderComponent(), and translateFields().

Referenced by __get(), TKPagedView::handleAjax(), and TKForm::renderContainer().

TKComponent::renderComponent ( class,
style,
events,
id 
) [abstract, protected]

Called when rendering; should be overridden by descendent components.

For internal use only.

This method is called only once to render an object. Future calls to render() will not call renderComponent() again. Thus, it can make assumptions that are only valid if it is called once per page load.

The toolkit pre-translates a number of common items so that they can be easily used when rendering. All classes and styles are pretranslated into ' class='...'' and ' style='...'' strings, as are events and the object id. $class[0] contains the contents of the 'class' property translated via Toolkit::classToString(). Similarly, $style[0] contains the contents of the 'style' property translated via Toolkit::styleToString. Additional classes and styles are contained in the array, to be referenced like $class['cell'] for the property 'cell_class'. The event JavaScript is a single self-contained string, that need not be modified.

Parameters:
$class [array]: array of pre-translated class properties
$style [array]: array of pre-translated style properties
$events [string]: all event JavaScript that should go inline
$id [string]: pre-translated ID of object (e.g., ' id='id27'')

Reimplemented in TKButton, TKHTML, TKIconButton, TKLabel, TKNCSILink, TKCheckBox, TKFormInput, TKFormLabel, TKRadioButton, TKSelect, TKTextArea, and TKContainer.

Referenced by render().

TKComponent::set ( fldName,
value 
)

Sets a property.

Each property has a type, of which there are five:

  1. String
  2. Numeric (string representing a number or a numeric value)
  3. Boolean
  4. Array
  5. Object
When setting a property you must provide a value that is of the right type, or an error will be indicated. Setting a property also completely erases the existing value. Use append() to append to or merge an array with the existing value of a property. If the property is an array, but the value is not, then the value is put inside an array and that is assigned to the property.

Parameters:
$fldName [string]: name of property
$value [mixed]: new value of property
Returns:
[TKComponent] this object

Definition at line 373 of file TKComponent.php5.

References SObject::setError().

TKComponent::setAction ( eventName,
action 
)

Associates an action with an event.

This function sets an action to happen when an event occurs. Read more about events and actions at Themes. Note that more than one action can be associated with an event and multiple actions will be executed in the order that they were assigned with setAction(). You can also use the shorthand notation to set events: $comp->onclick = new TKSomeAction(...) instead of setAction().

The action can be an instance of TKAction or its children, or it can be a string of JavaScript, or an array of two strings. The first string is JavaScript that will be inserted into the header of the page. The second string is JavaScript that will go directly in the event handler.

Parameters:
$eventName [string]: name of event
$action [TKAction]: action to be associated with event (can also be string or array.
Returns:
[boolean] success

Definition at line 652 of file TKComponent.php5.

References eventExists(), and SObject::setError().

Referenced by TKSelect::__construct(), TKRadioButton::__construct(), TKCheckBox::__construct(), and __set().

TKComponent::setId ( id  ) 

Sets a new ID for the object.

The ID should be unique, or the HTML generated will not be valid (although it will likely work). What won't work is any JavaScript based on the objects that have non-unique IDs. This function will also *try* to update any references to the ID in use. Unfortunately, the ID may be used in places out of direct control of this object, such as generated JS, so it is best to avoid calling this method if you are using strange TK actions or some other strange set up. Be prepared for subtle bugs, as well.

Parameters:
$id [string]: new ID for object

Definition at line 728 of file TKComponent.php5.

References $id, and Toolkit::setObjectId().

Referenced by TKPagedView::__construct().

TKComponent::setMany ( fields  ) 

Calls set() many times.

You pass in an array where the keys are properties to set and the values are the new values for those properties.

Parameters:
$fields [array]: property names and the associated values
Returns:
[TKComponent] this object

Definition at line 473 of file TKComponent.php5.

TKComponent::setPropChangeListener ( prop,
fn 
) [protected]

Adds a callback to be called when property changes.

For internal use only.

The callback will be called when a property changes. If the callback returns TRUE, then the property change is allowed to continue, otherwise it is 'vetoed'. The callback can also change the incoming value if it so chooses. Avoid using too many change listeners as they slow down Toolkit performance since they are called on every property change.

Parameters:
$prop [string]: name of property
$fn [callback]: function to call when prop changes; prototype: mylistener($prop,$newValue)
Returns:
[callback]: old callback for property, null if there was no previous one or false on failure

Definition at line 999 of file TKComponent.php5.

References SObject::setWarning().

Referenced by TKSelect::__construct().

TKComponent::setTheme ( theme  ) 

Sets the toolkit theme for this object.

To change the theme for all objects, call TKComponent::setDefaultTheme() or PageRender2::setToolkitTheme(). See Themes for more information on themes.

Parameters:
$theme [TKTheme] new theme object

Definition at line 600 of file TKComponent.php5.

References $theme.

TKComponent::setThemeClass ( class  ) 

Sets the theme class for this object.

The theme class is basically a way of specifying a category of objects within a given component class. For example, while there is only the TKLabel class, we might still want to have multiple types of TKLabel's, for themeing purposes.

Parameters:
$class [string]: theme class name

Definition at line 622 of file TKComponent.php5.

TKComponent::translateClass ( name,
extra = array() 
) [protected]

Retranslates a class property into a HTML string.

For internal use only.

This will take a class property, which is named "{$name}_class", adds to it any additional classes from the $extra array and then converts it to a string of the form class="foo bar baz" using the Toolkit::classToString() method.

If the name of the class property is simply "class", then the $name parameter should be 0.

Parameters:
$name [string]: name of class property without the trailing "_class"
$extra [array]: flat list of additional classes to put in the final string
Returns:
[string]: class string as described above

Definition at line 1135 of file TKComponent.php5.

References Toolkit::classToString().

Referenced by TKList::renderListItem().

TKComponent::translateFields ( extraClasses = array(),
extraStyles = array() 
) [protected]

Translates class, style and event properties to HTML strings.

For internal use only.

This method finds all properties that represent classes and styles and converts them to the appropriate ' class="foo bar"' and ' style="bar:xxx; baz:yyy"' style strings and puts those strings in arrays. It also generates event HTML. Note that while class and style generation are idempotent, event generation is not. Each call to generate events triggers code to be run in the TK action classes. The classes should be using the appropriate methods to make sure that JavaScript is not generated twice, but this is not guaranteed. As such, this method should only be called once when rendering a component.

It is usually called before renderComponent() is called. However, if you disable automatic field translation by calling enableTranslateFields(false), then it will not be called before renderComponent and must be called manually (or alternative means can be used to get class, style and event information).

You can provide extra classes and styles to this method, above and beyond those that are provided by the properties. Each entry in the $extraClasses or $extraStyles array must be an array appropriate for classes or styles, respectively, and the name of that index in the outer array should be the property name minus the trailing "_class" or "_style". For the simple "class" and "style" properties, the index should be 0. Essentially, the naming follows the conventions of what you get as the arguments to renderComponent().

Parameters:
$extraClasses [array]: additional classes to add to each property (see description above)
$extraStyles [array]: additional styles to add to each property
Returns:
[array]: the array contains four items (flat array, not associative):
  1. array of class strings, as would be passed into renderComponent()
  2. array of style strings, as would be passed into renderComponent()
  3. JavaScript for events, as would be passed into renderComponent()
  4. the component ID, converted to a string of the form ' id="<id>"'

Definition at line 1240 of file TKComponent.php5.

References getAllEventJS().

Referenced by render().

TKComponent::translateStyle ( name,
extra = array() 
) [protected]

Retranslates a style property into a HTML string.

For internal use only.

This will take a style property, which is named "{$name}_style", adds to it any additional styles from the $extra array and then converts it to a string of the form style="foo:xxx; bar:yyy; baz:zzz" using the Toolkit::styleToString() method.

If the name of the style property is simply "style", then the $name parameter should be 0.

Parameters:
$name [string]: name of style property without the trailing "_style"
$extra [array]: associative array of additional styles to put in the final string; if any styles provided in this extra array conflict with those in the property, the ones in the property are overridden.
Returns:
[string]: style string as described above

Definition at line 1156 of file TKComponent.php5.

References Toolkit::styleToString().

Referenced by TKList::renderListItem().


Member Data Documentation

TKComponent::$bTranslateFields [private]

If true, render() pre-translates class/style properties (see enableTranslateFields()).

For internal use only.

Definition at line 72 of file TKComponent.php5.

TKComponent::$directEvents [private]

JavaScript events and actions array.

For internal use only.

Definition at line 42 of file TKComponent.php5.

TKComponent::$eventExtra [private]

Additional information about events (to keep other arrays cleaner).

For internal use only.

Definition at line 48 of file TKComponent.php5.

Referenced by addEvent().

TKComponent::$hasActions [private]

If true, object has actions associated with events and needs to generate JS.

For internal use only.

Definition at line 51 of file TKComponent.php5.

TKComponent::$html [private]

TKComponent::$id [private]

TKComponent::$indirectEvents [private]

Indirect/custom events and actions array.

For internal use only.

Definition at line 45 of file TKComponent.php5.

TKComponent::$NULL_VALUE [static, private]

This is only needed because nulls need to be able to be returned by reference.

For internal use only.

Definition at line 103 of file TKComponent.php5.

TKComponent::$parent [private]

Parent component, or null if component has no parent.

For internal use only.

Definition at line 38 of file TKComponent.php5.

Referenced by TKTree::addItemsTo(), and TKTree::onAdd().

TKComponent::$properties [private]

Component properties array and their values.

For internal use only.

Definition at line 55 of file TKComponent.php5.

TKComponent::$propListeners [private]

Maps property names to callbacks that monitor property changes.

For internal use only.

Definition at line 61 of file TKComponent.php5.

TKComponent::$propTypes [private]

Maps property names to type information about property.

For internal use only.

Definition at line 58 of file TKComponent.php5.

TKComponent::$theme [private]

TKTheme (or derivative) associated with this component.

For internal use only.

Definition at line 65 of file TKComponent.php5.

Referenced by convertStdAttributes(), and setTheme().

TKComponent::$themeClass [private]

Theme class (see Themes).

For internal use only.

Definition at line 68 of file TKComponent.php5.

Event is direct (regular JavaScript event).

For internal use only.

Definition at line 96 of file TKComponent.php5.

Event is indirect (triggered by another TK event).

For internal use only.

Definition at line 99 of file TKComponent.php5.


The documentation for this class was generated from the following file:

Generated on Wed Nov 24 02:06:55 2010 for Common by  doxygen 1.5.6