Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_label\navigation\views\secondary Class Reference
Inheritance diagram for mod_label\navigation\views\secondary:
core\navigation\views\secondary core\navigation\views\view navigation_node renderable

Public Member Functions

 __wakeup ()
 Resets the page specific information on this node if it is being unserialised.
 
 action ()
 Get the action url for this navigation node.
 
 action_link_actions ()
 Return an array consisting of the actions for the action link.
 
 actionattributes ()
 Return an array consisting of the additional attributes for the action url.
 
 add ($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null)
 Adds a navigation node as a child of this node.
 
 add_attribute (string $name, string $value)
 Adds an HTML attribute to this node.
 
 add_class ($class)
 Adds a CSS class to this node.
 
 add_node (navigation_node $childnode, $beforekey=null)
 Adds a navigation node as a child of this one, given a $node object created using the create function.
 
 build_flat_navigation_list (flat_navigation $nodes, $showdivider=false, $label='')
 Walk the tree building up a list of all the flat navigation nodes.
 
 check_if_active ($strength=URL_MATCH_EXACT)
 Checks if this node is the active node.
 
 contains_active_node ()
 Checks if this node or any of its children contain the active node.
 
 find ($key, $type)
 Searches for a node of the given type with the given key.
 
 find_active_node ()
 Finds the active node.
 
 find_all_of_type ($type)
 Finds all nodes of a given type (recursive)
 
 find_expandable (array &$expandable)
 Finds all nodes that are expandable by AJAX.
 
 force_open ()
 Forces this node to be open and at the same time forces open all parents until the root node.
 
 get ($key, $type=null)
 Get the child of this node that has the given key + (optional) type.
 
 get_children_key_list ()
 Return a list of all the keys of all the child nodes.
 
 get_content ($shorttext=false)
 Gets the content for this node.
 
 get_css_type ()
 Gets the CSS class to add to this node to describe its type.
 
 get_overflow_menu_data ()
 Returns a url_select object with overflow navigation nodes.
 
 get_siblings ()
 Get a list of sibling navigation nodes at the same level as this one.
 
 get_tabs_array (array $inactive=array(), $return=false)
 Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page.
 
 get_title ()
 Gets the title to use for this node.
 
 has_action ()
 Used to easily determine if this link in the breadcrumbs has a valid action/url.
 
 has_children ()
 Checks if this node has or could have any children.
 
 has_internal_action ()
 Used to easily determine if the action is an internal link.
 
 has_siblings ()
 True if this nav node has siblings in the tree.
 
 hide (array $typestohide=null)
 Hides the node and any children it has.
 
 initialise ()
 Initialise the view based navigation based on the current context.
 
 is_action_link ()
 Check whether the node's action is of type action_link.
 
 is_hidden ()
 Used to easily determine if this link in the breadcrumbs is hidden.
 
 is_short_branch ()
 To better balance the admin tree, we want to group all the short top branches together.
 
 make_active ()
 Marks this node as active and forces it open.
 
 make_inactive ()
 Marks a node as inactive and recusised back to the base of the tree doing the same to all parents.
 
 remove ()
 Removes this node.
 
 remove_class ($class)
 Removes a CSS class from this node.
 
 search_for_active_node ($strength=URL_MATCH_BASE)
 Searches all children for the best matching active node.
 
 set_force_into_more_menu (bool $forceintomoremenu=false)
 Sets whether the node and its children should be added into a "more" menu whenever possible.
 
 set_overflow_selected_node (string $nodekey)
 Force a specific node in the 'coursereuse' course overflow to be selected, based on the provided node key.
 
 set_parent (navigation_node $parent)
 Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well.
 
 set_show_in_secondary_navigation (bool $show=true)
 Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.
 
 title (?string $title=null)
 Sets the title for this node and forces Moodle to utilise it.
 
 trim_if_empty ()
 Removes this node if it is empty.
 

Static Public Member Functions

static create ($text, $action=null, $type=self::TYPE_CUSTOM, $shorttext=null, $key=null, pix_icon $icon=null)
 Creates a navigation node, ready to add it as a child using add_node function.
 
static create_menu_element (array $navigationnodes, bool $forceheadings=false)
 Takes the given navigation nodes and searches for children and formats it all into an array in a format to be used by a url_select element.
 
static override_active_url (moodle_url $url, $loadadmintree=false)
 This sets the URL that the URL of new nodes get compared to when locating the active node.
 
static require_admin_tree ()
 Use when page is linked from the admin tree, if not used navigation could not find the page using current URL because the tree is not fully loaded.
 

Public Attributes

moodle_url action_link null $action = null
 An action for the node (link)
 
navigation_node $activenode
 $activenode A string identifier for the active node
 
