Stud.IP
6.0
|
Public Member Functions | |
__construct ($title, $url=NULL, $params=NULL) | |
initItem () | |
getImage () | |
getImageTag () | |
getTitle () | |
getDescription () | |
getURL () | |
getBadgeNumber () | |
getBadgeTimestamp () | |
hasBadgeNumber () | |
isActive () | |
isEnabled () | |
isVisible ($needs_image=false) | |
setActive ($active) | |
setEnabled ($enabled) | |
setImage (?\Icon $image) | |
setActiveImage (?\Icon $image) | |
setLinkAttributes ($attributes) | |
getLinkAttributes () | |
setTitle ($title) | |
setDescription ($description) | |
setURL ($url, $params=NULL) | |
setBadgeNumber ($badgeNumber) | |
setBadgeTimestamp ($badgeTimestamp) | |
activeSubNavigation () | |
addSubNavigation ($name, Navigation $navigation) | |
insertSubNavigation ($name, Navigation $navigation, $where) | |
getSubNavigation () | |
removeSubNavigation ($name) | |
getIterator () | |
Static Public Member Functions | |
static | activateItem ($path) |
static | addItem ($path, Navigation $navigation) |
static | insertItem ($path, Navigation $navigation, $where) |
static | removeItem ($path) |
static | getItem ($path) |
static | hasItem ($path) |
static | setRootNavigation (Navigation $navigation) |
Protected Member Functions | |
initSubNavigation () | |
Protected Attributes | |
$active | |
$enabled | |
$initialized = false | |
$active_image | |
$badgeNumber | |
$badgeTimestamp | |
$description | |
$image | |
$link_attributes = [] | |
$params | |
$subnav | |
$title | |
$url | |
This is the navigation base class that maintains the global navigation structure. All navigation objects are stored in a tree and can be accessed by their "path names", just like file names in a normal file system. The "root" of the tree is '/'.
So you can do for example:
$navigation = new Navigation('Home', 'index.php'); $profilenav = new Navigation('Profile', 'profile.php');
$navigation->addSubNavigation('profile', $profilenav);
Navigation::addItem('/home', $navigation); Navigation::activateItem('/home/profile');
__construct | ( | $title, | |
$url = NULL , |
|||
$params = NULL |
|||
) |
Initialize a new Navigation instance with the given title and URL (optional).
|
static |
Mark the navigation item at the given path as active. This is just a shortcut for doing:
Navigation::getItem($path)->setActive(true)
string | $path | path of navigation item |
activeSubNavigation | ( | ) |
Get the active subnavigation item of this navigation (if there is one). Returns NULL if the subnavigation has no active item.
|
static |
Add a new navigation item at the given path. If there is already an item with this path, the old one is replaced by the new item.
string | $path | path of new navigation item |
object | $navigation | navigation item to add |
addSubNavigation | ( | $name, | |
Navigation | $navigation | ||
) |
Add the given item to the subnavigation of this object. This also assigns a name to this subnavigation item. If there is already a subitem with this name, the old one is replaced by the new item.
string | $name | name of new navigation item |
object | $navigation | navigation item to add |
getBadgeNumber | ( | ) |
Return the badge number of this navigation item.
getBadgeTimestamp | ( | ) |
Return the badge number of this navigation item.
getDescription | ( | ) |
Return the description associated with this navigation item.
getImage | ( | ) |
getImageTag | ( | ) |
Shorthand method for creating an appropriate image tag for display.
|
static |
Return the navigation item at the given path.
string | $path | path of navigation item |
InvalidArgumentException | if the item cannot be found |
getIterator | ( | ) |
IteratorAggregate: Create iterator for request parameters.
getLinkAttributes | ( | ) |
Return the attributes that should be used in the link element surrounding this item's icon image.
getSubNavigation | ( | ) |
Return the list of subnavigation items of this object.
getTitle | ( | ) |
Return the current title associated with this navigation item.
getURL | ( | ) |
Return the current URL associated with this navigation item. If not URL is set but there are subnavigation items, the URL of the first visible subnavigation item is returned.
hasBadgeNumber | ( | ) |
Determines whether this navigation item has a badge number.
|
static |
Test whether there is a navigation item at the given path.
string | $path | path of navigation item |
initItem | ( | ) |
used to defer initialization of item metadata, override in subclasses if initialization is costly
|
protected |
Initialize the subnavigation of this item. This method is called once before the first item is added or removed.
|
static |
Add a new navigation item at the given path. The new item is inserted immediately before the item with the name given by $where (at the same level in the tree).
string | $path | path of new navigation item |
object | $navigation | navigation item to add |
string | $where | insert it before this item |
insertSubNavigation | ( | $name, | |
Navigation | $navigation, | ||
$where | |||
) |
Add the given item to the subnavigation of this object. The new item is inserted immediately before the item with the name given by $where (if there is one, it is appended to the end otherwise). This also assigns a name to this subnavigation item.
string | $name | name of new navigation item |
object | $navigation | navigation item to add |
string | $where | insert it before this item |
isActive | ( | ) |
Determine whether this navigation item is active.
isEnabled | ( | ) |
Return whether this navigation item is enabled.
isVisible | ( | $needs_image = false | ) |
Return whether this navigation item is visible.
boolean | $needs_image | requires an image |
|
static |
Remove the navigation item at the given path (if there is an item with this path).
string | $path | path of item to remove |
removeSubNavigation | ( | $name | ) |
Remove the given item from the subnavigation of this object (if there is an item with this name).
string | $name | name of item to remove |
setActive | ( | $active | ) |
Set the active status of this item. This can be used to override heuristics used by the class to determine this automatically.
boolean | $active | new active status |
setActiveImage | ( | ?\Icon | $image | ) |
Set the image for the active state of this navigation item. If no active image is set, the normal image is used for the active state.
\Icon | null | $image | an instance of class Icon depicting this item or null to remove the image |
setBadgeNumber | ( | $badgeNumber | ) |
Set the badge number of this navigation item.
string | $badgeNumber | the badge number |
setBadgeTimestamp | ( | $badgeTimestamp | ) |
Set the badge number of this navigation item.
string | $badgeNumber | the badge number |
setDescription | ( | $description | ) |
Set the description of this navigation item.
string | $description | description text |
setEnabled | ( | $enabled | ) |
Set the enabled status of this item. Disabled items are still visible but cannot be clicked.
boolean | $enabled | new enabled status |
setImage | ( | ?\Icon | $image | ) |
Set the image of this navigation item.
\Icon | null | $image | an instance of class Icon depicting this item or null to remove the image |
setLinkAttributes | ( | $attributes | ) |
Set the attributes that should be used in the link element surrounding this item's icon image.
array | $attributes | the attributes to pass to the surrounding link element |
|
static |
Set the root of the navigation tree. Must be called before any further items can be added to the tree.
object | $navigation | root navigation item |
setTitle | ( | $title | ) |
Set the title of this navigation item.
string | $title | display title |
setURL | ( | $url, | |
$params = NULL |
|||
) |
Set the URL of this navigation item. Additional URL parameters can be passed using the (optional) second parameter.
string | $title | display title |
array | $params | additional URL parameters |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |