silverorange Code


Swat.SwatMenuItem
/Swat/SwatMenuItem.php at line 27

Class SwatMenuItem

SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatMenuItem

public class SwatMenuItem
extends SwatControl

An item in a menu

SwatMenuItem objects may be added to SwatMenu or SwatMenuGroup widgets.

Copyright:
2007 silverorange
License:
http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
See Also:
SwatMenu
SwatMenuGroup

Field Summary
string

$link

The URI-reference (see RFC2396) linked by this menu item.

protected string

$stock_class

A CSS class set by the stock_id of this menu item.

string

$stock_id

The stock id of this menu item.

protected SwatAbstractMenu

$sub_menu

The sub menu of this menu item.

string

$title

The user-visible title of this menu item.

array|string

$value

A value or array of values to substitute into the link property of this menu item.

Method Summary
void

addChild(SwatAbstractMenu 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 menu item.

protected void

displaySubMenu()

Displays this menu item's sub-menu.

protected array

getCSSClassNames()

Gets the array of CSS classes that are applied to this menu item.

array

getDescendantStates()

Gets descendant states.

array

getDescendants(string class_name)

Gets descendant UI-objects.

SwatUIObject

getFirstDescendant(string class_name)

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

void

init()

Initializes this menu item.

void

setDescendantStates(array states)

Sets descendant states.

void

setFromStock(string stock_id, boolean overwrite_properties)

Sets the values of this menu item to a stock type.

void

setSubMenu(SwatAbstractMenu menu)

Sets the sub-menu of this menu item.

Methods inherited from Swat.SwatControl
addMessage, getNote, printWidgetTree
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/SwatMenuItem.php at line 45
public string $link

The URI-reference (see RFC2396) linked by this menu item

If no link is specified, this menu item does not link to anything.

Optionally uses vsprintf() syntax, for example:

<?php
$item
->link 'MySection/MyPage/%s?id=%s';
?>

See Also:
SwatMenuItem::$value

/Swat/SwatMenuItem.php at line 98

stock_class

protected string $stock_class = null

A CSS class set by the stock_id of this menu item


/Swat/SwatMenuItem.php at line 79

stock_id

public string $stock_id = null

The stock id of this menu item

Specifying a stock id initializes this menu item with a set of stock values.

See Also:
SwatToolLink::setFromStock()

/Swat/SwatMenuItem.php at line 91
protected SwatAbstractMenu $sub_menu

The sub menu of this menu item

See Also:
SwatMenuItem::setSubMenu()

/Swat/SwatMenuItem.php at line 67

title

public string $title

The user-visible title of this menu item


/Swat/SwatMenuItem.php at line 60

value

public array|string $value

A value or array of values to substitute into the link property of this menu item

The value property may be specified either as an array of values or as a single value. If an array is passed, a call to vsprintf() is done on the SwatMenuItem::$link property. If the value is a string a single sprintf() call is made.

See Also:
SwatMenuItem::$link

Method Detail

/Swat/SwatMenuItem.php at line 133

addChild

public void addChild(SwatAbstractMenu 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 set the sub-menu for a menu item, use SwatMenuItem::setSubMenu().

Parameters:
child - the child object to add.
Throws:
SwatInvalidClassException
if this menu item already has a sub-menu.
See Also:
SwatUIParent
SwatMenuItem::setSubMenu()

/Swat/SwatMenuItem.php at line 414

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/SwatMenuItem.php at line 173

display

public void display()

Displays this menu item

If this item has a sub-menu, the sub-menu is also displayed.


/Swat/SwatMenuItem.php at line 433

displaySubMenu

protected void displaySubMenu()

Displays this menu item's sub-menu


/Swat/SwatMenuItem.php at line 448

getCSSClassNames

protected array getCSSClassNames()

Gets the array of CSS classes that are applied to this menu item

Returns:
the array of CSS classes that are applied to this menu item.
See Also:
SwatUIObject::getCSSClassString()

/Swat/SwatMenuItem.php at line 371

getDescendantStates

public array getDescendantStates()

Gets descendant states

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

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

/Swat/SwatMenuItem.php at line 305

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 menu item. If descendant objects have identifiers, the identifier is used as the array key.
See Also:
SwatUIParent::getDescendants()

/Swat/SwatMenuItem.php at line 343

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 widget or null if no matching descendant is found.
See Also:
SwatUIParent::getFirstDescendant()

/Swat/SwatMenuItem.php at line 154

init

public void init()

Initializes this menu item


/Swat/SwatMenuItem.php at line 393

setDescendantStates

public void setDescendantStates(array states)

Sets descendant states

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

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

/Swat/SwatMenuItem.php at line 229

setFromStock

public void setFromStock(string stock_id, boolean overwrite_properties)

Sets the values of this menu item to a stock type

Valid stock type ids are:

Parameters:
stock_id - the identifier of the stock type to use.
overwrite_properties - whether to overwrite properties if they are already set.
Throws:
SwatUndefinedStockTypeException

/Swat/SwatMenuItem.php at line 108

setSubMenu

public void setSubMenu(SwatAbstractMenu menu)

Sets the sub-menu of this menu item

Parameters:
menu - the sub-menu for this menu item.

silverorange Code