Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 153 lines (5 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

view:: (4 methods):
  __construct()
  get_leaf_nodes()
  scan_for_active_node()
  active_node_scan()


Class: view  - X-Ref

Class view.

The base view class which expands on the navigation_node,

__construct(\moodle_page $page)   X-Ref
navigation constructor.

param: \moodle_page $page

get_leaf_nodes(navigation_node $source, array $nodes)   X-Ref
Get the leaf nodes for the nav view

param: navigation_node $source The settingsnav OR navigation object
param: array $nodes An array of nodes to fetch from the source which specifies the node type and final order
return: array $nodesordered The fetched nodes ordered based on final specification.

scan_for_active_node(navigation_node $node)   X-Ref
Scan the given node for the active node. It starts first with a strict search and then switches to a base search if
required.

param: navigation_node $node The node to scan.
return: navigation_node|null The active node or null.

active_node_scan(navigation_node $node,int $strictness = URL_MATCH_EXACT)   X-Ref
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'

param: navigation_node $node
param: int $strictness How stict to be with the scan for the active node.
return: navigation_node|null