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.

This file contains classes used to manage the navigation structures in Moodle and was introduced as part of the changes occuring in Moodle 2.0

Copyright: 2009 Sam Hemelryk
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 345 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: block_navigation  - X-Ref

The global navigation tree block class

Used to produce the global navigation block new to Moodle 2.0

init()   X-Ref
Set the initial properties for the block


instance_allow_multiple()   X-Ref
All multiple instances of this block

return: bool Returns false

applicable_formats()   X-Ref
Set the applicable formats for this block to all

return: array

instance_allow_config()   X-Ref
Allow the user to configure a block instance

return: bool Returns true

instance_can_be_hidden()   X-Ref
The navigation block cannot be hidden by default as it is integral to
the navigation of Moodle.

return: false

instance_can_be_docked()   X-Ref
Find out if an instance can be docked.

return: bool true or false depending on whether the instance can be docked or not.

get_required_javascript()   X-Ref
Gets Javascript that may be required for navigation


get_content()   X-Ref
Gets the content for this block by grabbing it from $this->page

return: object $this->content

get_navigation()   X-Ref
Returns the navigation

return: navigation_node The navigation object to display

html_attributes()   X-Ref
Returns the attributes to set for this block

This function returns an array of HTML attributes for this block including
the defaults.
{@link block_tree::html_attributes()} is used to get the default arguments
and then we check whether the user has enabled hover expansion and add the
appropriate hover class if it has.

return: array An array of HTML attributes

trim(navigation_node $node, $mode=1, $long=50, $short=25, $recurse=true)   X-Ref
Trims the text and shorttext properties of this node and optionally
all of its children.

param: navigation_node $node
param: int $mode One of navigation_node::TRIM_*
param: int $long The length to trim text to
param: int $short The length to trim shorttext to
param: bool $recurse Recurse all children

trim_left($string, $length)   X-Ref
Truncate a string from the left

param: string $string The string to truncate
param: int $length The length to truncate to
return: string The truncated string

trim_right($string, $length)   X-Ref
Truncate a string from the right

param: string $string The string to truncate
param: int $length The length to truncate to
return: string The truncated string

trim_center($string, $length)   X-Ref
Truncate a string in the center

param: string $string The string to truncate
param: int $length The length to truncate to
return: string The truncated string

get_aria_role()   X-Ref
Returns the role that best describes the navigation block... 'navigation'

return: string 'navigation'

get_config_for_external()   X-Ref
Return the plugin config settings for external functions.

return: stdClass the configs for both the block instance and plugin