array $attributes = []
 An array of HTML attributes for the node.
 
navigation_node_collection $children = array()
 An array of child nodes.
 
array $classes = array()
 An array of CSS classes for the node.
 
bool $collapse = false
 If set to true the node will be collapsed by default.
 
bool $display = true
 If set to false the node will not be displayed.
 
bool $forceintomoremenu = false
 If set to true this node will be forced into a "more" menu whenever possible.
 
bool $forceopen = false
 If set to true the node will be expanded by default.
 
bool $forcetitle = false
 If set to true a title will be added to the action no matter what.
 
bool $haschildren
 node that have children.
 
string $headertitle
 $headertitle The header for this particular menu
 
string $helpbutton = null
 A string that can be used to build a help button.
 
bool $hidden = false
 If set to true the node will be dimmed.
 
bool $hideicon = false
 Override to not display the icon even if one is provided.
 
pix_icon $icon = null
 The path to an icon to use for this node.
 
int $id = null
 Parameter to aid the coder in tracking [optional].
 
mixed $includesectionnum = false
 If set to an int, that section will be included even if it has no activities.
 
bool $isactive = false
 If set to true the node will be recognised as active.
 
bool $isexpandable = false
 Set to true if we KNOW that this node can be expanded.
 
string int $key = null
 The identifier for the node, used to retrieve the node.
 
bool $mainnavonly = false
 If set to true the the navigation bar should ignore this node.
 
string $moremenuid
 unique identifier.
 
int $nodetype = self::NODETYPE_LEAF
 See NODETYPE_* constants defined for this class.
 
navigation_node $parent = null
 A reference to the node parent, you should never set this directly you should always call set_parent.
 
bool $preceedwithhr = false
 If set to true then an HR will be printed before the node.
 
bool $requiresajaxloading = false
 does the node need to be loaded via ajax
 
string $shorttext = null
 Short text to use if requested [optional].
 
bool $showchildreninsubmenu = false
 If set to true the children of this node will be displayed within a submenu when applicable.
 
bool $showinflatnavigation = false
 If set to true this node will be added to the "flat" navigation.
 
bool $showinsecondarynavigation = true
 If set to true this node will be displayed in the "secondary" navigation when applicable.
 
string $tab
 tab element ID.
 
string lang_string $text = null
 The text to use for the node.
 
string $title = null
 The title attribute for an action if one is defined.
 
int $type = self::TYPE_UNKNOWN
 See TYPE_* constants defined for this class.
 
const COURSE_CURRENT = 2
 var int Course the current user is currently viewing
 
const COURSE_INDEX_PAGE = 'courseindexpage'
 var string The course index page navigation node
 
const COURSE_MY = 1
 var int Course the current user is enrolled in but not viewing
 
const COURSE_OTHER = 0
 var int Course the current user is not enrolled in
 
int const MAX_DISPLAYED_NAV_NODES = 5
 The maximum limit of navigation nodes displayed in the secondary navigation.
 
int const NODETYPE_BRANCH = 1
 Used to identify this node a branch, happens with children 1.
 
int const NODETYPE_LEAF = 0
 Used to identify this node a leaf (default) 0.
 
int const TYPE_ACTIVITY = 40
 Activity node type, e.g.
 
int const TYPE_CATEGORY = 10
 Category node type 10.
 
int const TYPE_CONTAINER = 90
 Setting node type, used for containers of no importance 90.
 
int const TYPE_COURSE = 20
 Course node type 20.
 
int const TYPE_CUSTOM = 60
 A custom node type, default when adding without specifing type 60.
 
const TYPE_MY_CATEGORY = 11
 var int Category displayed in MyHome navigation node
 
int const TYPE_RESOURCE = 50
 Resource node type, e.g.
 
int const TYPE_ROOTNODE = 0
 System node type 0.
 
int const TYPE_SECTION = 30
 Course Structure node type 30.
 
int const TYPE_SETTING = 70
 Setting node type, used only within settings nav 70.
 
int const TYPE_SITE_ADMIN = 71
 site admin branch node type, used only within settings nav 71
 
int const TYPE_SYSTEM = 1
 System node type 1.
 
null const TYPE_UNKNOWN = null
 Unknown node type null.
 
int const TYPE_USER = 80
 Setting node type, used only within settings nav 80.
 

Static Public Attributes

static bool $autofindactive = true
 toogles auto matching of active node
 

