Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Subclass of navigation_node allowing different rendering for the flat navigation in particular allowing dividers and indents. More...
Public Member Functions | |
__construct ($navnode, $indent) | |
A proxy constructor. | |
__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_collectionlabel () | |
Getter, get the label for this flat_navigation node, or it's parent if it doesn't have one. | |
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_indent () | |
Getter for "indent". | |
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. | |
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_section () | |
Does this node represent a course section link. | |
is_short_branch () | |
To better balance the admin tree, we want to group all the short top branches together. | |
isactive () | |
In flat navigation - sections are active if we are looking at activities in the section. | |
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_collectionlabel ($label) | |
Setter, a label is required for a flat navigation node that shows a divider. | |
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_indent ($val) | |
Setter for "indent". | |
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. | |
set_showdivider ($val, $label='') | |
Setter for "showdivider". | |
showdivider () | |
Getter for "showdivider". | |
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 | 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) | |
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 | $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 | 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 | |
add_context_locking_node (\navigation_node $node, context $context) | |
Add the menu item to handle locking and unlocking of a conext. | |
Protected Attributes | |
array | $namedtypes |
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 | |
Subclass of navigation_node allowing different rendering for the flat navigation in particular allowing dividers and indents.
flat_navigation_node::__construct | ( | $navnode, | |
$indent ) |
A proxy constructor.
mixed | $navnode | A navigation_node or an array |
|
inherited |
|
inherited |
Return an array consisting of the actions for the action link.
array | Formatted array to parse in a template |
|
inherited |
Return an array consisting of the additional attributes for the action url.
array | Formatted array to parse in a template |
|
inherited |
Adds a navigation node as a child of this node.
string | $text | |
moodle_url | action_link | string | $action | |
?int | $type | |
string | $shorttext | |
string | int | $key | |
pix_icon | $icon |
navigation_node |
Reimplemented in navbar, and settings_navigation.
|
inherited |
Adds an HTML attribute to this node.
string | $name | |
string | $value |
|
inherited |
Adds a CSS class to this node.
string | $class |
bool |
|
protectedinherited |
Add the menu item to handle locking and unlocking of a conext.
navigation_node | $node | Node to add |
context | $context | The context to be locked |
|
inherited |
Adds a navigation node as a child of this one, given a $node object created using the create function.
navigation_node | $childnode | Node to add |
string | $beforekey |
navigation_node | The added node |
|
inherited |
Walk the tree building up a list of all the flat navigation nodes.
flat_navigation | $nodes | List of the found flat navigation nodes. |
boolean | $showdivider | Show a divider before the first node. |
string | $label | A label for the collection of navigation links. |
|
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.
int | $strength | One of URL_MATCH_EXACT, URL_MATCH_PARAMS, or URL_MATCH_BASE |
bool |
|
inherited |
Checks if this node or any of its children contain the active node.
Recursive.
bool |
|
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.)
string | $text | |
moodle_url | action_link | $action | |
int | $type | |
string | $shorttext | |
string | int | $key | |
pix_icon | $icon |
navigation_node |
|
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.
int | string | $key | The key of the node we are looking for |
?int | $type | One of navigation_node\TYPE_* |
navigation_node|false |
Reimplemented in global_navigation.
|
inherited |
Finds the active node.
Searches this nodes children plus all of the children for the active node and returns it if found.
Recursive.
navigation_node|false |
|
inherited |
Finds all nodes of a given type (recursive)
int | $type | One of navigation_node\TYPE_* |
array |
|
inherited |
Finds all nodes that are expandable by AJAX.
array | $expandable | An array by reference to populate with expandable nodes. |
|
inherited |
Forces this node to be open and at the same time forces open all parents until the root node.
Recursive.
|
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.
int | string | $key | The key of the node we are looking for |
int | $type | One of navigation_node\TYPE_* |
navigation_node|false |
Reimplemented in global_navigation, and navbar.
|
inherited |
Return a list of all the keys of all the child nodes.
array | the keys. |
flat_navigation_node::get_collectionlabel | ( | ) |
Getter, get the label for this flat_navigation node, or it's parent if it doesn't have one.
string |
|
inherited |
Gets the content for this node.
bool | $shorttext | If true shorttext is used rather than the normal text |
string |
|
inherited |
Gets the CSS class to add to this node to describe its type.
string |
flat_navigation_node::get_indent | ( | ) |
Getter for "indent".
boolean |
|
inherited |
Get a list of sibling navigation nodes at the same level as this one.
bool|array | of navigation_node |
|
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());
array | $inactive | |
bool | $return |
array | Array (tabs, selected, inactive, activated, return) |
|
inherited |
Gets the title to use for this node.
string |
|
inherited |
Used to easily determine if this link in the breadcrumbs has a valid action/url.
boolean |
|
inherited |
Checks if this node has or could have any children.
bool | Returns true if it has children or could have (by AJAX expansion) |
|
inherited |
Used to easily determine if the action is an internal link.
bool |
|
inherited |
True if this nav node has siblings in the tree.
bool |
|
inherited |
Hides the node and any children it has.
array | $typestohide | Optional. 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. |
|
inherited |
Check whether the node's action is of type action_link.
bool |
|
inherited |
Used to easily determine if this link in the breadcrumbs is hidden.
boolean |
flat_navigation_node::is_section | ( | ) |
Does this node represent a course section link.
boolean |
|
inherited |
To better balance the admin tree, we want to group all the short top branches together.
This means < 8 nodes and no subtrees.
bool |
flat_navigation_node::isactive | ( | ) |
In flat navigation - sections are active if we are looking at activities in the section.
boolean |
|
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.
|
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.
moodle_url | $url | The url to use for the fullmeurl. |
bool | $loadadmintree | use true if the URL point to administration tree |
|
inherited |
Removes this node.
bool |
|
inherited |
Removes a CSS class from this node.
string | $class |
bool | True if the class was successfully removed. |
|
inherited |
Searches all children for the best matching active node.
int | $strength | The url match to be made. |
navigation_node|false |
flat_navigation_node::set_collectionlabel | ( | $label | ) |
Setter, a label is required for a flat navigation node that shows a divider.
string | $label |
|
inherited |
Sets whether the node and its children should be added into a "more" menu whenever possible.
bool | $forceintomoremenu |
flat_navigation_node::set_indent | ( | $val | ) |
Setter for "indent".
$val | boolean |
|
inherited |
Sets the parent for this node and if this node is active ensures that the tree is properly adjusted as well.
navigation_node | $parent |
|
inherited |
Sets whether the node and its children should be displayed in the "secondary" navigation when applicable.
bool | $show |
flat_navigation_node::set_showdivider | ( | $val, | |
$label = '' ) |
Setter for "showdivider".
$val | boolean |
$label | string Label for the group of nodes |
flat_navigation_node::showdivider | ( | ) |
Getter for "showdivider".
boolean |
|
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
string | null | $title |
string |
|
inherited |
Set to true if we KNOW that this node can be expanded.
|
protectedinherited |
|
inherited |
Activity node type, e.g.
Forum, Quiz 40
|
inherited |
Resource node type, e.g.
Link to a file, or label 50