Stud.IP  5.4
Navigation Class Reference
Inheritance diagram for Navigation:
AdminNavigation AutoNavigation AvatarNavigation BrowseNavigation CalendarNavigation CommunityNavigation ConsultationNavigation ContentsNavigation CourseNavigation FilesNavigation FooterNavigation DummyNavigation LoginNavigation MessagingNavigation MVVNavigation MVVSearchNavigation OERNavigation ProfileNavigation ResourceNavigation SearchNavigation StartNavigation StudipNavigation ToolsNavigation

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
 

Detailed Description

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');

Constructor & Destructor Documentation

◆ __construct()

__construct (   $title,
  $url = NULL,
  $params = NULL 
)

Initialize a new Navigation instance with the given title and URL (optional).

Member Function Documentation

◆ activateItem()

static activateItem (   $path)
static

Mark the navigation item at the given path as active. This is just a shortcut for doing:

Navigation::getItem($path)->setActive(true)

Parameters
string$pathpath of navigation item

◆ activeSubNavigation()

activeSubNavigation ( )

Get the active subnavigation item of this navigation (if there is one). Returns NULL if the subnavigation has no active item.

◆ addItem()

static addItem (   $path,
Navigation  $navigation 
)
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.

Parameters
string$pathpath of new navigation item
object$navigationnavigation item to add

◆ addSubNavigation()

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.

Parameters
string$namename of new navigation item
object$navigationnavigation item to add

◆ getBadgeNumber()

getBadgeNumber ( )

Return the badge number of this navigation item.

Returns
int the badge number

◆ getBadgeTimestamp()

getBadgeTimestamp ( )

Return the badge number of this navigation item.

Returns
int the badge number

◆ getDescription()

getDescription ( )

Return the description associated with this navigation item.

Returns
string description of item or NULL (no description set)

◆ getImage()

getImage ( )

Return the current image associated with this navigation item.

Returns
Icon an instance of class Icon depicting this item or NULL

◆ getImageTag()

getImageTag ( )

Shorthand method for creating an appropriate image tag for display.

Returns
string HTML tag snippet for the image

◆ getItem()

static getItem (   $path)
static

Return the navigation item at the given path.

Parameters
string$pathpath of navigation item
Returns
self
Exceptions
InvalidArgumentExceptionif the item cannot be found

◆ getIterator()

getIterator ( )

IteratorAggregate: Create interator for request parameters.

◆ getLinkAttributes()

getLinkAttributes ( )

Return the attributes that should be used in the link element surrounding this item's icon image.

Returns
array the attributes to pass to the surrounding link element

◆ getSubNavigation()

getSubNavigation ( )

Return the list of subnavigation items of this object.

◆ getTitle()

getTitle ( )

Return the current title associated with this navigation item.

Returns
string title of item or NULL (no title set)

◆ getURL()

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.

Returns
string url of item or NULL (no URL set)

◆ hasBadgeNumber()

hasBadgeNumber ( )

Determines whether this navigation item has a badge number.

◆ hasItem()

static hasItem (   $path)
static

Test whether there is a navigation item at the given path.

Parameters
string$pathpath of navigation item

◆ initItem()

initItem ( )

used to defer initialization of item metadata, override in subclasses if initialization is costly

◆ initSubNavigation()

initSubNavigation ( )
protected

Initialize the subnavigation of this item. This method is called once before the first item is added or removed.

◆ insertItem()

static insertItem (   $path,
Navigation  $navigation,
  $where 
)
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).

Parameters
string$pathpath of new navigation item
object$navigationnavigation item to add
string$whereinsert it before this item

◆ insertSubNavigation()

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.

Parameters
string$namename of new navigation item
object$navigationnavigation item to add
string$whereinsert it before this item

◆ isActive()

isActive ( )

Determine whether this navigation item is active.

◆ isEnabled()

isEnabled ( )

Return whether this navigation item is enabled.

◆ isVisible()

isVisible (   $needs_image = false)

Return whether this navigation item is visible.

Parameters
boolean$needs_imagerequires an image

◆ removeItem()

static removeItem (   $path)
static

Remove the navigation item at the given path (if there is an item with this path).

Parameters
string$pathpath of item to remove

◆ removeSubNavigation()

removeSubNavigation (   $name)

Remove the given item from the subnavigation of this object (if there is an item with this name).

Parameters
string$namename of item to remove

◆ setActive()

setActive (   $active)

Set the active status of this item. This can be used to override heuristics used by the class to determine this automatically.

Parameters
boolean$activenew active status

◆ setActiveImage()

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.

Parameters
\Icon | null$imagean instance of class Icon depicting this item or null to remove the image

◆ setBadgeNumber()

setBadgeNumber (   $badgeNumber)

Set the badge number of this navigation item.

Parameters
string$badgeNumberthe badge number

◆ setBadgeTimestamp()

setBadgeTimestamp (   $badgeTimestamp)

Set the badge number of this navigation item.

Parameters
string$badgeNumberthe badge number

◆ setDescription()

setDescription (   $description)

Set the description of this navigation item.

Parameters
string$descriptiondescription text

◆ setEnabled()

setEnabled (   $enabled)

Set the enabled status of this item. Disabled items are still visible but cannot be clicked.

Parameters
boolean$enablednew enabled status

◆ setImage()

setImage ( ?\Icon  $image)

Set the image of this navigation item.

Parameters
\Icon | null$imagean instance of class Icon depicting this item or null to remove the image

◆ setLinkAttributes()

setLinkAttributes (   $attributes)

Set the attributes that should be used in the link element surrounding this item's icon image.

Parameters
array$attributesthe attributes to pass to the surrounding link element

◆ setRootNavigation()

static setRootNavigation ( Navigation  $navigation)
static

Set the root of the navigation tree. Must be called before any further items can be added to the tree.

Parameters
object$navigationroot navigation item

◆ setTitle()

setTitle (   $title)

Set the title of this navigation item.

Parameters
string$titledisplay title

◆ setURL()

setURL (   $url,
  $params = NULL 
)

Set the URL of this navigation item. Additional URL parameters can be passed using the (optional) second parameter.

Parameters
string$titledisplay title
array$paramsadditional URL parameters

Field Documentation

◆ $active

$active
protected

◆ $active_image

$active_image
protected

◆ $badgeNumber

$badgeNumber
protected

◆ $badgeTimestamp

$badgeTimestamp
protected

◆ $description

$description
protected

◆ $enabled

$enabled
protected

◆ $image

$image
protected

◆ $initialized

$initialized = false
protected

◆ $link_attributes

$link_attributes = []
protected

◆ $params

$params
protected

◆ $subnav

$subnav
protected

◆ $title

$title
protected

◆ $url

$url
protected

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