Protected Member Functions

 active_node_scan (navigation_node $node, int $strictness=URL_MATCH_EXACT)
 This function recursively scans nodes until it finds the active node or there are no more nodes.
 
 add_context_locking_node (\navigation_node $node, context $context)
 Add the menu item to handle locking and unlocking of a conext.
 
 add_external_nodes_to_secondary (navigation_node $node, navigation_node $basenode, ?navigation_node $root=null, bool $forceadd=false)
 Recursive call to add all custom navigation nodes to secondary.
 
 add_ordered_nodes (array $nodes, ?navigation_node $rootnode=null)
 Adds the indexed nodes to the current view or a given node.
 
 force_nodes_into_more_menu (array $defaultmoremenunodes=[], ?int $maxdisplayednodes=null)
 Force certain secondary navigation nodes to be displayed in the "more" menu.
 
 get_course_overflow_nodes (?navigation_node $rootnode=null)
 Gets the overflow navigation nodes for the course administration category.
 
 get_default_admin_more_menu_nodes ()
 Define the keys of the admin secondary nav nodes that should be forced into the "more" menu by default.
 
 get_default_category_mapping ()
 Defines the default structure for the secondary nav in a category context.
 
 get_default_category_more_menu_nodes ()
 Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.
 
 get_default_course_mapping ()
 Defines the default structure for the secondary nav in a course context.
 
 get_default_course_more_menu_nodes ()
 Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.
 
 get_default_module_mapping ()
 Defines the default structure for the secondary nav in a module context.
 
 get_default_module_more_menu_nodes ()
 Define the keys of the module secondary nav nodes that should be forced into the "more" menu by default.
 
 get_expected_course_admin_nodes ()
 Returns a list of all expected nodes in the course administration.
 
 get_first_action_for_node (navigation_node $node)
 Some nodes are containers only with no action.
 
 get_leaf_nodes (navigation_node $source, array $nodes)
 Get the leaf nodes for the nav view.
 
 get_node_with_first_action (navigation_node $node, navigation_node $basenode)
 Returns a node with the action being from the first found child node that has an action (Recursive).
 
 get_other_overflow_menu_data (navigation_node $activenode)
 Gets overflow menu data for third party plugin settings.
 
 load_admin_navigation ()
 Load the site admin navigation.
 
 load_category_navigation ()
 Load the course category navigation.
 
 load_course_navigation (?navigation_node $rootnode=null)
 Load the course secondary navigation.
 
 load_module_navigation (settings_navigation $settingsnav, ?navigation_node $rootnode=null)
 Custom module construct for label.
 
 load_remaining_nodes (navigation_node $completenode, array $nodesmap, ?navigation_node $rootnode=null)
 Find the remaining nodes that need to be loaded into secondary based on the current context or a given node.
 
 load_single_activity_course_navigation ()
 Load the single activity course secondary navigation.
 
 node_matches_key_string (navigation_node $node, string $key)
 Recursively search a node and its children for a node matching the key string $key.
 
 nodes_match_current_url (navigation_node $node)
 Recursively looks for a match to the current page url.
 
 remove_unwanted_nodes (navigation_node $node)
 Recursively remove navigation nodes that should not be displayed in the secondary navigation.
 
 scan_for_active_node (navigation_node $node)
 Scan the given node for the active node.
 

Static Protected Member Functions

static does_menu_need_headings (navigation_node $navigationnode)
 Checks to see if the provided navigation node has children and determines if we want headings for a url select element.
 
static format_node_text (navigation_node $navigationnode)
 Returns the navigation node text in a string.
 
static get_flat_nav_array (navigation_node $navigationnode)
 Takes the navigation node and returns it in a flat fashion.
 
static get_headings_nav_array (navigation_node $navigationnode)
 For any navigation node that we have determined needs headings we return a more tree like array structure.
 
static get_more_child_nodes (navigation_node $node, array &$menublock)
 Recursively goes and gets all children nodes.
 
static get_whole_tree_flat (navigation_node $navigationnode)
 Recursively goes through the provided navigation node and returns a flat version.
 

Protected Attributes

stdClass $context
 $context the current context
 
navigation_node $courseoverflownode = null
 The course overflow node.
 
bool $initialised = false
 $initialised A switch to see if the navigation node is initialised
 
array $namedtypes
 
string $overflowselected = null
 The key of the node to set as selected in the course overflow menu, if explicitly set by a page.
 
moodle_page $page
 $page the moodle page that the navigation belongs to
 

Static Protected Attributes

static moodle_url $fullmeurl = null
 
static bool $loadadmintree = false
 should we load full admin tree or rely on AJAX for performance reasons
 

Detailed Description

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ action()

navigation_node::action ( )
inherited

Get the action url for this navigation node.

Called from templates.

Since
Moodle 3.2

◆ action_link_actions()

navigation_node::action_link_actions ( )
inherited

Return an array consisting of the actions for the action link.

Return values
arrayFormatted array to parse in a template

◆ actionattributes()

navigation_node::actionattributes ( )
inherited

Return an array consisting of the additional attributes for the action url.

