Stud.IP  5.4
 All Data Structures Namespaces Files Functions Variables Groups
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=null, $linkAttributes=[])
 
 setActiveImage (\Icon $image=null, $linkAttributes=[])
 
 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 (   $title,
  $url = NULL,
  $params = NULL 
)

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

Member Function Documentation

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 ( )

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

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 (   $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 ( )

Return the badge number of this navigation item.

Returns
int the badge number
getBadgeTimestamp ( )

Return the badge number of this navigation item.

Returns
int the badge number
getDescription ( )

Return the description associated with this navigation item.

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

Return the current image associated with this navigation item.

Returns
Icon an instance of class Icon depicting this item or NULL
getImageTag ( )

Shorthand method for creating an appropriate image tag for display.

Returns
string HTML tag snippet for the image
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 ( )

IteratorAggregate: Create interator for request parameters.

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 ( )

Return the list of subnavigation items of this object.

getTitle ( )

Return the current title associated with this navigation item.

Returns
string title of item or NULL (no title set)
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 ( )

Determines whether this navigation item has a badge number.

static hasItem (   $path)
static

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

Parameters
string$pathpath of navigation item
initItem ( )

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

initSubNavigation ( )
protected

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

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 (   $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 ( )

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.

Parameters
boolean$needs_imagerequires an image
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 (   $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 (   $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 ( \Icon  $image = null,
  $linkAttributes = [] 
)

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. Additional HTML attributes can be passed using the $options parameter (like 'style' or 'onclick').

Parameters
Icon$imagean instance of class Icon depicting this item
array$link_attributesadditional link attributes
setBadgeNumber (   $badgeNumber)

Set the badge number of this navigation item.

Parameters
string$badgeNumberthe badge number
setBadgeTimestamp (   $badgeTimestamp)

Set the badge number of this navigation item.

Parameters
string$badgeNumberthe badge number
setDescription (   $description)

Set the description of this navigation item.

Parameters
string$descriptiondescription text
setEnabled (   $enabled)

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

Parameters
boolean$enablednew enabled status
setImage ( \Icon  $image = null,
  $linkAttributes = [] 
)

Set the image of this navigation item. Additional HTML attributes can be passed using the $options parameter (like 'style' or 'onclick').

Parameters
Icon$imagean instance of class Icon depicting this item
array$link_attributesadditional link attributes
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
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 (   $title)

Set the title of this navigation item.

Parameters
string$titledisplay title
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
protected
$active_image
protected
$badgeNumber
protected
$badgeTimestamp
protected
$description
protected
$enabled
protected
$image
protected
$initialized = false
protected
$link_attributes = []
protected
$params
protected
$subnav
protected
$title
protected
$url
protected

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