This is the generic Menu class to be extended by the project

It loads the menu in two stages:

  1. $this->loadDefaultMenu() Normally you should not touch this to make upgrading easier

  2. $this->loadProjectMenu() This is where you can reorder, add or disable menu items, specific to your projects needs. Be aware that just using different rights in the Roles.php can also do the trick of hiding menu options.
package Gems
subpackage Menu
copyright Copyright (c) 2011 Erasmus MC
license New BSD License
since Class available since version 1.0
inherited_from \Gems_Menu_MenuAbstract

 Methods

Copy from \Zend_Translate_Adapter

_(string $text, string|\Zend_Locale $locale = null) : string
Inherited

Translates the given string returns the translation

Parameters

$text

string

Translation string

$locale

string\Zend_Locale

(optional) Locale/Language to use, identical with locale identifier, @see \Zend_Locale for more information

Returns

string

__construct()

__construct(\GemsEscort $escort) 
inherited_from \Gems_Menu_MenuAbstract::__construct()

Parameters

$escort

__construct()

__construct(\GemsEscort $escort) 
Inherited

Parameters

$escort

Add a agenda setup menu tree to the menu

addAgendaSetupMenu(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

Returns

\Gems_Menu_SubMenuItem

Add a browse / ceate / edit / show / / sleanup etc.

addAgendaSetupPage(string $label, string $privilege, string $controller, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

. menu item

Parameters

$label

string

$privilege

string

$controller

string

$other

array

Returns

\Gems_Menu_SubMenuItem

Shortcut function to create a ask menu, with hidden options.

addAskPage(string $label) 

This function is in \Gems_Menu instead of AbstractMenu because you should ALWAYS put this menu in the root menu.

Parameters

$label

string

Label for the whole menu

Add a browse / ceate / edit / show / etc.

addBrowsePage(string $label, string $privilege, string $controller, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

. menu item

Parameters

$label

string

$privilege

string

$controller

string

$other

array

Returns

\Gems_Menu_SubMenuItem

Add a menu item that is never added to the navigation tree and only shows up as a button.

addButtonOnly(string $label, string $privilege, string $controller, string $action = 'index', array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

$privilege

string

$controller

string

$action

string

$other

array

Returns

\Gems_Menu_SubMenuItem

Add a calendar page to the menu

addCalendarPage(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

Returns

\Gems_Menu_SubMenuItem

Add a Mail menu tree to the menu

addCommSetupMenu(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

Returns

\Gems_Menu_SubMenuItem

Shortcut function to create a contact container.

addContactPage(string $label) : \Gems_Menu_MenuAbstract

This function is in \Gems_Menu instead of AbstractMenu because you should ALWAYS put this menu in the root menu.

Parameters

$label

string

Label for the whole menu

Returns

\Gems_Menu_MenuAbstractThe new contact page

addContainer()

addContainer($label, $privilege = null, array $other = array()
Inherited

Parameters

$label

$privilege

$other

Shortcut function to create the export container.

addExportContainer(string $label) : \Gems_Menu_MenuAbstract
Inherited

Parameters

$label

string

Label for the container

Returns

\Gems_Menu_MenuAbstractThe new contact page

Add a file upload/download page to the menu

addFilePage(string $label, string $privilege, string $controller, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

The label to display for the menu item, null for access without display

$privilege

string

The privilege for the item, null is always, 'pr.islogin' must be logged in, 'pr.nologin' only when not logged in.

$controller

string

What controller to use

$other

array

Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'

Returns

\Gems_Menu_SubMenuItem

Shortcut function to create a setup container.

addGemsSetupContainer(string $label) 

This function is in \Gems_Menu instead of AbstractMenu because you should ALWAYS put this menu in the root menu.

Parameters

$label

string

Label for the whole menu

Add a roles browse edit page to the menu,

addGroupsPage(string $label, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

$other

array

Returns

\Gems_Menu_SubMenuItem

Use this to add a privilege that is not associated with a menu item.

addHiddenPrivilege(string $privilege, string $label = null) : \Gems_Menu

Parameters

$privilege

string

$label

string

Returns

\Gems_Menu

Shortcut function to create the import container.

addImportContainer(string $label) : \Gems_Menu_MenuAbstract
Inherited

Parameters

$label

string

Label for the container

Returns

\Gems_Menu_MenuAbstractThe new contact page

Add the log menu items

addLogControllers() 
Inherited

addLogonOffToken()

addLogonOffToken() 

Shortcut function to add all items needed for OpenRosa

addOpenRosaContainer(string $label, $parent = null

Should be enabled in application.ini by using useOpenRosa = 1

Parameters

$label

string

Label for the container

$parent

Add a page to the menu

addPage(string $label, string $privilege, string $controller, string $action = 'index', array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

The label to display for the menu item, null for access without display

$privilege

string

The privilege for the item, null is always, 'pr.islogin' must be logged in, 'pr.nologin' only when not logged in.

$controller

string

What controller to use

$action

string

The name of the action

$other

array

Array of extra options for this item, e.g. 'visible', 'allowed', 'class', 'icon', 'target', 'type', 'button_only'

Returns

\Gems_Menu_SubMenuItem

Add a list of report pages

addPlanPage(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

The label to display for the menu item, null for access without display

Returns

\Gems_Menu_SubMenuItem

Add pages that show the user technical information about the installation in the project.

addProjectInfoPage(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

Returns

\Gems_Menu_SubMenuItem

Add pages that show the user an overview of the tracks / surveys used in the project.

addProjectPage(string $label) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

Returns

\Gems_Menu_SubMenuItem

Shortcut function to create the respondent page.

addRespondentPage(string $label) : \Gems_Menu_MenuAbstract

Parameters

$label

string

Label for the container

Returns

\Gems_Menu_MenuAbstractThe new respondent page

Add a staff browse edit page to the menu,

addStaffPage(string $label, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

$other

array

Returns

\Gems_Menu_SubMenuItem

Add a Trackbuilder menu tree to the menu

addTrackBuilderMenu(string $label, array $other = array()) : \Gems_Menu_SubMenuItem
Inherited

Parameters

$label

string

$other

array

Returns

\Gems_Menu_SubMenuItem

find()

find(\Zend_Controller_Request_Abstract|array $request) : \Gems_Menu_SubMenuItem | null

Parameters

$request

\Zend_Controller_Request_Abstractarray

Returns

\Gems_Menu_SubMenuItemnull

findAll()

findAll($request) 

Parameters

$request

Find a menu item through specifying the controller and action

findAllowedController(string $controller, string $action = 'index') : \Gems_SubMenuItem

Parameters

$controller

string

$action

string

Returns

\Gems_SubMenuItem

Find a menu item through specifying the controller and action

findController(string $controller, string $action = 'index') : \Gems_SubMenuItem

Parameters

$controller

string

$action

string

Returns

\Gems_SubMenuItem

findFirst()

findFirst($request) 

Parameters

$request

getActivePath()

getActivePath(\Zend_Controller_Request_Abstract $request) 

Parameters

$request

getChildren()

getChildren() : array
Inherited

Returns

arrayof type \Gems_Menu_SubMenuItem

getCurrent()

getCurrent() : \Gems_Menu_SubMenuItem

Returns

\Gems_Menu_SubMenuItem

getCurrentChildren()

getCurrentChildren() 

Menulist populated with current items

getCurrentMenuList(\Zend_Controller_Request_Abstract $request, $parentLabel = null) : \Gems_Menu_MenuList

Parameters

$request

\Zend_Controller_Request_Abstract

$parentLabel

Returns

\Gems_Menu_MenuList

getCurrentParent()

getCurrentParent() : \Gems_Menu_SubMenuItem

Returns

\Gems_Menu_SubMenuItem

getMenuList()

getMenuList() : \Gems_Menu_MenuList

Returns

\Gems_Menu_MenuList

Use to set parameters that will be used when drawing the navigation menu.

getParameterSource() : \Gems_Menu_ParameterSource

Returns

\Gems_Menu_ParameterSource

Returns a (unique) list of privileges that are used in the menu

getUsedPrivileges() : array

Returns

array

hasChildren()

hasChildren() 
Inherited

isTopLevel()

isTopLevel() 
inherited_from \Gems_Menu_MenuAbstract::isTopLevel()

isTopLevel()

isTopLevel() 
Inherited

isVisible()

isVisible() 
inherited_from \Gems_Menu_MenuAbstract::isVisible()

isVisible()

isVisible() 
Inherited

This is where we load the default menu, be very careful to overload this function as it makes upgrading a lot more difficult

loadDefaultMenu() 

Plug your project menu into this function call

loadProjectMenu() 

Copy from \Zend_Translate_Adapter

plural(string $singular, string $plural, integer $number, string|\Zend_Locale $locale = null) : string
Inherited

Translates the given string using plural notations Returns the translated string

see

Parameters

$singular

string

Singular translation string

$plural

string

Plural translation string

$number

integer

Number for detecting the correct plural

$locale

string\Zend_Locale

(Optional) Locale/Language to use, identical with locale identifier, @see \Zend_Locale for more information

Returns

string

Renders the element into a html string

render(\Zend_View_Abstract $view) : string

The $view is used to correctly encode and escape the output

Parameters

$view

\Zend_View_Abstract

Returns

stringCorrectly encoded and escaped html output

setCurrent()

setCurrent(\Gems_Menu_SubMenuItem $item) 

Parameters

$item

setOnlyActiveBranchVisible()

setOnlyActiveBranchVisible($value = true

Parameters

$value

setVisible()

setVisible($value = true

Parameters

$value

Sorts the childeren on their order attribute (instead of the order the were added)

sortByOrder() : \Gems_Menu_MenuAbstract
Inherited

Returns

\Gems_Menu_MenuAbstract(continuation pattern)

uasort() function for sortByOrder()

sortOrder(self $aItem, self $bItem) : integer
InheritedStatic
see

Parameters

$aItem

self

$bItem

self

Returns

integer

Renders the top level menu items into a html element

toActiveBranchElement() : \MUtil_Html_HtmlElement

Returns

\MUtil_Html_HtmlElement

Renders the top level menu items into a html element

toTopLevelElement() : \MUtil_Html_HtmlElement

Returns

\MUtil_Html_HtmlElement

Generates a \Zend_Navigation object from the current menu

toZendNavigation(\Zend_Controller_Request_Abstract $request, mixed $actionController = null) : \Zend_Navigation

Parameters

$request

\Zend_Controller_Request_Abstract

$actionController

mixed

Returns

\Zend_Navigation

Adds privileges that are used in this menu item to the array

_addUsedPrivileges(array $privileges, $label) 
Inherited

Parameters

$privileges

array

$label

Get tge request to use for menu building

_getOriginalRequest() : \Zend_Controller_Request_Abstract
Inherited

Returns

\Zend_Controller_Request_Abstract

Returns a \Zend_Navigation creation array for this menu item, with sub menu items in 'pages'

_toNavigationArray(\Gems_Menu_ParameterCollector $source) : array
Inherited

Parameters

$source

\Gems_Menu_ParameterCollector

Returns

array

Add a sub item to this item.

add(array $args_array) : \Gems_Menu_SubMenuItem
Inherited

The argumenets can be any of those used for \Zend_Navigation_Page as well as some Gems specials.

  • 'action' The name of the action.
  • 'allowed' Is the user allowed to access this menu item. Is checked against ACL using 'privilige'.
  • 'button_only' Never in the menu, only shown as a button by the program.
  • 'class' Display class for the menu link.
  • 'controller' What controller to use.
  • 'icon' Icon to display with the label.
  • 'label' The label to display for the menu item.
  • 'privilege' The privilege needed to choose the item.
  • 'target' Optional target attribute for the link.
  • 'type' Optional content type for the link
  • 'visible' Is the item visible. Is checked against ACL using 'privilige'.

see

Parameters

$args_array

array

\MUtil_Ra::args array with defaults 'visible' and 'allowed' true.

Returns

\Gems_Menu_SubMenuItem

Set the visibility of the menu item and any sub items in accordance with the specified user role.

applyAcl(\Zend_Acl $acl, string $userRole) : \Gems_Menu_MenuAbstract
Inherited

Parameters

$acl

\Zend_Acl

$userRole

string

Returns

\Gems_Menu_MenuAbstract(continuation pattern)

findItem()

findItem(\<type> $options, \<type> $findDeep = true) : \Gems_Menu_SubMenuItem | null
Inherited

Parameters

$options

\<type>

$findDeep

\<type>

Returns

\Gems_Menu_SubMenuItemnull

findItemPath()

findItemPath($options) 
Inherited

Parameters

$options

findItems()

findItems($options, array $results) 
Inherited

Parameters

$options

$results

Helper function to create main menu html element.

renderFirst() : \MUtil_Html_ListElement

Allows overloading by sub classes.

Returns

\MUtil_Html_ListElement

Helper function to load the menu items to the html element.

renderItems(\MUtil_Html_ListElement $ul, array $items, boolean $cascade) 

Allows overloading by sub classes.

Parameters

$ul

\MUtil_Html_ListElement

$items

array

$cascade

boolean

render nested items

request2find()

request2find($request) 

Parameters

$request

Make sure only the active branch is visible

setBranchVisible(array $activeBranch) : \Gems_Menu_MenuAbstract
Inherited

Parameters

$activeBranch

array

Of \Gems_Menu_Menu Abstract items

Returns

\Gems_Menu_MenuAbstract(continuation pattern)

setForChildren()

setForChildren($key, $value) 
Inherited

Parameters

$key

$value

_findPath()

_findPath($request) 

Parameters

$request

 Properties

 

$escort

$escort : \GemsEscort

Default

 

Set output echo on for debugging

$verbose : boolean

Default

false
Static
 

$_menuUlClass

$_menuUlClass 

Default

'navigation nav nav-stacked'
 

$_subItems

$_subItems 

Default

array()
 

$translateAdapter

$translateAdapter : \Zend_Translate_Adapter

Default

 

$user

$user : \Gems_User_User

Default

 

$_currentMenuItem

$_currentMenuItem : \Gems_Menu_SubMenuItem

Default

 

$_hiddenPrivileges

$_hiddenPrivileges 

Default

array()
 

$_menuParameters

$_menuParameters : \Gems_Menu_ParameterSource

Default

 

$_onlyActiveBranchVisible

$_onlyActiveBranchVisible 

Default

false
 

$_visible

$_visible 

Default

true