Return values
arrayFormatted array to parse in a template

◆ active_node_scan()

core\navigation\views\view::active_node_scan ( navigation_node $node,
int $strictness = URL_MATCH_EXACT )
protectedinherited

This function recursively scans nodes until it finds the active node or there are no more nodes.

We are using a custom implementation here to adjust the strictness and also because we need the parent node and not the specific child node in the new views. e.g. Structure for site admin, SecondaryNav

  • Site Admin
  • Users
    • User policies
  • Courses In the above example, if we are on the 'User Policies' page, the active node should be 'Users'
Parameters
navigation_node$node
int$strictnessHow stict to be with the scan for the active node.
Return values
navigation_node|null

◆ add()

navigation_node::add ( $text,
$action = null,
$type = self::TYPE_CUSTOM,
$shorttext = null,
$key = null,
pix_icon $icon = null )
inherited

Adds a navigation node as a child of this node.

Parameters
string$text
moodle_url | action_link | string$action
?int$type
string$shorttext
string | int$key
pix_icon$icon
Return values
navigation_node

Reimplemented in navbar, and settings_navigation.

◆ add_attribute()

navigation_node::add_attribute ( string $name,
string $value )
inherited

Adds an HTML attribute to this node.

Parameters
string$name
string$value

◆ add_class()

navigation_node::add_class ( $class)
inherited

Adds a CSS class to this node.

Parameters
string$class
Return values
bool

◆ add_context_locking_node()

navigation_node::add_context_locking_node ( \navigation_node $node,
context $context )
protectedinherited

Add the menu item to handle locking and unlocking of a conext.

Parameters
navigation_node$nodeNode to add
context$contextThe context to be locked

◆ add_external_nodes_to_secondary()

core\navigation\views\secondary::add_external_nodes_to_secondary ( navigation_node $node,
navigation_node $basenode,
?navigation_node $root = null,
bool $forceadd = false )
protectedinherited

Recursive call to add all custom navigation nodes to secondary.

Parameters
navigation_node$nodeThe node which should be added to secondary
navigation_node$basenodeThe original parent node
navigation_node | null$rootThe parent node nodes are to be added/removed to.
bool$forceaddWhether or not to bypass the external action check and force add all nodes

◆ add_node()

navigation_node::add_node ( navigation_node $childnode,
$beforekey = null )
inherited

Adds a navigation node as a child of this one, given a $node object created using the create function.

Parameters
navigation_node$childnodeNode to add
string$beforekey
Return values
navigation_nodeThe added node

◆ add_ordered_nodes()

core\navigation\views\secondary::add_ordered_nodes ( array $nodes,
?navigation_node $rootnode = null )
protectedinherited

Adds the indexed nodes to the current view or a given node.

The key should indicate it's position in the tree. Any sub nodes needs to be numbered appropriately, e.g. 3.1 would make the identified node be listed under #3 node.

Parameters
array$nodesAn array of navigation nodes to be added.
navigation_node | null$rootnodeThe node where the nodes should be added into as children. If not explicitly defined, the nodes will be added to the secondary root node by default.

◆ build_flat_navigation_list()

navigation_node::build_flat_navigation_list ( flat_navigation $nodes,
$showdivider = false,
$label = '' )
inherited

Walk the tree building up a list of all the flat navigation nodes.

Deprecated
since Moodle 4.0
Parameters
flat_navigation$nodesList of the found flat navigation nodes.
boolean$showdividerShow a divider before the first node.
string$labelA label for the collection of navigation links.

◆ check_if_active()

navigation_node::check_if_active ( $strength = URL_MATCH_EXACT)
inherited

Checks if this node is the active node.

This is determined by comparing the action for the node against the defined URL for the page. A match will see this node marked as active.

Parameters
int$strengthOne of URL_MATCH_EXACT, URL_MATCH_PARAMS, or URL_MATCH_BASE
Return values
bool

◆ contains_active_node()

navigation_node::contains_active_node ( )
inherited

Checks if this node or any of its children contain the active node.

Recursive.

Return values
bool

◆ create()

static navigation_node::create ( $text,
$action = null,
$type = self::TYPE_CUSTOM,
$shorttext = null,
$key = null,
pix_icon $icon = null )
staticinherited

Creates a navigation node, ready to add it as a child using add_node function.

(The created node needs to be added before you can use it.)

Parameters
string$text
moodle_url | action_link$action
int$type
string$shorttext
string | int$key
pix_icon$icon
Return values
navigation_node

◆ create_menu_element()

static core\navigation\views\secondary::create_menu_element ( array $navigationnodes,
bool $forceheadings = false )
staticinherited

Takes the given navigation nodes and searches for children and formats it all into an array in a format to be used by a url_select element.

Parameters
navigation_node[]$navigationnodesNavigation nodes to format into a menu.
bool$forceheadingsWhether the returned array should be forced to use headings.
Return values
array|nullA url select element for navigating through the navigation nodes.

◆ does_menu_need_headings()

static core\navigation\views\secondary::does_menu_need_headings ( navigation_node $navigationnode)
staticprotectedinherited

Checks to see if the provided navigation node has children and determines if we want headings for a url select element.

Parameters
navigation_node$navigationnodeThe navigation node we are checking.
Return values
boolWhether we want headings or not.

◆ find()

navigation_node::find ( $key,
$type )
inherited

Searches for a node of the given type with the given key.

This searches this node plus all of its children, and their children.... If you know the node you are looking for is a child of this node then please use the get method instead.

Parameters
int | string$keyThe key of the node we are looking for
?int$typeOne of navigation_node\TYPE_*
Return values
navigation_node|false

Reimplemented in global_navigation.

◆ find_active_node()

navigation_node::find_active_node ( )
inherited

Finds the active node.

Searches this nodes children plus all of the children for the active node and returns it if found.

Recursive.

Return values
navigation_node|false

◆ find_all_of_type()

navigation_node::find_all_of_type ( $type)
inherited

Finds all nodes of a given type (recursive)

Parameters
int$typeOne of navigation_node\TYPE_*
Return values
array

◆ find_expandable()

navigation_node::find_expandable ( array & $expandable)
inherited

Finds all nodes that are expandable by AJAX.

Parameters
array$expandableAn array by reference to populate with expandable nodes.

◆ force_nodes_into_more_menu()

core\navigation\views\secondary::force_nodes_into_more_menu ( array $defaultmoremenunodes = [],
?int $maxdisplayednodes = null )
protectedinherited

Force certain secondary navigation nodes to be displayed in the "more" menu.

Parameters
array$defaultmoremenunodesArray with navigation node keys of the pre-defined nodes that should be added into the "more" menu by default
int | null$maxdisplayednodesThe maximum limit of navigation nodes displayed in the secondary navigation

◆ force_open()

navigation_node::force_open ( )
inherited

Forces this node to be open and at the same time forces open all parents until the root node.

Recursive.

◆ format_node_text()

static core\navigation\views\secondary::format_node_text ( navigation_node $navigationnode)
staticprotectedinherited

Returns the navigation node text in a string.

Parameters
navigation_node$navigationnodeThe navigationnode to return the text string of.
Return values
stringThe navigation node text string.

◆ get()

navigation_node::get ( $key,
$type = null )
inherited

Get the child of this node that has the given key + (optional) type.

If you are looking for a node and want to search all children + their children then please use the find method instead.

Parameters
int | string$keyThe key of the node we are looking for
int$typeOne of navigation_node\TYPE_*
Return values
navigation_node|false

Reimplemented in global_navigation, and navbar.

◆ get_children_key_list()

navigation_node::get_children_key_list ( )
inherited

Return a list of all the keys of all the child nodes.

Return values
arraythe keys.

◆ get_content()

navigation_node::get_content ( $shorttext = false)
inherited

Gets the content for this node.

Parameters
bool$shorttextIf true shorttext is used rather than the normal text
Return values
string

◆ get_course_overflow_nodes()

core\navigation\views\secondary::get_course_overflow_nodes ( ?navigation_node $rootnode = null)
protectedinherited

Gets the overflow navigation nodes for the course administration category.

Parameters
navigation_node | null$rootnodeThe node from where the course overflow nodes should be obtained. If not explicitly defined, the nodes will be obtained from the secondary root node by default.
Return values
navigation_nodeThe course overflow nodes.

◆ get_css_type()

navigation_node::get_css_type ( )
inherited

Gets the CSS class to add to this node to describe its type.

Return values
string

◆ get_default_admin_more_menu_nodes()

core\navigation\views\secondary::get_default_admin_more_menu_nodes ( )
protectedinherited

Define the keys of the admin secondary nav nodes that should be forced into the "more" menu by default.

Return values
array

◆ get_default_category_mapping()

core\navigation\views\secondary::get_default_category_mapping ( )
protectedinherited

Defines the default structure for the secondary nav in a category context.

In a category context, we are curating nodes from the settingsnav object. The following mapping construct specifies the type of the node, the key and in what order we want the node - defined as per the mockups.

Return values
array

◆ get_default_category_more_menu_nodes()

core\navigation\views\secondary::get_default_category_more_menu_nodes ( )
protectedinherited

Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.

Return values
array

◆ get_default_course_mapping()

core\navigation\views\secondary::get_default_course_mapping ( )
protectedinherited

