silverorange Code


Swat.SwatContainer
/Swat/SwatContainer.php at line 18

Class SwatContainer

SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatContainer

public class SwatContainer
extends SwatWidget

Swat container widget

Used as a base class for widgets which contain other widgets.

Copyright:
2004-2006 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1

Field Summary
protected array

$children

Children widgets.

protected array

$children_by_id

Children widgets indexed by id.

Fields inherited from Swat.SwatWidget
displayed, id, initialized, messages, processed, requires_id, sensitive, stylesheet
Fields inherited from Swat.SwatUIObject
classes, html_head_entry_set, parent, visible
Method Summary
void

add(SwatWidget widget)

Adds a widget.

void

addChild(SwatWidget child)

Adds a child object.

SwatUIObject

copy(string id_suffix)

Performs a deep copy of the UI tree starting with this UI object.

void

display()

Displays this container by calling SwatWidget::display() on all children.

protected void

displayChildren()

Displays the child widgets of this container.

SwatWidget

getChild(string id)

Gets a child widget.

array

getChildren(string class_name)

Gets all child widgets.

array

getDescendantStates()

Gets descendant states.

array

getDescendants(string class_name)

Gets descendant UI-objects.

SwatWidget

getFirst()

Gets the first child widget.

SwatUIObject

getFirstDescendant(string class_name)

Gets the first descendant UI-object of a specific class.

string

getFocusableHtmlId()

Gets the id attribute of the XHTML element displayed by this widget that should receive focus.

SwatHtmlHeadEntrySet

getHtmlHeadEntrySet()

Gets the SwatHtmlHeadEntry objects needed by this container.

array

getMessages()

Gets all messages.

boolean

hasMessage()

Checks for the presence of messages.

void

init()

Initializes this widget.

protected void

notifyOfAdd(SwatWidget widget)

Notifies this widget that a widget was added.

void

packEnd(SwatWidget widget)

Adds a widget to end.

void

packStart(SwatWidget widget)

Adds a widget to start.

void

printWidgetTree()

void

process()

Processes this container by calling SwatWidget::process() on all children.

SwatWidget

remove(SwatWidget widget)

Removes a widget.

SwatWidget

replace(SwatWidget widget, mixed new_widget)

Replace a widget.

protected void

sendAddNotifySignal(SwatWidget widget)

Sends the notification signal up the widget tree.

void

setDescendantStates(array states)

Sets descendant states.

Methods inherited from Swat.SwatWidget
addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer
Methods inherited from Swat.SwatUIObject
addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible

Field Detail

/Swat/SwatContainer.php at line 29

children

protected array $children = array()

Children widgets

An array containing the widgets that belong to this container.


/Swat/SwatContainer.php at line 39

children_by_id

protected array $children_by_id = array()

Children widgets indexed by id

An array containing widgets indexed by their id. This array only contains widgets that have a non-null id.


Method Detail

/Swat/SwatContainer.php at line 71

add

public void add(SwatWidget widget)

Adds a widget

Adds a widget as a child of this container. The widget must not have a parent already. The parent of the added widget is set to reference this container.

Parameters:
widget - a reference to the widget to add.

/Swat/SwatContainer.php at line 473

addChild

public void addChild(SwatWidget child)

Adds a child object

This method fulfills the SwatUIParent interface. It is used by SwatUI when building a widget tree and should not need to be called elsewhere. To add a widget to a container use SwatContainer::add().

Parameters:
child - a reference to the child object to add.
Throws:
SwatInvalidClassException

/Swat/SwatContainer.php at line 568

copy

public SwatUIObject copy(string id_suffix)

Performs a deep copy of the UI tree starting with this UI object

Parameters:
id_suffix - optional. A suffix to append to copied UI objects in the UI tree.
Returns:
a deep copy of the UI tree starting with this UI object.
See Also:
SwatUIObject::copy()

/Swat/SwatContainer.php at line 401

display

public void display()

Displays this container by calling SwatWidget::display() on all children


/Swat/SwatContainer.php at line 594

displayChildren

protected void displayChildren()

Displays the child widgets of this container

Subclasses that override the display method will typically call this method to display child widgets.


/Swat/SwatContainer.php at line 204

getChild

public SwatWidget getChild(string id)

Gets a child widget

Retrieves a widget from the list of widgets in the container based on the unique identifier of the widget.

Parameters:
id - the unique id of the widget to look for.
Returns:
the found widget or null if not found.

/Swat/SwatContainer.php at line 248

getChildren

public array getChildren(string class_name)

Gets all child widgets

Retrieves an array of all widgets directly contained by this container.

Parameters:
class_name - optional class name. If set, only widgets that are instances of $class_name are returned.
Returns:
the child widgets of this container.