Defines the default structure for the secondary nav in a course context.

In a course context, we are curating nodes from the settingsnav and navigation objects. The following mapping construct specifies which object we are fetching it from, the type of the node, the key and in what order we want the node - defined as per the mockups.

Return values
array

◆ get_default_course_more_menu_nodes()

core\navigation\views\secondary::get_default_course_more_menu_nodes ( )
protectedinherited

Define the keys of the course secondary nav nodes that should be forced into the "more" menu by default.

Return values
array

◆ get_default_module_mapping()

core\navigation\views\secondary::get_default_module_mapping ( )
protectedinherited

Defines the default structure for the secondary nav in a module context.

In a module context, we are curating nodes from the settingsnav object. The following mapping construct specifies the type of the node, the key and in what order we want the node - defined as per the mockups.

Return values
array

Reimplemented in mod_assign\navigation\views\secondary, mod_feedback\navigation\views\secondary, mod_glossary\navigation\views\secondary, and mod_quiz\navigation\views\secondary.

◆ get_default_module_more_menu_nodes()

core\navigation\views\secondary::get_default_module_more_menu_nodes ( )
protectedinherited

Define the keys of the module secondary nav nodes that should be forced into the "more" menu by default.

Return values
array

◆ get_expected_course_admin_nodes()

core\navigation\views\secondary::get_expected_course_admin_nodes ( )
protectedinherited

Returns a list of all expected nodes in the course administration.

Return values
arrayAn array of keys for navigation nodes in the course administration.

◆ get_first_action_for_node()

core\navigation\views\secondary::get_first_action_for_node ( navigation_node $node)
protectedinherited

Some nodes are containers only with no action.

If this container has an action then nothing is done. If it does not have an action then a search is done through the children looking for the first node that has an action. This action is then given to the parent node that is initially provided as a parameter.

Parameters
navigation_node$nodeThe navigation node that we want to ensure has an action tied to it.
Return values
navigation_nodeThe node intact with an action to use.

◆ get_flat_nav_array()

static core\navigation\views\secondary::get_flat_nav_array ( navigation_node $navigationnode)
staticprotectedinherited

Takes the navigation node and returns it in a flat fashion.

This is not recursive.

Parameters
navigation_node$navigationnodeThe navigation node that we want to format into an array in a flat structure.
Return values
arrayThe flat navigation array.

◆ get_headings_nav_array()

static core\navigation\views\secondary::get_headings_nav_array ( navigation_node $navigationnode)
staticprotectedinherited

For any navigation node that we have determined needs headings we return a more tree like array structure.

Parameters
navigation_node$navigationnodeThe navigation node to use for the formatted array structure.
Return values
arrayThe headings navigation array structure.

◆ get_leaf_nodes()

core\navigation\views\view::get_leaf_nodes ( navigation_node $source,
array $nodes )
protectedinherited

Get the leaf nodes for the nav view.

Parameters
navigation_node$sourceThe settingsnav OR navigation object
array$nodesAn array of nodes to fetch from the source which specifies the node type and final order
Return values
array\$nodesorderedThe fetched nodes ordered based on final specification.

◆ get_more_child_nodes()

static core\navigation\views\secondary::get_more_child_nodes ( navigation_node $node,
array & $menublock )
staticprotectedinherited

Recursively goes and gets all children nodes.

Parameters
navigation_node$nodeThe node to get the children of.
array$menublockUsed to put all child nodes in its own container.
Return values
arrayThe additional child nodes.

◆ get_node_with_first_action()

core\navigation\views\secondary::get_node_with_first_action ( navigation_node $node,
navigation_node $basenode )
protectedinherited

Returns a node with the action being from the first found child node that has an action (Recursive).

Parameters
navigation_node$nodeThe part of the node tree we are checking.
navigation_node$basenodeThe very first node to be used for the return.
Return values
navigation_node|null

◆ get_other_overflow_menu_data()

core\navigation\views\secondary::get_other_overflow_menu_data ( navigation_node $activenode)
protectedinherited

Gets overflow menu data for third party plugin settings.

Parameters
navigation_node$activenodeThe node to gather the children for to put into the overflow menu.
Return values
url_select|nullThe overflow menu in a url_select object.

◆ get_overflow_menu_data()

core\navigation\views\secondary::get_overflow_menu_data ( )
inherited

Returns a url_select object with overflow navigation nodes.

This looks to see if the current page is within the course administration, or some other page that requires an overflow select object.

Return values
url_select|nullThe overflow menu data.

◆ get_siblings()

navigation_node::get_siblings ( )
inherited

Get a list of sibling navigation nodes at the same level as this one.

Return values
bool|arrayof navigation_node

◆ get_tabs_array()

navigation_node::get_tabs_array ( array $inactive = array(),
$return = false )
inherited

Creates a tab representation of this nodes children that can be used with print_tabs to produce the tabs on a page.

call_user_func_array('print_tabs', $node->get_tabs_array());

Parameters
array$inactive
bool$return
Return values
arrayArray (tabs, selected, inactive, activated, return)

◆ get_title()

navigation_node::get_title ( )
inherited

Gets the title to use for this node.

Return values
string

◆ get_whole_tree_flat()

static core\navigation\views\secondary::get_whole_tree_flat ( navigation_node $navigationnode)
staticprotectedinherited

Recursively goes through the provided navigation node and returns a flat version.

Parameters
navigation_node$navigationnodeThe navigationnode.
Return values
arrayThe whole tree flat.

◆ has_action()

navigation_node::has_action ( )
inherited

Used to easily determine if this link in the breadcrumbs has a valid action/url.

Return values
boolean

◆ has_children()

navigation_node::has_children ( )
inherited

Checks if this node has or could have any children.

Return values
boolReturns true if it has children or could have (by AJAX expansion)

◆ has_internal_action()

navigation_node::has_internal_action ( )
inherited

Used to easily determine if the action is an internal link.

Return values
bool

◆ has_siblings()

navigation_node::has_siblings ( )
inherited

True if this nav node has siblings in the tree.

Return values
bool

◆ hide()

navigation_node::hide ( array $typestohide = null)
inherited

Hides the node and any children it has.

Since
Moodle 2.5
Parameters
array$typestohideOptional. An array of node types that should be hidden. If null all nodes will be hidden. If an array is given then nodes will only be hidden if their type mtatches an element in the array. e.g. array(navigation_node\TYPE_COURSE) would hide only course nodes.

◆ initialise()

core\navigation\views\secondary::initialise ( )
inherited

Initialise the view based navigation based on the current context.

As part of the initial restructure, the secondary nav is only considered for the following pages: 1 - Site admin settings 2 - Course page - Does not include front_page which has the same context. 3 - Module page

Reimplemented from core\navigation\views\view.

Reimplemented in core_block\navigation\views\secondary.

◆ is_action_link()

navigation_node::is_action_link ( )
inherited

Check whether the node's action is of type action_link.

Return values
bool

◆ is_hidden()

navigation_node::is_hidden ( )
inherited

Used to easily determine if this link in the breadcrumbs is hidden.

Return values
boolean

◆ is_short_branch()

navigation_node::is_short_branch ( )
inherited

To better balance the admin tree, we want to group all the short top branches together.

This means < 8 nodes and no subtrees.

Return values
bool

◆ load_course_navigation()

core\navigation\views\secondary::load_course_navigation ( ?navigation_node $rootnode = null)
protectedinherited

Load the course secondary navigation.

Since we are sourcing all the info from existing objects that already do the relevant checks, we don't do it again here.

Parameters
navigation_node | null$rootnodeThe node where the course navigation nodes should be added into as children. If not explicitly defined, the nodes will be added to the secondary root node by default.

◆ load_module_navigation()

mod_label\navigation\views\secondary::load_module_navigation ( settings_navigation $settingsnav,
?navigation_node $rootnode = null )
protected

Custom module construct for label.

Parameters
settings_navigation$settingsnavThe settings navigation object related to the module page
navigation_node | null$rootnodeThe node where the module navigation nodes should be added into as children. If not explicitly defined, the nodes will be added to the secondary root node by default.

Reimplemented from core\navigation\views\secondary.

◆ load_remaining_nodes()

core\navigation\views\secondary::load_remaining_nodes ( navigation_node $completenode,
array $nodesmap,
?navigation_node $rootnode = null )
protectedinherited

Find the remaining nodes that need to be loaded into secondary based on the current context or a given node.

Parameters
navigation_node$completenodeThe original node that we are sourcing information from
array$nodesmapThe map used to populate secondary nav in the given context
navigation_node | null$rootnodeThe node where the remaining nodes should be added into as children. If not explicitly defined, the nodes will be added to the secondary root node by default.

◆ make_active()

navigation_node::make_active ( )
inherited

Marks this node as active and forces it open.

Important: If you are here because you need to mark a node active to get the navigation to do what you want have you looked at navigation_node::override_active_url()? You can use it to specify a different URL to match the active navigation node on rather than having to locate and manually mark a node active.

◆ node_matches_key_string()

core\navigation\views\secondary::node_matches_key_string ( navigation_node $node,
string $key )
protectedinherited

Recursively search a node and its children for a node matching the key string $key.

Parameters
navigation_node$nodethe navigation node to check.
string$keythe key of the node to match.
Return values
navigation_node|nullnode if found, otherwise null.

◆ nodes_match_current_url()

core\navigation\views\secondary::nodes_match_current_url ( navigation_node $node)
protectedinherited

Recursively looks for a match to the current page url.

Parameters
navigation_node$nodeThe node to look through.
Return values
navigation_node|nullThe node that matches this page's url.

◆ override_active_url()

static navigation_node::override_active_url ( moodle_url $url,
$loadadmintree = false )
staticinherited

This sets the URL that the URL of new nodes get compared to when locating the active node.

The active node is the node that matches the URL set here. By default this is either $PAGE->url or if that hasn't been set $FULLME.

Parameters
moodle_url$urlThe url to use for the fullmeurl.
bool$loadadmintreeuse true if the URL point to administration tree

◆ remove()

navigation_node::remove ( )
inherited

Removes this node.

Return values
bool

◆ remove_class()

navigation_node::remove_class ( $class)
inherited

Removes a CSS class from this node.

Parameters
string$class
Return values
boolTrue if the class was successfully removed.

◆ remove_unwanted_nodes()

core\navigation\views\secondary::remove_unwanted_nodes ( navigation_node $node)
protectedinherited

Recursively remove navigation nodes that should not be displayed in the secondary navigation.

Parameters
navigation_node$nodeThe starting navigation node.

◆ scan_for_active_node()

core\navigation\views\view::scan_for_active_node ( navigation_node $node)
protectedinherited

Scan the given node for the active node.

It starts first with a strict search and then switches to a base search if required.

Parameters
navigation_node$nodeThe node to scan.
Return values
navigation_node|nullThe active node or null.

◆ search_for_active_node()

navigation_node::search_for_active_node ( $strength = URL_MATCH_BASE)
inherited

Searches all children for the best matching active node.

Parameters
int$strengthThe url match to be made.
Return values
navigation_node|false

◆ set_force_into_more_menu()

navigation_node::set_force_into_more_menu ( bool $forceintomoremenu = false)
inherited

Sets whether the node and its children should be added into a "more" menu whenever possible.

Parameters
bool$forceintomoremenu

◆ set_overflow_selected_node()

core\navigation\views\secondary::set_overflow_selected_node ( string $nodekey)
inherited

Force a specific node in the 'coursereuse' course overflow to be selected, based on the provided node key.

Normally, the selected node is determined by matching the page URL to the node URL. E.g. The page 'backup/restorefile.php' will match the "Restore" node which has a registered URL of 'backup/restorefile.php' because the URLs match.

This method allows a page to choose a specific node to match, which is useful in cases where the page knows its URL won't match the node it needs to reside under. I.e. this permits several pages to 'share' the same overflow node. When the page knows the PAGE->url won't match the node URL, the page can simply say "I want to match the 'XXX' node".

E.g.

  • The $PAGE->url is 'backup/restore.php' (this page is used during restores but isn't the main landing page for a restore)
  • The 'Restore' node in the overflow has a key of 'restore' and will only match 'backup/restorefile.php' by default (the main restore landing page).
  • The backup/restore.php page calls: $PAGE->secondarynav->set_overflow_selected_node(new moodle_url('restore'); and when the page is loaded, the 'Restore' node be presented as the selected node.
Parameters
string$nodekeyThe string key of the overflow node to match.

◆ set_parent()

navigation_node::set_parent ( navigation_node $parent)
inherited

Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well.

Parameters
navigation_node$parent

◆ set_show_in_secondary_navigation()

navigation_node::set_show_in_secondary_navigation ( bool $show = true)
inherited

Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.

Parameters
bool$show

◆ title()

navigation_node::title ( ?string $title = null)
inherited

Sets the title for this node and forces Moodle to utilise it.

Note that this method is named identically to the public "title" property of the class, which unfortunately confuses our Mustache renderer, because it will see the method and try and call it without any arguments (hence must be nullable) before trying to access the public property

Parameters
string | null$title
Return values
string

Member Data Documentation

◆ $isexpandable

bool navigation_node::$isexpandable = false
inherited

Set to true if we KNOW that this node can be expanded.


◆ $namedtypes

array navigation_node::$namedtypes
protectedinherited
Initial value:
= array(0 => 'system', 10 => 'category', 20 => 'course', 30 => 'structure', 40 => 'activity',
50 => 'resource', 60 => 'custom', 70 => 'setting', 71 => 'siteadmin', 80 => 'user',
90 => 'container')

◆ TYPE_ACTIVITY

int const navigation_node::TYPE_ACTIVITY = 40
inherited

Activity node type, e.g.

Forum, Quiz 40

◆ TYPE_RESOURCE

int const navigation_node::TYPE_RESOURCE = 50
inherited

Resource node type, e.g.

Link to a file, or label 50


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