/Swat/SwatContainer.php at line 350

getDescendantStates

public array getDescendantStates()

Gets descendant states

Retrieves an array of states of all stateful UI-objects in the widget subtree below this container.

Returns:
an array of UI-object states with UI-object identifiers as array keys.

/Swat/SwatContainer.php at line 278

getDescendants

public array getDescendants(string class_name)

Gets descendant UI-objects

Parameters:
class_name - optional class name. If set, only UI-objects that are instances of $class_name are returned.
Returns:
the descendant UI-objects of this container. If descendant objects have identifiers, the identifier is used as the array key.
See Also:
SwatUIParent::getDescendants()

/Swat/SwatContainer.php at line 224

getFirst

public SwatWidget getFirst()

Gets the first child widget

Retrieves the first child widget from the list of widgets in the container.

Returns:
the first widget in this container or null if there are no widgets in this container.

/Swat/SwatContainer.php at line 315

getFirstDescendant

public SwatUIObject getFirstDescendant(string class_name)

Gets the first descendant UI-object of a specific class

Parameters:
class_name - class name to look for.
Returns:
the first descendant UI-object or null if no matching descendant is found.
See Also:
SwatUIParent::getFirstDescendant()

/Swat/SwatContainer.php at line 519

getFocusableHtmlId

public string getFocusableHtmlId()

Gets the id attribute of the XHTML element displayed by this widget that should receive focus

Returns:
the id attribute of the XHTML element displayed by this widget that should receive focus or null if there is no such element.
See Also:
SwatWidget::getFocusableHtmlId()

/Swat/SwatContainer.php at line 496

getHtmlHeadEntrySet

public SwatHtmlHeadEntrySet getHtmlHeadEntrySet()

Gets the SwatHtmlHeadEntry objects needed by this container

Returns:
the {@link SwatHtmlHeadEntry} objects needed by this container.
See Also:
SwatUIObject::getHtmlHeadEntrySet()

/Swat/SwatContainer.php at line 421

getMessages

public array getMessages()

Gets all messages

Returns:
an array of gathered {@link SwatMessage} objects.
See Also:
SwatWidget::getMessages()

/Swat/SwatContainer.php at line 442

hasMessage

public boolean hasMessage()

Checks for the presence of messages

Returns:
true if this container or the subtree below this container has one or more messages.
See Also:
SwatWidget::hasMessage()

/Swat/SwatContainer.php at line 51

init

public void init()

Initializes this widget

Recursively initializes children widgets.

See Also:
SwatWidget::init()

/Swat/SwatContainer.php at line 611

notifyOfAdd

protected void notifyOfAdd(SwatWidget widget)

Notifies this widget that a widget was added

This widget may want to adjust itself based on the widget added or any of the widgets children.

Parameters:
widget - the widget that has been added.

/Swat/SwatContainer.php at line 176

packEnd

public void packEnd(SwatWidget widget)

Adds a widget to end

Adds a widget to the end of the list of widgets in this container.

Parameters:
widget - a reference to the widget to add.

/Swat/SwatContainer.php at line 151

packStart

public void packStart(SwatWidget widget)

Adds a widget to start

Adds a widget to the start of the list of widgets in this container.

Parameters:
widget - a reference to the widget to add.

/Swat/SwatContainer.php at line 538

printWidgetTree

public void printWidgetTree()

Todo:
document me

/Swat/SwatContainer.php at line 386

process

public void process()

Processes this container by calling SwatWidget::process() on all children


/Swat/SwatContainer.php at line 125

remove

public SwatWidget remove(SwatWidget widget)

Removes a widget

Removes a child widget from this container. The parent of the widget is set to null.

Parameters:
widget - a reference to the widget to remove.
Returns:
a reference to the removed widget, or null if the widget is not found.

/Swat/SwatContainer.php at line 91

replace

public SwatWidget replace(SwatWidget widget, mixed new_widget)

Replace a widget

Replaces a child widget in this container. The parent of the removed widget is set to null.

Parameters:
widget - a reference to the widget to be replaced.
widget - a reference to the new widget.
Returns:
a reference to the removed widget, or null if the widget is not found.

/Swat/SwatContainer.php at line 626

sendAddNotifySignal

protected void sendAddNotifySignal(SwatWidget widget)

Sends the notification signal up the widget tree

This container is notified of the added widget and then this method is called on the container parent.

Parameters:
widget - the widget that has been added.

/Swat/SwatContainer.php at line 372

setDescendantStates

public void setDescendantStates(array states)

Sets descendant states

Sets states on all stateful UI-objects in the widget subtree below this container.

Parameters:
states - an array of UI-object states with UI-object identifiers as array keys.

silverorange Code